/* ═══════════════════════════════════════════════════
   SYMPY WEB — Complete Stylesheet
   Matches Flutter app: #0F0F0F bg, #448AFF blue, #E040FB purple
═══════════════════════════════════════════════════ */
:root {
    --bg-dark:   #0F0F0F;
    --bg-card:   #161625;
    --accent-blue:   #448AFF;
    --accent-purple: #E040FB;
    --accent-red:    #ff4444;
    --accent-green:  #4CAF50;
    --text-white: #ffffff;
    --text-dim:   rgba(255,255,255,0.45);
    --card-bg:    rgba(255,255,255,0.04);
    --border:     rgba(255,255,255,0.08);
    --gradient-btn: linear-gradient(135deg, #448AFF, #E040FB);
}

/* ── RESET ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; width: 100%; }
body.app-page { overflow: hidden; }
body {
    background: var(--bg-dark);
    color: var(--text-white);
    font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    font-size: 16px;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}
input, textarea { user-select: text; }
a { text-decoration: none; color: inherit; }

/* ── GRADIENT BG ── */
.gradient-bg {
    position: fixed; inset: 0; z-index: -1;
    background: linear-gradient(160deg, rgba(68,138,255,0.1) 0%, #000 60%);
}

/* ── AUTOFILL FIX ── */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus {
    -webkit-text-fill-color: white !important;
    -webkit-box-shadow: 0 0 0 1000px #1a1a2e inset !important;
    transition: background-color 5000s;
}

/* ── CURSORS ── */
.clickable-text, button, .vibe-chip, .card, .drawer-item, .faq-q { cursor: pointer !important; }

/* ═══════════ SCREENS ═══════════ */
.screen {
    display: none;
    position: fixed; inset: 0;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}
.screen.active { display: flex; }

/* ═══════════ AUTH SCREENS ═══════════ */
.container {
    width: 100%; max-width: 420px;
    padding: 20px;
    display: flex; flex-direction: column;
    align-items: center; text-align: center;
}
.auth-card {
    background: rgba(255,255,255,0.03);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border);
    border-radius: 28px;
    padding: 36px 28px;
    width: 100%; max-width: 380px;
    text-align: center;
}
.logo-icon { font-size: 44px; color: var(--accent-blue); margin-bottom: 14px; display: block; }
.auth-title { font-size: 26px; font-weight: bold; margin-bottom: 4px; }
.subtitle { color: var(--text-dim); font-size: 14px; margin-bottom: 28px; }
.auth-form { display: flex; flex-direction: column; gap: 14px; width: 100%; }

.input-group {
    display: flex; align-items: center;
    background: rgba(255,255,255,0.06);
    border: 1px solid transparent;
    border-radius: 14px;
    padding: 0 16px;
    transition: border-color 0.2s;
}
.input-group:focus-within { border-color: var(--accent-blue); }
.input-group i { color: var(--text-dim); font-size: 15px; margin-right: 10px; flex-shrink: 0; }
.input-group input {
    flex: 1; background: transparent; border: none;
    color: white; padding: 16px 0; outline: none; font-size: 15px;
}

.forgot-pass { text-align: right; font-size: 13px; color: var(--accent-blue); }
.auth-switch { color: var(--text-dim); font-size: 14px; margin-top: 8px; }
.auth-switch span { color: var(--accent-blue); font-weight: 600; }

.btn-primary {
    position: relative;
    padding: 16px; border-radius: 40px; border: none;
    font-size: 16px; font-weight: bold;
    background: white; color: black;
    width: 100%; min-height: 54px;
    display: flex; justify-content: center; align-items: center; gap: 8px;
    transition: transform 0.15s, opacity 0.15s;
}
.btn-primary:active { transform: scale(0.97); }
.gradient-btn { background: var(--gradient-btn) !important; color: white !important; }
.btn-secondary {
    background: transparent; border: 1px solid var(--border);
    color: white; padding: 14px; border-radius: 40px; width: 100%;
    font-size: 15px; font-weight: 500;
    transition: border-color 0.2s;
}
.btn-secondary:hover { border-color: rgba(68,138,255,0.4); }

/* Spinner */
.loader {
    width: 20px; height: 20px;
    border: 3px solid rgba(255,255,255,0.2);
    border-top: 3px solid white;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Pulse */
.pulse { animation: pulse-anim 2s infinite; }
@keyframes pulse-anim {
    0%,100% { box-shadow: 0 0 0 0 rgba(68,138,255,0.4); }
    50% { box-shadow: 0 0 0 12px rgba(68,138,255,0); }
}

/* ═══════════ DRAWER ═══════════ */
#drawer-overlay {
    display: none;
    position: fixed; inset: 0; z-index: 998;
    background: rgba(0,0,0,0.55);
    backdrop-filter: blur(4px);
}
#drawer-overlay.open { display: block; }

#drawer {
    position: fixed; top: 0; left: -300px; bottom: 0;
    width: 280px; z-index: 999;
    background: #0d0d1f;
    border-right: 1px solid var(--border);
    display: flex; flex-direction: column;
    transition: left 0.3s cubic-bezier(0.4,0,0.2,1);
    overflow-y: auto;
}
#drawer.open { left: 0; }

.drawer-header {
    padding: 52px 20px 20px;
    background: linear-gradient(160deg, rgba(68,138,255,0.12), rgba(224,64,251,0.06));
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; gap: 14px;
}
.drawer-avatar-circle {
    width: 52px; height: 52px; border-radius: 50%; flex-shrink: 0;
    background: rgba(68,138,255,0.15);
    border: 2px solid rgba(68,138,255,0.35);
    display: flex; align-items: center; justify-content: center;
    font-size: 22px; color: var(--accent-blue);
}
.drawer-user-info { display: flex; flex-direction: column; gap: 3px; overflow: hidden; }
.drawer-user-info span:first-child { font-size: 15px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.drawer-email-text { font-size: 11px; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.drawer-quota-box {
    margin: 16px; padding: 14px;
    background: rgba(68,138,255,0.07);
    border: 1px solid rgba(68,138,255,0.15);
    border-radius: 14px;
    display: flex; flex-direction: column; gap: 8px;
}
.dq-row { display: flex; align-items: center; gap: 8px; }
.dq-bar {
    height: 5px; background: rgba(255,255,255,0.08);
    border-radius: 5px; overflow: hidden;
}
.dq-bar-fill {
    height: 100%; width: 0%;
    background: linear-gradient(90deg, var(--accent-blue), var(--accent-purple));
    border-radius: 5px; transition: width 0.5s ease;
}

.drawer-divider { height: 1px; background: var(--border); margin: 6px 0; }

.drawer-item {
    display: flex; align-items: center; gap: 12px;
    padding: 14px 20px; font-size: 14px; color: rgba(255,255,255,0.75);
    transition: background 0.15s;
    text-decoration: none;
}
.drawer-item:hover { background: rgba(255,255,255,0.05); }
.drawer-item i { width: 18px; text-align: center; color: var(--accent-blue); font-size: 15px; }
.drawer-danger { color: #ff6b6b !important; }
.drawer-danger i { color: #ff6b6b !important; }

.drawer-footer-text {
    margin-top: auto; padding: 20px;
    font-size: 11px; color: rgba(255,255,255,0.15); text-align: center;
}

/* ═══════════ VOICE SELECTION ═══════════ */
#voice-screen { justify-content: flex-start; }

.voice-topbar {
    position: absolute; top: 0; left: 0; right: 0;
    height: 68px; padding: 0 16px;
    display: flex; align-items: center; justify-content: space-between;
    background: rgba(0,0,0,0.5); backdrop-filter: blur(15px);
    border-bottom: 1px solid var(--border); z-index: 10;
}
.topbar-logo { font-size: 18px; font-weight: bold; color: var(--accent-blue); }
.topbar-logo i { margin-right: 6px; }
.topbar-menu-btn {
    background: none; border: none; color: white;
    font-size: 20px; padding: 10px; cursor: pointer;
}
.topbar-avatar {
    width: 38px; height: 38px; border-radius: 50%; object-fit: cover;
    border: 2px solid rgba(68,138,255,0.5);
}

.selection-grid {
    display: flex; gap: 16px; justify-content: center;
    flex-wrap: wrap; margin-bottom: 20px;
    width: 100%;
}
.card {
    background: var(--card-bg);
    border: 2px solid transparent;
    border-radius: 24px; padding: 20px 16px;
    cursor: pointer; transition: all 0.2s;
    width: 140px; text-align: center;
}
.card.selected {
    background: rgba(68,138,255,0.12);
    border-color: var(--accent-blue);
    box-shadow: 0 0 24px rgba(68,138,255,0.2);
}
.card:hover:not(.selected) { background: rgba(255,255,255,0.06); }
.card h3 { font-size: 16px; font-weight: 700; margin-bottom: 4px; }
.card span { font-size: 12px; color: var(--text-dim); }
.avatar-ring {
    width: 72px; height: 72px; border-radius: 50%;
    border: 3px solid var(--accent-blue);
    overflow: hidden; margin: 0 auto 12px;
}

.daily-limit-card {
    display: flex; align-items: center; gap: 12px;
    background: rgba(68,138,255,0.08);
    border: 1px solid rgba(68,138,255,0.2);
    border-radius: 16px; padding: 14px 18px;
    width: 100%; max-width: 320px;
    margin: 0 auto 20px; text-align: left;
}
.limit-icon {
    width: 36px; height: 36px; border-radius: 10px;
    background: rgba(68,138,255,0.15); flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    font-size: 15px; color: var(--accent-blue);
}
.limit-info { display: flex; flex-direction: column; gap: 2px; }
.limit-title { font-size: 13px; font-weight: 600; }
.limit-sub { font-size: 11px; color: var(--text-dim); }

/* ═══════════ VIBE SCREEN ═══════════ */
.vibe-back-btn {
    position: absolute; top: 20px; left: 16px;
    background: none; border: none; color: white; font-size: 20px; padding: 8px;
}
.vibe-grid { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin: 20px 0 32px; }
.vibe-chip {
    padding: 11px 22px; border-radius: 50px; font-size: 14px; font-weight: 500;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.1);
    transition: all 0.2s;
}
.vibe-chip.active {
    background: linear-gradient(135deg, rgba(68,138,255,0.3), rgba(224,64,251,0.25));
    border-color: var(--accent-blue);
    box-shadow: 0 0 16px rgba(68,138,255,0.2);
}

/* ═══════════ CHAT SCREEN ═══════════ */
#chat-screen {
    display: none; flex-direction: column;
    height: 100vh; overflow: hidden;
}
#chat-screen.active { display: flex !important; }

.chat-header {
    width: 100%; height: 64px; flex-shrink: 0;
    padding: 0 8px 0 4px;
    display: flex; align-items: center; justify-content: space-between;
    background: rgba(0,0,0,0.75);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid rgba(255,255,255,0.07);
    z-index: 50;
}
.header-info { display: flex; align-items: center; gap: 10px; overflow: hidden; }
.back-btn {
    background: none; border: none; color: white; font-size: 20px;
    padding: 10px 12px; flex-shrink: 0;
}
.chat-avatar-img {
    width: 40px; height: 40px; border-radius: 50%; object-fit: cover;
    border: 2px solid rgba(68,138,255,0.4); flex-shrink: 0;
}
.header-info h4 { font-size: 15px; font-weight: 700; }
.online-dot {
    width: 7px; height: 7px; border-radius: 50%;
    background: var(--accent-green);
    box-shadow: 0 0 6px var(--accent-green);
    animation: online-pulse 2s infinite;
}
@keyframes online-pulse { 0%,100%{opacity:1}50%{opacity:0.5} }

.header-actions { display: flex; align-items: center; gap: 2px; flex-shrink: 0; }
.header-call-btn {
    background: none; border: none;
    color: white; font-size: 20px; padding: 10px 12px;
    transition: color 0.2s;
}
.header-call-btn:hover { color: var(--accent-blue); }
.header-menu-btn {
    background: none; border: none;
    color: var(--text-dim); font-size: 18px; padding: 10px 12px;
}

/* Chat body */
.chat-body {
    flex: 1; width: 100%; overflow-y: auto;
    padding: 20px;
    padding-bottom: 130px; /* ensures last message never hidden behind input bar */
    display: flex; flex-direction: column; gap: 12px;
    background: #000;  /* set dynamically by selectVoice() in script.js */
    min-height: 0;
}
.chat-body::-webkit-scrollbar { width: 0; }

/* Messages */
.message {
    max-width: 85%; padding: 12px 16px;
    border-radius: 20px; font-size: 16px; line-height: 1.4;
    word-wrap: break-word;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}
.message.sympy {
    align-self: flex-start;
    background: rgba(255,255,255,0.15);
    border: 1px solid rgba(255,255,255,0.1);
    border-bottom-left-radius: 2px;
}
.message.user {
    align-self: flex-end;
    background: rgba(68,138,255,0.9);
    border-bottom-right-radius: 2px;
}
.message img {
    max-width: 100%; border-radius: 12px; display: block;
    margin-bottom: 6px;
}
.message .caption-text {
    font-size: 13px; opacity: 0.85; margin-top: 4px;
}

/* Typing */
.typing { display: flex !important; align-items: center; gap: 5px; padding: 14px 18px !important; width: fit-content; min-height: 44px; }
.dot { width: 7px; height: 7px; background: white; border-radius: 50%; opacity: 0.45; animation: bounce 1.4s infinite ease-in-out both; }
.dot:nth-child(1){animation-delay:-0.32s}.dot:nth-child(2){animation-delay:-0.16s}
@keyframes bounce { 0%,80%,100%{transform:scale(0)}40%{transform:scale(1);opacity:1} }

/* Summary banners */
#summary-container { width: 100%; flex-shrink: 0; }

/* Input area */
.chat-input-area {
    position: fixed; bottom: 0; left: 0; right: 0;
    padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
    background: rgba(10,10,20,0.97);
    backdrop-filter: blur(12px);
    border-top: 1px solid rgba(255,255,255,0.06);
    z-index: 50;
}
.input-wrapper {
    display: flex; align-items: center; gap: 6px;
    background: rgba(255,255,255,0.08);
    border-radius: 28px; padding: 5px 6px 5px 12px;
    border: 1px solid rgba(255,255,255,0.08);
}
.input-wrapper:focus-within { border-color: rgba(68,138,255,0.4); }
.input-wrapper input {
    flex: 1; background: transparent; border: none;
    color: white; padding: 10px 4px; outline: none; font-size: 15px;
}
.input-wrapper input::placeholder { color: rgba(255,255,255,0.25); }
.icon-btn {
    background: none; border: none; color: var(--text-dim);
    font-size: 18px; padding: 8px; flex-shrink: 0; transition: color 0.2s;
}
.icon-btn:hover { color: var(--accent-blue); }
.send-btn {
    width: 42px; height: 42px; border-radius: 50%; border: none;
    background: var(--gradient-btn); color: white; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    font-size: 16px; transition: transform 0.15s, opacity 0.15s;
}
.send-btn:active { transform: scale(0.9); }

/* ═══════════ IMAGE PREVIEW OVERLAY ═══════════ */
#image-preview-overlay {
    display: none; position: fixed; inset: 0; z-index: 1100;
    background: rgba(0,0,0,0.75); backdrop-filter: blur(8px);
    align-items: flex-end; justify-content: center;
}
#image-preview-overlay.open { display: flex; }
.img-preview-card {
    background: #13131f; border: 1px solid var(--border);
    border-radius: 24px 24px 0 0; padding: 0 0 24px;
    width: 100%; max-width: 480px;
    overflow: hidden;
}
.img-preview-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 16px 20px 12px;
    border-bottom: 1px solid var(--border);
    font-size: 15px; font-weight: 700;
}
.img-close-btn { background: none; border: none; color: var(--text-dim); font-size: 20px; padding: 4px; }
.img-preview-body {
    padding: 16px; display: flex; justify-content: center;
    max-height: 50vh; overflow: hidden;
}
#preview-img { max-width: 100%; max-height: 44vh; border-radius: 14px; object-fit: contain; }
.img-caption-row {
    display: flex; align-items: center; gap: 8px;
    padding: 12px 16px 0;
}
.img-caption-row input {
    flex: 1; background: rgba(255,255,255,0.07);
    border: 1px solid var(--border); border-radius: 24px;
    color: white; padding: 11px 16px; font-size: 14px; outline: none;
}
.img-caption-row input:focus { border-color: rgba(68,138,255,0.45); }
.img-caption-row input::placeholder { color: rgba(255,255,255,0.25); }

/* ═══════════ CALL OVERLAY ═══════════ */
#call-overlay {
    position: fixed; inset: 0; z-index: 1000;
    display: none; flex-direction: column;
    align-items: center; justify-content: center;
    padding: 0;
}
#call-overlay.active { display: flex !important; }

.call-bg {
    position: absolute; inset: 0; z-index: 0;
    background: radial-gradient(ellipse at 50% 35%, #1a1040 0%, #080818 60%, #000 100%);
    transition: background 0.5s;
}
.call-container {
    position: relative; z-index: 1;
    width: 100%; max-width: 420px;
    display: flex; flex-direction: column;
    align-items: center;
    padding: 0 24px 40px;
    height: 100vh; justify-content: center; gap: 0;
}

/* Top row */
.call-top-row {
    position: absolute; top: 0; left: 0; right: 0;
    display: flex; align-items: center; justify-content: space-between;
    padding: 52px 20px 16px;
}
.call-live-badge {
    display: flex; align-items: center; gap: 6px;
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 20px; padding: 6px 12px;
}
.call-live-dot {
    width: 7px; height: 7px; border-radius: 50%;
    background: #888; animation: none;
    transition: background 0.3s;
}
.call-live-dot.live { background: var(--accent-green); animation: online-pulse 1.5s infinite; }
.call-timer { font-size: 20px; font-weight: 300; font-variant-numeric: tabular-nums; letter-spacing: 2px; }
.call-quota-pill {
    display: flex; align-items: center; gap: 5px;
    background: rgba(255,255,255,0.07);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 20px; padding: 6px 12px;
    color: rgba(255,255,255,0.65);
}

/* Avatar */
.call-avatar-wrap {
    position: relative; width: 190px; height: 190px;
    margin-bottom: 24px;
}
.call-pulse-ring {
    position: absolute; inset: 0; border-radius: 50%;
    border: 2px solid rgba(68,138,255,0.35);
    animation: call-ring 3s ease-out infinite;
}
.call-pulse-ring.r2 { animation-delay: 1s; }
.call-pulse-ring.r3 { animation-delay: 2s; }
@keyframes call-ring { 0%{transform:scale(1);opacity:0.6} 100%{transform:scale(1.6);opacity:0} }
.call-avatar {
    width: 190px; height: 190px; border-radius: 50%; object-fit: cover;
    border: 4px solid rgba(255,255,255,0.1);
    box-shadow: 0 0 60px rgba(68,138,255,0.25);
    position: relative; z-index: 1;
}

.call-ai-name { font-size: 28px; font-weight: bold; margin-bottom: 6px; }
.call-vibe-tag {
    font-size: 12px; color: var(--text-dim);
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 20px; padding: 5px 14px; margin-bottom: 20px;
}

/* Waveform */
.call-wave {
    display: flex; align-items: center; gap: 4px; height: 36px; margin-bottom: 32px;
}
.wave-bar {
    width: 4px; background: var(--accent-blue);
    border-radius: 4px; opacity: 0.35;
    animation: wave-idle 1.5s ease-in-out infinite;
}
.wave-bar:nth-child(1){animation-delay:0s;height:10px}
.wave-bar:nth-child(2){animation-delay:0.1s;height:18px}
.wave-bar:nth-child(3){animation-delay:0.2s;height:28px}
.wave-bar:nth-child(4){animation-delay:0.3s;height:36px}
.wave-bar:nth-child(5){animation-delay:0.2s;height:28px}
.wave-bar:nth-child(6){animation-delay:0.1s;height:18px}
.wave-bar:nth-child(7){animation-delay:0s;height:10px}
@keyframes wave-idle {
    0%,100%{transform:scaleY(0.4);opacity:0.25}
    50%{transform:scaleY(1);opacity:0.55}
}
.call-wave.active .wave-bar {
    opacity: 0.9;
    animation: wave-active 0.6s ease-in-out infinite alternate;
}
@keyframes wave-active {
    from{transform:scaleY(0.3)} to{transform:scaleY(1)}
}

/* Controls */
.call-controls { display: flex; gap: 28px; align-items: center; }
.ctrl-wrap { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.ctrl-label { font-size: 11px; color: var(--text-dim); letter-spacing: 0.5px; }
.control-btn {
    width: 62px; height: 62px; border-radius: 50%; border: none;
    background: rgba(255,255,255,0.1);
    color: white; font-size: 22px;
    display: flex; align-items: center; justify-content: center;
    transition: background 0.2s, transform 0.15s;
}
.control-btn:active { transform: scale(0.92); }
.control-btn.muted { background: rgba(255,68,68,0.3); color: #ff6b6b; }
.control-btn.end-call {
    width: 72px; height: 72px; font-size: 26px;
    background: var(--accent-red);
    box-shadow: 0 8px 28px rgba(255,68,68,0.4);
}
.control-btn.active-blue { background: rgba(68,138,255,0.3); color: var(--accent-blue); }

/* ═══════════ SITE FOOTER ═══════════ */
#site-footer {
    position: fixed; bottom: 0; left: 0; right: 0;
    display: none; gap: 10px; justify-content: center; align-items: center;
    padding: 10px 16px; flex-wrap: wrap; z-index: 200;
    background: rgba(10,10,20,0.9); backdrop-filter: blur(10px);
    border-top: 1px solid rgba(255,255,255,0.05);
}
#site-footer a { color: rgba(255,255,255,0.28); font-size: 11px; text-decoration: none; transition: color 0.2s; }
#site-footer a:hover { color: var(--accent-blue); }
#site-footer span { color: rgba(255,255,255,0.12); font-size: 11px; }

/* Show footer on auth screens */
#login-screen.active ~ #site-footer,
#signup-screen.active ~ #site-footer,
#forgot-password-screen.active ~ #site-footer { display: flex !important; }