/* ====================================================================
   ALZAR AI CHAT — Floating Widget Styles
   Path:  css/modules/alzar-chat.css
   Theme: White panel, deep charcoal text, Logic Blue accents
          Respects light / dark brightness via CSS custom properties
   ==================================================================== */

/* ── Panel ────────────────────────────────────────────────────────── */

#alzar-chat-panel {
    position: fixed;
    bottom: 88px;          /* sits above the unified FAB */
    right: 24px;
    z-index: 10001;
    width: 380px;
    max-height: 540px;
    display: flex;
    flex-direction: column;
    border-radius: 16px;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
    transform: translateY(12px) scale(0.96);
    transition: opacity 0.25s ease, transform 0.25s ease;

    /* White Theme defaults */
    background: #ffffff;
    color: #1e293b;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(0, 0, 0, 0.06);
}
#alzar-chat-panel.open {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0) scale(1);
}

/* ── Header ───────────────────────────────────────────────────────── */

.ac-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    color: #fff;
    flex-shrink: 0;
}
.ac-header-icon {
    font-size: 1.3rem;
    display: flex;
}
.ac-header-title {
    font-weight: 600;
    font-size: 0.95rem;
    flex: 1;
}
.ac-header-close {
    background: none;
    border: none;
    color: rgba(255,255,255,0.8);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
    display: flex;
    transition: background 0.15s;
}
.ac-header-close:hover {
    background: rgba(255,255,255,0.15);
    color: #fff;
}

/* ── Chat log ─────────────────────────────────────────────────────── */

#alzar-chat-log {
    flex: 1;
    overflow-y: auto;
    padding: 16px 14px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: 200px;
    max-height: 340px;
    background: #f8fafc;
}

/* Bubbles */
.ac-bubble {
    display: flex;
    gap: 8px;
    max-width: 92%;
    animation: acFadeIn 0.2s ease;
}
.ac-bubble.ac-user {
    align-self: flex-end;
    flex-direction: row-reverse;
}
.ac-bubble.ac-model,
.ac-bubble.ac-error {
    align-self: flex-start;
}

.ac-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 0.85rem;
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    color: #fff;
}
.ac-error .ac-avatar {
    background: linear-gradient(135deg, #ef4444, #dc2626);
}

.ac-content {
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 0.875rem;
    line-height: 1.55;
    word-break: break-word;
}
.ac-user .ac-content {
    background: #3b82f6;
    color: #fff;
    border-bottom-right-radius: 4px;
}
.ac-model .ac-content {
    background: #ffffff;
    color: #1e293b;
    border: 1px solid #e2e8f0;
    border-bottom-left-radius: 4px;
}
.ac-error .ac-content {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
    border-bottom-left-radius: 4px;
}

.ac-content code {
    background: rgba(59, 130, 246, 0.08);
    padding: 1px 5px;
    border-radius: 4px;
    font-family: "JetBrains Mono", "Fira Code", monospace;
    font-size: 0.82em;
}

/* Thinking dots */
.ac-thinking .ac-content {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #64748b;
    font-style: italic;
}
.ac-dots {
    display: inline-flex;
    gap: 3px;
}
.ac-dots span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #3b82f6;
    animation: acDotPulse 1.2s ease-in-out infinite;
}
.ac-dots span:nth-child(2) { animation-delay: 0.2s; }
.ac-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes acDotPulse {
    0%, 60%, 100% { opacity: 0.25; transform: scale(0.8); }
    30%           { opacity: 1;    transform: scale(1.1); }
}

@keyframes acFadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ── Input area ───────────────────────────────────────────────────── */

.ac-input-bar {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 12px 14px;
    border-top: 1px solid #e2e8f0;
    background: #ffffff;
    flex-shrink: 0;
}

#alzar-chat-input {
    flex: 1;
    resize: none;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 10px 14px;
    font-size: 0.875rem;
    font-family: inherit;
    line-height: 1.45;
    max-height: 120px;
    outline: none;
    background: #f8fafc;
    color: #1e293b;
    transition: border-color 0.15s;
}
#alzar-chat-input:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12);
}
#alzar-chat-input::placeholder {
    color: #94a3b8;
}
#alzar-chat-input:disabled {
    opacity: 0.6;
}

#alzar-chat-send {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.05rem;
    color: #fff;
    background: #3b82f6;
    flex-shrink: 0;
    transition: background 0.15s;
}
#alzar-chat-send:hover {
    background: #2563eb;
}
#alzar-chat-send:disabled {
    background: #94a3b8;
    cursor: not-allowed;
}

/* ── Dark-mode overrides (for dark brightness) ────────────────────── */

html[data-brightness="dark"] #alzar-chat-panel,
html:not([data-brightness]) #alzar-chat-panel {
    background: #1e293b;
    color: #e2e8f0;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(255,255,255,0.06);
}
html[data-brightness="dark"] #alzar-chat-log,
html:not([data-brightness]) #alzar-chat-log {
    background: #0f172a;
}
html[data-brightness="dark"] .ac-model .ac-content,
html:not([data-brightness]) .ac-model .ac-content {
    background: #1e293b;
    color: #e2e8f0;
    border-color: #334155;
}
html[data-brightness="dark"] .ac-error .ac-content,
html:not([data-brightness]) .ac-error .ac-content {
    background: #450a0a;
    color: #fca5a5;
    border-color: #7f1d1d;
}
html[data-brightness="dark"] .ac-content code,
html:not([data-brightness]) .ac-content code {
    background: rgba(59, 130, 246, 0.15);
}
html[data-brightness="dark"] .ac-input-bar,
html:not([data-brightness]) .ac-input-bar {
    background: #1e293b;
    border-color: #334155;
}
html[data-brightness="dark"] #alzar-chat-input,
html:not([data-brightness]) #alzar-chat-input {
    background: #0f172a;
    color: #e2e8f0;
    border-color: #334155;
}
html[data-brightness="dark"] #alzar-chat-input:focus,
html:not([data-brightness]) #alzar-chat-input:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}
html[data-brightness="dark"] #alzar-chat-input::placeholder,
html:not([data-brightness]) #alzar-chat-input::placeholder {
    color: #64748b;
}

/* ── Scrollbar ────────────────────────────────────────────────────── */

#alzar-chat-log::-webkit-scrollbar { width: 5px; }
#alzar-chat-log::-webkit-scrollbar-track { background: transparent; }
#alzar-chat-log::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}
html[data-brightness="dark"] #alzar-chat-log::-webkit-scrollbar-thumb,
html:not([data-brightness]) #alzar-chat-log::-webkit-scrollbar-thumb {
    background: #475569;
}

/* ── Responsive ───────────────────────────────────────────────────── */

@media (max-width: 480px) {
    #alzar-chat-panel {
        right: 8px;
        left: 8px;
        bottom: 80px;
        width: auto;
        max-height: 70vh;
        border-radius: 14px;
    }
}
