/* ============================================
   AI CHATBOT & SEARCH STYLES — SAS Gee
   Fully theme-aware: uses CSS vars + [data-theme="dark"] overrides
   ============================================ */

/* ── Chatbot Widget Position ── */
.ai-chatbot-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1040;
}

.chatbot-toggle {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, #0EA5E9 0%, #0284C7 100%);
    border: none;
    color: white;
    font-size: 1.4rem;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(14,165,233,0.4);
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}
.chatbot-toggle:hover {
    transform: scale(1.08);
    box-shadow: 0 8px 28px rgba(14,165,233,0.5);
}

/* ── Chatbot Window ── */
.chatbot-window {
    position: absolute;
    bottom: 72px;
    right: 0;
    width: 340px;
    height: 490px;
    background: #FFFFFF;
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.15);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid #E5E5E5;
    transition: background 0.22s ease, border-color 0.18s ease;
}

[data-theme="dark"] .chatbot-window {
    background: #1E293B !important;
    border-color: #334155 !important;
    box-shadow: 0 10px 40px rgba(0,0,0,0.5) !important;
}

/* ── Header ── */
.chatbot-header {
    background: #0F172A;
    color: white;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    flex-shrink: 0;
}
[data-theme="dark"] .chatbot-header {
    background: #020617 !important;
    border-bottom-color: #1F2937 !important;
}

.chatbot-header h4 {
    flex: 1;
    font-size: 0.95rem;
    margin: 0;
    font-weight: 600;
    color: white;
}

.close-chat,
.new-chat-btn {
    background: none;
    border: none;
    color: #94A3B8;
    cursor: pointer;
    font-size: 0.95rem;
    padding: 4px 6px;
    border-radius: 6px;
    transition: color 0.2s, background 0.2s;
    line-height: 1;
}
.close-chat:hover,
.new-chat-btn:hover {
    color: white;
    background: rgba(255,255,255,0.1);
}

/* ── Messages Area ── */
.chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 14px;
    background: #F8FAFC;
    transition: background 0.22s ease;
}
[data-theme="dark"] .chatbot-messages {
    background: #0F172A !important;
}

/* ── Message Bubbles ── */
.message {
    margin-bottom: 10px;
    max-width: 85%;
    padding: 10px 13px;
    border-radius: 16px;
    font-size: 0.83rem;
    line-height: 1.45;
}
.message.bot {
    background: #FFFFFF;
    color: var(--text-dark, #0EA5E9);
    border: 1px solid #E5E5E5;
    border-bottom-left-radius: 4px;
    transition: background 0.22s ease, border-color 0.18s ease, color 0.18s ease;
}
[data-theme="dark"] .message.bot {
    background: #1E293B !important;
    color: #E2E8F0 !important;
    border-color: #334155 !important;
}
.message.user {
    background: #0EA5E9;
    color: white;
    margin-left: auto;
    border-bottom-right-radius: 4px;
}
[data-theme="dark"] .message.user {
    background: #3B82F6 !important;
}

/* ── Typing Indicator ── */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 10px 13px;
    background: #FFFFFF;
    border-radius: 16px;
    border-bottom-left-radius: 4px;
    width: fit-content;
    border: 1px solid #E5E5E5;
    margin-bottom: 10px;
    transition: background 0.22s ease, border-color 0.18s ease;
}
[data-theme="dark"] .typing-indicator {
    background: #1E293B !important;
    border-color: #334155 !important;
}
.typing-indicator span {
    width: 7px;
    height: 7px;
    background: #94A3B8;
    border-radius: 50%;
    animation: typing 1.4s infinite;
}
.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typing {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-8px); opacity: 1; }
}

/* ── Input Area ── */
.chatbot-input {
    display: flex;
    padding: 10px;
    border-top: 1px solid #E5E5E5;
    background: #FFFFFF;
    gap: 8px;
    flex-shrink: 0;
    transition: background 0.22s ease, border-color 0.18s ease;
}
[data-theme="dark"] .chatbot-input {
    background: #1E293B !important;
    border-top-color: #334155 !important;
}
.chatbot-input input {
    flex: 1;
    padding: 9px 14px;
    border: 1px solid #E5E5E5;
    border-radius: 24px;
    font-family: inherit;
    font-size: 0.83rem;
    background: #FFFFFF;
    color: var(--text-dark, #0EA5E9);
    outline: none;
    transition: border-color 0.2s, background 0.22s, color 0.18s;
}
.chatbot-input input:focus { border-color: #0EA5E9; }
[data-theme="dark"] .chatbot-input input {
    background: #0F172A !important;
    border-color: #334155 !important;
    color: #F1F5F9 !important;
}
[data-theme="dark"] .chatbot-input input::placeholder { color: #64748B !important; }
[data-theme="dark"] .chatbot-input input:focus { border-color: #3B82F6 !important; }

.chatbot-input button {
    background: #0EA5E9;
    border: none;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.chatbot-input button:hover { background: #0284C7; }
[data-theme="dark"] .chatbot-input button { background: #3B82F6; }
[data-theme="dark"] .chatbot-input button:hover { background: #60A5FA; }

/* ── Search Suggestions Dropdown ── */
.search-suggestions {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: #FFFFFF;
    border: 1px solid #E5E5E5;
    border-radius: 14px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.1);
    z-index: 1200;
    overflow: hidden;
    transition: background 0.22s ease, border-color 0.18s ease;
}
[data-theme="dark"] .search-suggestions {
    background: #1E293B !important;
    border-color: #334155 !important;
    box-shadow: 0 8px 32px rgba(0,0,0,0.5) !important;
}
.search-suggestion-item {
    padding: 11px 16px;
    cursor: pointer;
    transition: background 0.15s;
    border-bottom: 1px solid #F5F5F5;
    font-size: 0.88rem;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-dark, #0EA5E9);
}
.search-suggestion-item:hover { background: #F8FAFC; color: #0EA5E9; }
[data-theme="dark"] .search-suggestion-item {
    border-bottom-color: #334155 !important;
    color: #E2E8F0 !important;
}
[data-theme="dark"] .search-suggestion-item:hover {
    background: rgba(59,130,246,0.1) !important;
    color: #60A5FA !important;
}

/* ── Voice Search Button ── */
.voice-search-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 7px;
    border-radius: 50%;
    color: #94A3B8;
    font-size: 0.95rem;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.voice-search-btn:hover {
    color: #0EA5E9;
    background: rgba(14,165,233,0.1);
}
.voice-search-btn.listening {
    color: #EF4444;
    animation: pulse 1.5s infinite;
}
[data-theme="dark"] .voice-search-btn { color: #64748B; }
[data-theme="dark"] .voice-search-btn:hover {
    color: #3B82F6;
    background: rgba(59,130,246,0.15);
}

/* ── Image Search Button ── */
.image-search-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 7px;
    border-radius: 50%;
    color: #94A3B8;
    font-size: 0.95rem;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.image-search-btn:hover {
    color: #0EA5E9;
    background: rgba(14,165,233,0.1);
}
[data-theme="dark"] .image-search-btn { color: #64748B; }
[data-theme="dark"] .image-search-btn:hover {
    color: #3B82F6;
    background: rgba(59,130,246,0.15);
}

/* ── Image Search Modal ── */
.image-search-modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.8);
    z-index: 2500;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
    padding: 16px;
}
.image-search-modal.active { display: flex; }

.image-search-content {
    background: #1E293B;
    border-radius: 24px;
    padding: 28px;
    max-width: 480px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    border: 1px solid #334155;
}

.image-upload-area {
    background: #0F172A;
    border: 2px dashed #334155;
    border-radius: 16px;
    padding: 40px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
}
.image-upload-area:hover {
    border-color: #0EA5E9;
    background: rgba(14,165,233,0.05);
}

.ai-loading {
    width: 28px;
    height: 28px;
    border: 3px solid rgba(255,255,255,0.1);
    border-top-color: #0EA5E9;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    margin: 0 auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

.image-result-card:hover {
    border-color: #0EA5E9 !important;
    transform: translateX(4px);
    transition: all 0.2s ease;
}

/* ── Voice Notification Toast ── */
.voice-notification {
    position: fixed;
    bottom: 110px;
    right: 20px;
    background: #1E293B;
    border: 1px solid #0EA5E9;
    border-radius: 14px;
    padding: 11px 18px;
    color: white;
    z-index: 10000;
    animation: slideUp 0.3s ease;
    box-shadow: 0 4px 16px rgba(0,0,0,0.3);
    font-size: 0.88rem;
    max-width: 280px;
}
[data-theme="dark"] .voice-notification {
    background: #0F172A;
    border-color: #3B82F6;
}

/* ── Recommendation Cards (from ai-recommendation.js) ── */
.ai-rec-section {
    padding: 40px 24px;
    background: var(--bg-light, #F8FAFC);
    margin-top: 40px;
    transition: background 0.22s ease;
}
[data-theme="dark"] .ai-rec-section {
    background: #111827 !important;
}
.ai-rec-title {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text-dark, #0F172A);
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
}
[data-theme="dark"] .ai-rec-title { color: #F1F5F9 !important; }
.ai-rec-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 20px;
    max-width: 1200px;
    margin: 0 auto;
}
.ai-rec-card {
    text-decoration: none;
    background: var(--bg-white, #FFFFFF);
    border: 1px solid var(--border, #E5E5E5);
    border-radius: 16px;
    padding: 16px;
    text-align: center;
    display: block;
    transition: all 0.25s ease;
}
.ai-rec-card:hover {
    transform: translateY(-4px);
    border-color: #0EA5E9;
    box-shadow: 0 8px 24px rgba(14,165,233,0.15);
}
[data-theme="dark"] .ai-rec-card {
    background: #1E293B !important;
    border-color: #334155 !important;
}
[data-theme="dark"] .ai-rec-card:hover {
    border-color: #3B82F6 !important;
    box-shadow: 0 8px 24px rgba(59,130,246,0.2) !important;
}
.ai-rec-card img {
    width: 100%;
    height: 110px;
    object-fit: contain;
    margin-bottom: 10px;
    background: var(--bg-light, #F8FAFC);
    border-radius: 10px;
    padding: 8px;
}
[data-theme="dark"] .ai-rec-card img { background: #111827 !important; }
.ai-rec-name {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-dark, #0EA5E9);
    margin-bottom: 6px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
[data-theme="dark"] .ai-rec-name { color: #E2E8F0 !important; }
.ai-rec-price {
    font-weight: 700;
    font-size: 0.95rem;
    color: #0EA5E9;
}
[data-theme="dark"] .ai-rec-price { color: #60A5FA !important; }

/* ── Animations ── */
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}
@keyframes slideUp {
    from { opacity: 0; transform: translateY(16px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ── Mobile ── */
@media (max-width: 768px) {
    .ai-chatbot-widget {
        bottom: 18px;
        right: 16px;
        z-index: 1040;
    }
    .chatbot-toggle { width: 50px; height: 50px; font-size: 1.2rem; }
    .chatbot-window {
        width: calc(100vw - 36px);
        right: 0;
        bottom: 66px !important;
        height: 440px;
    }
    .image-search-content { padding: 20px; }
    .ai-rec-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
}
