﻿#anexly-chat-widget {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 999999;
    font-family: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

#anexly-chat-bubble {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: linear-gradient(135deg, #b66150 0%, #c57666 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(182, 97, 80, 0.4);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    margin-left: auto;
    margin-top: 16px;
}

#anexly-chat-bubble:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 16px rgba(182, 97, 80, 0.5);
}

#anexly-chat-bubble svg {
    width: 32px;
    height: 32px;
}

#anexly-chat-window {
    width: 360px;
    height: 650px;
    max-height: 85vh;
    background: #fbf9f8;
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

#anexly-chat-window.hidden {
    display: none;
    opacity: 0;
    transform: translateY(20px);
}

/* Maximized State for Desktop */
#anexly-chat-window.maximized {
    width: 600px;
    height: 80vh;
    max-height: 800px;
}

/* =========================================
   MOBILE CENTERED MODAL â€” phones â‰¤ 480px
   ========================================= */
@media screen and (max-width: 480px) {
    /* Widget anchored to bottom-right */
    #anexly-chat-widget {
        bottom: 20px;
        right: 16px;
    }

    #anexly-chat-bubble {
        margin: 0;
    }

    /* Centered modal popup â€” 85% height, 92% width */
    #anexly-chat-window {
        position: fixed;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        width: 92vw;
        max-width: 400px;
        height: 85vh;
        max-height: 85vh;
        border-radius: 20px;
        box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25), 0 4px 20px rgba(0,0,0,0.1);
    }

    #anexly-chat-window.maximized {
        width: 92vw;
        max-width: 400px;
        height: 85vh;
        max-height: 85vh;
        border-radius: 20px;
    }

    .anexly-expand-btn {
        display: none !important;
    }

    /* Quick action cards â€” tighter on small screens */
    #anexly-quick-actions {
        padding: 4px 12px 12px;
    }
    .anexly-qa-grid {
        gap: 7px;
    }
    .anexly-qa-card {
        padding: 10px 10px 8px;
        border-radius: 12px;
    }
    .anexly-qa-icon {
        width: 30px;
        height: 30px;
        border-radius: 8px;
    }
    .anexly-qa-label {
        font-size: 11.5px;
    }
    .anexly-qa-sub {
        font-size: 10px;
    }

    /* Messages area */
    #anexly-chat-messages {
        padding: 16px;
    }

    /* Input area safe area for iPhone home bar */
    #anexly-chat-input-area {
        padding-bottom: max(16px, env(safe-area-inset-bottom));
    }
}

/* Medium phones 481â€“768 */
@media screen and (min-width: 481px) and (max-width: 768px) {
    #anexly-chat-widget {
        bottom: 16px;
        right: 16px;
    }
    #anexly-chat-window {
        width: calc(100vw - 32px);
        height: 85vh;
        max-height: 700px;
        border-radius: 20px;
    }
    #anexly-chat-window.maximized {
        width: calc(100vw - 32px);
        height: 85vh;
        max-height: 700px;
        border-radius: 20px;
    }
    .anexly-expand-btn {
        display: none !important;
    }
}

/* Home View specific background gradient */
.home-active {
    background: linear-gradient(180deg, #b66150 0%, #ce8879 35%, #fbf9f8 45%, #fbf9f8 100%) !important;
}

#anexly-chat-bg-header {
    padding: 24px 20px 0;
    color: white;
}

.header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.logo-circle {
    background: white;
    border-radius: 50%;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.controls svg {
    width: 20px;
    height: 20px;
    margin-left: 12px;
    opacity: 0.8;
    cursor: pointer;
    transition: opacity 0.2s;
}
.controls svg:hover { opacity: 1; }

.greeting-text {
    font-size: 26px;
    font-weight: 700;
    line-height: 1.2;
    margin: 0 0 20px 0;
}

/* Home Card */
#anexly-chat-home-view {
    padding: 0 20px;
    flex-grow: 1;
    overflow-y: auto;
}
#anexly-chat-home-view.hidden { display: none; }

.home-card {
    background: white;
    border-radius: 16px;
    padding: 20px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
    margin-bottom: 20px;
}

.home-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 16px;
}

.home-card-header img {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}

.online-badge {
    background: #e6f6ee;
    color: #16a34a;
    font-size: 10px;
    font-weight: 700;
    padding: 4px 8px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 4px;
}
.online-badge .dot {
    width: 6px;
    height: 6px;
    background: #16a34a;
    border-radius: 50%;
}

.help-text {
    font-size: 16px;
    color: #4b5563;
    margin: 0 0 16px 0;
}

.start-chat-btn {
    width: 100%;
    background: #b16657;
    color: white;
    border: none;
    padding: 14px;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 600;
    font-family: inherit;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    transition: background 0.2s;
}
.start-chat-btn:hover { background: #9e5b4e; }
.start-chat-btn svg { width: 18px; height: 18px; }

/* Previous Chats Accordion */
.previous-chats-accordion {
    margin-top: 24px;
    border-top: 1px solid #f3f4f6;
    padding-top: 16px;
}
.ac-header {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    font-weight: 600;
    color: #1f2937;
    cursor: pointer;
}
.ac-header .chevron {
    margin-left: auto;
    color: #9ca3af;
}

.ac-items {
    margin-top: 12px;
}
.ac-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: #f9fafb;
    border-radius: 12px;
    margin-bottom: 8px;
    cursor: pointer;
}
.ac-item:hover { background: #f3f4f6; }
.ac-item img { width: 32px; height: 32px; border-radius: 50%; }
.ac-item-content { flex-grow: 1; overflow: hidden; }
.ac-item-title { font-size: 13px; font-weight: 500; color: #374151; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ac-item-date { font-size: 11px; color: #9ca3af; margin-top: 2px; }

/* Chat View */
#anexly-chat-conversation-view {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    height: 100%;
}
#anexly-chat-conversation-view.hidden { display: none; }

.chat-header-compact {
    background: #b16657;
    color: white;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.05);
}
.chat-header-compact .back-btn { cursor: pointer; }
.chat-header-info h3 { margin: 0; font-size: 15px; font-weight: 600; }
.chat-header-info p { margin: 2px 0 0; font-size: 11px; opacity: 0.8; }

#anexly-chat-messages {
    flex-grow: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: #fbf9f8;
}

.anexly-message {
    padding: 12px 16px;
    border-radius: 16px;
    max-width: 85%;
    word-wrap: break-word;
    font-size: 14px;
    line-height: 1.5;
}

.agent-message {
    background: white;
    color: #1f2937;
    align-self: flex-start;
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

.user-message {
    background: #b16657;
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
    box-shadow: 0 2px 8px rgba(177, 102, 87, 0.2);
}

#anexly-quick-actions {
    padding: 6px 14px 10px;
    background: #fff;
}

.anexly-qa-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    margin-bottom: 6px;
    padding-right: 4px; /* Give arrow breathing room */
}

.anexly-qa-header:hover .anexly-qa-toggle {
    color: #4b5563;
}

.anexly-qa-heading {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #b4a9a7;
    margin: 0 0 0 2px;
}

.anexly-qa-toggle {
    transition: transform 0.3s ease;
}

.anexly-qa-grid.collapsed {
    display: none;
}

.anexly-qa-toggle.collapsed {
    transform: rotate(-180deg);
}

.anexly-qa-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
}

.anexly-qa-card {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    background: #fff;
    border: 1.5px solid #f0e8e6;
    border-radius: 12px;
    padding: 8px 10px;
    cursor: pointer;
    text-align: left;
    transition: all 0.18s cubic-bezier(0.34, 1.56, 0.64, 1);
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.anexly-qa-card:hover {
    border-color: #c97b6a;
    background: linear-gradient(135deg, #fff5f3, #fff);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(177,102,87,0.12);
}

.anexly-qa-card:active {
    transform: scale(0.97);
    box-shadow: none;
}

.anexly-qa-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    background: linear-gradient(135deg, #fdecea, #fdf3f1);
    border-radius: 8px;
    color: #b16657;
    flex-shrink: 0;
    margin-bottom: 2px;
}

.anexly-qa-label {
    font-size: 11.5px;
    font-weight: 600;
    color: #3d2820;
    line-height: 1.2;
    display: block;
}

.anexly-qa-sub {
    font-size: 9.5px;
    color: #b4a09c;
    font-weight: 400;
    line-height: 1.2;
    display: block;
}

#anexly-chat-input-area {
    display: flex;
    padding: 16px 20px;
    background: white;
    border-top: 1px solid #f3f4f6;
    align-items: center;
}

#anexly-file-btn {
    cursor: pointer;
    margin-right: 12px;
    color: #9ca3af;
    transition: color 0.2s;
    display: flex;
    align-items: center;
}

#anexly-file-btn:hover {
    color: #b16657;
}

#anexly-file-btn.uploading {
    opacity: 0.5;
    pointer-events: none;
    animation: pulse 1s infinite alternate;
}

@keyframes pulse {
    from { opacity: 0.4; }
    to { opacity: 1; }
}

.anexly-message img {
    max-width: 100%;
    border-radius: 8px;
    margin-top: 5px;
}

#anexly-chat-input {
    flex-grow: 1;
    border: none;
    padding: 8px 0;
    outline: none;
    font-size: 15px;
    font-family: inherit;
}
#anexly-chat-input::placeholder { color: #9ca3af; }

#anexly-chat-input-area button {
    background: #b16657;
    color: white;
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: 12px;
    cursor: pointer;
    transition: background 0.2s;
}

#anexly-chat-input-area button:hover {
    background: #9e5b4e;
}

/* Typing Indicator */
#anexly-typing-indicator {
    padding: 4px 20px 10px;
    display: flex;
    gap: 5px;
}
#anexly-typing-indicator.hidden { display: none; }
.typing-dot {
    width: 6px;
    height: 6px;
    background: #b16657;
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out both;
}
.typing-dot:nth-child(1) { animation-delay: -0.32s; }
.typing-dot:nth-child(2) { animation-delay: -0.16s; }
@keyframes typing {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40% { transform: scale(1); opacity: 1; }
}

/* Footer Tabs */
#anexly-chat-footer {
    display: flex;
    background: white;
    border-top: 1px solid #f3f4f6;
    padding: 12px 0 16px 0;
}
.footer-tab {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    color: #9ca3af;
    cursor: pointer;
    transition: color 0.2s;
}
.footer-tab:hover { color: #6b7280; }
.footer-tab.active { color: #b16657; }
.footer-tab span { font-size: 11px; font-weight: 500; }

/* Lead Capture Form */
.anexly-lead-form {
    background: #ffffff;
    border: 1px solid #f1f5f9;
    border-radius: 12px;
    padding: 24px;
    margin: 15px auto;
    box-shadow: 0 4px 15px -1px rgba(0, 0, 0, 0.05), 0 2px 5px -1px rgba(0, 0, 0, 0.03);
    width: 90%;
}
.anexly-lead-form input:focus {
    outline: 2px solid #b16657;
    outline-offset: -1px;
}
.anexly-lead-form button:hover {
    background: #9e5b4e !important;
}

/* End Chat button in header */
.end-chat-header-btn {
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.4);
    color: white;
    margin-left: auto;
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.end-chat-header-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Rating Modal */
#anexly-rating-modal {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 1;
    transition: opacity 0.3s;
}

#anexly-rating-modal.hidden {
    display: none;
    opacity: 0;
}

.rating-modal-content {
    background: white;
    width: 280px;
    border-radius: 16px;
    padding: 24px;
    text-align: center;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.rating-modal-content h3 {
    margin: 0 0 8px;
    font-size: 18px;
    color: #1f2937;
}

.rating-modal-content p {
    margin: 0 0 20px;
    font-size: 14px;
    color: #6b7280;
}

.stars-container {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-bottom: 24px;
}

.anexly-star {
    font-size: 32px;
    color: #e5e7eb;
    cursor: pointer;
    transition: color 0.1s;
}

.anexly-star:hover, .anexly-star.hovered, .anexly-star.selected {
    color: #fbbf24;
}

.skip-rating-btn {
    background: transparent;
    border: none;
    color: #9ca3af;
    font-size: 14px;
    cursor: pointer;
    text-decoration: underline;
}

.skip-rating-btn:hover {
    color: #6b7280;
}

/* ============================================================
   FAQ VIEW
   ============================================================ */
#anexly-faq-view {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    overflow: hidden;
    background: linear-gradient(180deg, #b66150 0%, #ce8879 35%, #fbf9f8 45%, #fbf9f8 100%);
}

#anexly-faq-view.hidden {
    display: none;
}

/* Controls bar floating over the brown gradient */
#anexly-faq-bg-header {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    padding: 14px 16px 10px;
    flex-shrink: 0;
    gap: 10px;
}

#anexly-faq-bg-header svg {
    width: 20px;
    height: 20px;
    cursor: pointer;
    color: rgba(255,255,255,0.9);
    stroke: rgba(255,255,255,0.9);
}

#anexly-faq-bg-header svg:hover {
    color: white;
    stroke: white;
}

/* Scrollable content area */
#anexly-faq-body {
    flex-grow: 1;
    overflow-y: auto;
    padding: 0 14px 14px;
    display: flex;
    flex-direction: column;
}

/* ---- Single white card wrapping header + list ---- */
.faq-card-wrapper {
    background: white;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 4px 24px rgba(0,0,0,0.18);
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

/* FAQ header row inside the card */
.faq-header-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px;
    font-size: 15px;
    font-weight: 700;
    color: #1f2937;
    border-bottom: 1px solid #f0eeec;
}

.faq-header-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: #f5f3f2;
    border-radius: 50%;
    color: #6b7280;
    flex-shrink: 0;
}

/* FAQ list sits directly inside the card */
#anexly-faq-list.hidden {
    display: none;
}

.faq-list {
    list-style: none;
    margin: 0;
    padding: 0;
    background: white;
    overflow: hidden;
}

.faq-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 15px 16px;
    font-size: 13.5px;
    color: #1f2937;
    cursor: pointer;
    border-bottom: 1px solid #f0eeec;
    transition: background 0.15s ease;
    gap: 8px;
}

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

.faq-item:hover {
    background: #fdf9f8;
}

.faq-item span {
    flex: 1;
    line-height: 1.4;
}

.faq-item svg {
    color: #c4a09a;
    flex-shrink: 0;
}

.faq-item:hover svg {
    color: #a85244;
}

/* --- Article panel --- */
#anexly-faq-article {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

#anexly-faq-article.hidden {
    display: none;
}

.faq-article-card {
    background: transparent;
}

.faq-article-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 15px 16px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 700;
    color: #1f2937;
    border-bottom: 1px solid #f0eeec;
}

.faq-article-header svg {
    color: #c4a09a;
    flex-shrink: 0;
}

.faq-article-header:hover svg {
    color: #a85244;
}

.faq-article-body {
    padding: 16px;
    font-size: 13.5px;
    color: #374151;
    line-height: 1.65;
}

.faq-article-body strong {
    color: #1f2937;
}

.faq-article-body em {
    color: #a85244;
    font-style: normal;
    font-weight: 600;
}

/* ============================================================
   CHANNELS VIEW
   ============================================================ */
#anexly-channels-view {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    overflow: hidden;
    background: linear-gradient(180deg, #b66150 0%, #ce8879 35%, #fbf9f8 45%, #fbf9f8 100%);
}
#anexly-channels-view.hidden { display: none; }

#anexly-channels-bg-header {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    padding: 14px 16px 10px;
    flex-shrink: 0;
    gap: 10px;
}
#anexly-channels-bg-header svg {
    width: 20px;
    height: 20px;
    cursor: pointer;
    color: rgba(255,255,255,0.9);
    stroke: rgba(255,255,255,0.9);
}
#anexly-channels-bg-header svg:hover { color: white; stroke: white; }

#anexly-channels-body {
    flex-grow: 1;
    overflow-y: auto;
    padding: 0 14px 14px;
    display: flex;
    flex-direction: column;
}

.channel-info {
    display: flex;
    align-items: center;
    gap: 12px;
}
.channel-icon {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}
.telegram-icon { background: #2AABEE; }
.discord-icon { background: #5865F2; }
.instagram-icon { background: linear-gradient(45deg, #f09433 0%, #e6683c 25%, #dc2743 50%, #cc2366 75%, #bc1888 100%); }

