/* ── AI Chat Widget ── */

.chat-fab {
    position: fixed;
    bottom: calc(var(--footer-height, 40px) + 1rem);
    right: 1.5rem;
    z-index: 1000;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--primary-color);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-lg);
    transition: transform var(--transition-fast), background-color var(--transition-fast), box-shadow var(--transition-fast);
}

.chat-fab:hover {
    transform: scale(1.08);
    background: var(--primary-hover);
    box-shadow: var(--shadow-xl);
}

.chat-fab .material-symbols-rounded {
    font-size: 1.6rem;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.chat-fab.open .material-symbols-rounded {
    transform: rotate(90deg);
}

/* Chat panel */
.chat-panel {
    position: fixed;
    bottom: calc(var(--footer-height, 40px) + 56px + 1.5rem);
    right: 1.5rem;
    z-index: 999;
    width: 380px;
    max-height: 520px;
    background-color: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-2xl);
    box-shadow: var(--glass-shadow), var(--shadow-xl);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    pointer-events: none;
    transition: opacity 0.25s ease, transform 0.25s ease;
}

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

/* Header */
.chat-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    background: var(--primary-color);
    color: #fff;
}

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

.chat-header-icon .material-symbols-rounded {
    font-size: 1.2rem;
    color: #fff;
}

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

.chat-header-title {
    font-size: 0.95rem;
    font-weight: 600;
    line-height: 1.3;
}

.chat-header-subtitle {
    font-size: 0.75rem;
    opacity: 0.85;
}

/* Messages area */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    min-height: 200px;
    max-height: 320px;
}

.chat-msg {
    max-width: 85%;
    padding: 0.65rem 1rem;
    border-radius: var(--radius-xl);
    font-size: 0.875rem;
    line-height: 1.5;
    word-wrap: break-word;
}

.chat-msg.bot {
    align-self: flex-start;
    background: var(--surface-overlay);
    color: var(--text-primary);
    border-bottom-left-radius: var(--radius-sm);
}

.chat-msg.user {
    align-self: flex-end;
    background: var(--primary-color);
    color: #fff;
    border-bottom-right-radius: var(--radius-sm);
}

.chat-msg a {
    color: inherit;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.chat-msg.user a {
    color: #fff;
}

/* Quick replies */
.chat-quick-replies {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    padding: 0 1rem 0.75rem;
}

.chat-quick-btn {
    padding: 0.35rem 0.75rem;
    font-size: 0.8rem;
    font-family: inherit;
    border: 1px solid var(--glass-border);
    border-radius: 999px;
    background-color: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    color: var(--primary-color);
    cursor: pointer;
    transition: background-color var(--transition-fast), border-color var(--transition-fast);
    white-space: nowrap;
}

.chat-quick-btn:hover {
    background: var(--primary-light);
    border-color: var(--primary-color);
}

/* Input area */
.chat-input-area {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    border-top: 1px solid var(--border-color);
}

.chat-input {
    flex: 1;
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-xl);
    padding: 0.55rem 1rem;
    font-size: 0.875rem;
    font-family: inherit;
    background-color: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    color: var(--text-primary);
    outline: none;
    transition: border-color var(--transition-fast);
}

.chat-input::placeholder {
    color: var(--text-tertiary);
}

.chat-input:focus {
    border-color: var(--primary-color);
}

.chat-send-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary-color);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background var(--transition-fast), transform var(--transition-fast);
}

.chat-send-btn:hover {
    background: var(--primary-hover);
    transform: scale(1.05);
}

.chat-send-btn .material-symbols-rounded {
    font-size: 1.15rem;
}

/* Typing indicator */
.chat-typing {
    display: flex;
    gap: 4px;
    align-items: center;
    padding: 0.65rem 1rem;
    align-self: flex-start;
    background: var(--surface-overlay);
    border-radius: var(--radius-xl);
    border-bottom-left-radius: var(--radius-sm);
}

.chat-typing-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--text-tertiary);
    animation: chatTyping 1.2s infinite ease-in-out;
}

.chat-typing-dot:nth-child(2) { animation-delay: 0.15s; }
.chat-typing-dot:nth-child(3) { animation-delay: 0.3s; }

@keyframes chatTyping {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-4px); opacity: 1; }
}

/* ── Responsive ── */
@media (max-width: 480px) {
    .chat-panel {
        right: 0.75rem;
        left: 0.75rem;
        bottom: 5rem;
        width: auto;
        max-height: 70vh;
    }

    .chat-fab {
        bottom: 1rem;
        right: 1rem;
        width: 48px;
        height: 48px;
    }
}
