/* ============================================================
 *  AI CHAT FLOATING WIDGET — STYLES
 *  W3C Valid · RTL/LTR Compatible · Mobile First
 * ============================================================ */

/* ─── Widget Container ─── */
/* Essential widget/FAB layout moved to style.css for better LCP */

:root {
    --bg-card-solid: #ffffff;
    --border-subtle: #E2E8F0;
    --radius-md: 2px;
    --radius-lg: 999px;
    /*--clr-primary-900: #134E4A;*/
    /*--clr-primary-800: #115E59;*/
    /*--clr-primary-700: #0F766E;*/
    /*--clr-primary-600: #0D9488;*/
    /*--clr-primary-500: #14B8A6;*/
    /*--clr-primary-400: #2DD4BF;*/
    /*--clr-primary-100: #CCFBF1;*/
    /*--clr-primary-50: #F0FDFA;*/
    --clr-primary-900: #0B455C;
    --clr-primary-800: #0F5E7B;
    --clr-primary-700: #13779B;
    --clr-primary-600: #1B9FCA;
    --clr-primary-500: #26C1EA;
    --clr-primary-400: #5DCEEF;
    --clr-primary-100: #D8F2FB;
    --clr-primary-50: #EDF9FD;
    
    --clr-accent-500: #F59E0B;
    --clr-accent-400: #FBBF24;
    --clr-accent-600: #D97706;
    --clr-accent-800: #894606;
    --fs-xs: 0.75rem;
    --fs-sm: 0.875rem;
    --text-body: #ffffff;
    --text-muted: #64748B;
    --clr-slate-300: #CBD5E1;
    --clr-slate-200: #E2E8F0;
    --clr-slate-100: #F1F5F9;
    --clr-slate-50: #F8FAFC;
}

/* ─── Chat Panel ─── */
.ai-chat-panel {
    position: absolute;
    bottom: 80px;
    width: 380px;
    max-height: calc(100vh - 240px);
    background: var(--bg-card-solid);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    box-shadow:
        0 20px 60px rgba(0, 0, 0, 0.12),
        0 8px 20px rgba(0, 0, 0, 0.06);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: ai-panel-slide-in 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
    z-index: 1000;
}

.ai-chat-panel[hidden] {
    display: none !important;
}

html[dir="rtl"] .ai-chat-panel { left: 0; right: auto; transform-origin: bottom left; }
html[dir="ltr"] .ai-chat-panel { right: 0; left: auto; transform-origin: bottom right; }

@keyframes ai-panel-slide-in {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* ─── Header ─── */
.ai-chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    background: linear-gradient(135deg, var(--clr-primary-700) 0%, var(--clr-primary-900) 100%);
    color: #fff;
    gap: 12px;
    flex-shrink: 0;
}

.ai-chat-header__info {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.ai-chat-header__avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.ai-chat-header__title {
    font-size: var(--fs-sm);
    font-weight: 700;
    margin: 0;
    color: #fff;
    line-height: 1.3;
}

.ai-chat-header__subtitle {
    font-size: 0.7rem;
    opacity: 0.85;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 5px;
}

.ai-chat-status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #34d399;
    display: inline-block;
    box-shadow: 0 0 4px rgba(52, 211, 153, 0.5);
    animation: ai-status-pulse 2s ease-in-out infinite;
}

@keyframes ai-status-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.ai-chat-header__actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

.ai-chat-header__btn {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
    font-family: inherit;
}

.ai-chat-header__btn:hover {
    background: rgba(255, 255, 255, 0.25);
}

/* ─── Messages Area ─── */
.ai-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: 200px;
    max-height: 400px;
    scroll-behavior: smooth;
}

.ai-chat-messages::-webkit-scrollbar {
    width: 4px;
}

.ai-chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.ai-chat-messages::-webkit-scrollbar-thumb {
    background: var(--clr-slate-300);
    border-radius: 4px;
}

/* ─── Message Bubbles ─── */
.ai-chat-msg {
    display: flex;
    animation: ai-msg-in 0.3s ease;
}

@keyframes ai-msg-in {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.ai-chat-msg--user {
    justify-content: flex-end;
}

.ai-chat-msg--ai {
    justify-content: flex-start;
}

.ai-chat-msg__bubble {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: var(--radius-md);
    font-size: var(--fs-sm);
    line-height: 1.7;
    word-break: break-word;
}

.ai-chat-msg--user .ai-chat-msg__bubble {
    background: var(--clr-primary-700);
    color: #fff;
}

.ai-chat-msg--ai .ai-chat-msg__bubble {
    background: #f1f5f9;
    color: #334155;
    border: 1px solid var(--border-subtle);
}

.ai-chat-msg__greeting {
    font-weight: 700;
    font-size: medium;
    margin-bottom: 6px;
}

/* ─── Typing Indicator ─── */
.ai-chat-typing {
    display: inline-flex;
    gap: 4px;
    align-items: center;
}

.ai-chat-typing span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--clr-primary-600);
    animation: ai-typing-dot 1.4s ease-in-out infinite;
}

.ai-chat-typing span:nth-child(2) {
    animation-delay: 0.2s;
}

.ai-chat-typing span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes ai-typing-dot {
    0%, 80%, 100% {
        transform: scale(0.6);
        opacity: 0.4;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

.ai-chat-typing-text {
    font-size: var(--fs-xs);
    color: var(--text-muted);
    margin-inline-start: 8px;
}

/* ─── Suggested Questions ─── */
.ai-chat-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding-top: 4px;
}

.ai-chat-suggestion {
    padding: 6px 12px;
    font-size: 0.75rem;
    font-weight: 600;
    background: var(--clr-primary-50);
    color: var(--clr-primary-800);
    border: 1px solid var(--clr-primary-100);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
    text-align: start;
    line-height: 1.5;
}

.ai-chat-suggestion:hover {
    background: var(--clr-primary-700);
    color: #fff;
    border-color: var(--clr-primary-700);
    transform: translateY(-1px);
}

/* ─── Disclaimer ─── */
.ai-chat-disclaimer {
    padding: 6px 16px;
    font-size: 0.65rem;
    color: var(--text-muted);
    text-align: center;
    background: var(--clr-slate-50);
    border-top: 1px solid var(--border-subtle);
    margin: 0;
    line-height: 1.5;
}

/* ─── Input Area ─── */
.ai-chat-input-area {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 10px 12px;
    border-top: 1px solid var(--border-subtle);
    background: var(--bg-card-solid);
    flex-shrink: 0;
}

.ai-chat-input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    font-size: var(--fs-sm);
    font-family: inherit;
    line-height: 1.5;
    resize: none;
    outline: none;
    background: var(--clr-slate-50);
    color: #000;
    min-height: 65px;
    max-height: 120px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.ai-chat-input:focus {
    border-color: var(--clr-primary-500);
    box-shadow: 0 0 0 3px rgba(20, 184, 166, 0.12);
    background: var(--bg-card-solid);
}

.ai-chat-send {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: var(--radius-md);
    background: var(--clr-primary-700);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.2s ease, transform 0.15s ease, opacity 0.2s ease;
    font-family: inherit;
}

html[dir="rtl"] .ai-chat-send svg {
    transform: scaleX(-1);
}

.ai-chat-send:hover:not(:disabled) {
    background: var(--clr-primary-800);
    transform: scale(1.05);
}

.ai-chat-send:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}


/* ═══════════════════════════════════════════════════════
 *  RESPONSIVE — Mobile Optimization
 * ═══════════════════════════════════════════════════════ */

@media (max-width: 768px) {
    /* Mobile positioning rules moved to style.css */

    .ai-chat-fab {
        position: relative;
    }

    .ai-chat-panel {
        position: fixed !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        width: 100% !important;
        height: 100% !important;
        max-height: 100dvh !important;
        border-radius: 0 !important;
        pointer-events: auto;
        animation: none !important;
        transform: none !important;
    }

    .ai-chat-messages {
        max-height: none;
        flex: 1;
    }
}

/* ─── Luxury Link List ─── */
.ai-chat-msg__links {
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid rgba(0, 0, 0, 0.08);
}

.ai-chat-link-item {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.75rem;
    color: var(--clr-primary-700);
    text-decoration: none;
    margin-bottom: 8px;
    transition: all 0.2s ease;
    padding: 4px 0;
}

.ai-chat-link-item:hover {
    color: var(--clr-primary-900);
    transform: translateX(-4px);
}

html[dir="ltr"] .ai-chat-link-item:hover {
    transform: translateX(4px);
}

.ai-chat-link-dot {
    width: 6px;
    height: 6px;
    background-color: #22c55e;
    border-radius: 50%;
    flex-shrink: 0;
    box-shadow: 0 0 4px rgba(34, 197, 94, 0.4);
}

.ai-chat-link-text {
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ─── Print: Hide widget ─── */
@media print {
    .ai-chat-widget {
        display: none !important;
    }
}
