
:root {
    --chat-bg: #ffffff;
    --input-bg: #f1f3f4;
    --user-msg-bg: #e1f5fe;
    --agent-msg-bg: #fff8f2;
    --text-color: #202124;
    --accent-color: #1a73e8;
    --accent-color-secondary: #0d47a1;
    --header-text-color: #ffffff;
    --border-color: #dadce0;
    --error-color: #d93025;
    --font-family: 'Noto Sans', sans-serif;
    --border-radius: 18px; /* Message bubble radius */
    --widget-border-radius: 12px; /* Overall widget corner radius */
    --code-bg: #e8e8e8;
}

/* Apply custom colors from URL params if provided */
body {
    margin: 0;
    font-family: var(--font-family);
    background-color: var(--chat-bg); /* Widget background */
    color: var(--text-color);
    font-size: 14px;
    font-weight: 400;
    height: 100vh; /* Ensure body fills iframe height */
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.chat-widget-internal {
    width: 100%;
    height: 100%;
    background-color: var(--chat-bg);
    border-radius: var(--widget-border-radius);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-sizing: border-box;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
}

.chat-header {
    padding: 16px 20px;
    background: var(--accent-color);
    color: var(--header-text-color);
    flex-shrink: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.header-text-container {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.chat-header-title {
    font-size: 16px;
    letter-spacing: 0.3px;
    font-weight: 600;
    line-height: 1.2;
    margin: 0;
}

.chat-header-subtitle {
    font-size: 12px;
    letter-spacing: 0.2px;
    font-weight: 400;
    line-height: 1.2;
    margin: 0;
    color: rgba(255, 255, 255, 0.82);
}

.close-button {
    background: none;
    border: none;
    color: var(--header-text-color);
    font-size: 20px;
    cursor: pointer;
    padding: 4px;
    line-height: 1;
    opacity: 0.9;
    transition: all 0.2s ease;
    border-radius: 6px;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: 16px;
}

.close-button:hover {
    opacity: 1;
    background-color: rgba(255, 255, 255, 0.1);
}

.chat-messages {
    flex-grow: 1;
    padding: 16px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Scrollbar */
.chat-messages::-webkit-scrollbar { width: 6px; }
.chat-messages::-webkit-scrollbar-track { background: #f1f1f1; border-radius: 3px; }
.chat-messages::-webkit-scrollbar-thumb { background: #ccc; border-radius: 3px; }
.chat-messages::-webkit-scrollbar-thumb:hover { background: #aaa; }

.message {
    padding: 10px 14px;
    border-radius: var(--border-radius);
    max-width: 85%; /* Slightly increase max width */
    word-wrap: break-word;
    line-height: 1.5;
    font-weight: 400;
}

.user-message {
    background-color: var(--user-msg-bg);
    align-self: flex-end;
    border-bottom-right-radius: 6px;
    margin-left: auto;
    color: #1f1f1f; /* Ensure contrast if background is light */
}

.agent-message {
    background-color: var(--agent-msg-bg);
    align-self: flex-start;
    border-bottom-left-radius: 6px;
    margin-right: auto;
}

/* Styles for Rendered HTML/Markdown */
.agent-message p { margin-top: 0.5em; margin-bottom: 0.5em; }
.agent-message p:first-child { margin-top: 0; }
.agent-message p:last-child { margin-bottom: 0; }
.agent-message ul, .agent-message ol { margin: 0.7em 0 0.7em 0.7em; padding: 0; }
.agent-message ul ul, .agent-message ol ol, .agent-message ul ol, .agent-message ol ul { margin-top: 0.3em; margin-bottom: 0.3em; }
.agent-message li { margin-bottom: 0.4em; }
.agent-message a { color: var(--accent-color); text-decoration: underline; }
.agent-message a:hover { text-decoration: none; }
.agent-message pre { background-color: var(--code-bg); padding: 10px; border-radius: 8px; overflow-x: auto; font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace; font-size: 0.9em; margin: 0.7em 0; white-space: pre-wrap; word-wrap: break-word; }
.agent-message :not(pre) > code { background-color: var(--code-bg); padding: 0.2em 0.4em; border-radius: 4px; font-size: 0.9em; font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace; }
.agent-message pre code { background-color: transparent; padding: 0; border-radius: 0; font-size: inherit; font-family: inherit; white-space: inherit; word-wrap: inherit; }
.agent-message blockquote { border-left: 3px solid var(--border-color); padding-left: 10px; margin-left: 0; margin-right: 0; color: #5f6368; }
.agent-message hr { border: none; border-top: 1px solid var(--border-color); margin: 1em 0; }

/* Additional data display styles */
.additional-data {
    margin-top: 1em;
    padding: 1em;
    background-color: var(--code-bg);
    border-radius: 8px;
    font-family: monospace;
    white-space: pre-wrap;
    word-wrap: break-word;
    font-size: 0.9em;
    color: var(--text-color);
}

.additional-data-title {
    font-weight: 600;
    margin-bottom: 0.5em;
    color: var(--accent-color);
}

/* Member Widget Styles */
.chat-widget-container {
    width: 100%;
    border: none;
    border-radius: 10px;
    font-family: var(--font-family);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    background-color: #ffffff;
    padding: 1px 10px;
    box-sizing: border-box;
    margin-top: 0;
}

.chat-widget-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.chat-widget-item {
    display: flex;
    align-items: flex-start;
    padding: 12px 0;
    border-bottom: 1px solid #e9ecef;
    justify-content: space-between;
}

.chat-widget-item:last-child {
    border-bottom: none;
}

.member-widget-left-col {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-right: 15px;
    flex-shrink: 0;
    width: 85px;
    margin-top: 10px;
}

.member-widget-avatar {
    width: 85px;
    height: 85px;
    /* border-radius: 50%; */
    object-fit: contain;
    /* border: 2px solid var(--accent-color); */
}

.member-widget-main-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    margin-right: 8px;
}

.member-widget-name {
    font-size: 1.2em;
    font-weight: bold;
    margin: 0;
    color: #212529;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.member-widget-location {
    font-size: 0.9em;
    color: #d72660;
    margin-bottom: 4px;
    font-weight: 400;
}

.member-widget-description {
    font-size: 13px;
    color: #495057;
    margin-top: 0;
    margin-bottom: 8px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 5px;
}

.chat-widget-cta-buttons {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex-shrink: 0;
    align-items: flex-end;
    width: 90px; /* Ensure both buttons have the same width */
}

.chat-widget-cta-buttons .btn {
    padding: 7px 0;
    font-size: 0.7em;
    line-height: 1.5;
    width: 100%;
    text-align: center;
    border-radius: 6px;
    cursor: pointer;
    border: none;
    transition: all 0.2s ease;
    font-weight: 500;
    margin: 0;
    box-sizing: border-box;
}

.chat-widget-cta-buttons .btn-primary {
    background-color: var(--accent-color);
    color: #fff;
    text-decoration: none;
}

.chat-widget-cta-buttons .btn-primary:hover {
    background-color: var(--accent-color-secondary);
    text-decoration: none;
}

.chat-widget-cta-buttons .btn-default {
    color: #495057;
    background-color: #e9ecef;
    text-decoration: none;
}

.chat-widget-cta-buttons .btn-default:hover {
    background-color: #d3d9df;
}

.member-widget-verified {
    color: #34a853;
    margin-left: 4px;
    font-size: 0.9em;
}

.member-widget-rating {
    display: inline-flex;
    align-items: center;
    margin-left: 8px;
    font-size: 0.9em;
    color: #fbbc04;
}

.member-widget-rating .fa-star {
    margin-right: 4px;
}

.member-widget-rating .rating-value {
    font-weight: 600;
    margin-right: 2px;
}

.member-widget-rating .reviews-count {
    color: #5f6368;
    font-size: 0.9em;
}


.post-widget-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.post-widget-item {
    display: flex; /* Use flexbox for main layout */
    align-items: flex-start; /* Align items to the top */
    padding: 8px 0; /* Reduced item padding */
    border-bottom: 1px solid #e9ecef;
    justify-content: space-between;
}

.post-widget-item:last-child {
    border-bottom: none;
}

.post-widget-left-col {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-right: 10px; /* Adjusted space */
    flex-shrink: 0;
    width: 85px; /* Adjusted width for thumbnail */
}

.post-widget-thumbnail {
    width: 70px; /* Thumbnail size */
    height: 50px; /* Thumbnail size */
    border-radius: 4px; /* Rounded corners */
    margin-bottom: 4px; /* Space below thumbnail */
    object-fit: cover;
    border: 1px solid #ced4da; /* Subtle border */
}

.post-widget-author {
    font-size: 0.7em; /* Increased font size for author */
    color: #555; /* Muted text color */
    margin-top: 4px; /* Space above author */
    text-align: center; /* Center author text */
}

.post-widget-main-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    margin-right: 8px; /* Space before buttons */
}

.post-widget-title {
    font-size: 1.2em; /* Increased title font size */
    font-weight: bold;
    margin: 0;
    color: #212529;
    margin-bottom: 2px; /* Reduced space below title */
}

.post-widget-category-location-row {
    display: flex; /* Arrange category and location side-by-side */
    align-items: center;
    font-size: 0.7em; /* Increased font size for this row */
    color: #6c757d; /* Muted text color */
    margin-bottom: 4px; /* Reduced space below this row */
    flex-wrap: wrap; /* Allow wrapping if needed */
}


.post-widget-location {
     display: flex; /* Use flex for icon and text */
     align-items: center;
     margin: 0; /* Remove default margin */
}

.post-widget-location .glyphicon {
    font-size: 0.65em; /* Increased icon size */
    margin-right: 2px;
}


.post-widget-description {
    font-size: 13px; /* Increased description font size */
    color: #495057;
    margin-top: 0;
    margin-bottom: 4px; /* Reduced space below description */
    display: -webkit-box;
    -webkit-line-clamp: 2; /* Limit description to 2 lines */
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
}


 .post-widget-date-below-button {
     font-size: 0.7em; /* Increased font size for date below button */
     color: #6c757d; /* Match muted text color */
     margin-top: 4px; /* Space above the date */
     text-align: right; /* Align date to the right */
 }

 .post-widget-date-below-button .glyphicon {
     font-size: 0.65em; /* Increased icon size */
     margin-right: 2px;
 }

.loading-indicator {
    display: flex; /* Use flex for alignment */
    align-items: center;
    gap: 5px;
    padding: 10px 14px; /* Match message padding */
    border-radius: var(--border-radius); /* Match message radius */
    background-color: var(--agent-msg-bg); /* Match agent message bg */
    align-self: flex-start; /* Align left like agent messages */
    margin-right: auto;
    opacity: 0.8; /* Make it slightly faded */
    height: auto; /* Ensure height fits content */
    box-sizing: border-box; /* Include padding in size */
    min-height: 38px; /* Approx height of a single line message bubble */
}

.loading-indicator span {
    display: inline-block;
    width: 8px; /* Slightly larger dots */
    height: 8px;
    background-color: var(--text-color);
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out both;
}

.loading-indicator span:nth-child(1) { animation-delay: -0.32s; }
.loading-indicator span:nth-child(2) { animation-delay: -0.16s; }

@keyframes bounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1.0); }
}

.chat-input-area {
    display: flex;
    align-items: center;
    padding: 16px 20px;
    background-color: var(--chat-bg);
    flex-shrink: 0;
    border-top: 1px solid rgba(0, 0, 0, 0.08);
    box-shadow: 0 -1px 6px rgba(0, 0, 0, 0.05);
    position: relative;
}

#chat-input {
    flex-grow: 1;
    border: 1px solid rgba(0, 0, 0, 0.1);
    padding: 12px 16px;
    padding-right: 54px;
    border-radius: 12px;
    background-color: var(--input-bg);
    font-family: var(--font-family);
    font-size: 14px;
    font-weight: 400;
    outline: none;
    color: var(--text-color);
    transition: all 0.2s ease;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
    min-height: 24px;
    height: 48px;
    line-height: 24px;
    resize: none;
    max-height: 200px;
    overflow-y: auto;
    box-sizing: border-box;
    display: block;
    scrollbar-width: thin;
    scrollbar-color: transparent transparent;
}

#chat-input::-webkit-scrollbar {
    width: 6px;
}

#chat-input::-webkit-scrollbar-track {
    background: transparent;
}

#chat-input::-webkit-scrollbar-thumb {
    background-color: transparent;
    border-radius: 3px;
    transition: background-color 0.2s ease;
}

#chat-input:hover::-webkit-scrollbar-thumb {
    background-color: rgba(0, 0, 0, 0.2);
}

#chat-input:focus::-webkit-scrollbar-thumb {
    background-color: rgba(0, 0, 0, 0.2);
}

#chat-input::placeholder {
    color: #9AA0A6;
    font-weight: 400;
}

.send-button {
    position: absolute;
    right: 28px;
    background: var(--accent-color);
    color: white;
    border: none;
    border-radius: 8px;
    width: 32px;
    height: 32px;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
    padding: 0;
    box-shadow: 0 2px 6px rgba(26, 115, 232, 0.2);
}

.send-button svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
    transition: transform 0.2s ease;
}

.send-button:hover {
    background: var(--accent-color-secondary);
    box-shadow: 0 4px 8px rgba(26, 115, 232, 0.3);
}

.send-button:hover svg {
    transform: translateX(2px);
}

.send-button:disabled {
    background-color: #E8EAED;
    cursor: not-allowed;
    opacity: 0.8;
    box-shadow: none;
}

.send-button:disabled svg {
    fill: #9AA0A6;
}

.error-message {
    color: var(--error-color);
    font-size: 12px;
    font-weight: 500;
    text-align: center;
    padding: 8px 16px;
    background-color: #fce8e6;
    border-top: 1px solid var(--border-color);
    display: none;
    flex-shrink: 0; /* Prevent shrinking */
}

/* Add styles for suggestions */
.suggestions-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 12px 20px;
    border-top: 1px solid rgba(0, 0, 0, 0.08);
}

.suggestion-bubble {
    background-color: #f8f9fa;
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 16px;
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-color);
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    user-select: none;
    font-family: var(--font-family);
}

.suggestion-bubble:hover {
    background-color: #f1f3f4;
    border-color: rgba(0, 0, 0, 0.15);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.suggestion-bubble:active {
    background-color: #e8eaed;
    transform: scale(0.98);
}

.member-widget-categories, .member-widget-tags {
    font-size: 0.7em;
    color: #555;
    margin: 0;
    margin-right: 5px;
}

.chat-widget-category-badge, .chat-widget-tag-badge {
    display: inline-block;
    padding: 3px 10px;
    margin-right: 4px;
    margin-bottom: 3px;
    background-color: #17a2b8;
    color: #fff;
    border-radius: 4px;
    font-size: 9px;
    white-space: nowrap;
}

.post-widget-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 4px;
}

.chat-widget-tag {
    display: inline-block;
    padding: 3px 7px;
    margin-right: 4px;
    margin-bottom: 3px;
    background-color: #edfffa;
    color: #17a2b8;
    border-radius: 4px;
    font-size: 10px;
    white-space: nowrap;
    font-weight: 500;
}