/* ================================================================
   AI Assistant + drop-down menus — modern skin (Oct 2026)
   Loaded after every theme; ID-scoped so themes (which force cream
   inputs / navy headings) cannot override it.
   ================================================================ */

/* ---------- panel ---------- */
html body #aiSidebar {
    --ai-fg: #0f172a; --ai-muted: #64748b; --ai-line: #e2e8f0; --ai-soft: #f1f5f9;
    --ai-accent: #4f46e5; --ai-accent-2: #7c3aed;
    background: #ffffff !important;
    border-inline-start: 1px solid var(--ai-line) !important;
    box-shadow: -18px 0 50px rgba(15, 23, 42, 0.12) !important;
    font-family: 'Outfit', 'Inter', 'Cairo', sans-serif !important;
    color: var(--ai-fg) !important;
}

/* header */
html body #aiSidebar .ai-header {
    background: #ffffff !important;
    border-bottom: 1px solid var(--ai-line) !important;
    box-shadow: none !important;
}
html body #aiSidebar .fx-tile {
    background: linear-gradient(135deg, #6366f1, #8b5cf6) !important;
    box-shadow: 0 8px 18px -6px rgba(99, 102, 241, 0.55) !important;
    color: #fff !important;
}
html body #aiSidebar .fx-name {
    color: var(--ai-fg) !important; -webkit-text-fill-color: var(--ai-fg) !important;
    font-weight: 800 !important; letter-spacing: -0.01em;
}
html body #aiSidebar .fx-sub { color: var(--ai-muted) !important; -webkit-text-fill-color: var(--ai-muted) !important; }
html body #aiSidebar .fx-actions button {
    background: var(--ai-soft) !important; border: 1px solid transparent !important;
    color: #334155 !important; border-radius: 12px !important; box-shadow: none !important;
    transition: background .15s, color .15s, transform .12s;
}
html body #aiSidebar .fx-actions button:hover { background: #e0e7ff !important; color: var(--ai-accent) !important; }
html body #aiSidebar .fx-actions button:active { transform: scale(.94); }

/* controls row */
html body #aiSidebar .ai-controls { gap: 6px !important; align-items: center !important; }
html body #aiSidebar .new-chat-btn {
    width: 36px !important; height: 36px !important; min-width: 36px;
    display: inline-grid !important; place-items: center;
    border-radius: 10px !important; border: 1px solid var(--ai-line) !important;
    background: #fff !important; color: #475569 !important; box-shadow: none !important;
    font-size: 15px !important; padding: 0 !important;
    transition: background .15s, color .15s, border-color .15s, transform .12s;
}
html body #aiSidebar .new-chat-btn:hover { background: #eef2ff !important; border-color: #c7d2fe !important; color: var(--ai-accent) !important; }
html body #aiSidebar .new-chat-btn:active { transform: scale(.94); }
html body #aiSidebar #btnDownloadWord i { color: #2563eb; }
html body #aiSidebar #btnDownloadPdf i { color: #dc2626; }

/* ---------- drop-downs (AI panel + any select that opts in with .fk-select) ---------- */
html body #aiSidebar select.ai-context-select,
html body select.fk-select {
    -webkit-appearance: none !important; appearance: none !important;
    height: 36px !important; padding: 0 34px 0 12px !important;
    border-radius: 10px !important;
    border: 1px solid var(--ai-line, #e2e8f0) !important;
    background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1.5 1.5 6 6l4.5-4.5' fill='none' stroke='%236366f1' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat right 12px center !important;
    color: #0f172a !important; -webkit-text-fill-color: #0f172a !important;
    font: 600 13px 'Outfit', 'Inter', 'Cairo', sans-serif !important;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04) !important;
    cursor: pointer; transition: border-color .15s, box-shadow .15s, background-color .15s;
}
html body #aiSidebar select.ai-context-select:hover,
html body select.fk-select:hover { border-color: #c7d2fe !important; background-color: #fafbff !important; }
html body #aiSidebar select.ai-context-select:focus,
html body select.fk-select:focus { outline: none !important; border-color: #6366f1 !important; box-shadow: 0 0 0 4px rgba(99, 102, 241, .14) !important; }
html body #aiSidebar.rtl-mode select.ai-context-select,
[dir="rtl"] html body select.fk-select { padding: 0 12px 0 34px !important; background-position: left 12px center !important; }
html body #aiSidebar select.ai-context-select option { color: #0f172a; background: #fff; }

/* ---------- conversation ---------- */
html body #aiSidebar .ai-body {
    background:
        radial-gradient(circle at 15% 0%, rgba(99, 102, 241, 0.06), transparent 45%),
        radial-gradient(circle at 100% 100%, rgba(139, 92, 246, 0.05), transparent 40%),
        #f8fafc !important;
}
html body #aiSidebar .ai-avatar {
    background: linear-gradient(135deg, #6366f1, #8b5cf6) !important;
    color: #fff !important; box-shadow: 0 6px 14px -4px rgba(99, 102, 241, .5) !important;
}
html body #aiSidebar .ai-message:not(.user) .ai-bubble {
    background: #ffffff !important; color: #0f172a !important; -webkit-text-fill-color: #0f172a !important;
    border: 1px solid var(--ai-line) !important;
    border-radius: 18px 18px 18px 6px !important;
    box-shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 6px 18px -10px rgba(15, 23, 42, .18) !important;
    text-align: start !important; line-height: 1.55 !important;
}
html body #aiSidebar.rtl-mode .ai-message:not(.user) .ai-bubble { border-radius: 18px 18px 6px 18px !important; }
/* the welcome message's source has line breaks/indent: render it as normal text */
html body #aiSidebar .ai-message.system .ai-bubble { white-space: normal !important; }
html body #aiSidebar .ai-message.user .ai-bubble {
    background: linear-gradient(135deg, #6366f1, #4f46e5) !important;
    color: #fff !important; -webkit-text-fill-color: #fff !important;
    border: none !important; border-radius: 18px 18px 6px 18px !important;
    box-shadow: 0 10px 22px -12px rgba(79, 70, 229, .7) !important;
    text-align: start !important;
}
html body #aiSidebar.rtl-mode .ai-message.user .ai-bubble { border-radius: 18px 18px 18px 6px !important; }

/* ---------- footer ---------- */
html body #aiSidebar .ai-footer { background: #ffffff !important; border-top: 1px solid var(--ai-line) !important; box-shadow: 0 -10px 30px rgba(15, 23, 42, .04) !important; }
html body #aiSidebar .ai-quick, html body #aiSidebar .ai-style-btn {
    background: #fff !important; color: #4338ca !important; -webkit-text-fill-color: #4338ca !important;
    border: 1px solid #e0e7ff !important; border-radius: 999px !important;
    box-shadow: none !important; font-weight: 700 !important;
    transition: background .15s, border-color .15s, transform .12s;
}
html body #aiSidebar .ai-quick i, html body #aiSidebar .ai-style-btn i { color: #6366f1 !important; }
html body #aiSidebar .ai-quick:hover, html body #aiSidebar .ai-style-btn:hover { background: #eef2ff !important; border-color: #c7d2fe !important; }
html body #aiSidebar .ai-quick:active, html body #aiSidebar .ai-style-btn:active { transform: scale(.96); }
html body #aiSidebar .ai-style-btn.active { background: #4f46e5 !important; color: #fff !important; -webkit-text-fill-color: #fff !important; border-color: #4f46e5 !important; }
html body #aiSidebar .ai-style-btn.active i { color: #fff !important; }
html body #aiSidebar .ai-input-container {
    background: #fff !important; border: 1.5px solid var(--ai-line) !important;
    border-radius: 18px !important; box-shadow: 0 4px 16px -8px rgba(15, 23, 42, .15) !important;
    transition: border-color .15s, box-shadow .15s;
}
html body #aiSidebar .ai-input-container:focus-within { border-color: #6366f1 !important; box-shadow: 0 0 0 4px rgba(99, 102, 241, .12) !important; }
html body #aiSidebar #aiInput {
    background: transparent !important; border: none !important; box-shadow: none !important;
    color: #0f172a !important; -webkit-text-fill-color: #0f172a !important;
}
html body #aiSidebar #aiInput::placeholder { color: #94a3b8 !important; -webkit-text-fill-color: #94a3b8 !important; }
html body #aiSidebar #btnSendAi {
    background: linear-gradient(135deg, #6366f1, #4f46e5) !important;
    color: #fff !important; border: none !important; border-radius: 14px !important;
    box-shadow: 0 8px 18px -8px rgba(79, 70, 229, .7) !important;
}
html body #aiSidebar #btnSendAi i { color: #fff !important; }
html body #aiSidebar #btnSendAi:disabled { background: #c7d2fe !important; box-shadow: none !important; }
html body #aiSidebar .ai-disclaimer { color: #94a3b8 !important; -webkit-text-fill-color: #94a3b8 !important; font-size: 11.5px !important; }

/* ---------- app drop-down menus: ⋮ More menu + right-click / ⋯ menus ---------- */
html body .more-dropdown,
html body #nav-context-menu {
    background: rgba(255, 255, 255, 0.97) !important;
    -webkit-backdrop-filter: saturate(1.6) blur(16px); backdrop-filter: saturate(1.6) blur(16px);
    border: 1px solid rgba(15, 23, 42, 0.08) !important;
    border-radius: 16px !important;
    box-shadow: 0 18px 48px rgba(15, 23, 42, 0.18), 0 2px 6px rgba(15, 23, 42, 0.06) !important;
    padding: 6px !important;
    font-family: 'Outfit', 'Inter', 'Cairo', sans-serif !important;
}
html body .more-dropdown-item,
html body #nav-context-menu .ctx-menu-item {
    display: flex !important; align-items: center !important; gap: 10px !important;
    min-height: 40px; padding: 0 12px !important;
    border-radius: 10px !important; background: transparent !important;
    color: #1e293b !important; -webkit-text-fill-color: #1e293b !important;
    font-size: 14px !important; font-weight: 600 !important;
    transition: background .12s, color .12s;
}
html body .more-dropdown-item:hover,
html body #nav-context-menu .ctx-menu-item:hover { background: #eef2ff !important; color: #4338ca !important; -webkit-text-fill-color: #4338ca !important; }
html body .more-dropdown-item i,
html body #nav-context-menu .ctx-menu-item i { width: 18px; text-align: center; }
html body #nav-context-menu .ctx-menu-item:not(.delete) i { color: #6366f1 !important; }
html body #nav-context-menu .ctx-menu-item.delete,
html body #nav-context-menu .ctx-menu-item.delete i { color: #dc2626 !important; -webkit-text-fill-color: #dc2626 !important; }
html body #nav-context-menu .ctx-menu-item.delete:hover { background: #fef2f2 !important; }
html body .more-dropdown-divider,
html body #nav-context-menu .ctx-menu-separator { height: 1px !important; margin: 4px 6px !important; background: #eef2f7 !important; border: none !important; }

/* icons keep their own colours (text-fill on the row would otherwise paint icon fonts too) */
html body .more-dropdown-item i,
html body #nav-context-menu .ctx-menu-item i,
html body #aiSidebar .new-chat-btn i,
html body #aiSidebar .ai-quick i,
html body #aiSidebar .ai-style-btn i { -webkit-text-fill-color: currentColor !important; }


/* ---------- custom drop-down (js/utils/FkSelect.js) ---------- */
.fk-sel { position: relative; display: inline-flex; min-width: 0; flex: 0 1 auto; }
#aiSidebar .fk-sel[data-for="aiContextSelect"] { flex: 1 1 auto; }
.fk-sel .fk-sel-native { position: absolute !important; inset: 0; opacity: 0 !important; pointer-events: none !important; width: 100% !important; height: 100% !important; }
html body .fk-sel-btn {
    display: inline-flex !important; align-items: center; justify-content: space-between; gap: 10px;
    width: 100%; height: 36px; padding: 0 12px !important; margin: 0;
    border-radius: 10px !important; border: 1px solid #e2e8f0 !important;
    background: #fff !important; color: #0f172a !important; -webkit-text-fill-color: #0f172a !important;
    font: 600 13px 'Outfit', 'Inter', 'Cairo', sans-serif !important;
    box-shadow: 0 1px 2px rgba(15, 23, 42, .04) !important;
    cursor: pointer; transition: border-color .15s, box-shadow .15s, background .15s;
    touch-action: manipulation; -webkit-tap-highlight-color: transparent;
}
html body .fk-sel-btn:hover { border-color: #c7d2fe !important; background: #fafbff !important; }
html body .fk-sel-btn:focus-visible, html body .fk-sel-btn.is-open { outline: none; border-color: #6366f1 !important; box-shadow: 0 0 0 4px rgba(99, 102, 241, .14) !important; }
html body .fk-sel-btn:disabled { opacity: .5; cursor: default; }
.fk-sel-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: start; }
.fk-sel-chev { flex: none; color: #6366f1; transition: transform .2s; }
.fk-sel-btn.is-open .fk-sel-chev { transform: rotate(180deg); }

.fk-sel-menu {
    position: fixed; z-index: 2147483647;
    max-width: min(320px, calc(100vw - 16px));
    overflow-y: auto; overscroll-behavior: contain;
    padding: 6px;
    background: rgba(255, 255, 255, 0.98);
    -webkit-backdrop-filter: saturate(1.6) blur(16px); backdrop-filter: saturate(1.6) blur(16px);
    border: 1px solid rgba(15, 23, 42, 0.08);
    border-radius: 14px;
    box-shadow: 0 18px 48px rgba(15, 23, 42, .2), 0 2px 6px rgba(15, 23, 42, .06);
    font-family: 'Outfit', 'Inter', 'Cairo', sans-serif;
    opacity: 0; transform: translateY(-4px) scale(.98); transform-origin: top center;
    transition: opacity .14s, transform .16s cubic-bezier(.2, .8, .2, 1);
}
.fk-sel-menu.from-top { transform: translateY(4px) scale(.98); transform-origin: bottom center; }
.fk-sel-menu.show { opacity: 1; transform: none; }
.fk-sel-item {
    display: flex; align-items: center; gap: 10px; justify-content: space-between;
    min-height: 40px; padding: 0 12px;
    border-radius: 10px; cursor: pointer;
    color: #1e293b; font-size: 14px; font-weight: 600;
    -webkit-tap-highlight-color: transparent;
}
.fk-sel-item.is-act { background: #eef2ff; color: #4338ca; }
.fk-sel-item.is-sel { color: #4338ca; }
.fk-sel-item.is-dis { opacity: .45; cursor: default; }
.fk-sel-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fk-sel-check { flex: none; color: #4f46e5; opacity: 0; }
.fk-sel-item.is-sel .fk-sel-check { opacity: 1; }
.fk-sel-div { height: 1px; margin: 5px 8px; background: #eef2f7; }
@media (prefers-reduced-motion: reduce) { .fk-sel-menu, .fk-sel-chev { transition: none; } }
