/* ============================================================
   PORTFOLIO ASSISTANT — CHAT WIDGET STYLES
   Matches portfolio's Inter font + indigo #4F46E5 accent
   ============================================================ */

/* ── Root Container ───────────────────────────────────────── */
#chat-widget-root {
    position: fixed;
    bottom: 1.75rem;
    right: 1.75rem;
    z-index: 9000;
    font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
    font-size: 14px;
    line-height: 1.5;
}

/* ── Floating Trigger Button ──────────────────────────────── */
#chat-trigger-btn {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: #4F46E5;
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(79, 70, 229, 0.45);
    transition: transform 200ms ease, background 150ms ease, box-shadow 200ms ease;
    outline: none;
    position: relative;
}

#chat-trigger-btn:hover {
    background: #4338CA;
    transform: scale(1.08);
    box-shadow: 0 6px 28px rgba(79, 70, 229, 0.55);
}

#chat-trigger-btn:focus-visible {
    outline: 3px solid #818CF8;
    outline-offset: 3px;
}

#chat-trigger-btn svg {
    width: 24px;
    height: 24px;
    transition: opacity 200ms ease, transform 200ms ease;
}

#chat-trigger-btn .icon-chat { display: block; }
#chat-trigger-btn .icon-close { display: none; }

#chat-trigger-btn.open .icon-chat { display: none; }
#chat-trigger-btn.open .icon-close { display: block; }

/* Notification dot — shown on first load */
#chat-trigger-btn .chat-notif-dot {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #EF4444;
    border: 2px solid #fff;
    animation: pulse-dot 2s ease-in-out infinite;
}

@keyframes pulse-dot {
    0%, 100% { transform: scale(1); opacity: 1; }
    50%       { transform: scale(1.3); opacity: 0.8; }
}

#chat-trigger-btn.open .chat-notif-dot,
#chat-trigger-btn.seen .chat-notif-dot {
    display: none;
}

/* ── Chat Panel ───────────────────────────────────────────── */
#chat-panel {
    position: absolute;
    bottom: calc(100% + 16px);
    right: 0;
    width: 380px;
    max-height: 540px;
    background: #fff;
    border-radius: 16px;
    border: 1px solid #E2E8F0;
    box-shadow: 0 20px 60px rgba(15, 23, 42, 0.15), 0 4px 16px rgba(15, 23, 42, 0.08);
    display: flex;
    flex-direction: column;
    overflow: hidden;

    /* Closed state */
    opacity: 0;
    transform: translateY(12px) scale(0.97);
    pointer-events: none;
    transition: opacity 220ms ease, transform 220ms ease;
    transform-origin: bottom right;
}

#chat-panel.visible {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: all;
}

/* ── Panel Header ─────────────────────────────────────────── */
.chat-header {
    background: linear-gradient(135deg, #4F46E5 0%, #6366F1 100%);
    padding: 16px 18px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.chat-header-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid rgba(255, 255, 255, 0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.chat-header-avatar svg {
    width: 18px;
    height: 18px;
    color: #fff;
}

.chat-header-info {
    flex: 1;
    min-width: 0;
}

.chat-header-name {
    color: #fff;
    font-weight: 700;
    font-size: 13.5px;
    letter-spacing: 0.01em;
}

.chat-header-status {
    color: rgba(255, 255, 255, 0.75);
    font-size: 11.5px;
    display: flex;
    align-items: center;
    gap: 5px;
    margin-top: 1px;
}

.chat-status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #34D399;
    flex-shrink: 0;
}

/* ── Messages Area ────────────────────────────────────────── */
#chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    scroll-behavior: smooth;
}

#chat-messages::-webkit-scrollbar {
    width: 4px;
}

#chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

#chat-messages::-webkit-scrollbar-thumb {
    background: #CBD5E1;
    border-radius: 4px;
}

/* ── Individual Messages ──────────────────────────────────── */
.chat-msg {
    display: flex;
    flex-direction: column;
    max-width: 88%;
    animation: msg-in 200ms ease;
}

@keyframes msg-in {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.chat-msg.user {
    align-self: flex-end;
    align-items: flex-end;
}

.chat-msg.ai {
    align-self: flex-start;
    align-items: flex-start;
}

.chat-bubble {
    padding: 9px 13px;
    border-radius: 14px;
    font-size: 13px;
    line-height: 1.6;
    word-wrap: break-word;
    white-space: pre-wrap;
}

.chat-msg.user .chat-bubble {
    background: #4F46E5;
    color: #fff;
    border-bottom-right-radius: 4px;
}

.chat-msg.ai .chat-bubble {
    background: #F1F5F9;
    color: #1E293B;
    border-bottom-left-radius: 4px;
    border: 1px solid #E2E8F0;
}

.chat-msg-time {
    font-size: 10.5px;
    color: #94A3B8;
    margin-top: 3px;
    padding: 0 2px;
}

/* ── Typing Indicator ─────────────────────────────────────── */
#chat-typing {
    display: none;
    align-self: flex-start;
}

#chat-typing.visible {
    display: flex;
}

.typing-bubble {
    background: #F1F5F9;
    border: 1px solid #E2E8F0;
    border-radius: 14px;
    border-bottom-left-radius: 4px;
    padding: 10px 14px;
    display: flex;
    align-items: center;
    gap: 4px;
    animation: msg-in 200ms ease;
}

.typing-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #94A3B8;
    animation: typing-bounce 1.2s ease-in-out infinite;
}

.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing-bounce {
    0%, 60%, 100% { transform: translateY(0); }
    30%           { transform: translateY(-5px); }
}

/* ── Suggested Questions ──────────────────────────────────── */
#chat-suggestions {
    padding: 0 14px 10px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex-shrink: 0;
}

.chat-suggestions-label {
    font-size: 11px;
    font-weight: 600;
    color: #94A3B8;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 2px;
}

.suggestion-btn {
    display: block;
    width: 100%;
    text-align: left;
    background: #F8FAFC;
    border: 1px solid #E2E8F0;
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 12.5px;
    color: #334155;
    cursor: pointer;
    font-family: inherit;
    transition: background 130ms ease, border-color 130ms ease, color 130ms ease;
    line-height: 1.4;
}

.suggestion-btn:hover {
    background: #EEF2FF;
    border-color: #C7D2FE;
    color: #4F46E5;
}

/* ── Chat Input Area ──────────────────────────────────────── */
.chat-input-area {
    padding: 12px 14px 14px;
    border-top: 1px solid #F1F5F9;
    background: #FAFAFA;
    display: flex;
    gap: 8px;
    align-items: flex-end;
    flex-shrink: 0;
}

#chat-input {
    flex: 1;
    resize: none;
    border: 1px solid #E2E8F0;
    border-radius: 10px;
    padding: 9px 12px;
    font-family: inherit;
    font-size: 13px;
    color: #0F172A;
    background: #fff;
    outline: none;
    max-height: 100px;
    min-height: 40px;
    transition: border-color 150ms ease, box-shadow 150ms ease;
    line-height: 1.5;
}

#chat-input::placeholder {
    color: #94A3B8;
}

#chat-input:focus {
    border-color: #818CF8;
    box-shadow: 0 0 0 3px rgba(129, 140, 248, 0.15);
}

#chat-send-btn {
    width: 38px;
    height: 38px;
    border-radius: 9px;
    background: #4F46E5;
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 150ms ease, transform 120ms ease;
    outline: none;
}

#chat-send-btn:hover:not(:disabled) {
    background: #4338CA;
    transform: scale(1.05);
}

#chat-send-btn:focus-visible {
    outline: 3px solid #818CF8;
    outline-offset: 2px;
}

#chat-send-btn:disabled {
    background: #C7D2FE;
    cursor: not-allowed;
    transform: none;
}

#chat-send-btn svg {
    width: 16px;
    height: 16px;
}

/* ── Disclaimer ───────────────────────────────────────────── */
.chat-disclaimer {
    text-align: center;
    font-size: 10.5px;
    color: #94A3B8;
    padding: 4px 14px 10px;
    background: #FAFAFA;
}

/* ── Error State ──────────────────────────────────────────── */
.chat-msg.error .chat-bubble {
    background: #FEF2F2;
    color: #B91C1C;
    border-color: #FECACA;
}

/* ── Mobile Responsive ────────────────────────────────────── */
@media (max-width: 480px) {
    #chat-widget-root {
        bottom: 1rem;
        right: 1rem;
        left: 1rem;
    }

    #chat-panel {
        width: 100%;
        right: 0;
        left: 0;
        max-height: 70vh;
        border-radius: 16px;
    }

    #chat-trigger-btn {
        position: fixed;
        bottom: 1rem;
        right: 1rem;
        left: auto;
    }
}

/* ── Reduced Motion ───────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
    #chat-panel,
    .chat-msg,
    .typing-bubble,
    #chat-trigger-btn,
    .suggestion-btn {
        transition: none;
        animation: none;
    }

    .chat-notif-dot {
        animation: none;
    }

    .typing-dot {
        animation: none;
        opacity: 0.5;
    }
}
