/* ===== CHAT AREA + MESSAGES + TYPING =====
 * GetAdvice v5.7 — Enhanced welcome card, pill animations, glow effects.
 * File: css/chat.css
 */

/* ── Chat container ── */
#chat {
    position: relative;
    z-index: 5;
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: var(--space-lg);
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
}

#chat::-webkit-scrollbar { width: 4px; }
#chat::-webkit-scrollbar-track { background: transparent; }
#chat::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 4px; }

/* ── Welcome card ── */
.welcome {
    display: flex;
    align-items: center;
    justify-content: center;
    /* Use the stable full-viewport height so the card doesn't reflow
       when the iOS keyboard opens and --app-height shrinks. */
    min-height: var(--app-height-full, 100%);
    animation: welcomeEntry 0.8s var(--ease-out) forwards;
}

@keyframes welcomeEntry {
    from { opacity: 0; transform: translateY(20px) scale(0.97); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.welcome-container {
    position: relative;
    text-align: center;
    padding: var(--space-2xl) var(--space-xl);
    max-width: 480px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-3xl);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    overflow: hidden;
}

/* ── v5.1: Gradient shimmer on welcome card ── */
.welcome-container::before {
    content: '';
    position: absolute;
    top: 0; left: -50%;
    width: 200%; height: 100%;
    background: linear-gradient(105deg, transparent 40%, rgba(124, 92, 252, 0.04) 45%, rgba(224, 64, 251, 0.04) 50%, transparent 55%);
    animation: cardShimmer 6s ease-in-out infinite;
}

@keyframes cardShimmer {
    0%, 100% { transform: translateX(-30%); }
    50% { transform: translateX(30%); }
}

.welcome-icon {
    font-size: 48px;
    display: block;
    margin-bottom: var(--space-lg);
    animation: wave 2.5s ease-in-out infinite;
    transform-origin: 70% 70%;
    position: relative;
    z-index: 1;
}

@keyframes wave {
    0%, 100% { transform: rotate(0deg); }
    10% { transform: rotate(14deg); }
    20% { transform: rotate(-8deg); }
    30% { transform: rotate(14deg); }
    40% { transform: rotate(-4deg); }
    50% { transform: rotate(10deg); }
    60%, 100% { transform: rotate(0deg); }
}

/* ── v5.1: Gradient text on welcome heading ── */
.welcome-container h2 {
    font-size: var(--font-size-xl);
    font-weight: 700;
    letter-spacing: -0.02em;
    margin-bottom: var(--space-sm);
    background: linear-gradient(135deg, var(--text-primary), var(--accent-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    position: relative;
    z-index: 1;
}

.welcome-container p {
    color: var(--text-secondary);
    font-size: var(--font-size-base);
    line-height: 1.5;
    margin-bottom: var(--space-xl);
    position: relative;
    z-index: 1;
}

/* ── Suggestion pills ── */
.suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-sm);
    justify-content: center;
    position: relative;
    z-index: 1;
}

.suggestion-pill {
    background: var(--bg-glass);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 10px var(--space-lg);
    border-radius: var(--radius-xl);
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s var(--ease-spring);
    font-family: inherit;
}

/* ── v5.1: Enhanced pill hover with lift + glow ── */
.suggestion-pill:hover {
    background: rgba(124, 92, 252, 0.12);
    border-color: var(--border-glow);
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(124, 92, 252, 0.15);
}

.suggestion-pill:focus-visible {
    outline: 2px solid var(--accent-light);
    outline-offset: 2px;
}

.suggestion-pill:active {
    transform: scale(0.95) translateY(0);
    background: rgba(124, 92, 252, 0.2);
}

/* ── Messages ── */
.message {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: var(--space-lg);
    animation: msgEntry 0.4s var(--ease-out) forwards;
    opacity: 0;
    transform: translateY(12px);
}

@keyframes msgEntry { to { opacity: 1; transform: translateY(0); } }

.message.user { flex-direction: row-reverse; }

/* ── v5.1: Larger avatars with glow ── */
.message-avatar {
    width: 34px; height: 34px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: var(--font-size-xs);
    font-weight: 600;
}

.message.bot .message-avatar {
    background: linear-gradient(135deg, var(--accent), var(--accent-hot));
    box-shadow: 0 0 12px var(--accent-glow);
}

.message.user .message-avatar {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-secondary);
}

.message-bubble {
    max-width: 80%;
    padding: var(--space-md) var(--space-lg);
    border-radius: var(--radius-lg);
    font-size: var(--font-size-base);
    line-height: 1.55;
    word-wrap: break-word;
}

.message.bot .message-bubble {
    background: var(--bot-bubble);
    border: 1px solid var(--border);
    border-bottom-left-radius: var(--radius-sm);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.2);
}

.message.user .message-bubble {
    background: var(--user-bubble);
    border-bottom-right-radius: var(--radius-sm);
    box-shadow: 0 4px 24px rgba(124, 92, 252, 0.25);
}

/* ── Typing indicator ── */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 14px var(--radius-lg);
    background: var(--bot-bubble);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    border-bottom-left-radius: var(--radius-sm);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.typing-dot {
    width: 7px; height: 7px;
    background: var(--accent-light);
    border-radius: 50%;
    animation: typingBounce 1.4s ease-in-out infinite;
}

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

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

/* ── Scroll-to-bottom button ── */
#scroll-btn {
    position: fixed;
    /* Sit above the input area (input ~44px + padding ~24px + safe-bottom) */
    bottom: calc(44px + var(--space-md) * 2 + var(--safe-bottom) + 8px);
    left: 50%;
    transform: translateX(-50%);
    width: 36px; height: 36px;
    border-radius: 50%;
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-primary);
    display: none;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 11;
    font-size: var(--font-size-input);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    transition: all var(--transition-fast);
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

#scroll-btn:focus-visible {
    outline: 2px solid var(--accent-light, #a78bfa);
    outline-offset: 2px;
}

#scroll-btn:active { transform: translateX(-50%) scale(0.9); }

/* ── Streaming cursor (typewriter effect) ── */
.streaming-cursor {
    display: inline;
    color: var(--accent-light);
    animation: cursorBlink 0.8s step-end infinite;
    font-size: 0.85em;
    margin-left: 1px;
    vertical-align: baseline;
}

@keyframes cursorBlink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

.message-bubble.streaming {
    min-height: 20px;
}
