/**
 * Test Platform - Asosiy CSS
 * Responsive: Mobile-first yondashuv
 */

/* ============================================
   CSS O'ZGARUVCHILARI
   ============================================ */
:root {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-card: #1e293b;
    --bg-hover: #334155;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --accent: #6366f1;
    --accent-hover: #4f46e5;
    --accent-light: rgba(99, 102, 241, 0.15);
    --success: #22c55e;
    --success-light: rgba(34, 197, 94, 0.15);
    --danger: #ef4444;
    --danger-light: rgba(239, 68, 68, 0.15);
    --warning: #f59e0b;
    --warning-light: rgba(245, 158, 11, 0.15);
    --border: #334155;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
    --font-main: 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
    --transition: 0.2s ease;
}

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

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

body {
    font-family: var(--font-main);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--accent-hover); }

img { max-width: 100%; height: auto; }

/* ============================================
   LAYOUT
   ============================================ */
.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 16px;
}

.page { padding: 20px 0; }

/* ============================================
   HEADER
   ============================================ */
.header {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    padding: 12px 0;
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(12px);
}

.header__inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.header__logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    font-size: 18px;
    color: var(--text-primary);
}

.header__logo img { width: 36px; height: 36px; border-radius: 50%; }

.header__nav { display: flex; align-items: center; gap: 8px; }

.header__nav a, .header__nav button {
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    transition: all var(--transition);
    border: none;
    background: none;
    cursor: pointer;
}

.header__nav a:hover, .header__nav button:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.header__nav a.active {
    background: var(--accent-light);
    color: var(--accent);
}

/* Mobile menu */
.header__menu-toggle {
    display: none;
    padding: 8px;
    background: none;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
}

/* ============================================
   KARTALAR
   ============================================ */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    transition: all var(--transition);
}

.card:hover { border-color: var(--accent); }

.card__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.card__title { font-size: 18px; font-weight: 700; }
.card__subtitle { font-size: 14px; color: var(--text-secondary); margin-top: 4px; }

/* ============================================
   TUGMALAR
   ============================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border: none;
    border-radius: var(--radius-md);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
}

.btn--primary { background: var(--accent); color: white; }
.btn--primary:hover { background: var(--accent-hover); transform: translateY(-1px); }

.btn--success { background: var(--success); color: white; }
.btn--success:hover { background: #16a34a; }

.btn--danger { background: var(--danger); color: white; }
.btn--danger:hover { background: #dc2626; }

.btn--outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-primary);
}
.btn--outline:hover { border-color: var(--accent); color: var(--accent); }

.btn--sm { padding: 8px 16px; font-size: 13px; }
.btn--lg { padding: 16px 32px; font-size: 17px; }
.btn--full { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ============================================
   FORMA ELEMENTLARI
   ============================================ */
.form-group { margin-bottom: 20px; }

.form-label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.form-input, .form-select, .form-textarea {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 15px;
    font-family: var(--font-main);
    transition: border-color var(--transition);
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-light);
}

.form-input::placeholder { color: var(--text-muted); }

.form-textarea { min-height: 100px; resize: vertical; }

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

/* ============================================
   TEST KODI QIDIRISH
   ============================================ */
.search-code {
    display: flex;
    gap: 12px;
    max-width: 500px;
    margin: 0 auto;
}

.search-code .form-input {
    flex: 1;
    text-align: center;
    font-size: 20px;
    letter-spacing: 6px;
    text-transform: uppercase;
    font-weight: 700;
}

/* ============================================
   FAN KARTOCHKALARI (Dashboard)
   ============================================ */
.subjects-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 16px;
}

.subject-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    text-align: center;
    transition: all var(--transition);
    cursor: pointer;
}

.subject-card:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.subject-card__icon { font-size: 32px; margin-bottom: 8px; }
.subject-card__name { font-size: 14px; font-weight: 600; }
.subject-card__count { font-size: 13px; color: var(--text-muted); margin-top: 4px; }

/* ============================================
   TEST ISHLASH
   ============================================ */
.test-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    margin-bottom: 24px;
}

.timer {
    font-size: 24px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    padding: 8px 20px;
    background: var(--accent-light);
    color: var(--accent);
    border-radius: var(--radius-md);
}

.timer--warning { background: var(--warning-light); color: var(--warning); }
.timer--danger { background: var(--danger-light); color: var(--danger); animation: pulse 1s infinite; }

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

/* Savol ko'rinishi */
.question {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    margin-bottom: 16px;
}

.question__number {
    font-size: 13px;
    font-weight: 700;
    color: var(--accent);
    margin-bottom: 8px;
}

.question__text { font-size: 16px; line-height: 1.7; margin-bottom: 16px; }

/* Variant tanlash */
.options { display: flex; flex-direction: column; gap: 8px; }

.option {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition);
}

.option:hover { border-color: var(--accent); background: var(--accent-light); }

.option.selected {
    border-color: var(--accent);
    background: var(--accent-light);
}

.option__letter {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-secondary);
    border-radius: 50%;
    font-weight: 700;
    font-size: 14px;
    flex-shrink: 0;
}

.option.selected .option__letter {
    background: var(--accent);
    color: white;
}

/* Natija ko'rinishi */
.option.correct {
    border-color: var(--success);
    background: var(--success-light);
}

.option.correct .option__letter {
    background: var(--success);
    color: white;
}

.option.wrong {
    border-color: var(--danger);
    background: var(--danger-light);
}

.option.wrong .option__letter {
    background: var(--danger);
    color: white;
}

/* Ochiq javob input */
.open-answer-input {
    width: 100%;
    padding: 14px 16px;
    background: var(--bg-primary);
    border: 2px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 18px;
    font-weight: 600;
    text-transform: uppercase;
}

.open-answer-input:focus {
    border-color: var(--accent);
    outline: none;
}

.open-answer-input.correct { border-color: var(--success); background: var(--success-light); }
.open-answer-input.wrong { border-color: var(--danger); background: var(--danger-light); }

/* ============================================
   NATIJALAR
   ============================================ */
.result-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

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

.result-stat__value {
    font-size: 28px;
    font-weight: 800;
    margin-bottom: 4px;
}

.result-stat__value--success { color: var(--success); }
.result-stat__value--danger { color: var(--danger); }
.result-stat__value--accent { color: var(--accent); }

.result-stat__label { font-size: 13px; color: var(--text-muted); }

/* Percentile */
.percentile-bar {
    width: 100%;
    height: 24px;
    background: var(--bg-primary);
    border-radius: 12px;
    overflow: hidden;
    position: relative;
    margin: 12px 0;
}

.percentile-bar__fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), var(--success));
    border-radius: 12px;
    transition: width 1s ease;
}

.percentile-bar__text {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 12px;
    font-weight: 700;
}

/* ============================================
   MATEMATIK KLAVIATURA
   ============================================ */
.math-keyboard {
    display: none;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 12px;
    margin-top: 8px;
}

.math-keyboard--visible { display: block; }

.math-keyboard__row { display: flex; gap: 6px; margin-bottom: 6px; }
.math-keyboard__row:last-child { margin-bottom: 0; }

.math-keyboard__key {
    flex: 1;
    padding: 14px 8px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 18px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
}

.math-keyboard__key:hover { background: var(--accent-light); border-color: var(--accent); }
.math-keyboard__key--delete { background: var(--danger-light); color: var(--danger); }
.math-keyboard__key--done { background: var(--success-light); color: var(--success); }

/* ============================================
   TARIFLAR
   ============================================ */
.tariffs-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
}

.tariff-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 32px 24px;
    text-align: center;
    position: relative;
    transition: all var(--transition);
}

.tariff-card--recommended {
    border-color: var(--accent);
    box-shadow: 0 0 30px rgba(99, 102, 241, 0.2);
}

.tariff-card--recommended::before {
    content: 'Tavsiya etiladi';
    position: absolute;
    top: -12px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--accent);
    color: white;
    padding: 4px 16px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 700;
}

.tariff-card__name { font-size: 22px; font-weight: 800; margin-bottom: 8px; }
.tariff-card__price { font-size: 32px; font-weight: 800; color: var(--accent); margin-bottom: 4px; }
.tariff-card__period { font-size: 14px; color: var(--text-muted); margin-bottom: 24px; }

.tariff-card__features { text-align: left; margin-bottom: 24px; }

.tariff-feature {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    font-size: 14px;
    color: var(--text-secondary);
}

.tariff-feature svg { width: 18px; height: 18px; flex-shrink: 0; }
.tariff-feature--yes svg { stroke: var(--success); }
.tariff-feature--no svg { stroke: var(--text-muted); }
.tariff-feature--no { opacity: 0.5; }

/* ============================================
   PWA O'RNATISH BANNER
   ============================================ */
.install-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 12px 20px;
    background: linear-gradient(135deg, var(--accent), #818cf8);
    color: white;
    flex-wrap: wrap;
}

.install-banner__content { display: flex; align-items: center; gap: 12px; }
.install-banner__icon { width: 40px; height: 40px; border-radius: 10px; }
.install-banner__text { display: flex; flex-direction: column; }
.install-banner__text strong { font-size: 14px; }
.install-banner__text span { font-size: 12px; opacity: 0.85; }
.install-banner__actions { display: flex; gap: 8px; }

.install-banner__dismiss {
    padding: 8px 16px;
    background: rgba(255,255,255,0.2);
    border: none;
    border-radius: var(--radius-sm);
    color: white;
    cursor: pointer;
    font-size: 13px;
}

.install-banner__install {
    padding: 8px 20px;
    background: white;
    border: none;
    border-radius: var(--radius-sm);
    color: var(--accent);
    cursor: pointer;
    font-weight: 700;
    font-size: 13px;
}

/* ============================================
   OFFLINE BILDIRISHNOMA
   ============================================ */
.offline-notice {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px;
    background: var(--danger);
    color: white;
    font-size: 14px;
    font-weight: 600;
}

/* ============================================
   BILDIRISHNOMALAR
   ============================================ */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 20px;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 500;
    z-index: 1000;
    animation: slideIn 0.3s ease;
    max-width: 400px;
}

.notification--info { background: var(--accent); color: white; }
.notification--success { background: var(--success); color: white; }
.notification--error { background: var(--danger); color: white; }
.notification--warning { background: var(--warning); color: #1a1a1a; }

.notification button {
    background: none;
    border: none;
    color: inherit;
    font-size: 20px;
    cursor: pointer;
    opacity: 0.7;
}

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

/* ============================================
   JADVAL
   ============================================ */
.table-wrapper { overflow-x: auto; }

.table {
    width: 100%;
    border-collapse: collapse;
}

.table th, .table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
}

.table th {
    font-weight: 700;
    color: var(--text-muted);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.table tr:hover td { background: var(--bg-hover); }

/* ============================================
   BADGES
   ============================================ */
.badge {
    display: inline-flex;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 700;
}

.badge--success { background: var(--success-light); color: var(--success); }
.badge--danger { background: var(--danger-light); color: var(--danger); }
.badge--warning { background: var(--warning-light); color: var(--warning); }
.badge--accent { background: var(--accent-light); color: var(--accent); }

/* ============================================
   RESPONSIVE - TABLET
   ============================================ */
@media (max-width: 768px) {
    .header__nav {
        display: flex;
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        gap: 4px;
        padding: 8px 0;
    }
    .header__nav a, .header__nav button {
        white-space: nowrap;
        font-size: 12px;
        padding: 6px 10px;
        flex-shrink: 0;
    }
    .header__inner {
        flex-wrap: wrap;
    }
    .header__menu-toggle { display: none; }

    .subjects-grid { grid-template-columns: repeat(2, 1fr); }
    .tariffs-grid { grid-template-columns: 1fr; }
    .result-summary { grid-template-columns: repeat(2, 1fr); }

    .container { padding: 0 12px; }
    .card { padding: 16px; }
}

/* ============================================
   RESPONSIVE - TELEFON
   ============================================ */
@media (max-width: 480px) {
    html { font-size: 14px; }

    .subjects-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .subject-card { padding: 14px; }

    .test-header { flex-direction: column; gap: 12px; text-align: center; }
    .timer { font-size: 20px; }

    .search-code { flex-direction: column; }
    .search-code .form-input { font-size: 18px; }

    .result-summary { grid-template-columns: 1fr 1fr; }

    .math-keyboard__key { padding: 12px 4px; font-size: 16px; }

    .install-banner { flex-direction: column; text-align: center; }
    .install-banner__content { flex-direction: column; }

    .notification { left: 10px; right: 10px; max-width: none; }
}

/* ============================================
   RESPONSIVE - KATTA EKRANLAR
   ============================================ */
@media (min-width: 1400px) {
    .container { max-width: 1320px; }
    .subjects-grid { grid-template-columns: repeat(5, 1fr); }
}
