/* ============================================================
   LogoAI Web — Asosiy Stillar
   ============================================================ */

:root {
    --primary:      #4A6CF7;
    --primary-dark: #3451D1;
    --secondary:    #7C3AED;
    --success:      #10B981;
    --warning:      #F59E0B;
    --error:        #EF4444;
    --easy:         #10B981;
    --medium:       #F59E0B;
    --hard:         #EF4444;

    --bg:           #F0F2FF;
    --bg-card:      #FFFFFF;
    --text:         #1F2937;
    --text-muted:   #6B7280;
    --border:       #E5E7EB;

    --grad-start:   #4A6CF7;
    --grad-end:     #7C3AED;
    --gradient:     linear-gradient(135deg, var(--grad-start), var(--grad-end));

    --radius-sm:    8px;
    --radius-md:    14px;
    --radius-lg:    20px;
    --radius-xl:    28px;
    --shadow-sm:    0 2px 8px rgba(74,108,247,.08);
    --shadow-md:    0 4px 20px rgba(74,108,247,.12);
    --shadow-lg:    0 8px 32px rgba(74,108,247,.16);
    --transition:   .2s ease;

    --nav-h:        64px;
    --sidebar-w:    240px;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg:       #0D1117;
        --bg-card:  #161B27;
        --text:     #F3F4F6;
        --text-muted:#9CA3AF;
        --border:   #2D3748;
    }
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; scroll-behavior: smooth; }

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

img { max-width: 100%; }

/* ── LAYOUT ─────────────────────────────────────────── */
.app-layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-w);
    background: var(--bg-card);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 100;
    transition: transform var(--transition);
}

.sidebar-brand {
    padding: 20px 20px 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-brand .logo-icon {
    width: 40px; height: 40px;
    background: var(--gradient);
    border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center;
    font-size: 20px;
}

.sidebar-brand .logo-text {
    font-size: 18px; font-weight: 700;
    background: var(--gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.sidebar-nav { flex: 1; padding: 12px 0; overflow-y: auto; }

.nav-item {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 20px;
    border-radius: 0;
    color: var(--text-muted);
    font-size: 14px; font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
    position: relative;
}

.nav-item:hover, .nav-item.active {
    background: linear-gradient(135deg, rgba(74,108,247,.08), rgba(124,58,237,.08));
    color: var(--primary);
    text-decoration: none;
}

.nav-item.active::before {
    content: '';
    position: absolute; left: 0; top: 4px; bottom: 4px;
    width: 3px;
    background: var(--gradient);
    border-radius: 0 3px 3px 0;
}

.nav-item .nav-icon {
    width: 36px; height: 36px;
    background: rgba(74,108,247,.08);
    border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.nav-item.active .nav-icon { background: var(--gradient); }

.main-content {
    margin-left: var(--sidebar-w);
    flex: 1;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.page-header {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    padding: 16px 28px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky; top: 0; z-index: 50;
}

.page-header h1 {
    font-size: 20px; font-weight: 700;
}

.page-body {
    padding: 28px;
    flex: 1;
    max-width: 1100px;
    width: 100%;
    margin: 0 auto;
}

/* ── KARTOCHKALAR ───────────────────────────────────── */
.card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    padding: 20px;
    box-shadow: var(--shadow-sm);
}

.card-title {
    font-size: 15px; font-weight: 700;
    margin-bottom: 14px;
    display: flex; align-items: center; gap: 8px;
}

.stat-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    padding: 20px;
    text-align: center;
    box-shadow: var(--shadow-sm);
}

.stat-value {
    font-size: 32px; font-weight: 800;
    line-height: 1.2;
    background: var(--gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.stat-label {
    font-size: 13px; color: var(--text-muted);
    margin-top: 4px;
}

/* ── TUGMALAR ───────────────────────────────────────── */
.btn {
    display: inline-flex; align-items: center; justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border-radius: var(--radius-md);
    font-size: 14px; font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all var(--transition);
    text-decoration: none;
    line-height: 1;
}

.btn-primary {
    background: var(--gradient);
    color: white;
    box-shadow: 0 4px 14px rgba(74,108,247,.35);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(74,108,247,.45);
    color: white; text-decoration: none;
}

.btn-outline {
    background: transparent;
    border: 2px solid var(--primary);
    color: var(--primary);
}

.btn-outline:hover { background: rgba(74,108,247,.08); text-decoration: none; }

.btn-danger { background: var(--error); color: white; }
.btn-success { background: var(--success); color: white; }
.btn-warning { background: var(--warning); color: white; }

.btn-lg { padding: 16px 32px; font-size: 16px; border-radius: var(--radius-lg); }
.btn-sm { padding: 8px 16px; font-size: 13px; }
.btn-full { width: 100%; }

.btn:disabled { opacity: .5; cursor: not-allowed; transform: none !important; }

/* ── FORM ───────────────────────────────────────────── */
.form-group { margin-bottom: 18px; }

.form-label {
    display: block;
    font-size: 13px; font-weight: 600; color: var(--text-muted);
    margin-bottom: 6px;
    text-transform: uppercase; letter-spacing: .5px;
}

.form-input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--border);
    border-radius: var(--radius-md);
    font-size: 15px;
    background: var(--bg-card);
    color: var(--text);
    transition: border-color var(--transition);
    outline: none;
}

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

.form-error {
    color: var(--error);
    font-size: 13px;
    margin-top: 6px;
}

/* ── ALERT ──────────────────────────────────────────── */
.alert {
    padding: 14px 18px;
    border-radius: var(--radius-md);
    font-size: 14px;
    margin-bottom: 16px;
    display: flex; align-items: center; gap: 10px;
}

.alert-success { background: rgba(16,185,129,.1); color: #065F46; border: 1px solid rgba(16,185,129,.3); }
.alert-error   { background: rgba(239,68,68,.1);  color: #7F1D1D; border: 1px solid rgba(239,68,68,.3); }
.alert-info    { background: rgba(74,108,247,.1); color: #1E3A8A; border: 1px solid rgba(74,108,247,.3); }

/* ── BADGE / PILL ───────────────────────────────────── */
.badge {
    display: inline-flex; align-items: center;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px; font-weight: 600;
    line-height: 1;
}

.badge-success { background: rgba(16,185,129,.12); color: #065F46; }
.badge-warning { background: rgba(245,158,11,.12); color: #92400E; }
.badge-error   { background: rgba(239,68,68,.12);  color: #7F1D1D; }
.badge-primary { background: rgba(74,108,247,.12); color: #1E3A8A; }

/* ── PROGRESS BAR ───────────────────────────────────── */
.progress-bar {
    height: 8px;
    background: var(--border);
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    border-radius: 4px;
    background: var(--gradient);
    transition: width .6s ease;
}

/* ── LETTER CARDS ───────────────────────────────────── */
.letter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 16px;
}

.letter-card {
    background: var(--bg-card);
    border: 2px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    display: flex; align-items: center; gap: 14px;
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
    color: var(--text);
}

.letter-card:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
    text-decoration: none; color: var(--text);
}

.letter-circle {
    width: 54px; height: 54px;
    border-radius: 50%;
    background: var(--gradient);
    display: flex; align-items: center; justify-content: center;
    font-size: 22px; font-weight: 800; color: white;
    flex-shrink: 0;
}

/* ── WORD EXERCISE ──────────────────────────────────── */
.word-card {
    background: var(--bg-card);
    border-radius: var(--radius-xl);
    border: 2px solid var(--border);
    padding: 32px;
    text-align: center;
    margin-bottom: 20px;
    box-shadow: var(--shadow-sm);
}

.word-display {
    font-size: 52px; font-weight: 900;
    background: var(--gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    line-height: 1.2;
    margin-bottom: 8px;
}

.word-phonetic {
    font-size: 18px; color: var(--text-muted);
    font-style: italic;
}

/* ── MIC BUTTON ─────────────────────────────────────── */
.mic-wrap {
    display: flex; flex-direction: column;
    align-items: center; gap: 16px;
    margin: 24px 0;
}

.mic-btn {
    width: 90px; height: 90px;
    border-radius: 50%;
    background: var(--gradient);
    border: none; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    font-size: 36px;
    color: white;
    box-shadow: 0 4px 20px rgba(74,108,247,.4);
    transition: all var(--transition);
    position: relative;
}

.mic-btn:hover { transform: scale(1.06); }

.mic-btn.recording {
    background: linear-gradient(135deg, #EF4444, #DC2626);
    box-shadow: 0 4px 20px rgba(239,68,68,.5);
    animation: pulse-mic 1.2s infinite;
}

@keyframes pulse-mic {
    0%,100% { transform: scale(1); box-shadow: 0 4px 20px rgba(239,68,68,.5); }
    50%      { transform: scale(1.08); box-shadow: 0 4px 32px rgba(239,68,68,.7); }
}

.mic-btn .pulse-ring {
    position: absolute;
    border-radius: 50%;
    border: 3px solid rgba(239,68,68,.4);
    animation: ring-expand 1.5s infinite;
}

@keyframes ring-expand {
    0%   { width:90px; height:90px; opacity:.8; }
    100% { width:150px; height:150px; opacity:0; }
}

/* ── COUNTDOWN ──────────────────────────────────────── */
.countdown {
    font-size: 64px; font-weight: 900;
    background: var(--gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    line-height: 1;
    min-height: 80px;
    display: flex; align-items: center; justify-content: center;
}

/* ── RESULT ─────────────────────────────────────────── */
.result-ring {
    width: 140px; height: 140px;
    margin: 0 auto 16px;
    position: relative;
}

.result-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }

.result-ring .ring-bg { fill: none; stroke: var(--border); stroke-width: 10; }
.result-ring .ring-fill {
    fill: none; stroke-width: 10;
    stroke-linecap: round;
    stroke-dasharray: 314;
    stroke-dashoffset: 314;
    transition: stroke-dashoffset 1.2s ease;
}

.result-pct {
    position: absolute; inset: 0;
    display: flex; align-items: center; justify-content: center;
    font-size: 28px; font-weight: 800;
}

.stars { font-size: 28px; text-align: center; margin: 8px 0; }

/* ── TIP CARD ───────────────────────────────────────── */
.tip-card {
    background: linear-gradient(135deg, rgba(74,108,247,.06), rgba(124,58,237,.06));
    border: 1px solid rgba(74,108,247,.2);
    border-radius: var(--radius-md);
    padding: 14px 16px;
    display: flex; gap: 10px;
    font-size: 13px;
    margin-bottom: 16px;
}

.ai-card {
    background: linear-gradient(135deg, rgba(74,108,247,.06), rgba(124,58,237,.06));
    border: 1px solid rgba(74,108,247,.2);
    border-radius: var(--radius-lg);
    padding: 18px;
    margin: 16px 0;
}

.ai-card-title {
    font-size: 13px; font-weight: 700;
    color: var(--primary);
    margin-bottom: 10px;
    display: flex; align-items: center; gap: 6px;
}

/* ── TOAST ──────────────────────────────────────────── */
#toast-container {
    position: fixed; bottom: 24px; right: 24px;
    z-index: 9999; display: flex; flex-direction: column; gap: 10px;
}

.toast {
    padding: 14px 20px;
    border-radius: var(--radius-md);
    background: #1F2937; color: white;
    font-size: 14px; font-weight: 500;
    box-shadow: var(--shadow-lg);
    animation: toast-in .3s ease;
    display: flex; align-items: center; gap: 10px;
    max-width: 320px;
}

.toast.success { background: var(--success); }
.toast.error   { background: var(--error); }

@keyframes toast-in {
    from { transform: translateX(100%); opacity: 0; }
    to   { transform: translateX(0);    opacity: 1; }
}

/* ── AUTH PAGES ─────────────────────────────────────── */
.auth-wrap {
    min-height: 100vh;
    display: flex; align-items: center; justify-content: center;
    background: var(--gradient);
    padding: 20px;
}

.auth-card {
    background: var(--bg-card);
    border-radius: var(--radius-xl);
    padding: 40px;
    width: 100%; max-width: 420px;
    box-shadow: var(--shadow-lg);
}

.auth-logo {
    text-align: center; margin-bottom: 24px;
}

.auth-logo .icon { font-size: 52px; display: block; }
.auth-logo h1 {
    font-size: 28px; font-weight: 800;
    background: var(--gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* ── GAMES ──────────────────────────────────────────── */
.game-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
}

.game-card {
    background: var(--bg-card);
    border: 2px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none; color: var(--text);
}

.game-card:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-md);
    transform: translateY(-3px);
    text-decoration: none; color: var(--text);
}

.game-icon { font-size: 42px; display: block; margin-bottom: 12px; }
.game-title { font-size: 16px; font-weight: 700; margin-bottom: 4px; }
.game-desc  { font-size: 13px; color: var(--text-muted); }

/* Memory game */
.memory-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    max-width: 400px;
    margin: 0 auto;
}

.memory-card {
    aspect-ratio: 1;
    background: var(--gradient);
    border-radius: var(--radius-md);
    display: flex; align-items: center; justify-content: center;
    font-size: 22px; font-weight: 800; color: white;
    cursor: pointer;
    transition: all .3s;
    user-select: none;
    border: none;
}

.memory-card.revealed {
    background: white;
    color: var(--primary);
    border: 2px solid var(--primary);
}

.memory-card.matched {
    background: var(--success);
    color: white;
    border: none;
    cursor: default;
}

.memory-card:not(.revealed):not(.matched):hover { transform: scale(1.05); }

/* ── VIDEO GRID ─────────────────────────────────────── */
.video-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}

.video-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: all var(--transition);
    cursor: pointer;
    text-decoration: none; color: var(--text);
}

.video-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
    border-color: var(--primary);
    text-decoration: none; color: var(--text);
}

.video-thumb {
    position: relative; height: 160px;
    background: linear-gradient(135deg, #1a1a2e, #16213e);
    display: flex; align-items: center; justify-content: center;
}

.video-thumb img { width: 100%; height: 100%; object-fit: cover; }

.play-overlay {
    position: absolute; inset: 0;
    background: rgba(0,0,0,.3);
    display: flex; align-items: center; justify-content: center;
    font-size: 42px; color: white;
    opacity: 0; transition: opacity var(--transition);
}

.video-card:hover .play-overlay { opacity: 1; }

.video-info { padding: 14px; }
.video-title { font-size: 14px; font-weight: 600; margin-bottom: 4px; }
.video-desc  { font-size: 12px; color: var(--text-muted); }
.video-dur   { font-size: 12px; color: var(--primary); margin-top: 6px; font-weight: 600; }

/* Video modal */
.video-modal-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,.85);
    z-index: 1000;
    display: flex; align-items: center; justify-content: center;
    padding: 20px;
    animation: fade-in .2s ease;
}

@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

.video-modal {
    width: 100%; max-width: 840px;
    background: #000;
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.video-modal-header {
    background: #1a1a2e;
    padding: 14px 18px;
    display: flex; align-items: center; justify-content: space-between;
    color: white;
}

.video-modal iframe {
    width: 100%;
    aspect-ratio: 16/9;
    display: block;
    border: none;
}

/* ── PROFILE ────────────────────────────────────────── */
.avatar-grid {
    display: flex; flex-wrap: wrap; gap: 10px;
    margin-top: 10px;
}

.avatar-opt {
    width: 48px; height: 48px;
    border-radius: 50%;
    border: 2px solid var(--border);
    font-size: 24px;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; transition: all var(--transition);
    background: var(--bg);
}

.avatar-opt:hover, .avatar-opt.selected {
    border-color: var(--primary);
    background: rgba(74,108,247,.08);
    transform: scale(1.1);
}

/* ── TABLE ──────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }

table {
    width: 100%; border-collapse: collapse;
    font-size: 14px;
}

th {
    text-align: left; padding: 10px 14px;
    font-size: 12px; font-weight: 600;
    color: var(--text-muted); text-transform: uppercase;
    letter-spacing: .5px;
    border-bottom: 1px solid var(--border);
}

td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(74,108,247,.03); }

/* ── RESPONSIVE ─────────────────────────────────────── */
@media (max-width: 768px) {
    :root { --sidebar-w: 0px; }

    .sidebar {
        transform: translateX(-240px);
        width: 240px;
    }

    .sidebar.open { transform: translateX(0); }

    .main-content { margin-left: 0; }

    .stat-grid { grid-template-columns: 1fr 1fr; }

    .page-body { padding: 16px; }

    .memory-grid { grid-template-columns: repeat(4, 1fr); gap: 8px; }

    .hamburger {
        display: flex; align-items: center; justify-content: center;
        width: 40px; height: 40px;
        background: transparent; border: none;
        font-size: 22px; cursor: pointer; color: var(--text);
    }

    /* Mobil mikrofon - kattaroq, bosish oson */
    .mic-btn {
        width: 110px; height: 110px;
        font-size: 42px;
    }

    .word-display { font-size: 38px; }

    .grid-2 { grid-template-columns: 1fr 1fr; }

    /* Mobil uchun tugmalar kattaroq */
    .btn-lg { padding: 16px 24px; font-size: 16px; }

    /* Yuqori menyu kichik ekranda */
    .page-header h1 { font-size: 16px; }
}

/* Touch qurilmalar uchun */
@media (hover: none) and (pointer: coarse) {
    .btn { min-height: 48px; }
    .mic-btn { width: 100px; height: 100px; }
    .nav-item { padding: 14px 20px; }
}

@media (min-width: 769px) {
    .hamburger { display: none; }
}

/* ── UTILITIES ──────────────────────────────────────── */
.text-primary   { color: var(--primary) !important; }
.text-success   { color: var(--success) !important; }
.text-warning   { color: var(--warning) !important; }
.text-error     { color: var(--error)   !important; }
.text-muted     { color: var(--text-muted) !important; }
.text-center    { text-align: center; }
.fw-bold        { font-weight: 700; }
.mt-1  { margin-top: 8px; }
.mt-2  { margin-top: 16px; }
.mt-3  { margin-top: 24px; }
.mb-1  { margin-bottom: 8px; }
.mb-2  { margin-bottom: 16px; }
.mb-3  { margin-bottom: 24px; }
.gap-2 { gap: 16px; }
.flex  { display: flex; align-items: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.hidden { display: none !important; }
.loading { opacity: .5; pointer-events: none; }

/* Skeleton */
.skeleton {
    background: linear-gradient(90deg,
        var(--border) 25%, rgba(74,108,247,.06) 50%, var(--border) 75%);
    background-size: 200% 100%;
    animation: skeleton-wave 1.5s infinite;
    border-radius: var(--radius-sm);
}

@keyframes skeleton-wave {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Overlap mobile nav */
.mobile-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,.4);
    z-index: 99;
}

.mobile-overlay.active { display: block; }
