/* ============================================
   DARSHIKA CHATBOT V2 - FUTURISTIC UI DESIGN
   Theme: Dual Mode (Dark/Light) with Golden Accents
   ============================================ */

/* Light Theme (Default) - Clean & Professional */
:root, [data-theme="light"] {
    --p: #E6A817;
    --pl: #F7C748;
    --pd: #C98F0A;
    --pg: rgba(230, 168, 23, 0.25);
    --bg: #F8F9FC;
    --bg2: #FFFFFF;
    --card: #FFFFFF;
    --card-hover: #FFFBF0;
    --glass: rgba(255, 255, 255, 0.95);
    --border: #E5E7EB;
    --border-hover: #E6A817;
    --txt: #1F2937;
    --txt2: #4B5563;
    --txt3: #9CA3AF;
    --ok: #10B981;
    --err: #EF4444;
    --grad: linear-gradient(135deg, #E6A817 0%, #F7C748 100%);
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    --shadow-hover: 0 12px 40px rgba(230, 168, 23, 0.15);
    --msg-user-txt: #FFFFFF;
    --msg-ai-bg: #F3F4F6;
    --sidebar-bg: linear-gradient(180deg, #FFFFFF 0%, #F8F9FC 100%);
    --input-bg: #F9FAFB;
    --r1: 8px;
    --r2: 12px;
    --r3: 16px;
    --r4: 24px;
}

/* Dark Theme - Elegant & Modern */
[data-theme="dark"] {
    --p: #F59E0B;
    --pl: #FBBF24;
    --pd: #D97706;
    --pg: rgba(245, 158, 11, 0.3);
    --bg: #111827;
    --bg2: #1F2937;
    --card: #1F2937;
    --card-hover: #374151;
    --glass: rgba(31, 41, 55, 0.95);
    --border: #374151;
    --border-hover: #F59E0B;
    --txt: #F9FAFB;
    --txt2: #D1D5DB;
    --txt3: #6B7280;
    --ok: #34D399;
    --err: #F87171;
    --grad: linear-gradient(135deg, #F59E0B 0%, #FBBF24 100%);
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    --shadow-hover: 0 12px 40px rgba(245, 158, 11, 0.2);
    --msg-user-txt: #111827;
    --msg-ai-bg: #374151;
    --sidebar-bg: linear-gradient(180deg, #1F2937 0%, #111827 100%);
    --input-bg: #374151;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; overflow: hidden; }
body { font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; background: var(--bg); color: var(--txt); line-height: 1.6; }

/* Animated Background */
.bg-animation { position: fixed; inset: 0; z-index: 0; overflow: hidden; }
.bg-gradient {
    position: absolute; inset: 0;
    background: var(--bg);
    transition: background 0.4s ease;
}

[data-theme="light"] .bg-gradient {
    background: linear-gradient(135deg, #F8F9FC 0%, #EEF2FF 50%, #FEF3C7 100%);
}

[data-theme="dark"] .bg-gradient {
    background: linear-gradient(135deg, #111827 0%, #1F2937 50%, #111827 100%);
}

[data-theme="light"] .bg-grid {
    background-image: linear-gradient(rgba(0,0,0,0.02) 1px, transparent 1px),
                      linear-gradient(90deg, rgba(0,0,0,0.02) 1px, transparent 1px);
}

[data-theme="dark"] .bg-grid {
    background-image: linear-gradient(rgba(255,255,255,0.02) 1px, transparent 1px),
                      linear-gradient(90deg, rgba(255,255,255,0.02) 1px, transparent 1px);
}

[data-theme="light"] .shape { opacity: 0.03; }
[data-theme="dark"] .shape { opacity: 0.08; }
@keyframes gShift { 0%, 100% { opacity: 1; } 50% { opacity: 0.8; } }

.bg-grid {
    position: absolute; inset: 0;
    background-image: linear-gradient(rgba(255,255,255,0.02) 1px, transparent 1px),
                      linear-gradient(90deg, rgba(255,255,255,0.02) 1px, transparent 1px);
    background-size: 60px 60px;
    animation: gridMove 30s linear infinite;
}
@keyframes gridMove { 0% { transform: translate(0, 0); } 100% { transform: translate(60px, 60px); } }

.floating-shapes { position: absolute; inset: 0; pointer-events: none; }
.shape { position: absolute; border-radius: 50%; background: var(--grad); opacity: 0.1; filter: blur(60px); animation: float 15s ease-in-out infinite; }
.s1 { width: 400px; height: 400px; top: -100px; left: -100px; }
.s2 { width: 300px; height: 300px; top: 50%; right: -50px; animation-delay: -5s; }
.s3 { width: 200px; height: 200px; bottom: 10%; left: 30%; animation-delay: -10s; }
@keyframes float { 0%, 100% { transform: translate(0, 0) scale(1); } 50% { transform: translate(-20px, 20px) scale(0.95); } }

/* App Container */
.app-container { position: relative; z-index: 1; display: flex; height: 100vh; padding: 20px; gap: 20px; }

/* Sidebar — compact vertical rhythm so user-card + toggles + footer all fit on smaller viewports */
.sidebar {
    width: 272px; min-width: 272px;
    background: var(--sidebar-bg);
    border: 1px solid var(--border);
    border-radius: var(--r4);
    display: flex; flex-direction: column; padding: 16px 16px 14px;
    animation: slideL 0.6s ease-out;
    box-shadow: var(--shadow);
}
@keyframes slideL { from { opacity: 0; transform: translateX(-30px); } to { opacity: 1; transform: translateX(0); } }

.logo { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.logo-icon {
    width: 38px; height: 38px; background: #fff; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 20px; color: var(--bg); box-shadow: 0 0 30px var(--pg);
    overflow: hidden; padding: 2px; flex-shrink: 0;
}
.logo-text { display: flex; flex-direction: column; line-height: 1.1; }
.logo-title {
    font-family: 'Space Grotesk', sans-serif; font-size: 18px; font-weight: 700;
    background: var(--grad); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}
.logo-sub { font-size: 10px; color: var(--txt3); text-transform: uppercase; letter-spacing: 1.3px; margin-top: 2px; }

/* User Card — tighter padding and margins so the content block reads denser */
.user-card {
    position: relative; background: var(--card); border: 1px solid var(--border);
    border-radius: var(--r3); padding: 14px 14px 12px; text-align: center;
    margin-bottom: 10px; flex: 1; overflow: hidden;
    box-shadow: var(--shadow);
}
.avatar-wrap { position: relative; display: inline-block; margin-bottom: 8px; }
.avatar-ring { position: absolute; inset: -3px; border-radius: 50%; background: var(--grad); animation: rotate 4s linear infinite; }
@keyframes rotate { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
.avatar {
    position: relative; width: 56px; height: 56px; background: var(--card); border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 22px; font-weight: 700; color: var(--p); z-index: 1;
    border: 3px solid var(--card);
}
[data-theme="dark"] .avatar { background: var(--bg); border-color: var(--bg); }
.status-dot { position: absolute; bottom: 2px; right: 2px; width: 13px; height: 13px; background: var(--ok); border: 2px solid var(--bg); border-radius: 50%; z-index: 2; }
.user-card h3 { font-size: 15px; font-weight: 700; margin-bottom: 2px; line-height: 1.15; }
.role { font-size: 11.5px; color: var(--txt3); margin-bottom: 10px; }

.stats { display: flex; flex-direction: column; gap: 5px; margin-bottom: 10px; }
.stat { display: flex; align-items: center; gap: 8px; padding: 6px 10px; background: var(--input-bg); border-radius: var(--r1); font-size: 12px; color: var(--txt2); border: 1px solid var(--border); }
.stat i { color: var(--p); width: 14px; font-size: 11px; }

.btn-profile {
    width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 6px;
    padding: 8px 12px; background: var(--input-bg); border: 1px solid var(--border);
    border-radius: var(--r2); color: var(--txt2); font-size: 12px; cursor: pointer; transition: 0.2s;
}
.btn-profile:hover { background: var(--card-hover); border-color: var(--p); color: var(--p); }

/* Sidebar footer — logout + attribution tightly grouped at the bottom */
.sidebar-footer {
    margin-top: auto;
    padding-top: 10px;
    border-top: 1px solid var(--border);
    display: flex; flex-direction: column; gap: 8px;
}
.logout-form { margin: 0; }
.btn-logout {
    width: 100%;
    display: flex; align-items: center; justify-content: center; gap: 8px;
    padding: 8px 12px;
    background: var(--input-bg);
    border: 1px solid var(--border);
    border-radius: var(--r2);
    color: var(--txt2);
    font-size: 12.5px; font-weight: 600;
    cursor: pointer;
    transition: background .15s ease, border-color .15s ease, color .15s ease, transform .1s ease;
}
.btn-logout i { font-size: 13px; }
.btn-logout:hover {
    background: rgba(239, 68, 68, 0.08);
    border-color: #EF4444;
    color: #EF4444;
}
.btn-logout:active { transform: translateY(1px); }
.btn-logout:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.25);
}
[data-theme="dark"] .btn-logout:hover { background: rgba(239, 68, 68, 0.14); }

.powered { text-align: center; font-size: 10.5px; color: var(--txt3); line-height: 1.3; }
.powered strong { color: var(--p); display: block; margin-top: 1px; }

/* Main Content */
.main-content {
    flex: 1; background: var(--card);
    border: 1px solid var(--border); border-radius: var(--r4);
    overflow: hidden; display: flex; flex-direction: column; animation: slideR 0.6s ease-out;
    box-shadow: var(--shadow);
}
@keyframes slideR { from { opacity: 0; transform: translateX(30px); } to { opacity: 1; transform: translateX(0); } }

/* Stages */
.stage { display: none; flex-direction: column; height: 100%; padding: 16px 32px 32px; overflow-y: auto; }
.stage.active { display: flex; }

.stage-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 24px; }
.stage-header.compact { align-items: center; margin-bottom: 24px; }

.greeting { display: flex; align-items: flex-start; gap: 20px; }
.g-icon {
    width: 64px; height: 64px; background: var(--grad); border-radius: var(--r3);
    display: flex; align-items: center; justify-content: center;
    font-size: 28px; color: var(--bg); box-shadow: 0 0 40px var(--pg); animation: pulse 2s ease-in-out infinite;
}
@keyframes pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.05); } }

.g-text h1 { font-family: 'Space Grotesk', sans-serif; font-size: 32px; font-weight: 700; margin: -10px 0 0 0; }
.g-text h1 .hl { background: var(--grad); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
.g-text p { font-size: 15px; color: var(--txt2); max-width: 500px; margin-top: -4px; }
.g-text p.greeting-tagline { font-size: 16px; font-weight: 500; color: var(--txt1); line-height: 1.45; margin-top: 4px; }

.ai-badge {
    position: relative; display: flex; align-items: center; gap: 8px;
    padding: 10px 18px; background: rgba(245, 166, 35, 0.1);
    border: 1px solid rgba(245, 166, 35, 0.3); border-radius: 50px;
    font-size: 12px; font-weight: 600; color: var(--p);
}
.pulse-dot { position: absolute; left: 14px; width: 8px; height: 8px; background: var(--p); border-radius: 50%; animation: pulseR 2s ease-out infinite; }
@keyframes pulseR { 0% { box-shadow: 0 0 0 0 var(--pg); } 100% { box-shadow: 0 0 0 12px transparent; } }

.prompt { margin-bottom: 24px; }
.prompt h2 { font-family: 'Space Grotesk', sans-serif; font-size: 24px; font-weight: 600; margin-bottom: 8px; }
.prompt p { font-size: 14px; color: var(--txt3); }

/* Options Grid */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; flex: 1; align-content: start; align-items: start; }

.opt-card {
    position: relative; background: var(--card); border: 1px solid var(--border);
    border-radius: var(--r3); padding: 24px; cursor: pointer;
    transition: all 0.3s ease; overflow: hidden; text-align: left;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
    display: flex; flex-direction: column; align-items: flex-start; justify-content: flex-start;
    height: 180px; min-height: 180px; max-height: 180px;
}
.opt-card::before {
    content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px;
    background: var(--grad); transform: scaleX(0); transform-origin: left; transition: transform 0.3s;
}
.opt-card:hover { background: var(--card-hover); border-color: var(--border-hover); transform: translateY(-4px); box-shadow: var(--shadow-hover); }
.opt-card:hover::before { transform: scaleX(1); }
[data-theme="light"] .opt-card { box-shadow: 0 2px 12px rgba(0,0,0,0.06); }
[data-theme="light"] .opt-card:hover { box-shadow: 0 8px 30px rgba(230, 168, 23, 0.12); }

.opt-card .card-top { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; width: 100%; }
.opt-card .c-icon {
    width: 42px; height: 42px; background: var(--input-bg); border-radius: var(--r2);
    display: flex; align-items: center; justify-content: center;
    font-size: 18px; color: var(--p); flex-shrink: 0; transition: 0.2s;
    border: 1px solid var(--border);
}
.opt-card:hover .c-icon { background: var(--grad); color: #FFF; border-color: transparent; }
[data-theme="dark"] .opt-card:hover .c-icon { color: var(--bg); }
.opt-card .title { font-size: 16px; font-weight: 600; line-height: 1.3; }
.opt-card .desc {
    font-size: 13px; color: var(--txt2); line-height: 1.5;
    height: 78px; min-height: 78px; overflow: hidden;
    display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical;
}
.opt-card .arrow { position: absolute; top: 24px; right: 24px; opacity: 0; transform: translateX(-10px); transition: 0.2s; color: var(--p); }
.opt-card:hover .arrow { opacity: 1; transform: translateX(0); }

/* Stage Footer & Buttons */
.stage-footer { margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--border); }
.btn-reset { display: inline-flex; align-items: center; gap: 8px; padding: 12px 20px; background: var(--input-bg); border: 1px solid var(--border); border-radius: var(--r2); color: var(--txt2); font-size: 13px; cursor: pointer; transition: 0.2s; }
.btn-reset:hover { background: var(--card-hover); border-color: var(--p); color: var(--p); }
.btn-back { display: inline-flex; align-items: center; gap: 8px; padding: 10px 18px; background: var(--input-bg); border: 1px solid var(--border); border-radius: var(--r2); color: var(--txt2); font-size: 13px; cursor: pointer; transition: 0.2s; }
.btn-back:hover { background: var(--card-hover); border-color: var(--p); color: var(--p); }

.breadcrumb { display: flex; align-items: center; gap: 12px; font-size: 14px; color: var(--txt3); }
.breadcrumb .active { color: var(--p); font-weight: 500; }
.breadcrumb i { font-size: 10px; }

/* Chat Panel */
.chat-panel { display: flex; flex-direction: column; height: 100%; }
.chat-header { display: flex; justify-content: space-between; align-items: center; padding: 20px 24px; background: var(--card); border-bottom: 1px solid var(--border); }
.chat-info { display: flex; align-items: stretch; gap: 14px; }
.chat-avatar { position: relative; width: 48px; height: 48px; background: var(--grad); border-radius: var(--r2); display: flex; align-items: center; justify-content: center; font-size: 22px; color: var(--bg); flex-shrink: 0; }
.chat-avatar .online { position: absolute; bottom: -2px; right: -2px; width: 14px; height: 14px; background: var(--ok); border: 2px solid var(--bg); border-radius: 50%; }
.chat-meta { display: flex; flex-direction: column; justify-content: space-between; }
.chat-meta strong { display: block; font-size: 16px; line-height: 1; }
.chat-status { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--ok); }
.chat-status .dot { width: 4px; height: 4px; background: var(--ok); border-radius: 50%; animation: typing 1.4s infinite; display: none; }
.chat-status.typing .dot { display: block; }
.chat-status.typing .txt { display: none; }
.dot:nth-child(2) { animation-delay: 0.2s; }
.dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes typing { 0%, 60%, 100% { opacity: 0.3; transform: scale(1); } 30% { opacity: 1; transform: scale(1.2); } }

.chat-actions { display: flex; gap: 8px; }
.btn-action { width: 42px; height: 42px; background: var(--input-bg); border: 1px solid var(--border); border-radius: var(--r2); color: var(--txt2); font-size: 16px; cursor: pointer; transition: 0.2s; }
.btn-action:hover { background: var(--card-hover); border-color: var(--p); color: var(--p); }
.btn-action-text { 
    display: flex; align-items: center; gap: 6px; 
    padding: 8px 14px; height: 38px;
    background: var(--input-bg); border: 1px solid var(--border); 
    border-radius: var(--r2); color: var(--txt2); 
    font-size: 13px; font-weight: 500; cursor: pointer; transition: 0.2s; 
}
.btn-action-text i { font-size: 14px; }
.btn-action-text:hover { background: var(--card-hover); border-color: var(--p); color: var(--p); }

/* Messages */
.messages { flex: 1; padding: 24px; overflow-y: auto; display: flex; flex-direction: column; gap: 20px; }
.message { display: flex; gap: 12px; max-width: 75%; animation: msgIn 0.3s ease-out; }
@keyframes msgIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
.message.user { align-self: flex-end; flex-direction: row-reverse; }
.msg-avatar { width: 36px; height: 36px; border-radius: var(--r1); display: flex; align-items: center; justify-content: center; font-size: 14px; flex-shrink: 0; }
.message.ai .msg-avatar { background: var(--grad); color: #FFF; }
[data-theme="dark"] .message.ai .msg-avatar { color: var(--bg); }
.message.user .msg-avatar { background: var(--input-bg); border: 1px solid var(--border); color: var(--p); font-weight: 600; }
.msg-content { display: flex; flex-direction: column; gap: 6px; }
.msg-sender { font-size: 11px; font-weight: 600; color: var(--txt3); text-transform: uppercase; letter-spacing: 0.5px; }
.message.user .msg-sender { text-align: right; }
.msg-bubble { padding: 14px 18px; border-radius: var(--r3); font-size: 14px; line-height: 1.6; }
.message.user .msg-bubble { white-space: pre-wrap; }
.message.ai .msg-bubble { background: var(--card); border: 1px solid var(--border); border-top-left-radius: 4px; }
.message.user .msg-bubble { background: var(--grad); color: var(--msg-user-txt); border-bottom-right-radius: 4px; }
.message.ai .msg-bubble { background: var(--msg-ai-bg); }

/* Markdown Styles for AI Messages */
.msg-bubble .md-para { margin: 0 0 8px 0; }
.msg-bubble .md-para:last-child { margin-bottom: 0; }
.msg-bubble .md-list { margin: 8px 0 8px 20px; padding: 0; list-style: none; }
.msg-bubble .md-list li { position: relative; margin-bottom: 6px; padding-left: 18px; }
.msg-bubble .md-list li:last-child { margin-bottom: 0; }
.msg-bubble .md-list li::before { 
    content: ''; 
    position: absolute; 
    left: 0; 
    top: 10px; 
    width: 6px; 
    height: 6px; 
    background: var(--p); 
    border-radius: 50%; 
}
.msg-bubble strong { font-weight: 600; color: var(--p); }
.msg-bubble em { font-style: italic; color: var(--txt2); }
.msg-bubble .md-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--p);
    text-decoration: none;
    font-weight: 500;
    background: var(--pg);
    padding: 6px 12px;
    border-radius: var(--r1);
    transition: all 0.2s ease;
    border: 1px solid transparent;
}
.msg-bubble .md-link:hover {
    background: var(--grad);
    color: #FFF;
    border-color: var(--p);
    transform: translateY(-1px);
}
.msg-bubble .md-link i {
    font-size: 10px;
    opacity: 0.8;
}

/* Theme Toggle Button — compact height to free vertical room in the sidebar */
.theme-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 7px 12px;
    background: var(--input-bg);
    border: 1px solid var(--border);
    border-radius: var(--r2);
    margin-bottom: 8px;
    cursor: pointer;
    transition: 0.2s;
}
.theme-toggle:hover { background: var(--card-hover); border-color: var(--p); }
.theme-toggle-label { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--txt2); }
.theme-toggle-label i { color: var(--p); width: 14px; font-size: 12px; }
.theme-switch {
    position: relative;
    width: 48px;
    height: 26px;
    background: var(--border);
    border-radius: 13px;
    transition: 0.3s;
}
.theme-switch::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 20px;
    height: 20px;
    background: #FFF;
    border-radius: 50%;
    transition: 0.3s;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}
[data-theme="dark"] .theme-switch::after { left: 25px; }
[data-theme="dark"] .theme-switch { background: var(--p); }
.theme-icon { font-size: 14px; transition: 0.3s; color: var(--txt3); }
[data-theme="light"] .theme-icon.sun { color: var(--p); }
[data-theme="dark"] .theme-icon.moon { color: var(--p); }

/* Language Toggle Switch */
.lang-switch {
    position: relative;
    width: 48px;
    height: 26px;
    background: var(--border);
    border-radius: 13px;
    transition: 0.3s;
}
.lang-switch::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 20px;
    height: 20px;
    background: #FFF;
    border-radius: 50%;
    transition: 0.3s;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}
.lang-switch.active::after { left: 25px; }
.lang-switch.active { background: var(--p); }
.lang-flag { transition: 0.3s; object-fit: cover; }

/* Input Area */
.input-area { padding: 20px 24px; background: var(--card); border-top: 1px solid var(--border); }
.input-wrap { position: relative; display: flex; align-items: flex-end; background: var(--input-bg); border: 1px solid var(--border); border-radius: var(--r3); padding: 4px; transition: 0.2s; }
.input-wrap:focus-within { border-color: var(--p); box-shadow: 0 0 0 3px var(--pg); }
.input-wrap textarea { flex: 1; background: transparent; border: none; padding: 14px 16px; font-size: 14px; color: var(--txt); resize: none; min-height: 48px; max-height: 120px; font-family: inherit; line-height: 1.5; }
.input-wrap textarea::placeholder { color: var(--txt3); }
.input-wrap textarea:focus { outline: none; }
.input-wrap textarea:disabled { cursor: not-allowed; opacity: 0.5; }
.input-actions { display: flex; align-items: center; gap: 12px; padding-right: 8px; padding-bottom: 8px; }
.counter { font-size: 11px; color: var(--txt3); }
.btn-send { width: 44px; height: 44px; background: var(--grad); border: none; border-radius: var(--r2); color: #FFF; font-size: 16px; cursor: pointer; transition: 0.2s; display: flex; align-items: center; justify-content: center; }
[data-theme="dark"] .btn-send { color: var(--bg); }
.btn-send:hover:not(:disabled) { transform: scale(1.05); box-shadow: var(--shadow-hover); }
.btn-send:disabled { background: var(--border); color: var(--txt3); cursor: not-allowed; }
/* Loading state: spinner on send button while AI is responding */
.btn-send.loading { background: var(--grad); opacity: 0.7; cursor: wait; }
.btn-send.loading i { animation: spin 1s linear infinite; }
@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

/* Typing cursor: blinking caret shown during typewriter reveal of AI response */
.typing-cursor {
    display: inline-block;
    width: 2px;
    height: 1.1em;
    background: var(--p);
    margin-left: 2px;
    vertical-align: text-bottom;
    border-radius: 1px;
    animation: blink-cursor 0.7s step-end infinite;
}
@keyframes blink-cursor { 0%, 100% { opacity: 1; } 50% { opacity: 0; } }

.hint { margin-top: 8px; font-size: 11px; color: var(--txt3); text-align: center; }
.hourly-usage {
    margin-top: 6px;
    font-size: 12px;
    text-align: center;
    color: #0F766E;
    font-weight: 600;
}
[data-theme="dark"] .hourly-usage { color: #5EEAD4; }
.hourly-usage.near-limit { color: #B45309; }
[data-theme="dark"] .hourly-usage.near-limit { color: #FCD34D; }
.hourly-usage.limit-hit { color: #B91C1C; }
[data-theme="dark"] .hourly-usage.limit-hit { color: #FCA5A5; }
.hidden { display: none !important; }

/* Modal */
.modal { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.5); backdrop-filter: blur(8px); display: none; justify-content: center; align-items: center; z-index: 1000; padding: 20px; }
[data-theme="dark"] .modal { background: rgba(0, 0, 0, 0.7); }
.modal.active { display: flex; }
.modal-box { position: relative; background: var(--card); border: 1px solid var(--border); border-radius: var(--r4); max-width: 520px; width: 100%; max-height: 90vh; overflow-y: auto; animation: modalIn 0.3s ease-out; box-shadow: 0 20px 60px rgba(0,0,0,0.2); }
@keyframes modalIn { from { opacity: 0; transform: scale(0.95) translateY(20px); } to { opacity: 1; transform: scale(1) translateY(0); } }
.modal-close { position: absolute; top: 20px; right: 20px; width: 36px; height: 36px; background: var(--input-bg); border: 1px solid var(--border); border-radius: var(--r1); color: var(--txt2); font-size: 16px; cursor: pointer; transition: 0.2s; z-index: 1; }
.modal-close:hover { background: #FEE2E2; border-color: var(--err); color: var(--err); }
[data-theme="dark"] .modal-close:hover { background: rgba(248, 113, 113, 0.1); }
.modal-head { text-align: center; padding: 40px 32px 24px; }
.modal-icon { width: 72px; height: 72px; margin: 0 auto 20px; background: var(--grad); border-radius: var(--r3); display: flex; align-items: center; justify-content: center; font-size: 32px; color: #FFF; }
[data-theme="dark"] .modal-icon { color: var(--bg); }
.modal-head h3 { font-family: 'Space Grotesk', sans-serif; font-size: 24px; margin-bottom: 8px; }
.modal-body { padding: 0 32px 32px; }
.feedback-compact { max-width: 480px; max-height: 85vh; }
.feedback-compact .modal-body { padding: 0 24px 24px; }

/* Profile modal */
.profile-modal .modal-box {
    max-width: 960px;
    max-height: 68vh;
    padding: 0;
    overflow: hidden;
}
.profile-modal .modal-close {
    top: 18px;
    right: 18px;
    background: rgba(255, 255, 255, 0.75);
    backdrop-filter: blur(10px);
}
[data-theme="dark"] .profile-modal .modal-close {
    background: rgba(17, 24, 39, 0.8);
}
.profile-shell {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.profile-hero {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 18px 20px;
    border: 1px solid rgba(230, 168, 23, 0.18);
    border-radius: var(--r4);
    background:
        radial-gradient(circle at top right, rgba(230, 168, 23, 0.2), transparent 34%),
        linear-gradient(135deg, rgba(230, 168, 23, 0.1), rgba(255, 255, 255, 0.96));
}
[data-theme="dark"] .profile-hero {
    background:
        radial-gradient(circle at top right, rgba(245, 158, 11, 0.2), transparent 34%),
        linear-gradient(135deg, rgba(55, 65, 81, 0.92), rgba(31, 41, 55, 0.96));
    border-color: rgba(245, 158, 11, 0.2);
}
.profile-hero-main {
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 0;
}
.profile-avatar {
    width: 68px;
    height: 68px;
    border-radius: 22px;
    background: var(--grad);
    color: #FFF;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    font-weight: 700;
    box-shadow: 0 18px 40px rgba(230, 168, 23, 0.28);
    flex-shrink: 0;
}
[data-theme="dark"] .profile-avatar {
    color: var(--bg);
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
}
.profile-identity {
    min-width: 0;
}
.profile-eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--p);
    margin-bottom: 8px;
}
.profile-title {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 24px;
    line-height: 1.1;
    margin-bottom: 8px;
    color: var(--txt);
}
.profile-name {
    font-size: 14px;
    color: var(--txt2);
}
.profile-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}
.profile-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 11px;
    border-radius: 999px;
    border: 1px solid rgba(230, 168, 23, 0.22);
    background: rgba(255, 255, 255, 0.82);
    color: var(--txt2);
    font-size: 11px;
    font-weight: 600;
}
[data-theme="dark"] .profile-badge {
    background: rgba(17, 24, 39, 0.56);
    border-color: rgba(245, 158, 11, 0.22);
}
.profile-badge i {
    color: var(--p);
}
.profile-note {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.8);
    border: 1px solid rgba(230, 168, 23, 0.16);
    color: var(--txt2);
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}
[data-theme="dark"] .profile-note {
    background: rgba(17, 24, 39, 0.72);
    border-color: rgba(245, 158, 11, 0.2);
}
.profile-note i {
    color: var(--ok);
}
.profile-stat-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
}
.profile-stat-card {
    min-width: 0;
    padding: 14px 15px;
    border-radius: var(--r3);
    border: 1px solid var(--border);
    background: linear-gradient(180deg, var(--card) 0%, var(--input-bg) 100%);
    box-shadow: var(--shadow);
}
.profile-stat-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 10px;
}
.profile-stat-top i {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    background: rgba(230, 168, 23, 0.12);
    color: var(--p);
    font-size: 14px;
}
.profile-stat-label {
    display: block;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--txt3);
}
.profile-stat-value {
    font-size: 14px;
    line-height: 1.3;
    font-weight: 700;
    color: var(--txt);
    overflow-wrap: anywhere;
}
.profile-detail-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}
.profile-panel {
    padding: 16px 18px;
    border-radius: var(--r3);
    border: 1px solid var(--border);
    background: var(--card);
    box-shadow: var(--shadow);
}
.profile-panel.full {
    grid-column: 1 / -1;
}
.profile-panel-head {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}
.profile-panel-icon {
    width: 36px;
    height: 36px;
    border-radius: 14px;
    background: rgba(230, 168, 23, 0.12);
    color: var(--p);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.profile-panel-head h4 {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 16px;
    line-height: 1.2;
    margin: 0;
}
.profile-panel-head p {
    margin: 2px 0 0;
    color: var(--txt3);
    font-size: 11px;
    line-height: 1.35;
}
.profile-list {
    display: grid;
    gap: 8px;
}
.profile-item {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
}
.profile-item:last-child {
    padding-bottom: 0;
    border-bottom: 0;
}
.profile-item-label {
    font-size: 11px;
    color: var(--txt3);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    flex: 0 0 145px;
}
.profile-item-value {
    font-size: 13px;
    font-weight: 600;
    color: var(--txt);
    text-align: right;
    overflow-wrap: anywhere;
}
.profile-empty-text {
    font-size: 14px;
    color: var(--txt3);
}
.skills {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.skill {
    padding: 6px 11px;
    background: rgba(230, 168, 23, 0.1);
    border: 1px solid rgba(230, 168, 23, 0.18);
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    color: var(--p);
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--txt3); }

/* ============================================
   MOBILE HEADER (hidden on desktop)
   ============================================ */
.mobile-header {
    display: none; /* hidden on desktop */
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--r3);
    box-shadow: var(--shadow);
    flex-shrink: 0;
}
.mobile-menu-btn {
    width: 40px; height: 40px;
    background: var(--input-bg); border: 1px solid var(--border);
    border-radius: var(--r1); color: var(--txt2);
    font-size: 18px; cursor: pointer; transition: 0.2s;
    display: flex; align-items: center; justify-content: center;
}
.mobile-menu-btn:hover { background: var(--card-hover); border-color: var(--p); color: var(--p); }
.mobile-logo {
    display: flex; align-items: center; gap: 8px;
}
.mobile-logo-icon {
    width: 34px; height: 34px; background: #fff; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 16px; color: var(--bg);
    overflow: hidden; padding: 2px;
}
.mobile-logo-title {
    font-family: 'Space Grotesk', sans-serif; font-size: 18px; font-weight: 700;
    background: var(--grad); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}
.mobile-actions { display: flex; gap: 6px; }
.mobile-action-btn {
    width: 36px; height: 36px;
    background: var(--input-bg); border: 1px solid var(--border);
    border-radius: var(--r1); color: var(--txt2);
    font-size: 15px; cursor: pointer; transition: 0.2s;
    display: flex; align-items: center; justify-content: center;
}
.mobile-action-btn:hover { background: var(--card-hover); border-color: var(--p); color: var(--p); }

/* Sidebar Overlay (hidden by default) */
.sidebar-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 99;
    opacity: 0;
    transition: opacity 0.3s ease;
}
.sidebar-overlay.active { display: block; opacity: 1; }

/* ============================================
   RESPONSIVE: Tablet (<=1024px)
   ============================================ */
@media (max-width: 1024px) {
    .app-container {
        flex-direction: column;
        padding: 10px;
        gap: 10px;
    }
    .mobile-header { display: flex; }

    /* Sidebar becomes a slide-out panel on mobile */
    .sidebar {
        position: fixed;
        top: 0; left: 0; bottom: 0;
        width: 300px; min-width: 300px;
        border-radius: 0 var(--r4) var(--r4) 0;
        z-index: 100;
        transform: translateX(-100%);
        transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
        overflow-y: auto;
    }
    .sidebar.open {
        transform: translateX(0);
    }

    /* Main content takes full remaining height */
    .main-content {
        flex: 1;
        min-height: 0;
        height: calc(100vh - 80px); /* viewport minus mobile header + padding */
        border-radius: var(--r3);
    }
    .stats { flex-direction: row; flex-wrap: wrap; }

    /* Hide sidebar theme/lang toggles since mobile header has them */
    .sidebar .theme-toggle { display: flex; } /* keep visible in slide-out panel */

    .stage { padding: 12px 24px 24px; }
    .g-text h1 { font-size: 28px; }
    .g-icon { width: 52px; height: 52px; font-size: 24px; }
}

/* ============================================
   RESPONSIVE: Mobile (<=768px)
   ============================================ */
@media (max-width: 768px) {
    .app-container { padding: 6px; gap: 6px; }

    .mobile-header { padding: 8px 12px; border-radius: var(--r2); }

    .sidebar {
        width: 280px; min-width: 280px;
        padding: 20px;
    }

    .main-content {
        height: calc(100vh - 66px);
        border-radius: var(--r2);
    }

    /* Stage content */
    .stage { padding: 10px 16px 16px; }
    .stage-header { flex-direction: column; gap: 12px; margin-bottom: 16px; }
    .greeting { flex-direction: column; align-items: center; text-align: center; gap: 12px; }
    .g-icon { width: 48px; height: 48px; font-size: 22px; }
    .g-text h1 { font-size: 22px; }
    .g-text p { font-size: 13px; }
    .ai-badge { padding: 8px 14px; font-size: 11px; }
    .prompt h2 { font-size: 20px; }
    .prompt p { font-size: 13px; }

    /* Grid cards */
    .grid { grid-template-columns: 1fr; gap: 10px; }
    .opt-card { padding: 16px; height: 168px; min-height: 168px; max-height: 168px; }
    .opt-card .c-icon { width: 36px; height: 36px; font-size: 16px; }
    .opt-card .card-top { gap: 10px; margin-bottom: 8px; }
    .opt-card .title { font-size: 15px; }
    .opt-card .desc { font-size: 12px; height: 72px; min-height: 72px; }
    .opt-card .arrow { top: 16px; right: 16px; }

    /* Chat panel */
    .chat-header { padding: 12px 14px; gap: 8px; }
    .chat-avatar { width: 38px; height: 38px; font-size: 18px; }
    .chat-meta strong { font-size: 14px; }
    .chat-actions { gap: 4px; }
    .btn-action-text { padding: 6px 10px; font-size: 12px; height: 34px; }
    .btn-action-text span { display: none; } /* hide text labels, keep icons only */
    .btn-action-text i { font-size: 16px; }

    /* Messages */
    .messages { padding: 14px; gap: 14px; }
    .message { max-width: 92%; gap: 8px; }
    .msg-avatar { width: 30px; height: 30px; font-size: 12px; }
    .msg-bubble { padding: 10px 14px; font-size: 13px; }
    .msg-sender { font-size: 10px; }

    /* Input area */
    .input-area { padding: 10px 12px; }
    .input-wrap textarea { padding: 10px 12px; font-size: 14px; min-height: 42px; }
    .btn-send { width: 40px; height: 40px; font-size: 15px; }
    .hint { font-size: 10px; margin-top: 4px; }

    /* Stage footer */
    .stage-footer { margin-top: 16px; padding-top: 14px; }
    .btn-reset, .btn-back { padding: 10px 16px; font-size: 12px; }

    /* Breadcrumb */
    .breadcrumb { font-size: 12px; gap: 8px; }

    /* Modal adjustments */
    .modal { padding: 10px; }
    .modal-box { max-width: 100%; border-radius: var(--r3); max-height: 95vh; }
    .modal-head { padding: 30px 20px 16px; }
    .modal-head h3 { font-size: 20px; }
    .modal-body { padding: 0 20px 24px; }
    .modal-icon { width: 56px; height: 56px; font-size: 26px; }
    .modal-close { top: 12px; right: 12px; width: 32px; height: 32px; font-size: 14px; }
    .feedback-compact { max-width: 100%; }
    .feedback-compact .modal-body { padding: 0 16px 20px; }

    /* Profile modal */
    .profile-modal .modal-box { max-width: 100%; }
    .profile-shell { padding: 14px; gap: 12px; }
    .profile-hero {
        padding: 16px 16px;
        flex-direction: column;
        align-items: flex-start;
    }
    .profile-hero-main {
        width: 100%;
        align-items: flex-start;
    }
    .profile-avatar {
        width: 72px;
        height: 72px;
        border-radius: 22px;
        font-size: 26px;
    }
    .profile-title { font-size: 21px; }
    .profile-note {
        width: 100%;
        justify-content: center;
        white-space: normal;
    }
    .profile-stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
    .profile-detail-grid { grid-template-columns: 1fr; gap: 12px; }
    .profile-panel { padding: 14px; }
    .profile-item-label { flex-basis: 120px; }
    .profile-item-value { text-align: left; }

    /* Thumbs */
    .thumbs-btn { padding: 4px 10px; font-size: 13px; }
}

/* ============================================
   RESPONSIVE: Small Mobile (<=480px)
   ============================================ */
@media (max-width: 480px) {
    .profile-shell { padding: 12px; }
    .profile-hero {
        padding: 14px 12px;
        border-radius: var(--r3);
    }
    .profile-hero-main {
        flex-direction: column;
        gap: 14px;
    }
    .profile-avatar {
        width: 64px;
        height: 64px;
        border-radius: 18px;
        font-size: 24px;
    }
    .profile-title { font-size: 19px; }
    .profile-badges { gap: 8px; }
    .profile-badge { width: 100%; justify-content: flex-start; }
    .profile-stat-grid { grid-template-columns: 1fr; }
    .profile-panel { padding: 12px; }
    .profile-item {
        flex-direction: column;
        gap: 6px;
    }
    .profile-item-label { flex: none; }
    .mobile-header { padding: 6px 10px; }
    .mobile-logo-title { font-size: 16px; }
    .mobile-logo-icon { width: 30px; height: 30px; font-size: 14px; }
    .mobile-action-btn { width: 32px; height: 32px; font-size: 14px; }
    .mobile-menu-btn { width: 36px; height: 36px; font-size: 16px; }

    .main-content { height: calc(100vh - 58px); }

    .sidebar { width: 260px; min-width: 260px; padding: 16px; }

    .stage { padding: 8px 12px 12px; }
    .g-text h1 { font-size: 20px; }
    .prompt h2 { font-size: 18px; }

    .chat-header { padding: 10px 12px; }
    .chat-avatar { width: 34px; height: 34px; font-size: 16px; }
    .chat-meta strong { font-size: 13px; }

    .messages { padding: 10px; gap: 10px; }
    .message { max-width: 95%; }
    .msg-bubble { padding: 8px 12px; font-size: 13px; line-height: 1.5; }

    .input-area { padding: 8px 10px; }
    .input-wrap textarea { padding: 8px 10px; font-size: 13px; }
    .btn-send { width: 38px; height: 38px; }
    .counter { font-size: 10px; }
    .hint { display: none; } /* hide hint on very small screens */
}

/* Prevent body scroll when sidebar is open on mobile */
body.sidebar-open { overflow: hidden; }

/* ============================================
   MESSAGE FEEDBACK (Thumbs Up/Down)
   ============================================ */
.msg-feedback {
    display: flex;
    gap: 6px;
    margin-top: 8px;
}

.thumbs-btn {
    background: var(--input-bg);
    border: 1px solid var(--border);
    border-radius: var(--r1);
    padding: 6px 12px;
    cursor: pointer;
    font-size: 14px;
    color: var(--txt3);
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.thumbs-btn:hover {
    background: var(--card-hover);
    border-color: var(--p);
    color: var(--p);
    transform: scale(1.1);
}

.thumbs-btn.active {
    background: var(--grad);
    border-color: var(--p);
    color: #FFF;
    box-shadow: 0 4px 12px var(--pg);
}

[data-theme="dark"] .thumbs-btn.active {
    color: var(--bg);
}

.thumbs-btn i {
    pointer-events: none;
}

/* ============================================
   FEEDBACK FORM MODAL
   ============================================ */
.feedback-form {
    padding: 0;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--txt2);
    margin-bottom: 8px;
}

.form-group textarea,
.form-group input[type="text"],
.form-group input[type="email"] {
    width: 100%;
    padding: 12px 14px;
    background: var(--input-bg);
    border: 1px solid var(--border);
    border-radius: var(--r2);
    font-size: 14px;
    color: var(--txt);
    font-family: inherit;
    resize: vertical;
    transition: 0.2s;
}

.form-group textarea:focus,
.form-group input:focus {
    outline: none;
    border-color: var(--p);
    box-shadow: 0 0 0 3px var(--pg);
}

.form-group textarea {
    min-height: 100px;
}

/* Star Rating */
.rating-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 24px;
}

.rating-container label {
    font-size: 14px;
    font-weight: 500;
    color: var(--txt2);
    margin-bottom: 12px;
}

#ratingStars {
    display: flex;
    gap: 8px;
}

#ratingStars .star {
    font-size: 32px;
    color: var(--border);
    cursor: pointer;
    transition: all 0.2s ease;
}

#ratingStars .star:hover,
#ratingStars .star.active {
    color: var(--p);
    transform: scale(1.15);
}

#ratingStars .star i {
    pointer-events: none;
}

/* Submit Button */
.btn-submit-feedback {
    width: 100%;
    padding: 14px 24px;
    background: var(--grad);
    border: none;
    border-radius: var(--r2);
    font-size: 14px;
    font-weight: 600;
    color: #FFF;
    cursor: pointer;
    transition: 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

[data-theme="dark"] .btn-submit-feedback {
    color: var(--bg);
}

.btn-submit-feedback:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-hover);
}

.btn-submit-feedback:disabled {
    background: var(--border);
    color: var(--txt3);
    cursor: not-allowed;
    transform: none;
}

/* ========== Mock Interview Styles ========== */

/* Action buttons (difficulty select, next question, retry) */
.mock-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 4px 0;
}
.mock-btn {
    padding: 10px 20px;
    border: 2px solid var(--p);
    border-radius: 12px;
    background: transparent;
    color: var(--p);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
}
.mock-btn:hover:not(.disabled) {
    background: var(--p);
    color: #fff;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(var(--p-rgb, 99,102,241), 0.3);
}
.mock-btn.selected {
    background: var(--p);
    color: #fff;
}
.mock-btn.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

/* Progress bar for quiz questions */
.mock-progress {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
    padding: 0 4px;
}
.mock-progress-bar {
    flex: 1;
    height: 6px;
    background: var(--border);
    border-radius: 3px;
    overflow: hidden;
}
.mock-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--p), var(--pl, var(--p)));
    border-radius: 3px;
    transition: width 0.4s ease;
}
.mock-progress-text {
    font-size: 12px;
    font-weight: 600;
    color: var(--txt3);
    white-space: nowrap;
}

/* MCQ option buttons */
.mock-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 10px;
}
.mock-option {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border: 2px solid var(--border);
    border-radius: 12px;
    background: var(--bg2, var(--bg));
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
    font-family: inherit;
    font-size: 14px;
    color: var(--txt);
}
.mock-option:hover:not(.disabled) {
    border-color: var(--p);
    background: rgba(var(--p-rgb, 99,102,241), 0.05);
    transform: translateX(4px);
}
.mock-option.selected {
    border-color: var(--p);
    background: rgba(var(--p-rgb, 99,102,241), 0.1);
    font-weight: 600;
}
.mock-option.disabled {
    opacity: 0.6;
    cursor: not-allowed;
    pointer-events: none;
}
.mock-option-key {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--p);
    color: #fff;
    font-weight: 700;
    font-size: 14px;
    flex-shrink: 0;
}
.mock-option-text {
    flex: 1;
    line-height: 1.4;
}

/* Responsive: stack buttons vertically on small screens */
@media (max-width: 480px) {
    .mock-buttons {
        flex-direction: column;
    }
    .mock-btn {
        width: 100%;
        text-align: center;
    }
}

/* ========== CAPTCHA Challenge Card ========== */
.captcha-card {
    background: linear-gradient(135deg, #fef9ef 0%, #fff7e6 100%);
    border: 1px solid #f0d78e;
    border-radius: 12px;
    padding: 16px 18px;
    max-width: 380px;
    box-shadow: 0 2px 8px rgba(240, 200, 80, 0.15);
}
.captcha-header {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    font-size: 0.95rem;
    color: #b8860b;
    margin-bottom: 8px;
}
.captcha-header i { font-size: 1.1rem; }
.captcha-header.captcha-success {
    color: #16a34a;
}
.captcha-msg {
    font-size: 0.85rem;
    color: #555;
    margin: 0 0 8px 0;
    line-height: 1.4;
}
.captcha-instruction {
    font-size: 0.82rem;
    color: #777;
    margin: 0 0 10px 0;
}
.captcha-question-box {
    background: #fff;
    border: 2px dashed #e0c060;
    border-radius: 8px;
    text-align: center;
    padding: 12px 10px;
    margin-bottom: 12px;
}
.captcha-question {
    font-size: 1.35rem;
    font-weight: 700;
    color: #333;
    letter-spacing: 1px;
}
.captcha-form { margin: 0; }
.captcha-input-row {
    display: flex;
    gap: 8px;
    align-items: center;
}
.captcha-input {
    flex: 1;
    padding: 8px 12px;
    border: 1.5px solid #d4c99e;
    border-radius: 8px;
    font-size: 1rem;
    outline: none;
    transition: border-color 0.2s;
    background: #fff;
}
.captcha-input:focus {
    border-color: #b8860b;
    box-shadow: 0 0 0 2px rgba(184, 134, 11, 0.15);
}
.captcha-input.is-invalid {
    border-color: #ef4444;
    box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.12);
}
.captcha-submit {
    padding: 8px 18px;
    border: none;
    border-radius: 8px;
    background: #b8860b;
    color: #fff;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: background 0.2s;
    white-space: nowrap;
}
.captcha-submit:hover { background: #9a7209; }
.captcha-submit:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}
.captcha-error {
    color: #ef4444;
    font-size: 0.82rem;
    margin-top: 6px;
    font-weight: 500;
}

/* ============================================
   GUEST: "Login to continue" card
   Shown in chat when a guest's free-message
   allowance is exhausted.
   ============================================ */
.login-card {
    background: linear-gradient(135deg, #eef4ff 0%, #e6efff 100%);
    border: 1px solid #b9cdf5;
    border-radius: 12px;
    padding: 16px 18px;
    max-width: 380px;
    box-shadow: 0 2px 8px rgba(80, 120, 240, 0.15);
}
.login-card-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    font-size: 0.95rem;
    color: #2a52be;
    margin-bottom: 8px;
}
.login-card-msg {
    font-size: 0.85rem;
    color: #555;
    margin: 0 0 12px 0;
    line-height: 1.4;
}
.login-card-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 20px;
    border: none;
    border-radius: 8px;
    background: #2a52be;
    color: #fff;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: background 0.2s;
}
.login-card-btn:hover { background: #1f3f9a; }

/* ============================================
   ACCESSIBILITY: prefers-reduced-motion
   Disables all animations and transitions when
   the user's OS requests reduced motion.
   ============================================ */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }

    .bg-grid { animation: none; }
    .shape { animation: none; filter: none; opacity: 0.04; }
    .bg-gradient { animation: none; transition: none; }
    .floating-shapes { display: none; }
}

/* ============================================
   PERFORMANCE: GPU hints for animated elements
   ============================================ */
.bg-grid,
.shape,
.bg-gradient {
    will-change: transform;
    transform: translateZ(0);
}

/* ============================================
   PERFORMANCE: Reduce blur & hide heavy FX on mobile
   Heavy blur + animated gradients + floating shapes
   cause battery drain and laggy input on low-end phones.
   ============================================ */
@media (max-width: 768px) {
    .shape { filter: blur(20px); opacity: 0.04; }
    .floating-shapes { display: none; }
    .bg-grid { animation-duration: 60s; }
    .modal { backdrop-filter: blur(4px); }
}

@media (max-width: 480px) {
    .shape { display: none; }
    .bg-grid { display: none; }
    .modal { backdrop-filter: none; background: rgba(0, 0, 0, 0.6); }
}

/* ============================================
   ACCESSIBILITY: Fix overflow:hidden on html/body
   overflow:hidden on body can cause scrolling
   problems inside nested containers and breaks
   accessibility. Use overflow on .app-container instead.
   ============================================ */
html { overflow: hidden; }
body { overflow: auto; }

/* =======================================================================
   FEEDBACK MODAL (redesigned — professional, responsive, themed)
   Design intent:
     - Self-contained styling so the feedback popup renders even when its
       HTML is injected / re-rendered dynamically.
     - Uses existing CSS custom properties from chatbot-v2 (--p, --pl, --card,
       --border, --txt, --txt2, --txt3, --input-bg, --ok, --err) so it
       automatically adapts to light/dark theme.
     - Pure server-side HTML + minimal JS for interactivity (emoji / tag
       toggling, captcha refresh, submit) per project code-style rules.
   ======================================================================= */
.fb-modal .modal-box { max-width: 520px; }
.fb-header {
    display: flex; align-items: center; gap: 14px;
    padding: 22px 28px 16px;
    border-bottom: 1px solid var(--border);
    background: linear-gradient(135deg, rgba(230,168,23,0.06), rgba(247,199,72,0.02));
}
.fb-header-icon {
    width: 44px; height: 44px; flex-shrink: 0;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--p), var(--pl));
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-size: 20px;
    box-shadow: 0 6px 14px rgba(230,168,23,0.35);
}
[data-theme="dark"] .fb-header-icon { color: #111; }
.fb-header-text h3 {
    margin: 0; font-family: 'Space Grotesk', sans-serif;
    font-size: 18px; font-weight: 700; color: var(--txt);
}
.fb-header-text p {
    margin: 2px 0 0; font-size: 12.5px; color: var(--txt3);
}

.fb-body { padding: 20px 28px 24px; }
.fb-section { margin-bottom: 18px; }
.fb-section:last-child { margin-bottom: 0; }
.fb-label {
    display: block; font-size: 11.5px; font-weight: 700;
    color: var(--txt2);
    margin-bottom: 8px;
    text-transform: uppercase; letter-spacing: 0.6px;
}
.fb-label .fb-optional {
    font-weight: 500; color: var(--txt3);
    text-transform: none; letter-spacing: 0; margin-left: 6px;
}

/* Emoji rating row */
.fb-emoji-row {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
}
.fb-emoji-opt {
    display: flex; flex-direction: column; align-items: center;
    gap: 4px;
    padding: 10px 4px 8px;
    background: var(--input-bg);
    border: 2px solid var(--border);
    border-radius: 12px;
    cursor: pointer;
    transition: transform .15s ease, border-color .15s ease, background .15s ease, box-shadow .15s ease;
    user-select: none;
}
.fb-emoji-opt:hover {
    border-color: var(--p);
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(230,168,23,0.15);
}
.fb-emoji-opt span.fb-emoji {
    font-size: 26px; line-height: 1;
    transition: transform .15s ease;
}
.fb-emoji-opt:hover span.fb-emoji { transform: scale(1.12); }
.fb-emoji-opt small {
    font-size: 10.5px; font-weight: 600;
    color: var(--txt3);
}
.fb-emoji-opt.selected {
    background: linear-gradient(135deg, var(--p), var(--pl));
    border-color: var(--p);
    box-shadow: 0 6px 16px rgba(230,168,23,0.35);
}
.fb-emoji-opt.selected small { color: #fff; }
[data-theme="dark"] .fb-emoji-opt.selected small { color: #111; }

/* Quick tag chips */
.fb-tag-row {
    display: flex; flex-wrap: wrap; gap: 6px;
}
.fb-tag {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 6px 12px;
    background: var(--input-bg);
    border: 1px solid var(--border);
    border-radius: 18px;
    font-size: 12px; font-weight: 500;
    color: var(--txt2);
    cursor: pointer;
    transition: all .15s ease;
    user-select: none;
}
.fb-tag:hover {
    border-color: var(--p); color: var(--p);
    background: rgba(230,168,23,0.06);
}
.fb-tag.selected {
    background: var(--p); border-color: var(--p); color: #fff;
}
[data-theme="dark"] .fb-tag.selected { color: #111; }

/* Textarea */
.fb-textarea {
    width: 100%;
    min-height: 76px;
    padding: 11px 13px;
    background: var(--input-bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    font: inherit; font-size: 13.5px;
    color: var(--txt);
    resize: vertical;
    transition: border-color .15s ease, box-shadow .15s ease;
    box-sizing: border-box;
}
.fb-textarea:focus {
    outline: none;
    border-color: var(--p);
    box-shadow: 0 0 0 3px rgba(230,168,23,0.15);
}
.fb-textarea::placeholder { color: var(--txt3); }
.fb-char-count {
    display: block; text-align: right;
    font-size: 11px; color: var(--txt3); margin-top: 4px;
}

/* CAPTCHA strip */
.fb-captcha {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 12px;
    background: rgba(230,168,23,0.08);
    border: 1px dashed rgba(230,168,23,0.45);
    border-radius: 10px;
}
.fb-captcha-q {
    font-size: 14px; color: var(--txt); font-weight: 600;
    display: inline-flex; align-items: center; gap: 6px;
}
.fb-captcha-q b {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 30px; height: 30px;
    padding: 0 6px;
    background: linear-gradient(135deg, var(--p), var(--pl));
    color: #fff;
    border-radius: 7px;
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
}
[data-theme="dark"] .fb-captcha-q b { color: #111; }
.fb-captcha input[type="number"] {
    -moz-appearance: textfield;
    width: 62px; height: 34px;
    padding: 0 8px;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 14px; font-weight: 700;
    text-align: center;
    color: var(--txt);
    background: var(--card);
    transition: border-color .15s ease, box-shadow .15s ease;
}
.fb-captcha input[type="number"]:focus {
    outline: none;
    border-color: var(--p);
    box-shadow: 0 0 0 3px rgba(230,168,23,0.18);
}
.fb-captcha input::-webkit-outer-spin-button,
.fb-captcha input::-webkit-inner-spin-button {
    -webkit-appearance: none; margin: 0;
}
.fb-captcha-refresh {
    width: 34px; height: 34px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--txt2);
    cursor: pointer;
    transition: all .15s ease;
    display: inline-flex; align-items: center; justify-content: center;
}
.fb-captcha-refresh:hover {
    border-color: var(--p); color: var(--p);
    transform: rotate(60deg);
}
.fb-captcha-note {
    font-size: 11px; color: var(--txt3);
    margin-left: auto; display: flex; align-items: center; gap: 4px;
}

/* Inline validation */
.fb-error {
    display: none;
    margin-top: 8px;
    padding: 8px 12px;
    background: rgba(239,68,68,0.08);
    border: 1px solid rgba(239,68,68,0.35);
    border-radius: 8px;
    color: #B91C1C;
    font-size: 12.5px;
    font-weight: 500;
}
[data-theme="dark"] .fb-error { color: #FCA5A5; background: rgba(239,68,68,0.12); }
.fb-error.show { display: block; animation: fbShake .35s ease; }
@keyframes fbShake {
    0%,100% { transform: translateX(0); }
    25%     { transform: translateX(-4px); }
    75%     { transform: translateX(4px); }
}
.fb-textarea.is-invalid,
.fb-captcha.is-invalid input[type="number"] {
    border-color: #EF4444;
}

/* Actions */
.fb-actions {
    display: flex; gap: 10px; margin-top: 20px;
    padding-top: 16px; border-top: 1px solid var(--border);
}
.fb-btn {
    flex: 1;
    display: inline-flex; align-items: center; justify-content: center;
    gap: 7px;
    padding: 11px 16px;
    border-radius: 10px;
    font-size: 13.5px; font-weight: 600;
    cursor: pointer;
    transition: all .15s ease;
    border: 1px solid transparent;
}
.fb-btn:disabled { opacity: .6; cursor: not-allowed; }
.fb-btn.cancel {
    background: var(--input-bg);
    border-color: var(--border);
    color: var(--txt2);
}
.fb-btn.cancel:hover:not(:disabled) {
    background: #FEE2E2; border-color: #EF4444; color: #EF4444;
}
[data-theme="dark"] .fb-btn.cancel:hover:not(:disabled) {
    background: rgba(239,68,68,0.12);
}
.fb-btn.submit {
    background: linear-gradient(135deg, var(--p), var(--pl));
    color: #fff;
    box-shadow: 0 4px 12px rgba(230,168,23,0.25);
}
[data-theme="dark"] .fb-btn.submit { color: #111; }
.fb-btn.submit:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(230,168,23,0.38);
}
.fb-btn .fb-spinner { display: none; }
.fb-btn.is-loading .fb-spinner { display: inline-block; }
.fb-btn.is-loading .fb-label-text,
.fb-btn.is-loading i.fa-paper-plane { display: none; }

/* Success state */
.fb-success {
    text-align: center; padding: 18px 8px 10px;
    animation: fbFadeIn .3s ease;
}
@keyframes fbFadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }
.fb-success-icon {
    width: 68px; height: 68px; margin: 0 auto 14px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--p), var(--pl));
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-size: 30px;
    box-shadow: 0 8px 20px rgba(230,168,23,0.35);
    animation: fbPop .4s cubic-bezier(.25,1.4,.5,1);
}
[data-theme="dark"] .fb-success-icon { color: #111; }
@keyframes fbPop { 0% { transform: scale(.4); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
.fb-success h3 {
    font-size: 18px; margin: 0 0 6px; color: var(--txt);
    font-family: 'Space Grotesk', sans-serif;
}
.fb-success p { font-size: 13px; color: var(--txt3); margin: 0; }

/* Small-screen tweaks */
@media (max-width: 520px) {
    .fb-header { padding: 16px 18px 12px; }
    .fb-body { padding: 16px 18px 18px; }
    .fb-emoji-row { gap: 5px; }
    .fb-emoji-opt { padding: 8px 2px 6px; }
    .fb-emoji-opt span.fb-emoji { font-size: 22px; }
    .fb-emoji-opt small { font-size: 9.5px; }
    .fb-captcha { flex-wrap: wrap; }
    .fb-captcha-note { flex-basis: 100%; margin: 0; }
    .fb-actions { flex-direction: column-reverse; }
}

/* Reduced motion: skip all decorative animations */
@media (prefers-reduced-motion: reduce) {
    .fb-emoji-opt, .fb-tag, .fb-btn, .fb-captcha-refresh,
    .fb-textarea, .fb-captcha input[type="number"], .fb-success-icon {
        transition: none !important; animation: none !important;
    }
    .fb-error.show { animation: none !important; }
}
