/**
 * AutoFit AI Search - Chat Assistant Stylesheet
 *
 * v3.7.7 - COMPACT EMPTY-STATE IN CHAT (UI POLISH):
 *
 *          Mirrors the shortcode-side change from the same
 *          release so the empty-state hint in the chat window
 *          is visually consistent with the shortcode card.
 *
 *          Changed in .autofit-section-empty (chat scope):
 *            • padding:       24px 16px → 12px 14px
 *            • font-size:     15px → 12.5px
 *            • icon size:     36px → 20px
 *            • icon margin:   14px → 4px
 *            • max-width:     none → 300px (centered)
 *            • border-radius: 10px → 8px
 *            • line-height:   1.8 → 1.5
 *
 *          Mobile breakpoints adjusted proportionally:
 *            @media (max-width: 480px):
 *              padding 22px 14px → 12px 14px
 *              font    15px → 12.5px
 *              icon    32px → 20px
 *              margin  12px → 4px
 *
 *          Because the chat window is narrower (380px on
 *          desktop) than the shortcode card, the max-width is
 *          300px (vs 340px on the shortcode) so the box still
 *          reads as a centered hint rather than a full-width
 *          block.
 *
 *          NO other rule in this file changed.
 *
 *          FILES CHANGED IN v3.7.7 (4 total):
 *            * assets/css/autofit-shortcode.css
 *            * assets/css/autofit-assistant.css            (this file)
 *            * includes/core/class-autofit-assets.php
 *            * autofit-ai-search.php
 *
 *          NOTHING ELSE CHANGED -- every other rule is
 *          byte-for-byte identical to v2.15.6.
 *
 * v2.15.6 - CHAT GRID LAYOUT FIX (UX BUG):
 *
 *          PROBLEM:
 *            The chat's product sections (main / near_matches /
 *            suggestions) reuse AutoFit.Section.render(), which
 *            adds the class .autofit-sc-products-grid. That class
 *            is a CSS Grid whose fallback column count is 2 on
 *            mobile (media max-width: 900px) and 4 on desktop —
 *            controlled by --autofit-columns-mobile / -columns.
 *
 *            Those CSS variables are only defined on
 *            .autofit-search-card[data-autofit-instance]
 *            (shortcode). The chat window never received them,
 *            so the chat grid always fell back to 2 (mobile) /
 *            4 (desktop) columns — regardless of the store
 *            owner's setting.
 *
 *          FIX:
 *            Added a scoped override at the end of this file
 *            that forces the chat grid into a vertical stack
 *            (display:flex; flex-direction:column).
 *
 *          NO OTHER CHANGES — every other rule is byte-for-byte
 *          identical to v2.15.3.
 *
 * v2.15.3 - CHAT INPUT-GROUP LIGHT IN DARK MODE (UX FIX).
 * v2.15.2 - THEME RING AROUND TOGGLE IN CHAT (VISUAL POLISH).
 * v2.15.1 - NEUMORPHIC THEME TOGGLE IN CHAT (REDESIGN).
 * v2.15.0 - DARK/LIGHT MODE + THEME TOGGLE IN CHAT.
 * v2.14.4 - BOLDER / LARGER EMPTY-STATE MESSAGES IN CHAT.
 * v2.14.3 - FIX: TOGGLE SPACING.
 * v2.14.1 - TOGGLE POLISH IN CHAT.
 * v2.14.0 - COLLAPSIBLE SECTIONS + BOLDER TITLES.
 * v2.13.3 - THREE-SECTION STYLES IN CHAT (Phase 7).
 * v2.13.0 - TYPO CORRECTION BANNER (Phase 4).
 * v2.12.0 - CHAT SORT CONTROL STYLES.
 * v2.11.0 - CHAT RESULTS PAGINATION STYLES.
 * v2.9.7  - CHAT RECENT-SEARCH CHIPS VISIBILITY FIX.
 * v2.8.52 - CHAT CARD READABILITY.
 * v2.8.46 - HYBRID PRODUCT BADGES.
 * v2.8.20 - Price layout (white-space: pre-line).
 * v2.8.17 - Mobile UX.
 * v2.8.5  - Suggested Products styles for the chat surface.
 * v2.8.1  - FIX: Corrected malformed CSS comment.
 * v2.5.9  - Added: .autofit-custom-icon-img / .autofit-custom-icon-text.
 * v2.5.8  - Square aspect ratio for chat product images.
 * v2.5.6  - Fixed syntax errors.
 */

#autofit-chat-fab,
#autofit-chat-close,
#autofit-chat-clear-btn,
#autofit-chat-send-btn,
#autofit-chat-voice-btn,
#autofit-chat-recent .autofit-recent-item,
.autofit-chat-prod-card,
.autofit-chat-suggestions-btn,
.autofit-chat-pagination .autofit-page-btn,
.autofit-chat-sort .autofit-sort-select,
.autofit-typo-cancel,
.autofit-result-section .autofit-page-btn,
.autofit-result-section .autofit-sort-select,
.autofit-section-toggle,
.autofit-theme-toggle {
    touch-action: manipulation;
}

#autofit-chat-fab {
    position: fixed;
    bottom: calc(20px + env(safe-area-inset-bottom, 0px));
    right: calc(20px + env(safe-area-inset-right, 0px));
    background: #2563eb;
    color: #fff;
    border-radius: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(37, 99, 235, 0.4);
    z-index: 9999;
    transition: 0.2s;
    padding: 8px 16px;
    font-family: Tahoma, Arial, sans-serif;
    min-height: 44px;
    min-width: 44px;
}

#autofit-chat-fab:hover {
    transform: scale(1.04);
    background: #1d4ed8;
}

#autofit-chat-fab:focus-visible,
#autofit-chat-close:focus-visible,
#autofit-chat-clear-btn:focus-visible,
#autofit-chat-send-btn:focus-visible,
#autofit-chat-voice-btn:focus-visible {
    outline: 2px solid #2563eb;
    outline-offset: 2px;
}

#autofit-chat-fab:focus-visible {
    outline-color: #fff;
}

.autofit-fab-content {
    display: flex;
    align-items: center;
    gap: 8px;
}

.autofit-fab-custom-img {
    width: 26px;
    height: 26px;
    object-fit: contain;
    border-radius: 50%;
    display: block;
}

.autofit-fab-custom-text {
    font-size: 20px;
    line-height: 1;
}

.autofit-fab-text {
    font-size: 13px;
    font-weight: 600;
    color: #fff;
    white-space: nowrap;
}

.autofit-custom-icon-img {
    width: 20px;
    height: 20px;
    object-fit: contain;
    display: block;
    pointer-events: none;
}

.autofit-custom-icon-text {
    font-size: 16px;
    line-height: 1;
    pointer-events: none;
}

#autofit-chat-window {
    position: fixed;
    bottom: calc(90px + env(safe-area-inset-bottom, 0px));
    right: calc(20px + env(safe-area-inset-right, 0px));
    width: 380px;
    max-width: calc(100vw - 30px);
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
    border: 1px solid #e2e8f0;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    font-family: Tahoma, Arial, sans-serif;
    direction: rtl;
    transition: background-color 0.4s ease, border-color 0.4s ease;
}

#autofit-chat-window.autofit-chat-hidden {
    display: none;
}

/* =========================================================
Chat header — 2-column layout
========================================================= */
.autofit-chat-header {
    background: #2563eb;
    color: #fff;
    padding: 12px 15px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding-top: calc(12px + env(safe-area-inset-top, 0px));
    transition: background-color 0.4s ease;
}

.autofit-chat-header h3 {
    margin: 0;
    font-size: 15px;
    font-weight: 700;
    color: #fff;
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.autofit-chat-header-actions {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    flex: 0 0 auto;
}

/* =========================================================
NEUMORPHIC THEME TOGGLE (in chat)
========================================================= */

/* ---------- CHAT VARIANT (light mode — on blue header) ---------- */
.autofit-theme-toggle-chat {
    --autofit-toggle-pill-a:     rgba(255, 255, 255, 0.28);
    --autofit-toggle-pill-b:     rgba(255, 255, 255, 0.08);
    --autofit-toggle-rim-hi:     rgba(255, 255, 255, 0.55);
    --autofit-toggle-rim-lo:     rgba(0, 0, 0, 0.35);
    --autofit-toggle-icon:       #ffffff;
    --autofit-toggle-icon-glow:  transparent;
    --autofit-toggle-shadow:     rgba(0, 0, 0, 0.35);
    --autofit-toggle-focus:      #ffffff;
    --autofit-toggle-ring:       rgba(0, 0, 0, 0.85);

    flex: 0 0 auto;
    position: relative;
    width: 108px;
    height: 59px;
    min-width: 108px;
    min-height: 59px;
    padding: 0;
    margin: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background:
        radial-gradient(90px 70px at 30% 30%,
            var(--autofit-toggle-rim-hi), transparent 60%),
        linear-gradient(155deg,
            var(--autofit-toggle-pill-a),
            var(--autofit-toggle-pill-b));
    border: none;
    border-radius: 999px;
    box-shadow:
        inset 0 2px 3px var(--autofit-toggle-rim-hi),
        inset 0 -6px 10px var(--autofit-toggle-rim-lo),
        0 0 0 2px var(--autofit-toggle-ring),
        0 18px 30px -12px var(--autofit-toggle-shadow);
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
    transition: box-shadow 0.4s ease, background 0.4s ease;
    overflow: hidden;
    touch-action: manipulation;
}

.autofit-theme-toggle-chat::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    box-shadow: 0 1px 1px var(--autofit-toggle-rim-hi);
    pointer-events: none;
}

.autofit-theme-toggle-chat:hover {
    box-shadow:
        inset 0 2px 3px var(--autofit-toggle-rim-hi),
        inset 0 -8px 12px var(--autofit-toggle-rim-lo),
        0 0 0 2px var(--autofit-toggle-ring),
        0 22px 36px -12px var(--autofit-toggle-shadow);
}

.autofit-theme-toggle-chat:active {
    transform: translateY(1px);
}

.autofit-theme-toggle-chat:focus-visible {
    outline: 2px solid var(--autofit-toggle-focus);
    outline-offset: 4px;
}

/* ---------- Icons ---------- */
.autofit-theme-toggle-chat .autofit-toggle-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 26px;
    height: 26px;
    display: block;
    pointer-events: none;
    transition:
        opacity 0.45s ease,
        transform 0.5s cubic-bezier(0.6, -0.2, 0.3, 1.3),
        filter 0.5s ease;
}

.autofit-theme-toggle-chat .autofit-toggle-moon {
    color: var(--autofit-toggle-icon);
    opacity: 1;
    transform: translate(-50%, -50%) scale(1) rotate(0deg);
    filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.25));
}

.autofit-theme-toggle-chat .autofit-toggle-sun {
    color: var(--autofit-toggle-icon);
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.5) rotate(-90deg);
}

/* ---------- DARK MODE (chat window is dark) ---------- */
#autofit-chat-window[data-autofit-theme="dark"] .autofit-theme-toggle-chat {
    --autofit-toggle-pill-a:     #1c1f24;
    --autofit-toggle-pill-b:     #08090b;
    --autofit-toggle-rim-hi:     rgba(255, 255, 255, 0.08);
    --autofit-toggle-rim-lo:     rgba(0, 0, 0, 0.6);
    --autofit-toggle-icon:       #dfe6f5;
    --autofit-toggle-icon-glow:  #6fa8ff;
    --autofit-toggle-shadow:     rgba(0, 0, 0, 0.6);
    --autofit-toggle-focus:      #6fa8ff;
    --autofit-toggle-ring:       rgba(255, 255, 255, 0.9);
}

#autofit-chat-window[data-autofit-theme="dark"] .autofit-theme-toggle-chat .autofit-toggle-moon {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.5) rotate(90deg);
    filter: drop-shadow(0 0 8px var(--autofit-toggle-icon-glow));
}

#autofit-chat-window[data-autofit-theme="dark"] .autofit-theme-toggle-chat .autofit-toggle-sun {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1) rotate(0deg);
    filter:
        drop-shadow(0 0 10px var(--autofit-toggle-icon-glow))
        drop-shadow(0 0 22px var(--autofit-toggle-icon-glow));
}

/* ---------- INACTIVE STATE (before JS loads) ---------- */
.autofit-theme-toggle-chat.autofit-theme-toggle-inactive {
    opacity: 0;
    visibility: hidden;
}
.autofit-theme-toggle-chat:not(.autofit-theme-toggle-inactive) {
    opacity: 1;
    visibility: visible;
    transition:
        opacity 0.2s ease,
        visibility 0.2s ease,
        box-shadow 0.4s ease,
        background 0.4s ease;
}

/* Close button */
#autofit-chat-close {
    background: transparent;
    border: none;
    color: #fff;
    font-size: 16px;
    cursor: pointer;
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px;
    border-radius: 8px;
    transition: background 0.2s;
}

#autofit-chat-close:hover,
#autofit-chat-close:active {
    background: rgba(255, 255, 255, 0.15);
}

#autofit-chat-close:focus-visible {
    outline-color: #fff;
}

#autofit-chat-messages {
    padding: 12px;
    height: 340px;
    overflow-y: auto;
    background: #f8fafc;
    display: flex;
    flex-direction: column;
    gap: 10px;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    overscroll-behavior-y: contain;
    transition: background-color 0.4s ease;
}

.autofit-chat-msg {
    padding: 10px 12px;
    border-radius: 10px;
    font-size: 13px;
    width: 100%;
    line-height: 1.4;
    box-sizing: border-box;
    word-wrap: break-word;
    transition: background-color 0.4s ease, color 0.4s ease;
}

.autofit-chat-msg.ai {
    background: #e2e8f0;
    color: #1e293b;
    align-self: flex-start;
}

.autofit-chat-msg.user {
    background: #2563eb;
    color: #fff;
    align-self: flex-end;
    width: auto;
    max-width: 90%;
}

.autofit-chat-input-area {
    padding: 10px;
    background: #fff;
    border-top: 1px solid #e2e8f0;
    padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
    transition: background-color 0.4s ease, border-color 0.4s ease;
}

.autofit-chat-input-area .autofit-search-input-group {
    display: flex;
    gap: 6px;
    align-items: center;
    background: #f8fafc;
    padding: 6px;
    border: 2px solid #cbd5e1;
    border-radius: 10px;
    transition: all 0.3s ease;
    margin-bottom: 8px;
}

.autofit-chat-input-area .autofit-search-input-group:focus-within {
    border-color: #2563eb;
    background: #fff;
}

#autofit-chat-input {
    flex: 1;
    border: none;
    background: transparent;
    padding: 6px;
    font-size: 13px;
    outline: none;
    color: #1e293b;
    font-family: Tahoma, Arial, sans-serif;
    transition: color 0.4s ease;
}

#autofit-chat-input::placeholder {
    color: #94a3b8;
}

#autofit-chat-clear-btn {
    background: #fff;
    border: 1px solid #cbd5e1;
    width: 44px;
    height: 44px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #64748b;
    padding: 0;
    flex-shrink: 0;
    transition: background-color 0.4s ease, border-color 0.4s ease, color 0.4s ease;
}

#autofit-chat-clear-btn.autofit-chat-clear-hidden {
    display: none;
}

#autofit-chat-send-btn {
    width: 100%;
    background: #2563eb;
    color: #fff;
    border: none;
    padding: 12px;
    min-height: 44px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    font-family: Tahoma, Arial, sans-serif;
    margin-top: 8px;
}

#autofit-chat-send-btn:hover {
    background: #1d4ed8;
}

#autofit-chat-voice-btn {
    width: 100%;
    background: #25D366;
    color: #fff;
    border: none;
    padding: 12px;
    min-height: 48px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    font-family: Tahoma, Arial, sans-serif;
    margin-top: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: 0.2s;
    box-shadow: 0 2px 8px rgba(37, 211, 102, 0.3);
}

#autofit-chat-voice-btn:hover {
    background: #1DA851;
    box-shadow: 0 4px 12px rgba(37, 211, 102, 0.5);
}

#autofit-chat-voice-btn .autofit-voice-icon {
    fill: currentColor;
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

#autofit-chat-voice-btn.recording {
    background: #dc2626;
    box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.6);
    animation: voice-pulse 1.2s ease-in-out infinite;
}

#autofit-chat-voice-btn.recording .autofit-voice-icon {
    fill: #fff;
}

@keyframes voice-pulse {
    0% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.5); }
    70% { box-shadow: 0 0 0 12px rgba(220, 38, 38, 0); }
    100% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0); }
}

#autofit-chat-recent {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 8px;
}

#autofit-chat-recent:empty {
    display: none !important;
}

#autofit-chat-recent .autofit-recent-item {
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    color: #334155;
    font-size: 11px;
    padding: 4px 10px;
    border-radius: 20px;
    cursor: pointer;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-height: 32px;
    display: inline-flex;
    align-items: center;
    transition: background-color 0.4s ease, color 0.4s ease, border-color 0.4s ease;
}

#autofit-chat-recent .autofit-recent-item:hover {
    background: #e2e8f0;
}

@keyframes autofitFadeIn {
    from {
        opacity: 0;
        transform: translateY(6px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.autofit-chat-products-list {
    margin-top: 8px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.autofit-chat-products-container {
    margin-top: 8px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.autofit-chat-prod-card {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    background: #fff;
    padding: 12px;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    text-decoration: none;
    color: #1e293b;
    transition: all 0.2s ease;
    animation: autofitFadeIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.autofit-chat-prod-card:hover {
    border-color: #2563eb;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.1);
}

.autofit-chat-prod-img-wrap {
    position: relative;
    flex-shrink: 0;
    width: 84px;
    height: 84px;
    display: block;
    line-height: 0;
}

.autofit-chat-prod-img-wrap .autofit-chat-prod-img {
    display: block;
    width: 100%;
    height: 100%;
    aspect-ratio: 1 / 1;
    object-fit: cover;
    object-position: center;
    border-radius: 6px;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    box-sizing: border-box;
}

.autofit-chat-prod-img {
    width: 84px;
    height: 84px;
    aspect-ratio: 1 / 1;
    object-fit: cover;
    object-position: center;
    border-radius: 6px;
    flex-shrink: 0;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
}

.autofit-chat-prod-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.autofit-chat-prod-name {
    font-weight: 700;
    font-size: 14px;
    color: #1e293b;
    line-height: 1.5;
    word-break: break-word;
    white-space: normal;
    overflow: visible;
}

.autofit-chat-prod-price {
    color: #2563eb;
    font-size: 14px;
    font-weight: 700;
    white-space: pre-line;
    line-height: 1.5;
}

.autofit-chat-prod-view {
    align-self: flex-start;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #eff6ff;
    color: #2563eb;
    border: 1px solid #bfdbfe;
    border-radius: 6px;
    padding: 4px 10px;
    font-size: 11px;
    font-weight: 600;
    line-height: 1.2;
    margin-top: 2px;
    pointer-events: none;
    white-space: nowrap;
}

.autofit-chat-prod-card:hover .autofit-chat-prod-view {
    background: #2563eb;
    color: #fff;
    border-color: #2563eb;
}

.autofit-skeleton-loading {
    animation: autofitFadeIn 0.3s ease;
}

.autofit-skeleton-card {
    pointer-events: none;
}

.autofit-skeleton-img {
    width: 84px;
    height: 84px;
    aspect-ratio: 1 / 1;
    border-radius: 6px;
    background: linear-gradient(90deg, #e2e8f0 25%, #f1f5f9 50%, #e2e8f0 75%);
    background-size: 200% 100%;
    animation: autofitSkeletonShimmer 1.5s infinite;
    flex-shrink: 0;
}

.autofit-skeleton-line {
    height: 14px;
    border-radius: 4px;
    background: linear-gradient(90deg, #e2e8f0 25%, #f1f5f9 50%, #e2e8f0 75%);
    background-size: 200% 100%;
    animation: autofitSkeletonShimmer 1.5s infinite;
    margin-bottom: 6px;
}

.autofit-skeleton-name { width: 85%; }
.autofit-skeleton-name-short { width: 60%; }
.autofit-skeleton-price {
    width: 40%;
    height: 12px;
    margin-top: 4px;
}

@keyframes autofitSkeletonShimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.autofit-chat-suggestions-btn {
    display: block;
    width: 100%;
    box-sizing: border-box;
    padding: 10px 12px;
    margin: 0 0 8px 0;
    background: #16a34a;
    color: #fff;
    border: none;
    border-radius: 10px;
    font-family: Tahoma, Arial, sans-serif;
    font-size: 13px;
    font-weight: 600;
    line-height: 1.4;
    text-align: center;
    cursor: pointer;
    box-shadow: 0 3px 10px rgba(22, 163, 74, 0.2);
    transition: background 0.2s ease, box-shadow 0.2s ease;
    min-height: 40px;
}

.autofit-chat-suggestions-btn:hover {
    background: #15803d;
    box-shadow: 0 5px 14px rgba(22, 163, 74, 0.35);
}

.autofit-chat-suggestions-btn:focus-visible {
    outline: 2px solid #16a34a;
    outline-offset: 2px;
}

.autofit-chat-suggestions-btn.autofit-suggestions-btn-active {
    background: #15803d;
}

.autofit-chat-suggestions-container {
    display: none;
    margin-top: 6px;
}

.autofit-chat-suggestions-container.autofit-suggestions-visible {
    display: block;
}

.autofit-suggestions-chat-list {
    margin-top: 4px;
}

.autofit-suggestions-chat-list .autofit-chat-prod-card {
    border-left: 3px solid #16a34a;
}

.autofit-suggestions-chat-list .autofit-chat-prod-card:hover {
    border-color: #16a34a;
    box-shadow: 0 2px 8px rgba(22, 163, 74, 0.15);
}

.autofit-chat-prod-img-wrap .autofit-product-badges {
    position: absolute;
    top: 3px;
    left: 3px;
    z-index: 3;
    display: flex;
    flex-direction: column;
    gap: 3px;
    pointer-events: none;
    max-width: calc(100% - 6px);
}

.autofit-chat-prod-img-wrap .autofit-badge-out-of-stock,
.autofit-chat-prod-img-wrap .autofit-badge-on-sale,
.autofit-chat-prod-img-wrap .autofit-badge-new,
.autofit-chat-prod-img-wrap .autofit-badge-featured {
    display: inline-block;
    align-self: flex-start;
    background: #dc2626;
    color: #ffffff;
    padding: 3px 7px;
    font-size: 10px;
    font-weight: 700;
    line-height: 1.2;
    border-radius: 4px;
    white-space: nowrap;
    font-family: Tahoma, Arial, sans-serif;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
    text-shadow: none;
}

/* =========================================================
   THREE-SECTION RENDERING (chat surface)
   ========================================================= */
.autofit-chat-banners {
    display: block;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    margin: 0 0 8px 0;
}
.autofit-chat-banners:empty {
    display: none;
    margin: 0;
}
.autofit-section-host {
    display: block;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    margin: 0 0 20px 0;
    padding: 0;
}
.autofit-section-host:last-child {
    margin-bottom: 0;
}
.autofit-section-host:empty {
    display: none;
    margin: 0;
}
.autofit-result-section {
    display: block;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    margin: 0 0 14px 0;
    padding: 0;
}
.autofit-result-section:last-child {
    margin-bottom: 0;
}
.autofit-result-section + .autofit-result-section {
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px dashed #cbd5e1;
}
/* Section title in chat */
.autofit-section-title {
    margin: 0 0 10px 0;
    padding: 0 0 8px 0;
    font-family: Tahoma, Arial, sans-serif;
    font-size: 16px;
    font-weight: 800;
    color: #0f172a;
    line-height: 1.35;
    letter-spacing: -0.2px;
    text-align: right;
    direction: rtl;
    border-bottom: 2.5px solid #2563eb;
    display: flex;
    align-items: center;
    gap: 8px;
}
.autofit-section-title::before {
    content: "📋";
    font-size: 18px;
    flex-shrink: 0;
}
.autofit-result-section[data-section="near_matches"] .autofit-section-title {
    border-bottom-color: #0891b2;
}
.autofit-result-section[data-section="near_matches"] .autofit-section-title::before {
    content: "🔍";
}
.autofit-result-section[data-section="suggestions"] .autofit-section-title {
    border-bottom-color: #16a34a;
}
.autofit-result-section[data-section="suggestions"] .autofit-section-title::before {
    content: "💡";
}

/* =========================================================
   COLLAPSIBLE TOGGLE BUTTON IN CHAT
   ========================================================= */
.autofit-result-section[data-collapsible="1"] {
    margin: 0 !important;
    padding: 0 !important;
}
.autofit-section-toggle {
    display: block !important;
    position: relative !important;
    width: 100% !important;
    min-height: 46px !important;
    padding: 12px 50px !important;
    margin: 0 !important;
    background: #0891b2 !important;
    color: #ffffff !important;
    border: none !important;
    border-radius: 10px !important;
    box-shadow: 0 3px 10px rgba(8, 145, 178, 0.22) !important;
    font-family: Tahoma, Arial, sans-serif !important;
    font-size: 14px !important;
    font-weight: 700 !important;
    line-height: 1.4 !important;
    text-align: center !important;
    direction: rtl !important;
    cursor: pointer !important;
    box-sizing: border-box !important;
    -webkit-appearance: none !important;
    appearance: none !important;
    transition: background-color 0.15s ease, box-shadow 0.15s ease !important;
    touch-action: manipulation;
}
.autofit-section-toggle:hover {
    background: #0e7490 !important;
    box-shadow: 0 5px 14px rgba(8, 145, 178, 0.32) !important;
}
.autofit-section-toggle:active {
    transform: translateY(1px) !important;
}
.autofit-section-toggle:focus-visible {
    outline: 2px solid #0891b2 !important;
    outline-offset: 2px !important;
}
.autofit-toggle-label {
    display: inline !important;
    text-align: center !important;
    padding: 0 !important;
    margin: 0 !important;
    font: inherit !important;
    color: inherit !important;
    word-break: break-word;
}
.autofit-result-section .autofit-toggle-icon {
    position: absolute !important;
    left: 12px !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 24px !important;
    height: 24px !important;
    background: rgba(255, 255, 255, 0.18) !important;
    border-radius: 50% !important;
    font-size: 10px !important;
    line-height: 1 !important;
    transition: transform 0.25s ease;
    pointer-events: none;
}
.autofit-result-section.autofit-section-open .autofit-toggle-icon {
    transform: translateY(-50%) rotate(0deg);
}
.autofit-result-section[data-section="suggestions"] .autofit-section-toggle {
    background: #16a34a !important;
    box-shadow: 0 3px 10px rgba(22, 163, 74, 0.22) !important;
}
.autofit-result-section[data-section="suggestions"] .autofit-section-toggle:hover {
    background: #15803d !important;
    box-shadow: 0 5px 14px rgba(22, 163, 74, 0.32) !important;
}
.autofit-result-section[data-section="suggestions"] .autofit-section-toggle:focus-visible {
    outline-color: #16a34a !important;
}
.autofit-section-body {
    display: block;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    padding: 12px 0 0 0;
}
.autofit-section-body:empty {
    display: none;
    padding: 0;
}

.autofit-section-sort {
    margin: 0 0 8px 0;
    padding: 0;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    direction: rtl;
    text-align: center;
}
.autofit-section-sort:empty {
    display: none;
    margin: 0;
}
.autofit-section-pagination {
    margin: 10px 0 0 0;
    padding: 0;
    width: 100%;
    text-align: center;
    direction: rtl;
}
.autofit-section-pagination:empty {
    display: none;
    margin: 0;
}

/* =========================================================
   EMPTY STATE IN CHAT — COMPACT (v3.7.7)
   =========================================================
   Reduced from the previous "BOLD + LARGE" size, matching
   the shortcode-side change from the same release. The chat
   window is narrower (380px) so the max-width is 300px.
   ========================================================= */
.autofit-section-empty {
    margin: 0 auto !important;
    padding: 12px 14px !important;
    max-width: 300px !important;
    width: 100% !important;
    text-align: center !important;
    font-family: Tahoma, Arial, sans-serif !important;
    font-size: 12.5px !important;
    font-weight: 700 !important;
    color: #334155 !important;
    background: #f8fafc !important;
    border: 2px dashed #94a3b8 !important;
    border-radius: 8px !important;
    line-height: 1.5 !important;
    letter-spacing: -0.1px !important;
    direction: rtl !important;
    box-sizing: border-box !important;
}
.autofit-section-empty::before {
    content: "🔎" !important;
    display: block !important;
    font-size: 20px !important;
    line-height: 1 !important;
    margin-bottom: 4px !important;
    opacity: 0.85 !important;
}

/* Products grid inside a chat section. */
.autofit-result-section .autofit-chat-products-list {
    margin-top: 0;
}
/* Sort control inside a chat section (compact). */
.autofit-result-section .autofit-sort-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-family: Tahoma, Arial, sans-serif;
    font-size: 11px;
    font-weight: 600;
    color: #334155;
    white-space: nowrap;
}
.autofit-result-section .autofit-sort-select {
    display: inline-block;
    min-width: 130px;
    max-width: 100%;
    height: 32px;
    padding: 3px 8px;
    margin: 0;
    background: #ffffff;
    color: #1e293b;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    font-family: Tahoma, Arial, sans-serif;
    font-size: 11px;
    font-weight: 600;
    line-height: 1.3;
    text-align: right;
    direction: rtl;
    cursor: pointer;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='7' viewBox='0 0 10 7'%3E%3Cpath fill='%2364748b' d='M5 7L0 0h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: left 8px center;
    padding-left: 22px;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
    touch-action: manipulation;
}
.autofit-result-section .autofit-sort-select:hover {
    border-color: #2563eb;
}
.autofit-result-section .autofit-sort-select:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}
/* Pagination inside a chat section (compact). */
.autofit-result-section .autofit-pagination-inner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 4px 0;
}
.autofit-result-section .autofit-page-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    min-height: 32px;
    padding: 3px 7px;
    margin: 0;
    background: #ffffff;
    color: #1e293b;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    font-family: Tahoma, Arial, sans-serif;
    font-size: 11px;
    font-weight: 600;
    line-height: 1.2;
    text-align: center;
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
    -webkit-appearance: none;
    appearance: none;
    user-select: none;
}
.autofit-result-section .autofit-page-btn:hover {
    background: #eff6ff;
    border-color: #2563eb;
    color: #1d4ed8;
}
.autofit-result-section .autofit-page-btn:active {
    background: #dbeafe;
    transform: translateY(1px);
}
.autofit-result-section .autofit-page-btn:focus-visible {
    outline: 2px solid #2563eb;
    outline-offset: 2px;
}
.autofit-result-section .autofit-page-btn.autofit-page-active {
    background: #2563eb;
    border-color: #2563eb;
    color: #ffffff;
    cursor: default;
}
.autofit-result-section .autofit-page-btn.autofit-page-active:hover {
    background: #2563eb;
    color: #ffffff;
}
.autofit-result-section .autofit-page-btn.autofit-page-disabled,
.autofit-result-section .autofit-page-btn[disabled] {
    background: #f1f5f9;
    border-color: #e2e8f0;
    color: #94a3b8;
    cursor: not-allowed;
    opacity: 0.7;
}
.autofit-result-section .autofit-page-ellipsis {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    min-height: 32px;
    padding: 0 3px;
    color: #64748b;
    font-weight: 700;
    user-select: none;
    font-size: 11px;
}
/* Typo banner (chat surface). */
.autofit-typo-banner {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    border-radius: 8px;
    padding: 10px 12px;
    margin: 0 0 10px 0;
    direction: rtl;
    text-align: right;
    font-family: Tahoma, Arial, sans-serif;
    box-sizing: border-box;
    width: 100%;
    max-width: 100%;
}
.autofit-typo-icon {
    font-size: 16px;
    line-height: 1;
    flex-shrink: 0;
}
.autofit-typo-text {
    flex: 1 1 auto;
    min-width: 0;
}
.autofit-typo-main {
    font-size: 12px;
    font-weight: 700;
    color: #166534;
    line-height: 1.5;
    margin-bottom: 2px;
    word-break: break-word;
}
.autofit-typo-sub {
    font-size: 10px;
    color: #166534;
    opacity: 0.8;
    line-height: 1.4;
    word-break: break-word;
}
.autofit-typo-cancel {
    flex-shrink: 0;
    background: #ffffff;
    border: 1px solid #16a34a;
    color: #16a34a;
    border-radius: 6px;
    padding: 5px 10px;
    font-size: 10px;
    font-weight: 600;
    line-height: 1.3;
    cursor: pointer;
    min-height: 30px;
    font-family: Tahoma, Arial, sans-serif;
    white-space: nowrap;
    transition: background-color 0.15s ease, color 0.15s ease;
    -webkit-appearance: none;
    appearance: none;
    touch-action: manipulation;
}
.autofit-typo-cancel:hover {
    background: #16a34a;
    color: #ffffff;
}
.autofit-typo-cancel:active {
    background: #15803d;
    color: #ffffff;
}
.autofit-typo-cancel:focus-visible {
    outline: 2px solid #16a34a;
    outline-offset: 2px;
}
/* Year hint banner (chat surface). */
.autofit-year-hint-banner {
    display: flex;
    align-items: center;
    gap: 6px;
    background: #fefce8;
    border: 1px solid #fde68a;
    border-radius: 8px;
    padding: 8px 10px;
    margin: 0 0 10px 0;
    text-align: right;
    direction: rtl;
    font-family: Tahoma, Arial, sans-serif;
    font-size: 11px;
    color: #92400e;
    line-height: 1.5;
    box-sizing: border-box;
    width: 100%;
    max-width: 100%;
}

/* =========================================================
   Legacy chat sort control (kept for compat)
   ========================================================= */
.autofit-chat-sort {
    margin: 10px 0 0 0;
    padding: 0;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    direction: rtl;
    text-align: center;
}
.autofit-chat-sort:empty {
    display: none;
    margin: 0;
}
.autofit-chat-sort .autofit-sort-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-family: Tahoma, Arial, sans-serif;
    font-size: 12px;
    font-weight: 600;
    color: #334155;
    white-space: nowrap;
}
.autofit-chat-sort .autofit-sort-select {
    display: inline-block;
    min-width: 140px;
    max-width: 100%;
    height: 34px;
    padding: 4px 10px;
    margin: 0;
    background: #ffffff;
    color: #1e293b;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    font-family: Tahoma, Arial, sans-serif;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.3;
    text-align: right;
    direction: rtl;
    cursor: pointer;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='7' viewBox='0 0 10 7'%3E%3Cpath fill='%2364748b' d='M5 7L0 0h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: left 9px center;
    padding-left: 26px;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
    touch-action: manipulation;
}
.autofit-chat-sort .autofit-sort-select:hover {
    border-color: #2563eb;
}
.autofit-chat-sort .autofit-sort-select:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}
.autofit-chat-sort .autofit-sort-select:focus-visible {
    outline: 2px solid #2563eb;
    outline-offset: 2px;
}

/* =========================================================
   Legacy chat pagination (kept for compat)
   ========================================================= */
.autofit-chat-pagination {
    margin: 10px 0 0 0;
    padding: 0;
    width: 100%;
    text-align: center;
    direction: rtl;
}
.autofit-chat-pagination:empty {
    display: none;
}
.autofit-chat-pagination .autofit-pagination-inner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 4px 0;
}
.autofit-chat-pagination .autofit-page-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 34px;
    min-height: 34px;
    padding: 4px 8px;
    margin: 0;
    background: #ffffff;
    color: #1e293b;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    font-family: Tahoma, Arial, sans-serif;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.2;
    text-align: center;
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
    -webkit-appearance: none;
    appearance: none;
    user-select: none;
}
.autofit-chat-pagination .autofit-page-btn:hover {
    background: #eff6ff;
    border-color: #2563eb;
    color: #1d4ed8;
}
.autofit-chat-pagination .autofit-page-btn:active {
    background: #dbeafe;
    transform: translateY(1px);
}
.autofit-chat-pagination .autofit-page-btn:focus-visible {
    outline: 2px solid #2563eb;
    outline-offset: 2px;
}
.autofit-chat-pagination .autofit-page-btn.autofit-page-active {
    background: #2563eb;
    border-color: #2563eb;
    color: #ffffff;
    box-shadow: 0 2px 6px rgba(37, 99, 235, 0.3);
    cursor: default;
}
.autofit-chat-pagination .autofit-page-btn.autofit-page-active:hover {
    background: #2563eb;
    color: #ffffff;
}
.autofit-chat-pagination .autofit-page-btn.autofit-page-disabled,
.autofit-chat-pagination .autofit-page-btn[disabled] {
    background: #f1f5f9;
    border-color: #e2e8f0;
    color: #94a3b8;
    cursor: not-allowed;
    opacity: 0.7;
}
.autofit-chat-pagination .autofit-page-ellipsis {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    min-height: 34px;
    padding: 0 3px;
    color: #64748b;
    font-weight: 700;
    user-select: none;
    font-size: 12px;
}

/* =========================================================
📱 MOBILE (max-width 480)
========================================================= */
@media (max-width: 480px) {
    #autofit-chat-window {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100vw;
        max-width: 100vw;
        height: 100vh;
        max-height: 100vh;
        height: 100dvh;
        max-height: 100dvh;
        border-radius: 0;
        border: none;
        z-index: 99999;
        display: flex;
        flex-direction: column;
    }

    #autofit-chat-window.autofit-chat-hidden {
        display: none !important;
    }

    .autofit-chat-header {
        padding: 16px 20px;
        padding-top: calc(16px + env(safe-area-inset-top, 0px));
        background: #2563eb;
    }

    .autofit-chat-header h3 {
        font-size: 16px;
    }

    .autofit-chat-header-actions {
        gap: 6px;
    }

    .autofit-theme-toggle-chat {
        width: 90px;
        height: 49px;
        min-width: 90px;
        min-height: 49px;
    }
    .autofit-theme-toggle-chat .autofit-toggle-icon {
        width: 22px;
        height: 22px;
    }

    #autofit-chat-close {
        font-size: 22px;
        padding: 8px;
    }

    #autofit-chat-messages {
        flex: 1;
        height: auto !important;
        max-height: none;
        padding: 16px;
    }

    .autofit-chat-input-area {
        padding: 12px 16px;
        padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
        background: #fff;
        box-shadow: 0 -4px 15px rgba(0, 0, 0, 0.05);
    }

    #autofit-chat-input {
        font-size: 16px !important;
    }

    #autofit-chat-voice-btn {
        font-size: 15px;
        min-height: 52px;
        padding: 14px;
    }

    #autofit-chat-send-btn {
        font-size: 15px;
        min-height: 48px;
    }

    #autofit-chat-clear-btn {
        width: 44px;
        height: 44px;
    }

    .autofit-chat-prod-card {
        padding: 14px;
        gap: 14px;
    }

    .autofit-chat-prod-img-wrap {
        width: 88px;
        height: 88px;
    }

    .autofit-chat-prod-img {
        width: 88px;
        height: 88px;
    }

    .autofit-chat-prod-name {
        font-size: 15px;
        line-height: 1.55;
    }

    .autofit-chat-prod-price {
        font-size: 15px;
    }

    .autofit-chat-prod-view {
        font-size: 12px;
        padding: 5px 12px;
    }

    .autofit-skeleton-img {
        width: 88px;
        height: 88px;
    }

    .autofit-skeleton-line {
        height: 15px;
    }

    #autofit-chat-recent .autofit-recent-item {
        font-size: 12px;
        padding: 6px 12px;
        min-height: 36px;
    }

    .autofit-chat-suggestions-btn {
        font-size: 14px;
        min-height: 46px;
        padding: 12px;
    }

    .autofit-chat-prod-img-wrap .autofit-badge-out-of-stock,
    .autofit-chat-prod-img-wrap .autofit-badge-on-sale,
    .autofit-chat-prod-img-wrap .autofit-badge-new,
    .autofit-chat-prod-img-wrap .autofit-badge-featured {
        font-size: 11px;
        padding: 3px 8px;
    }

    .autofit-chat-pagination .autofit-page-btn,
    .autofit-result-section .autofit-page-btn {
        min-width: 38px;
        min-height: 38px;
        padding: 5px 10px;
        font-size: 13px;
    }
    .autofit-chat-pagination .autofit-page-ellipsis,
    .autofit-result-section .autofit-page-ellipsis {
        min-height: 38px;
    }

    .autofit-chat-sort .autofit-sort-label,
    .autofit-result-section .autofit-sort-label {
        flex-direction: column;
        align-items: stretch;
        gap: 5px;
        width: 100%;
        font-size: 12px;
    }
    .autofit-chat-sort .autofit-sort-select,
    .autofit-result-section .autofit-sort-select {
        width: 100%;
        min-width: 0;
        max-width: 100%;
        height: 40px;
        font-size: 13px;
        padding: 6px 28px 6px 10px;
        background-position: left 9px center;
    }

    .autofit-typo-banner {
        flex-wrap: wrap;
        padding: 10px 12px;
    }
    .autofit-typo-text {
        flex-basis: calc(100% - 28px);
    }
    .autofit-typo-main {
        font-size: 13px;
    }
    .autofit-typo-sub {
        font-size: 11px;
    }
    .autofit-typo-cancel {
        width: 100%;
        margin-top: 6px;
        min-height: 38px;
        font-size: 12px;
    }

    .autofit-section-title {
        font-size: 15px;
        margin-bottom: 10px;
        padding-bottom: 8px;
        border-bottom-width: 2.5px;
    }
    .autofit-section-title::before {
        font-size: 17px;
    }
    .autofit-section-toggle {
        min-height: 48px !important;
        padding: 12px 48px !important;
        font-size: 14px !important;
    }
    .autofit-result-section .autofit-toggle-icon {
        width: 26px;
        height: 26px;
        font-size: 11px;
        left: 12px;
    }
    .autofit-section-host {
        margin-bottom: 16px;
    }
    .autofit-section-body {
        padding-top: 12px;
    }

    /* ✅ v3.7.7: compact empty state on mobile */
    .autofit-section-empty {
        padding: 12px 14px !important;
        font-size: 12.5px !important;
        border-radius: 8px !important;
        max-width: 300px !important;
        line-height: 1.5 !important;
    }
    .autofit-section-empty::before {
        font-size: 20px !important;
        margin-bottom: 4px !important;
    }
}

@media (max-width: 380px) {
    .autofit-theme-toggle-chat {
        width: 78px;
        height: 43px;
        min-width: 78px;
        min-height: 43px;
    }
    .autofit-theme-toggle-chat .autofit-toggle-icon {
        width: 20px;
        height: 20px;
    }
    /* ✅ v3.7.7: very small screens — even tighter */
    .autofit-section-empty {
        padding: 10px 12px !important;
        font-size: 12px !important;
    }
    .autofit-section-empty::before {
        font-size: 18px !important;
        margin-bottom: 3px !important;
    }
}

@media (max-height: 500px) and (orientation: landscape) {
    #autofit-chat-messages {
        height: 200px !important;
    }

    .autofit-chat-header {
        padding: 8px 16px;
    }
}

/* =========================================================
✅ v2.15.0 / v2.15.1 / v2.15.2 / v2.15.3: DARK MODE — SCOPED TO CHAT
=========================================================

✅ v2.15.3 CHANGES (UX FIX):
   The chat input-group now stays LIGHT in dark mode,
   matching the shortcode card. Only the surrounding
   input-area (padding region) remains dark.

   Changed:
     • input-group background:   #0f172a → #f8fafc
     • input-group border:       #334155 → #cbd5e1
     • focus-within background:  #0f172a → #ffffff
     • focus-within border:      #3b82f6 → #2563eb
     • input color:              #f1f5f9 → #1e293b
     • input placeholder:        #64748b → #94a3b8
     • clear-btn background:     #1e293b → #ffffff
     • clear-btn border:         #334155 → #cbd5e1
     • clear-btn icon:           #cbd5e1 → #64748b
     • clear-btn hover bg:       #334155 → #f1f5f9
     • clear-btn hover icon:     #ffffff → #0f172a
========================================================= */
#autofit-chat-window[data-autofit-theme="dark"] {
    background: #1e293b;
    border-color: #334155;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}
#autofit-chat-window[data-autofit-theme="dark"] .autofit-chat-header {
    background: #0f172a;
}
#autofit-chat-window[data-autofit-theme="dark"] .autofit-chat-header h3 {
    color: #f1f5f9;
}
#autofit-chat-window[data-autofit-theme="dark"] #autofit-chat-close {
    color: #f1f5f9;
}
#autofit-chat-window[data-autofit-theme="dark"] #autofit-chat-close:hover,
#autofit-chat-window[data-autofit-theme="dark"] #autofit-chat-close:active {
    background: rgba(255, 255, 255, 0.15);
}
#autofit-chat-window[data-autofit-theme="dark"] #autofit-chat-messages {
    background: #0f172a;
}
#autofit-chat-window[data-autofit-theme="dark"] .autofit-chat-msg.ai {
    background: #334155;
    color: #e2e8f0;
}
#autofit-chat-window[data-autofit-theme="dark"] .autofit-chat-msg.user {
    background: #3b82f6;
    color: #ffffff;
}
#autofit-chat-window[data-autofit-theme="dark"] .autofit-chat-input-area {
    background: #1e293b;
    border-top-color: #334155;
}

/* ✅ v2.15.3: input-group STAYS LIGHT in dark mode */
#autofit-chat-window[data-autofit-theme="dark"] .autofit-chat-input-area .autofit-search-input-group {
    background: #f8fafc;
    border-color: #cbd5e1;
}
#autofit-chat-window[data-autofit-theme="dark"] .autofit-chat-input-area .autofit-search-input-group:focus-within {
    background: #ffffff;
    border-color: #2563eb;
}
#autofit-chat-window[data-autofit-theme="dark"] #autofit-chat-input {
    color: #1e293b;
}
#autofit-chat-window[data-autofit-theme="dark"] #autofit-chat-input::placeholder {
    color: #94a3b8;
}
#autofit-chat-window[data-autofit-theme="dark"] #autofit-chat-clear-btn {
    background: #ffffff;
    border-color: #cbd5e1;
    color: #64748b;
}
#autofit-chat-window[data-autofit-theme="dark"] #autofit-chat-clear-btn:hover {
    background: #f1f5f9;
    color: #0f172a;
}

/* Rest of the dark mode (send btn, recent chips, product cards, ...) */
#autofit-chat-window[data-autofit-theme="dark"] #autofit-chat-send-btn {
    background: #3b82f6;
}
#autofit-chat-window[data-autofit-theme="dark"] #autofit-chat-send-btn:hover {
    background: #2563eb;
}
#autofit-chat-window[data-autofit-theme="dark"] #autofit-chat-recent .autofit-recent-item {
    background: #1e293b;
    border-color: #334155;
    color: #cbd5e1;
}
#autofit-chat-window[data-autofit-theme="dark"] #autofit-chat-recent .autofit-recent-item:hover {
    background: #334155;
}
#autofit-chat-window[data-autofit-theme="dark"] .autofit-chat-prod-card {
    background: #1e293b;
    border-color: #334155;
    color: #e2e8f0;
}
#autofit-chat-window[data-autofit-theme="dark"] .autofit-chat-prod-card:hover {
    border-color: #3b82f6;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.15);
}
#autofit-chat-window[data-autofit-theme="dark"] .autofit-chat-prod-name {
    color: #f1f5f9;
}
#autofit-chat-window[data-autofit-theme="dark"] .autofit-chat-prod-price {
    color: #60a5fa;
}
#autofit-chat-window[data-autofit-theme="dark"] .autofit-chat-prod-view {
    background: #1e40af;
    color: #dbeafe;
    border-color: #1e3a8a;
}
#autofit-chat-window[data-autofit-theme="dark"] .autofit-chat-prod-card:hover .autofit-chat-prod-view {
    background: #3b82f6;
    color: #ffffff;
    border-color: #3b82f6;
}
#autofit-chat-window[data-autofit-theme="dark"] .autofit-skeleton-img,
#autofit-chat-window[data-autofit-theme="dark"] .autofit-skeleton-line {
    background: linear-gradient(90deg, #334155 25%, #475569 50%, #334155 75%);
    background-size: 200% 100%;
}
#autofit-chat-window[data-autofit-theme="dark"] .autofit-chat-suggestions-btn {
    background: #16a34a;
}
#autofit-chat-window[data-autofit-theme="dark"] .autofit-chat-suggestions-btn:hover,
#autofit-chat-window[data-autofit-theme="dark"] .autofit-chat-suggestions-btn.autofit-suggestions-btn-active {
    background: #15803d;
}
#autofit-chat-window[data-autofit-theme="dark"] .autofit-chat-prod-img-wrap .autofit-badge-out-of-stock,
#autofit-chat-window[data-autofit-theme="dark"] .autofit-chat-prod-img-wrap .autofit-badge-on-sale,
#autofit-chat-window[data-autofit-theme="dark"] .autofit-chat-prod-img-wrap .autofit-badge-new,
#autofit-chat-window[data-autofit-theme="dark"] .autofit-chat-prod-img-wrap .autofit-badge-featured {
    background: #dc2626;
    color: #ffffff;
}
#autofit-chat-window[data-autofit-theme="dark"] .autofit-chat-pagination .autofit-page-btn,
#autofit-chat-window[data-autofit-theme="dark"] .autofit-result-section .autofit-page-btn {
    background: #1e293b;
    color: #e2e8f0;
    border-color: #334155;
}
#autofit-chat-window[data-autofit-theme="dark"] .autofit-chat-pagination .autofit-page-btn:hover,
#autofit-chat-window[data-autofit-theme="dark"] .autofit-result-section .autofit-page-btn:hover {
    background: #1e40af;
    border-color: #3b82f6;
    color: #dbeafe;
}
#autofit-chat-window[data-autofit-theme="dark"] .autofit-chat-pagination .autofit-page-btn.autofit-page-active,
#autofit-chat-window[data-autofit-theme="dark"] .autofit-result-section .autofit-page-btn.autofit-page-active {
    background: #3b82f6;
    border-color: #3b82f6;
    color: #ffffff;
}
#autofit-chat-window[data-autofit-theme="dark"] .autofit-chat-pagination .autofit-page-ellipsis,
#autofit-chat-window[data-autofit-theme="dark"] .autofit-result-section .autofit-page-ellipsis {
    color: #94a3b8;
}
#autofit-chat-window[data-autofit-theme="dark"] .autofit-chat-sort .autofit-sort-label,
#autofit-chat-window[data-autofit-theme="dark"] .autofit-result-section .autofit-sort-label {
    color: #e2e8f0;
}
#autofit-chat-window[data-autofit-theme="dark"] .autofit-chat-sort .autofit-sort-select,
#autofit-chat-window[data-autofit-theme="dark"] .autofit-result-section .autofit-sort-select {
    background-color: #1e293b;
    color: #e2e8f0;
    border-color: #334155;
    background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='7' viewBox='0 0 10 7'%3E%3Cpath fill='%2394a3b8' d='M5 7L0 0h10z'/%3E%3C/svg%3E");
}
#autofit-chat-window[data-autofit-theme="dark"] .autofit-typo-banner {
    background: #052e16;
    border-color: #14532d;
}
#autofit-chat-window[data-autofit-theme="dark"] .autofit-typo-main,
#autofit-chat-window[data-autofit-theme="dark"] .autofit-typo-sub {
    color: #86efac;
}
#autofit-chat-window[data-autofit-theme="dark"] .autofit-typo-cancel {
    background: #1e293b;
    border-color: #16a34a;
    color: #86efac;
}
#autofit-chat-window[data-autofit-theme="dark"] .autofit-typo-cancel:hover {
    background: #16a34a;
    color: #ffffff;
}
#autofit-chat-window[data-autofit-theme="dark"] .autofit-section-title {
    color: #f8fafc;
    border-bottom-color: #3b82f6;
}
#autofit-chat-window[data-autofit-theme="dark"] .autofit-result-section[data-section="near_matches"] .autofit-section-title {
    border-bottom-color: #06b6d4;
}
#autofit-chat-window[data-autofit-theme="dark"] .autofit-result-section[data-section="suggestions"] .autofit-section-title {
    border-bottom-color: #22c55e;
}
#autofit-chat-window[data-autofit-theme="dark"] .autofit-result-section + .autofit-result-section {
    border-top-color: #334155;
}
#autofit-chat-window[data-autofit-theme="dark"] .autofit-section-empty {
    color: #cbd5e1 !important;
    background: #0f172a !important;
    border-color: #475569 !important;
}
#autofit-chat-window[data-autofit-theme="dark"] .autofit-year-hint-banner {
    background: #422006;
    border-color: #78350f;
    color: #fde68a;
}

/* =========================================================
✅ v2.15.6: CHAT GRID → VERTICAL STACK (UX FIX)
=========================================================

PROBLEM:
  Product cards inside the chat sections (main /
  near_matches / suggestions) are rendered with the class
  .autofit-sc-products-grid — a CSS Grid whose fallback
  column count is 2 on mobile (media max-width: 900px) and
  4 on desktop.

  That column count is controlled by CSS custom properties:
    --autofit-columns         (desktop, fallback 4)
    --autofit-columns-mobile  (mobile,  fallback 2)

  Those variables are only defined on
  .autofit-search-card[data-autofit-instance] (shortcode),
  via wp_add_inline_style() in class-autofit-assets.php.
  The chat window (#autofit-chat-window) never received
  them — so the chat's grid always fell back to 2 columns
  on mobile and 4 columns on desktop, regardless of the
  store owner's "تعداد ستون‌های موبایل" / "تعداد ستون‌های
  دسکتاپ" settings.

FIX:
  Force the chat's product grid into a vertical stack
  (display:flex; flex-direction:column). This is the
  correct layout for a 380px-wide chat panel, and it
  matches the store owner's expectation of a clean
  single-column list.

SCOPE:
  Scoped exclusively to #autofit-chat-window. The
  shortcode surface (.autofit-search-card) is untouched
  and continues to honor --autofit-columns / -mobile
  exactly as before.

  A duplicate rule is injected inline from
  class-autofit-assets.php (maybe_inject_toggle_inline_css)
  for hosts where this external file returns 404
  (e.g. mr-shock.com). Both rules are identical.

========================================================= */
#autofit-chat-window .autofit-sc-products-grid {
    display: flex !important;
    flex-direction: column !important;
    grid-template-columns: none !important;
    gap: 10px !important;
    width: 100% !important;
    max-width: 100% !important;
}

/* =========================================================
prefers-reduced-motion
========================================================= */
@media (prefers-reduced-motion: reduce) {
    #autofit-chat-fab,
    #autofit-chat-fab *,
    #autofit-chat-window,
    #autofit-chat-window * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
    .autofit-chat-pagination .autofit-page-btn:active,
    .autofit-result-section .autofit-page-btn:active,
    .autofit-section-toggle:active,
    .autofit-theme-toggle:active,
    .autofit-theme-toggle-chat:active {
        transform: none !important;
    }
    .autofit-toggle-icon {
        transition: none !important;
    }
    .autofit-theme-toggle-chat .autofit-toggle-icon {
        transition: none !important;
    }
}