/* =====================================================
   TRAINING LMS — Основные стили (Mobile-first)
   ===================================================== */

/* === RESET & BASE === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.6; color: #333; background: #f5f7fa; min-height: 100vh; font-size: 1rem;
}
a { color: #2563eb; text-decoration: none; }
a:hover { color: #1d4ed8; text-decoration: underline; }
img { max-width: 100%; height: auto; }

/* === FONT SIZE CONTROLS === */
.font-size-controls { display: flex; gap: 2px; align-items: center; margin-left: auto; margin-right: 12px; }
.font-btn { background: transparent; border: none; color: #fff; padding: 4px 8px; font-size: 16px; font-weight: 700; cursor: pointer; line-height: 1; transition: opacity .15s; opacity: 0.8; }
.font-btn:hover { opacity: 1; }

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

/* === HEADER === */
.header { background: #1e293b; color: #fff; position: sticky; top: 0; z-index: 100; box-shadow: 0 2px 8px rgba(0,0,0,.15); font-size: 16px; }
.header-inner { max-width: 1200px; margin: 0 auto; padding: 0 16px; display: flex; align-items: center; justify-content: space-between; height: 56px; }
.logo { color: #fff; font-size: 17px; font-weight: 700; text-decoration: none; white-space: nowrap; }
.burger { display: block; background: none; border: none; color: #fff; font-size: 24px; cursor: pointer; padding: 4px 8px; }
.nav { display: none; position: fixed; top: 56px; left: 0; right: 0; bottom: 0; background: #1e293b; flex-direction: column; padding: 16px; z-index: 99; overflow-y: auto; }
.nav.open { display: flex; }
.nav-link { color: #cbd5e1; padding: 12px 8px; border-bottom: 1px solid #334155; display: block; font-size: 16px; text-decoration: none; }
.nav-link:hover { color: #fff; text-decoration: none; background: #334155; }
.nav-admin { color: #fbbf24; }
.nav-logout { color: #f87171; }
.nav-user { margin-top: auto; padding-top: 16px; border-top: 1px solid #334155; }
.nav-username { color: #94a3b8; display: block; padding: 8px; font-size: 14px; }

/* === MAIN & FOOTER === */
.main { padding: 20px 0; min-height: calc(100vh - 56px - 60px); }
.footer { background: #e2e8f0; text-align: center; padding: 16px; color: #64748b; font-size: 14px; }

/* === ALERTS === */
.alert { padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; font-size: 0.95rem; line-height: 1.5; }
.alert-success { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.alert-danger { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.alert-warning { background: #fef9c3; color: #854d0e; border: 1px solid #fde68a; }
.alert-info { background: #dbeafe; color: #1e40af; border: 1px solid #bfdbfe; }
.alert a { color: inherit; font-weight: 600; text-decoration: underline; }

/* === BUTTONS === */
.btn { display: inline-block; padding: 8px 16px; border: 1px solid #d1d5db; border-radius: 6px; background: #fff; color: #374151; font-size: 0.9rem; cursor: pointer; text-decoration: none; text-align: center; transition: background .15s; line-height: 1.5; }
.btn:hover { background: #f3f4f6; text-decoration: none; }
.btn-primary { background: #2563eb; color: #fff; border-color: #2563eb; }
.btn-primary:hover { background: #1d4ed8; color: #fff; }
.btn-danger { background: #ef4444; color: #fff; border-color: #ef4444; }
.btn-danger:hover { background: #dc2626; color: #fff; }
.btn-sm { padding: 4px 10px; font-size: 0.8rem; }
.btn-lg { padding: 12px 24px; font-size: 1.1rem; }
.btn-block { display: block; width: 100%; }

/* === FORMS === */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; margin-bottom: 4px; font-weight: 500; font-size: 0.9rem; color: #374151; }
.form-control { width: 100%; padding: 10px 12px; border: 1px solid #d1d5db; border-radius: 6px; font-size: 1rem; background: #fff; color: #111; transition: border-color .15s; }
.form-control:focus { outline: none; border-color: #2563eb; box-shadow: 0 0 0 3px rgba(37,99,235,.15); }
.form-sm { max-width: 120px; }
.form-row { display: flex; gap: 12px; flex-wrap: wrap; }
.form-row .form-group { flex: 1; min-width: 120px; }
.form-inline { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 20px; }
.form-inline .form-control { width: auto; flex: 1; min-width: 150px; }
.form-card { background: #fff; padding: 20px; border-radius: 10px; box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.form-actions { margin-top: 20px; display: flex; gap: 8px; }

/* === TABLES === */
.table-wrap { overflow-x: auto; margin-bottom: 20px; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; background: #fff; border-radius: 8px; overflow: hidden; box-shadow: 0 1px 3px rgba(0,0,0,.06); }
.table th, .table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid #e5e7eb; font-size: 0.9rem; }
.table th { background: #f8fafc; font-weight: 600; color: #475569; white-space: nowrap; }
.table tr:hover { background: #f8fafc; }
.table-sm th, .table-sm td { padding: 6px 10px; font-size: 0.85rem; }
.actions-cell { white-space: nowrap; }
.actions-cell .btn { margin: 0 2px; }

/* === BADGES & TAGS === */
.badge { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 0.8rem; font-weight: 600; white-space: nowrap; }
.badge-success { background: #dcfce7; color: #166534; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-warning { background: #fef9c3; color: #854d0e; }
.badge-info { background: #dbeafe; color: #1e40af; }
.tag { display: inline-block; padding: 3px 10px; border-radius: 6px; font-size: 0.8rem; background: #e5e7eb; color: #475569; margin: 2px 4px 2px 0; }
.tag-success { background: #dcfce7; color: #166534; }
.tag-danger { background: #fee2e2; color: #991b1b; }

/* === CARDS === */
.card-grid { display: grid; grid-template-columns: 1fr; gap: 12px; margin-bottom: 24px; }
.card { display: block; background: #fff; border-radius: 10px; padding: 20px; box-shadow: 0 1px 3px rgba(0,0,0,.08); text-decoration: none; color: #333; transition: box-shadow .2s, transform .2s; border: 1px solid #e5e7eb; }
.card:hover { box-shadow: 0 4px 12px rgba(0,0,0,.12); transform: translateY(-2px); text-decoration: none; color: #333; }
.card-icon { font-size: 2rem; margin-bottom: 8px; }
.card-title { font-size: 1rem; font-weight: 600; margin-bottom: 4px; }
.card-desc { font-size: 0.85rem; color: #64748b; margin-bottom: 8px; }
.card-meta { font-size: 0.8rem; color: #94a3b8; }

/* === AUTH === */
.auth-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: linear-gradient(135deg, #1e293b 0%, #334155 100%); padding: 16px; }
.auth-card { background: #fff; border-radius: 12px; padding: 32px 24px; width: 100%; max-width: 400px; box-shadow: 0 8px 30px rgba(0,0,0,.2); }
.auth-title { text-align: center; font-size: 1.3rem; margin-bottom: 4px; color: #1e293b; }
.auth-subtitle { text-align: center; color: #64748b; margin-bottom: 20px; font-size: 0.9rem; }
.auth-link { text-align: center; margin-top: 16px; font-size: 0.9rem; }

/* === READINESS === */
.readiness-block { display: flex; align-items: center; gap: 20px; background: #fff; padding: 20px; border-radius: 10px; margin-bottom: 24px; box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.readiness-circle { width: 90px; height: 90px; border-radius: 50%; background: conic-gradient(#2563eb calc(var(--percent) * 1%), #e5e7eb 0%); display: flex; align-items: center; justify-content: center; flex-shrink: 0; position: relative; }
.readiness-circle::before { content: ''; width: 70px; height: 70px; border-radius: 50%; background: #fff; position: absolute; }
.readiness-number { position: relative; z-index: 1; font-size: 1.2rem; font-weight: 700; color: #2563eb; }
.readiness-info h2 { font-size: 1.1rem; margin-bottom: 4px; }
.readiness-info p { font-size: 0.9rem; color: #64748b; }
.readiness-bar { background: #e5e7eb; border-radius: 8px; height: 32px; position: relative; margin-bottom: 24px; overflow: hidden; }
.readiness-fill { height: 100%; background: #2563eb; border-radius: 8px; transition: width .5s; }
.readiness-label { position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%); font-weight: 700; font-size: 0.9rem; }

/* === STATS === */
.stats-overview { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 24px; }
.stat-card { background: #fff; border-radius: 10px; padding: 16px; text-align: center; box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.stat-value { font-size: 1.5rem; font-weight: 700; color: #2563eb; }
.stat-label { font-size: 0.8rem; color: #64748b; margin-top: 2px; }

/* === BREADCRUMB === */
.breadcrumb { font-size: 0.85rem; color: #64748b; margin-bottom: 12px; }
.breadcrumb a { color: #2563eb; }

/* === TOPICS === */
.topic-list { display: flex; flex-direction: column; gap: 12px; margin-bottom: 24px; }
.topic-card { background: #fff; border-radius: 10px; padding: 16px; box-shadow: 0 1px 3px rgba(0,0,0,.08); border-left: 4px solid #e5e7eb; }
.topic-card.topic-completed { border-left-color: #22c55e; }
.topic-header { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.topic-header h3 { font-size: 1rem; }
.topic-header h3 a { color: #1e293b; }
.topic-desc { font-size: 0.85rem; color: #64748b; margin-bottom: 8px; }
.topic-meta { font-size: 0.8rem; color: #94a3b8; margin-bottom: 8px; display: flex; gap: 12px; }
.topic-progress { margin-bottom: 8px; }
.topic-actions { display: flex; gap: 8px; }
.subtopic-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 20px; }
.subtopic-item { display: block; padding: 10px 16px; background: #fff; border-radius: 6px; border: 1px solid #e5e7eb; color: #333; }
.subtopic-item:hover { background: #f8fafc; text-decoration: none; }

/* === THEORY === */
.theory { background: #fff; padding: 20px; border-radius: 10px; margin-bottom: 20px; box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.theory h1 { font-size: 1.3rem; margin-bottom: 8px; }
.theory-meta { display: flex; gap: 12px; align-items: center; margin-bottom: 16px; font-size: 0.85rem; color: #64748b; }
.theory-content { line-height: 1.7; font-size: 1rem; }
.theory-content h2 { margin-top: 20px; margin-bottom: 8px; font-size: 1.3rem; }
.theory-content h3 { margin-top: 16px; margin-bottom: 8px; font-size: 1.15rem; }
.theory-content h4 { font-size: 1.05rem; }
.theory-content p { margin-bottom: 12px; font-size: 1rem; }
.theory-content ul, .theory-content ol { margin-left: 20px; margin-bottom: 12px; font-size: 1rem; }
.theory-content li { margin-bottom: 4px; }
.theory-content table { font-size: 0.95rem; }
.theory-actions { margin-top: 20px; }
.theory-score { margin-top: 8px; font-size: 0.9rem; }

/* === TEST === */
.test-start-card { background: #fff; border-radius: 10px; padding: 24px; max-width: 600px; margin: 0 auto; text-align: center; box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.test-start-card h1 { font-size: 1.2rem; margin-bottom: 16px; }
.test-info { margin-bottom: 20px; text-align: left; }
.test-info p { margin-bottom: 4px; font-size: 0.95rem; }
.test-progress { margin-bottom: 16px; }
.test-progress-bar { background: #e5e7eb; border-radius: 6px; height: 8px; overflow: hidden; margin-bottom: 4px; }
.test-progress-fill { height: 100%; background: #2563eb; border-radius: 6px; transition: width .3s; }
.test-progress-text { font-size: 0.85rem; color: #64748b; }
.test-question-card { background: #fff; border-radius: 10px; padding: 24px; max-width: 700px; margin: 0 auto; box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.question-type { font-size: 0.8rem; color: #64748b; margin-bottom: 8px; }
.question-text { font-size: 1.1rem; margin-bottom: 20px; line-height: 1.5; }
.answers-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 20px; }
.answer-option { display: flex; align-items: flex-start; gap: 10px; padding: 12px 16px; border: 2px solid #e5e7eb; border-radius: 8px; cursor: pointer; transition: border-color .15s, background .15s; min-height: 48px; }
.answer-option:hover { border-color: #93c5fd; background: #eff6ff; }
.answer-option input { margin-top: 4px; flex-shrink: 0; width: 18px; height: 18px; cursor: pointer; }
.answer-option input:checked ~ .answer-text { font-weight: 600; }
.answer-text { font-size: 0.95rem; line-height: 1.4; }
.test-explanation { background: #fff; border-radius: 10px; padding: 24px; max-width: 700px; margin: 0 auto; box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.explanation-text { background: #fef9c3; border-radius: 8px; padding: 16px; margin: 16px 0; line-height: 1.6; font-size: 0.95rem; }

/* === RESULT === */
.test-result-card { background: #fff; border-radius: 10px; padding: 32px; max-width: 500px; margin: 0 auto; text-align: center; box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.result-score { margin: 20px 0; padding: 24px; border-radius: 12px; }
.result-passed { background: #dcfce7; }
.result-failed { background: #fee2e2; }
.result-percent { display: block; font-size: 3rem; font-weight: 700; }
.result-passed .result-percent { color: #166534; }
.result-failed .result-percent { color: #991b1b; }
.result-label { display: block; font-size: 1.1rem; font-weight: 600; margin-top: 4px; }
.result-details { margin-bottom: 20px; }
.result-details p { margin: 4px 0; font-size: 0.95rem; color: #64748b; }
.result-actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }

/* === REVIEW === */
.review-question { background: #fff; border-radius: 10px; padding: 16px; margin-bottom: 12px; border-left: 4px solid #e5e7eb; box-shadow: 0 1px 3px rgba(0,0,0,.06); }
.review-correct { border-left-color: #22c55e; }
.review-wrong { border-left-color: #ef4444; }
.review-q-header { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; font-size: 0.85rem; }
.review-num { font-weight: 700; color: #64748b; }
.review-status { font-size: 1.2rem; }
.review-time { color: #94a3b8; margin-left: auto; }
.review-q-text { font-weight: 500; margin-bottom: 10px; }
.review-answer { padding: 8px 12px; border-radius: 6px; margin-bottom: 4px; font-size: 0.9rem; border: 1px solid #e5e7eb; }
.answer-correct { background: #dcfce7; border-color: #bbf7d0; }
.answer-wrong-selected { background: #fee2e2; border-color: #fecaca; }
.answer-correct-selected { background: #dcfce7; border-color: #22c55e; font-weight: 600; }
.review-explanation { background: #fef9c3; padding: 12px; border-radius: 6px; margin-top: 8px; font-size: 0.9rem; line-height: 1.5; }

/* === WEAK TOPICS === */
.weak-topics { display: flex; flex-direction: column; gap: 6px; margin-bottom: 20px; }
.weak-topic-item { display: flex; justify-content: space-between; align-items: center; padding: 10px 16px; background: #fff; border-radius: 8px; border: 1px solid #fecaca; color: #333; }
.weak-topic-item:hover { background: #fee2e2; text-decoration: none; }

/* === PROGRESS MAP === */
.progress-category { margin-bottom: 24px; }
.progress-category h2 { font-size: 1.1rem; margin-bottom: 8px; }
.progress-topics { display: flex; flex-direction: column; gap: 4px; }
.progress-topic { display: flex; justify-content: space-between; align-items: center; padding: 8px 12px; border-radius: 6px; background: #fff; border-left: 3px solid #e5e7eb; font-size: 0.9rem; }
.progress-topic.completed { border-left-color: #22c55e; background: #f0fdf4; }
.progress-topic.in-progress { border-left-color: #2563eb; background: #eff6ff; }
.progress-topic a { color: #333; }

/* === ADMIN ANSWER ROW === */
.answer-row { display: flex; gap: 8px; align-items: center; margin-bottom: 6px; }
.answer-row .form-control { flex: 1; }
.answer-row .answer-check { width: 20px; height: 20px; flex-shrink: 0; }

/* === ANSWER HIGHLIGHTS (разбор при ошибке) === */
.answer-option--correct { background: rgba(34, 197, 94, 0.15) !important; border-color: rgba(34, 197, 94, 0.4) !important; cursor: default; }
.answer-option--wrong { background: rgba(239, 68, 68, 0.15) !important; border-color: rgba(239, 68, 68, 0.4) !important; cursor: default; }
.answer-option--correct:hover, .answer-option--wrong:hover { background: rgba(34, 197, 94, 0.15); border-color: rgba(34, 197, 94, 0.4); }
.answer-option--wrong:hover { background: rgba(239, 68, 68, 0.15); border-color: rgba(239, 68, 68, 0.4); }

/* === THEORY BLOCKS (обучающий контент) === */
.theory-block { border-radius: 10px; padding: 16px 20px; margin: 20px 0; font-size: 1rem; line-height: 1.6; }
.theory-block h4 { margin: 0 0 8px 0; font-size: 1.05rem; }
.theory-block p { margin-bottom: 8px; }
.theory-block p:last-child { margin-bottom: 0; }
.theory-block ul, .theory-block ol { margin-left: 16px; margin-bottom: 8px; }
.theory-block--info { background: #eff6ff; border-left: 4px solid #3b82f6; }
.theory-block--info h4 { color: #1e40af; }
.theory-block--warning { background: #fef9c3; border-left: 4px solid #eab308; }
.theory-block--warning h4 { color: #854d0e; }
.theory-block--practice { background: #f0fdf4; border-left: 4px solid #22c55e; }
.theory-block--practice h4 { color: #166534; }
.theory-block--dialog { background: #faf5ff; border-left: 4px solid #a855f7; }
.theory-block--dialog h4 { color: #6b21a8; }
.theory-block--tip { background: #fff7ed; border-left: 4px solid #f97316; }
.theory-block--tip h4 { color: #9a3412; }
.theory-block--faq { background: #f8fafc; border-left: 4px solid #64748b; margin-bottom: 16px; }
.theory-block--faq h4 { color: #334155; font-size: 0.95rem; }
.theory-block--summary { background: #eff6ff; border: 2px solid #3b82f6; }
.theory-block--summary h4 { color: #1e40af; }
.theory-block--next { background: #f0fdf4; border: 2px dashed #22c55e; }
.theory-block--next h4 { color: #166534; }
.theory-table { width: 100%; border-collapse: collapse; margin: 16px 0; font-size: 0.9rem; }
.theory-table th, .theory-table td { border: 1px solid #e5e7eb; padding: 8px 12px; text-align: left; }
.theory-table th { background: #f1f5f9; font-weight: 600; color: #334155; }
.theory-table tr:hover { background: #f8fafc; }

/* === UTILITY === */
.text-muted { color: #94a3b8; }
h1 { font-size: 1.4rem; margin-bottom: 16px; color: #1e293b; }
h2 { font-size: 1.15rem; margin-top: 24px; margin-bottom: 12px; color: #1e293b; }

/* === RESPONSIVE — TABLET (576px+) === */
@media (min-width: 576px) {
    .card-grid { grid-template-columns: repeat(2, 1fr); }
    .stats-overview { grid-template-columns: repeat(4, 1fr); }
}

/* === RESPONSIVE — DESKTOP (768px+) === */
@media (min-width: 768px) {
    .burger { display: none; }
    .nav { display: flex; position: static; flex-direction: row; background: none; padding: 0; align-items: center; gap: 0; }
    .nav-link { padding: 8px 12px; border-bottom: none; font-size: 14px; }
    .nav-user { margin-top: 0; margin-left: 16px; padding-top: 0; border-top: none; display: flex; align-items: center; gap: 8px; }
    .nav-username { display: inline; padding: 0; }
    .card-grid { grid-template-columns: repeat(3, 1fr); }
    .container { padding: 0 24px; }
}

/* === RESPONSIVE — LARGE (992px+) === */
@media (min-width: 992px) {
    .card-grid { grid-template-columns: repeat(4, 1fr); gap: 16px; }
    h1 { font-size: 1.6rem; }
}
