/* RC ONEFILE — Chat Widget Styles
   Palette aligned with ritournellescanines.com theme:
   Primary: #fcaf3b (golden), Secondary: #d88344 (terracotta)
   Background: #fdf6ea (cream), Text: #2b2b2b, Cards: #fff
*/

.rc-chat {
    max-width: 720px;
    width: 100%;
    margin: 0 auto;
    font-family: inherit;
    font-size: 15px;
    color: #2b2b2b;
    line-height: 1.5;
}

/* === Consent Banner === */

.rc-chat-consent {
    border: 1px solid #fcaf3b;
    border-radius: 20px;
    padding: 28px 32px;
    background: #fff;
    box-shadow: 0 0 14px rgba(0, 0, 0, 0.2);
    text-align: left;
    max-width: 800px;
    margin: 0 auto;
}

.rc-chat-consent__icon {
    font-size: 28px;
    margin-bottom: 8px;
    text-align: center;
}

.rc-chat-consent__title {
    font-weight: 600;
    font-size: 18px;
    margin-bottom: 16px;
    color: #2b2b2b;
    text-align: center;
}

.rc-chat-consent__text {
    color: #2b2b2b;
    font-size: 14px;
    line-height: 1.6;
    margin-bottom: 20px;
    text-align: left;
}

.rc-chat-consent__text strong {
    font-weight: 700;
}

/* Button container - GDPR parity */
.rc-chat-consent__buttons {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

.rc-chat-consent__accept,
.rc-chat-consent__decline {
    flex: 1;
    min-width: 120px;
    max-width: 200px;
    padding: 12px 18px;
    border-radius: 30px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    border: 2px solid #d1d5db;
}

/* Accept button - primary but not biased */
.rc-chat-consent__accept {
    background: #fcaf3b;
    color: #fff;
    border-color: #fcaf3b;
}

/* Accept button when alone (inline mode - no buttons container) */
.rc-chat-consent > .rc-chat-consent__accept {
    display: block;
    margin: 20px auto 0;
    min-width: 240px;
    max-width: 300px;
    padding: 14px 24px;
}

.rc-chat-consent__accept:hover {
    background: #d88344;
    border-color: #d88344;
    transform: translateY(-1px);
}

/* Decline button - equal visual weight (GDPR 2026) */
.rc-chat-consent__decline {
    background: #fff;
    color: #6b7280;
    border-color: #d1d5db;
}

.rc-chat-consent__decline:hover {
    background: #f9fafb;
    border-color: #9ca3af;
    color: #374151;
    transform: translateY(-1px);
}

/* === Profile Selection === */

.rc-chat-profiles {
    border: 1px solid #fcaf3b;
    border-radius: 20px;
    padding: 24px;
    background: #fff;
    box-shadow: 0 0 14px rgba(0, 0, 0, 0.2);
    text-align: center;
}

.rc-chat-profiles__title {
    font-weight: 600;
    font-size: 17px;
    margin-bottom: 16px;
    color: #2b2b2b;
}

.rc-chat-profiles__grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 10px;
}

.rc-chat-profiles__btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 16px 12px;
    background: #fff;
    border: 1px solid #fdf6ea;
    border-radius: 10px;
    cursor: pointer;
    font-size: 14px;
    color: #2b2b2b;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.rc-chat-profiles__btn:hover {
    border-color: #fcaf3b;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.rc-chat-profiles__btn-icon {
    font-size: 24px;
}

.rc-chat-profiles__btn-label {
    font-weight: 500;
    text-align: center;
    line-height: 1.3;
}

/* === Chat Container === */

.rc-chat-container {
    border: 1px solid #fcaf3b;
    border-radius: 20px;
    background: #fff;
    box-shadow: 0 0 14px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* === Header === */

.rc-chat-header {
    display: flex;
    justify-content: flex-end;
    padding: 8px 12px;
    border-bottom: 1px solid #fdf6ea;
}

.rc-chat-new-btn {
    padding: 4px 12px;
    background: transparent;
    border: 1px solid #fdf6ea;
    border-radius: 6px;
    font-size: 12px;
    color: #6c7a8b;
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s;
}

.rc-chat-new-btn:hover {
    border-color: #fcaf3b;
    color: #2b2b2b;
}

/* === Detach Button === */

.rc-chat-detach-btn {
    padding: 4px 10px;
    background: transparent;
    border: 1px solid #fdf6ea;
    border-radius: 6px;
    font-size: 14px;
    color: #6c7a8b;
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s;
    line-height: 1;
}

.rc-chat-detach-btn:hover {
    border-color: #fcaf3b;
    color: #2b2b2b;
}

/* === Detached Notice === */

.rc-chat-detached-notice {
    border: 1px solid #fdf6ea;
    border-radius: 20px;
    padding: 24px;
    background: #fff;
    box-shadow: 0 0 14px rgba(0, 0, 0, 0.2);
    text-align: center;
    color: #6c7a8b;
    font-size: 14px;
    font-style: italic;
}

.rc-chat-detached-notice .rc-chat-btn {
    margin-top: 12px;
    padding: 10px 24px;
    background: #fcaf3b;
    color: #ffffff;
    border: 1px solid #fcaf3b;
    border-radius: 30px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}

.rc-chat-detached-notice .rc-chat-btn:hover {
    background: #d88344;
    border-color: #d88344;
}

/* === Copy Button === */

.rc-chat-copy-btn {
    display: block;
    margin-top: 8px;
    padding: 2px 10px;
    background: transparent;
    border: 1px solid #fdf6ea;
    border-radius: 4px;
    font-size: 11px;
    color: #6c7a8b;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s, border-color 0.15s, color 0.15s;
}

.rc-chat-message--assistant:hover .rc-chat-copy-btn {
    opacity: 1;
}

.rc-chat-copy-btn:hover {
    border-color: #fcaf3b;
    color: #2b2b2b;
}

/* === Messages Area === */

.rc-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    max-height: 500px;
    min-height: 200px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.rc-chat-message {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.55;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.rc-chat-message--user {
    align-self: flex-end;
    background: #fef5e1;
    color: #2b2b2b;
    border-bottom-right-radius: 4px;
}

.rc-chat-message--assistant {
    align-self: flex-start;
    background: #ffffff;
    color: #2b2b2b;
    border: 1px solid #fdf6ea;
    border-bottom-left-radius: 4px;
}

.rc-chat-message--assistant p {
    margin: 0 0 8px 0;
}

.rc-chat-message--assistant p:last-child {
    margin-bottom: 0;
}

.rc-chat-message--assistant strong {
    font-weight: 600;
}

.rc-chat-message--assistant em {
    font-style: italic;
}

.rc-chat-message--assistant code {
    background: #fdf6ea;
    padding: 1px 5px;
    border-radius: 4px;
    font-size: 13px;
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

.rc-chat-message--assistant ul,
.rc-chat-message--assistant ol {
    margin: 4px 0 8px 18px;
    padding: 0;
}

.rc-chat-message--assistant li {
    margin-bottom: 2px;
}

.rc-chat-message--assistant a {
    color: #d88344;
    text-decoration: underline;
}

.rc-chat-message--assistant a:hover {
    color: #b5682e;
}

/* === Headings in messages (reduced sizes for better readability) === */

.rc-chat-message--assistant h1 {
    font-size: 1.3em;
    font-weight: 600;
    margin: 12px 0 8px 0;
    color: #2b2b2b;
}

.rc-chat-message--assistant h2 {
    font-size: 1.2em;
    font-weight: 600;
    margin: 10px 0 6px 0;
    color: #2b2b2b;
}

.rc-chat-message--assistant h3 {
    font-size: 1.1em;
    font-weight: 600;
    margin: 8px 0 4px 0;
    color: #2b2b2b;
}

.rc-chat-message--assistant h4,
.rc-chat-message--assistant h5,
.rc-chat-message--assistant h6 {
    font-size: 1em;
    font-weight: 600;
    margin: 6px 0 4px 0;
    color: #2b2b2b;
}

/* === Message Timestamps (P3 UX improvement) === */

.rc-chat-message-time {
    font-size: 11px;
    color: #999;
    margin-top: 6px;
    text-align: right;
    font-style: italic;
}

/* === Status Indicator (tool calls) === */

.rc-chat-status {
    align-self: flex-start;
    padding: 8px 14px;
    font-size: 13px;
    font-style: italic;
    color: #6c7a8b;
    display: flex;
    align-items: center;
    gap: 8px;
}

.rc-chat-status__dot {
    width: 8px;
    height: 8px;
    background: #d88344;
    border-radius: 50%;
    animation: rc-chat-pulse 1.2s ease-in-out infinite;
}

@keyframes rc-chat-pulse {
    0%, 100% { opacity: 0.4; }
    50% { opacity: 1; }
}

/* === Typing Indicator (modern 3-dots animation) === */

.rc-chat-typing {
    align-self: flex-start;
    display: inline-flex;
    gap: 4px;
    padding: 14px 18px;
    background: #ffffff;
    border-radius: 18px;
    border-bottom-left-radius: 6px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

.rc-chat-typing span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #8b7355;
    animation: typing-bounce 1.4s infinite ease-in-out;
}

.rc-chat-typing span:nth-child(1) {
    animation-delay: 0s;
}

.rc-chat-typing span:nth-child(2) {
    animation-delay: 0.2s;
}

.rc-chat-typing span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing-bounce {
    0%, 60%, 100% {
        transform: translateY(0);
    }
    30% {
        transform: translateY(-10px);
    }
}

/* === Sources (PubMed) === */

.rc-chat-sources {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid #fdf6ea;
    font-size: 12px;
}

.rc-chat-sources__title {
    font-weight: 600;
    color: #6c7a8b;
    margin-bottom: 4px;
}

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

.rc-chat-sources__item {
    margin-bottom: 3px;
}

.rc-chat-sources__item a {
    color: #d88344;
    text-decoration: none;
    font-size: 12px;
}

.rc-chat-sources__item a:hover {
    text-decoration: underline;
    color: #b5682e;
}

/* === Quick Reply Buttons (suggested actions) === */

.rc-chat-quick-replies {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.rc-chat-quick-reply-btn {
    padding: 8px 14px;
    border: 1px solid #fcaf3b;
    border-radius: 16px;
    background: #fff;
    color: #2b2b2b;
    font-size: 14px;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}

.rc-chat-quick-reply-btn:hover {
    background: #fcaf3b;
    color: #fff;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(252, 175, 59, 0.2);
}

.rc-chat-quick-reply-btn:active {
    transform: translateY(0);
}

/* === Enhanced Error Display (P2 UX improvement) === */

.rc-chat-error {
    padding: 16px 20px;
    background: #fff3cd;
    border: 1px solid #ffc107;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    margin: 12px 0;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
}

.rc-chat-error-icon {
    font-size: 32px;
    line-height: 1;
}

.rc-chat-error-text {
    color: #856404;
    font-size: 14px;
    line-height: 1.5;
    text-align: center;
    max-width: 400px;
}

.rc-chat-retry-btn {
    padding: 10px 20px;
    background: #fcaf3b;
    color: #fff;
    border: none;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    margin-top: 4px;
}

.rc-chat-retry-btn:hover {
    background: #d88344;
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(252, 175, 59, 0.3);
}

.rc-chat-retry-btn:active {
    transform: translateY(0);
}

/* === Scroll to Bottom Button (P2 UX improvement) === */

.rc-chat-scroll-bottom-btn {
    position: absolute;
    bottom: 100px;
    right: 24px;
    width: 44px;
    height: 44px;
    background: #fcaf3b;
    color: #fff;
    border: none;
    border-radius: 50%;
    font-size: 20px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.rc-chat-scroll-bottom-btn:hover {
    background: #d88344;
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.rc-chat-scroll-bottom-btn:active {
    transform: scale(1.05);
}

/* === Code Details (collapsible executed code) === */

.rc-chat-code-details {
    margin-top: 8px;
}

.rc-chat-code-details summary {
    cursor: pointer;
    color: #8b7355;
    font-size: 0.85em;
    user-select: none;
}

.rc-chat-code-details summary:hover {
    color: #d88344;
}

.rc-chat-code-details pre {
    background: #2d2d2d;
    color: #f0f0f0;
    padding: 12px;
    border-radius: 6px;
    overflow-x: auto;
    font-size: 0.8em;
    margin-top: 4px;
    line-height: 1.4;
}

.rc-chat-code-details code {
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
    background: transparent;
    padding: 0;
    color: inherit;
    font-size: inherit;
}

/* === Error Message === */

.rc-chat-message--error {
    align-self: center;
    background: #fff7f7;
    border: 1px solid #f0b5b5;
    color: #b04747;
    text-align: center;
    font-size: 13px;
    max-width: 90%;
}

/* === Input Area === */

.rc-chat-input-area {
    border-top: 1px solid #fdf6ea;
    padding: 12px 16px;
    display: flex;
    align-items: flex-end;
    gap: 8px;
    background: #fdf6ea;
}

.rc-chat-input-area textarea {
    flex: 1;
    resize: none;
    border: 1px solid #fdf6ea;
    border-radius: 10px;
    padding: 8px 12px;
    font-size: 14px;
    font-family: inherit;
    line-height: 1.4;
    min-height: 38px;
    max-height: 120px;
    outline: none;
    transition: border-color 0.15s;
    color: #2b2b2b;
    background: #fff;
}

.rc-chat-input-area textarea:focus {
    border-color: #fcaf3b;
}

.rc-chat-input-area textarea::placeholder {
    color: #9ca8b7;
}

.rc-chat-send-btn {
    padding: 12px 18px;
    background: #fcaf3b;
    color: #ffffff;
    border: 1px solid #fcaf3b;
    border-radius: 30px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
    white-space: nowrap;
}

.rc-chat-send-btn:hover {
    background: #d88344;
    border-color: #d88344;
}

.rc-chat-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* === Upload Bar === */

.rc-chat-upload-bar {
    border-top: 1px solid #fdf6ea;
    padding: 8px 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    background: #fdf6ea;
    font-size: 13px;
}

.rc-chat-upload-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 5px 12px;
    background: transparent;
    border: 1px solid #fdf6ea;
    border-radius: 6px;
    font-size: 13px;
    color: #2b2b2b;
    cursor: pointer;
    transition: border-color 0.15s;
}

.rc-chat-upload-btn:hover {
    border-color: #fcaf3b;
}

.rc-chat-upload-status {
    color: #00a550;
    font-weight: 600;
    font-size: 13px;
    flex: 1;
}

.rc-chat-upload-status--empty {
    color: #6c7a8b !important;
    font-weight: 400 !important;
}

/* === PDF Upload Bar === */

/* === Hidden file input === */

.rc-chat-file-input {
    display: none;
}

/* === Responsive (mobile-first) === */

@media (max-width: 600px) {
    .rc-chat-profiles__grid {
        grid-template-columns: 1fr;
    }

    .rc-chat-message {
        max-width: 92%;
    }

    .rc-chat-messages {
        max-height: 400px;
        padding: 12px;
    }

    .rc-chat-consent,
    .rc-chat-profiles {
        padding: 18px 14px;
    }

    .rc-chat-input-area {
        padding: 10px 12px;
    }
}

/* === Mobile: Popup mode overrides ===
   Restore flex layout on mobile popup (override fixed max-height above) */
@media (max-width: 600px) {
    /* Messages: must use flex to fill viewport, not fixed height */
    .rc-chat-overlay .rc-chat-messages {
        max-height: none !important;
        min-height: 0 !important;
        flex: 1 !important;
        padding: 12px 16px;
    }

    /* Header: reduce padding for mobile */
    .rc-chat-overlay .rc-chat-header {
        padding: 10px 16px;
        min-height: 50px;
    }

    /* Input area: adjust padding */
    .rc-chat-overlay .rc-chat-input-area {
        padding: 12px 16px 16px !important;
    }

    /* Upload bar: adjust padding */
    .rc-chat-overlay .rc-chat-upload-bar {
        padding: 6px 16px 10px;
    }

    /* Messages: increase max-width on small screens */
    .rc-chat-overlay .rc-chat-message {
        max-width: 92% !important;
    }
}

/* === Image display (matplotlib plots) === */

.rc-chat-image {
    margin: 16px 0;
    padding: 12px;
    background: #fdf6ea;
    border-radius: 12px;
    border: 1px solid #fcaf3b;
}

.rc-chat-image img {
    max-width: 100%;
    height: auto;
    display: block;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

/* === Tables (Markdown) === */

.rc-chat-table {
    border-collapse: collapse;
    margin: 12px 0;
    width: 100%;
    font-size: 14px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    overflow: hidden;
}

.rc-chat-table thead {
    background: #fdf6ea;
}

.rc-chat-table th {
    padding: 10px 12px;
    text-align: left;
    font-weight: 600;
    color: #2b2b2b;
    border-bottom: 2px solid #fcaf3b;
}

.rc-chat-table td {
    padding: 8px 12px;
    border-bottom: 1px solid #f0f0f0;
    color: #2b2b2b;
}

.rc-chat-table tbody tr:last-child td {
    border-bottom: none;
}

.rc-chat-table tbody tr:hover {
    background: #fdfaf5;
}

/* ============================================================
   OVERLAY MODE — Full-screen overlay (replaces window.open popup)
   ============================================================ */

/* --- Trigger Button (shown in widget container) --- */
.rc-chat-trigger {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 14px 24px;
    background: linear-gradient(135deg, #fcaf3b 0%, #d88344 100%);
    color: #fff;
    border: none;
    border-radius: 50px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(252, 175, 59, 0.3);
    transition: all 0.3s ease;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

.rc-chat-trigger:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(252, 175, 59, 0.4);
}

.rc-chat-trigger:active {
    transform: translateY(0);
}

.rc-chat-trigger svg {
    flex-shrink: 0;
}

/* --- Overlay Container (full-screen) --- */
.rc-chat-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    background: #fdf6ea;
    z-index: 999999;
    display: none;
    flex-direction: column;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.rc-chat-overlay.active {
    display: flex;
}

/* --- Content container (fills overlay height) --- */
.rc-chat-overlay > .rc-chat {
    flex: 1;
    display: flex;
    flex-direction: column;
    max-width: none;
    width: 100%;
    margin: 0;
    overflow: hidden;
}

/* --- Close Button --- */
.rc-chat-overlay-close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 50%;
    cursor: pointer;
    font-size: 20px;
    color: #6b7280;
    transition: all 0.2s;
    z-index: 10;
}

.rc-chat-overlay-close:hover {
    background: #fff;
    color: #d88344;
    border-color: #d88344;
    transform: scale(1.1);
}

/* --- Chat Container (inside overlay) --- */
.rc-chat-overlay .rc-chat-container {
    border: none;
    border-radius: 0;
    box-shadow: none;
    background: #fdf6ea;
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    max-height: none;
}

/* --- Header --- */
.rc-chat-overlay .rc-chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 24px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    background: #fdf6ea;
    min-height: 56px;
    flex-shrink: 0;
}

.rc-chat-overlay .rc-chat-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.rc-chat-overlay .rc-chat-logo {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
}

.rc-chat-overlay .rc-chat-logo img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border: none;
    border-radius: 0;
}

.rc-chat-overlay .rc-chat-title {
    font-size: 16px;
    font-weight: 600;
    color: #2b2b2b;
    margin: 0;
}

.rc-chat-overlay .rc-chat-header-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.rc-chat-overlay .rc-chat-export-btn,
.rc-chat-overlay .rc-chat-new-btn,
.rc-chat-overlay .rc-chat-close-btn {
    background: transparent;
    border: 1px solid rgba(0, 0, 0, 0.12);
    border-radius: 20px;
    padding: 6px 16px;
    font-size: 13px;
    font-weight: 500;
    color: #6b7280;
    cursor: pointer;
    transition: all 0.15s;
}

.rc-chat-overlay .rc-chat-export-btn:hover,
.rc-chat-overlay .rc-chat-new-btn:hover,
.rc-chat-overlay .rc-chat-close-btn:hover {
    border-color: #d88344;
    color: #d88344;
    background: rgba(216, 131, 68, 0.05);
}

/* Close button: larger × symbol */
.rc-chat-overlay .rc-chat-close-btn {
    font-size: 20px;
    line-height: 1;
    padding: 4px 12px;
}

/* --- Messages Area ---
   Central column: max 750px, auto-centered via padding.
   Messages align left (assistant) or right (user) within column. */
.rc-chat-overlay .rc-chat-messages {
    flex: 1 !important;
    overflow-y: auto;
    overflow-x: hidden;  /* Fix #80: prevent horizontal scrollbar */
    max-height: none !important;
    min-height: 0 !important;
    background: #fdf6ea;
    display: flex;
    flex-direction: column;
    gap: 16px;
    /* Center content in a ~750px column */
    padding: 32px max(24px, calc(50% - 375px));
}

/* --- Messages --- */
.rc-chat-overlay .rc-chat-message {
    max-width: 80% !important;
    padding: 14px 18px;
    border-radius: 18px !important;
    font-size: 15px;
    line-height: 1.6;
}

.rc-chat-overlay .rc-chat-message--user {
    align-self: flex-end !important;
    background: #FDE3BA !important;
    color: #2b2b2b !important;
    border: none !important;
    border-bottom-right-radius: 6px !important;
    box-shadow: none !important;
    margin-left: auto;
}

.rc-chat-overlay .rc-chat-message--assistant {
    align-self: flex-start !important;
    background: #ffffff !important;
    color: #2b2b2b !important;
    border: none !important;
    border-bottom-left-radius: 6px !important;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06) !important;
    margin-right: auto;
}

.rc-chat-overlay .rc-chat-status {
    max-width: 750px;
    width: 100%;
}

/* --- Input Area ---
   Same flex layout as embed mode (which works well), but styled for popup.
   Centered in same ~750px column as messages. */
.rc-chat-overlay .rc-chat-input-area {
    border-top: none !important;
    background: #fdf6ea !important;
    padding: 16px max(24px, calc(50% - 375px)) 20px !important;
    display: flex !important;
    align-items: flex-end !important;
    gap: 10px !important;
    flex-shrink: 0;
    width: 100% !important;
    box-sizing: border-box !important;
}

/* Textarea: auto-grows like in embed mode */
.rc-chat-overlay .rc-chat-input-area textarea {
    flex: 1 !important;
    border: 1px solid rgba(0, 0, 0, 0.12) !important;
    border-radius: 20px !important;
    padding: 12px 16px !important;
    font-size: 15px !important;
    font-family: inherit !important;
    background: #ffffff !important;
    min-height: 44px !important;
    max-height: 150px !important;
    outline: none;
    color: #2b2b2b;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
    transition: border-color 0.15s, box-shadow 0.15s;
    box-sizing: border-box !important;
    resize: none !important;
}

.rc-chat-overlay .rc-chat-input-area textarea:focus {
    border-color: #fcaf3b !important;
    box-shadow: 0 1px 6px rgba(252, 175, 59, 0.15) !important;
}

.rc-chat-overlay .rc-chat-input-area textarea::placeholder {
    color: #a0a0a0;
}

/* Send button: next to textarea (not inside), styled as icon button */
.rc-chat-overlay .rc-chat-send-btn {
    border-radius: 50% !important;
    padding: 0 !important;
    font-size: 20px !important;
    font-weight: 700;
    background: #fcaf3b;
    color: #fff;
    border: none !important;
    cursor: pointer;
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
    transition: background 0.15s, transform 0.1s;
    flex-shrink: 0;
    line-height: 1;
}

.rc-chat-overlay .rc-chat-send-btn:hover {
    background: #d88344;
    transform: scale(1.05);
}

.rc-chat-overlay .rc-chat-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* --- Upload Bar --- */
.rc-chat-overlay .rc-chat-upload-bar {
    border-top: none !important;
    padding: 8px max(24px, calc(50% - 375px)) 12px;
    background: #fdf6ea !important;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.rc-chat-overlay .rc-chat-upload-btn {
    background: transparent;
    border: none;
    border-radius: 6px;
    padding: 4px 10px;
    color: #8b7355;
    font-size: 13px;
    cursor: pointer;
    transition: color 0.15s;
}

.rc-chat-overlay .rc-chat-upload-btn:hover {
    color: #d88344;
    background: rgba(216, 131, 68, 0.06);
    border: none;
}

.rc-chat-overlay .rc-chat-upload-status {
    font-size: 13px;
    color: #00a550;
    font-weight: 600;
}

/* --- Hide detach button in popup --- */
.rc-chat-overlay .rc-chat-detach-btn {
    display: none;
}

/* --- Popup Images --- */
.rc-chat-overlay .rc-chat-image {
    background: #fff;
    border: none;
    border-radius: 12px;
    padding: 12px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}

/* --- Popup Sources --- */
.rc-chat-overlay .rc-chat-sources {
    border-top: 1px solid rgba(0, 0, 0, 0.06);
    padding-top: 12px;
    margin-top: 16px;
}

/* --- Popup Copy Button --- */
.rc-chat-overlay .rc-chat-copy-btn {
    color: #8b7355;
    border-color: rgba(0, 0, 0, 0.08);
}

.rc-chat-overlay .rc-chat-copy-btn:hover {
    color: #d88344;
    border-color: #d88344;
}

/* --- Popup Consent & Profiles (shown in popup on new chat) --- */
.rc-chat-overlay .rc-chat-consent,
.rc-chat-overlay .rc-chat-profiles {
    max-width: 600px;
    margin: auto;
    border-color: rgba(0, 0, 0, 0.08);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}
