/* =========================================================
   СДВГ База — Course Platform Styles
   Brand: cream bg, coral accents, MoiAmova handwriting font
   ========================================================= */

@font-face {
    font-family: 'MoiAmova';
    src: url('/fonts/moiamova-1.otf') format('opentype');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Montserrat';
    src: url('/fonts/Montserrat-VariableFont_wght.ttf') format('truetype');
    font-weight: 100 900;
    font-style: normal;
    font-display: swap;
}

:root {
    --bg-cream: #FDF5EF;
    --bg-white: #FFFFFF;
    --coral: #D98880;
    --coral-light: #F2D5D0;
    --coral-dark: #C07570;
    --mint: #7DCEA0;
    --blue-soft: #85C1E9;
    --text-dark: #2C2C2B;
    --text-mid: #666;
    --text-light: #999;
    --gray-bg: #F1F1F0;
    --gray-border: #E5E5E5;
    --shadow-sm: 0 2px 8px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 16px rgba(0,0,0,0.08);
    --radius: 12px;
    --radius-lg: 16px;
    --max-width: 700px;
    --font-body: 'Montserrat', 'Segoe UI', sans-serif;
    --font-hand: 'MoiAmova', 'Georgia', cursive;
}

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

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--font-body);
    background: var(--bg-cream);
    color: var(--text-dark);
    line-height: 1.7;
    min-height: 100dvh;
    -webkit-font-smoothing: antialiased;
}

/* ---- Screens ---- */
.screen { display: none; min-height: 100dvh; }
.screen.active { display: flex; flex-direction: column; }

/* ---- Top Bar ---- */
.top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--bg-white);
    border-bottom: 1px solid var(--gray-border);
    position: sticky;
    top: 0;
    z-index: 100;
}
.bar-title {
    font-family: var(--font-hand);
    font-size: 1.1rem;
    color: var(--coral);
    flex: 1;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.brand-small {
    font-family: var(--font-hand);
    color: var(--coral);
    font-size: 1.2rem;
}

/* ---- Buttons ---- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 14px 28px;
    border-radius: var(--radius);
    border: none;
    font-family: var(--font-body);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.btn-primary {
    background: var(--coral);
    color: white;
    width: 100%;
}
.btn-primary:hover { background: var(--coral-dark); }
.btn-primary:active { transform: scale(0.98); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-nav {
    background: var(--gray-bg);
    color: var(--text-dark);
    padding: 12px 20px;
    font-size: 0.9rem;
}
.btn-nav:hover { background: var(--gray-border); }

.btn-icon {
    background: none;
    border: none;
    font-size: 1.3rem;
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    color: var(--text-dark);
    transition: background 0.2s;
}
.btn-icon:hover { background: var(--gray-bg); }

.btn-link {
    background: none;
    border: none;
    color: var(--coral);
    cursor: pointer;
    font-size: 0.9rem;
    margin-top: 12px;
    font-family: var(--font-body);
}

.progress-badge {
    background: var(--coral-light);
    color: var(--coral-dark);
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 700;
}

/* ---- Progress Bar ---- */
.progress-bar-container {
    height: 3px;
    background: var(--gray-bg);
}
.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--coral), var(--mint));
    transition: width 0.5s ease;
    border-radius: 0 2px 2px 0;
}

/* ---- Input Fields ---- */
.input-field {
    width: 100%;
    padding: 14px 18px;
    border: 2px solid var(--gray-border);
    border-radius: var(--radius);
    font-size: 1rem;
    font-family: var(--font-body);
    background: var(--bg-white);
    color: var(--text-dark);
    transition: border-color 0.2s;
    outline: none;
}
.input-field:focus { border-color: var(--coral); }
.input-field::placeholder { color: var(--text-light); }

.error-msg {
    color: #e74c3c;
    font-size: 0.85rem;
    min-height: 20px;
    margin-top: 8px;
}

/* =========== LOGIN =========== */
.login-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100dvh;
    padding: 24px;
    max-width: 400px;
    margin: 0 auto;
}
.login-logo {
    text-align: center;
    margin-bottom: 40px;
}
.heart-icon {
    font-size: 3rem;
    color: var(--coral);
    animation: heartbeat 2s infinite;
}
@keyframes heartbeat {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}
.brand-title {
    font-family: var(--font-hand);
    font-size: 2.5rem;
    color: var(--coral);
    margin-top: 8px;
}
.brand-subtitle {
    color: var(--text-light);
    font-size: 0.95rem;
    margin-top: 12px;
}

.login-step { display: none; width: 100%; }
.login-step.active { display: flex; flex-direction: column; gap: 12px; }
.login-label { color: var(--text-mid); text-align: center; margin-bottom: 4px; }

/* OTP digits */
.otp-inputs {
    display: flex;
    gap: 8px;
    justify-content: center;
}
.otp-digit {
    width: 48px;
    height: 56px;
    text-align: center;
    font-size: 1.5rem;
    font-weight: 700;
    border: 2px solid var(--gray-border);
    border-radius: var(--radius);
    outline: none;
    font-family: var(--font-body);
    background: var(--bg-white);
    color: var(--text-dark);
    transition: border-color 0.2s;
}
.otp-digit:focus { border-color: var(--coral); }

/* =========== DASHBOARD =========== */
.dashboard-content {
    padding: 16px;
    max-width: var(--max-width);
    margin: 0 auto;
    width: 100%;
}
.welcome-card {
    background: linear-gradient(135deg, var(--coral), var(--coral-dark));
    border-radius: var(--radius-lg);
    padding: 24px;
    color: white;
    margin-bottom: 20px;
    box-shadow: var(--shadow-md);
}
.welcome-card h2 {
    font-family: var(--font-hand);
    font-size: 1.5rem;
    margin-bottom: 4px;
}
.welcome-card p { opacity: 0.9; font-size: 0.9rem; }

.courses-grid { display: flex; flex-direction: column; gap: 16px; }

.course-card {
    background: var(--bg-white);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}
.course-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.course-card:active { transform: scale(0.99); }

.course-card-cover {
    width: 100%;
    height: 160px;
    object-fit: cover;
    background: var(--coral-light);
}
.course-card-body { padding: 16px; }
.course-card-body h3 {
    font-family: var(--font-hand);
    color: var(--coral);
    font-size: 1.3rem;
    margin-bottom: 6px;
}
.course-card-body p { color: var(--text-mid); font-size: 0.85rem; margin-bottom: 12px; }
.course-card-progress {
    height: 6px;
    background: var(--gray-bg);
    border-radius: 3px;
    overflow: hidden;
}
.course-card-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--coral), var(--mint));
    border-radius: 3px;
    transition: width 0.5s;
}
.course-card-stats {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    color: var(--text-light);
    margin-top: 8px;
}

/* =========== COURSE SECTIONS =========== */
.sections-list {
    padding: 16px;
    max-width: var(--max-width);
    margin: 0 auto;
    width: 100%;
}
.section-block {
    margin-bottom: 16px;
}
.section-header {
    font-family: var(--font-hand);
    font-size: 1.1rem;
    color: var(--coral);
    padding: 12px 0;
    border-bottom: 2px solid var(--coral-light);
    margin-bottom: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.section-header::after { content: '▾'; font-size: 0.8rem; color: var(--text-light); }
.section-header.collapsed::after { content: '▸'; }

.section-lessons { display: flex; flex-direction: column; gap: 4px; }
.section-header.collapsed + .section-lessons { display: none; }

.lesson-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 12px;
    border-radius: var(--radius);
    cursor: pointer;
    transition: background 0.15s;
}
.lesson-item:hover { background: var(--coral-light); }
.lesson-item:active { background: var(--gray-border); }

/* Lesson icon + completion badge */
.lesson-icon-wrap {
    position: relative;
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}
.lesson-icon-placeholder {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 2px solid var(--gray-border);
}
.lesson-done-badge {
    position: absolute;
    bottom: -2px;
    right: -2px;
    width: 16px;
    height: 16px;
    background: var(--mint);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.55rem;
    font-weight: 700;
    color: white;
    border: 2px solid var(--bg-cream);
    line-height: 1;
}
.lesson-item.completed {
    background: rgba(125, 206, 160, 0.08);
}
.lesson-item.completed .lesson-item-title {
    color: var(--text-mid);
}
.lesson-item-title {
    flex: 1;
    font-size: 0.95rem;
    color: var(--text-dark);
}
.lesson-icon {
    width: 28px;
    height: 28px;
    object-fit: contain;
    flex-shrink: 0;
    border-radius: 4px;
}
.lesson-item-time {
    font-size: 0.8rem;
    color: var(--text-light);
}

/* =========== LESSON =========== */
.lesson-content-wrapper {
    flex: 1;
    overflow-y: auto;
    padding: 20px 16px 120px;
    max-width: var(--max-width);
    margin: 0 auto;
    width: 100%;
}
.lesson-title {
    font-family: var(--font-hand);
    font-size: 1.8rem;
    color: var(--coral);
    margin-bottom: 20px;
    line-height: 1.3;
}

/* Audio player */
.audio-player {
    background: var(--gray-bg);
    border-radius: var(--radius);
    padding: 12px 16px;
    margin-bottom: 24px;
}
.audio-label {
    font-size: 0.85rem;
    color: var(--text-mid);
    font-style: italic;
    margin-bottom: 8px;
}
.audio-player audio {
    width: 100%;
    height: 36px;
    border-radius: 8px;
}

/* Lesson body — styled content */
.lesson-body {
    font-size: 1.05rem;
    line-height: 1.8;
    color: var(--text-dark);
}
.lesson-body h2 {
    font-family: var(--font-hand);
    font-size: 1.8rem;
    color: var(--coral);
    margin: 24px 0 6px;
}
.lesson-body h3 {
    font-family: var(--font-hand);
    font-size: 1.2rem;
    color: var(--coral-dark);
    margin: 24px 0 8px;
}
.lesson-body p { margin-bottom: 8px; }
.lesson-body strong { color: var(--text-dark); }
.lesson-body em { color: var(--text-mid); }
.lesson-body a {
    color: var(--mint);
    text-decoration: underline;
    text-decoration-color: rgba(125, 206, 160, 0.3);
    text-underline-offset: 3px;
}
.lesson-body a:hover { text-decoration-color: var(--mint); }

/* Callout blocks */
.lesson-body blockquote {
    background: var(--coral-light);
    border-left: 4px solid var(--coral);
    border-radius: 0 var(--radius) var(--radius) 0;
    padding: 16px 20px;
    margin: 20px 0;
    font-style: italic;
}
.lesson-body ul, .lesson-body ol {
    padding-left: 24px;
    margin-bottom: 16px;
}
.lesson-body li { margin-bottom: 8px; }
.lesson-body li::marker { color: var(--coral); }

/* Icon lists (chapters with icons) */
.lesson-body .icon-list {
    list-style: none;
    padding-left: 0;
}
.lesson-body .icon-list li {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 0;
}
.lesson-body .icon-list li img {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    margin: 0;
    border-radius: 0;
}

/* Figures */
.lesson-body figure {
    margin: 20px 0;
    text-align: center;
}
.lesson-body figure img {
    margin: 0 auto;
}

.lesson-body table {
    width: 100%;
    border-collapse: collapse;
    margin: 20px 0;
    font-size: 0.9rem;
}
.lesson-body th {
    background: var(--coral);
    color: white;
    padding: 10px 12px;
    text-align: left;
}
.lesson-body td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--gray-border);
}
.lesson-body tr:nth-child(even) { background: var(--gray-bg); }

.lesson-body img {
    max-width: 100%;
    border-radius: var(--radius);
    margin: 16px 0;
}

/* Lesson nav */
.lesson-nav {
    display: flex;
    gap: 6px;
    padding: 20px 0;
    flex-wrap: nowrap;
    justify-content: center;
    align-items: stretch;
}
.lesson-nav .btn {
    flex: 1;
    text-align: center;
    white-space: nowrap;
    font-size: 12px;
    padding: 10px 8px;
}
.btn-toc {
    background: #b4d1eb;
    color: white;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
}
.btn-toc:hover { opacity: 0.85; }
.btn-complete-bottom { white-space: nowrap; }

/* Video player */
.video-container {
    margin: 24px 0;
    border-radius: 12px;
    overflow: hidden;
    background: #000;
}
.video-container video {
    width: 100%;
    display: block;
}

/* Collapsible summary */
.collapsible-summary {
    margin: 16px 0;
    border-left: 4px solid #ec8384;
    border-radius: 0 8px 8px 0;
    background: #FDF5EF;
}
.collapsible-summary summary {
    cursor: pointer;
    padding: 12px 16px;
    font-weight: 600;
    color: #555;
    list-style: none;
}
.collapsible-summary summary::before {
    content: '▶ ';
    font-size: 0.8em;
}
.collapsible-summary[open] summary::before {
    content: '▼ ';
}
.collapsible-summary .summary-content {
    padding: 0 16px 16px;
}

/* Lesson actions in header */
.lesson-actions { display: flex; gap: 4px; }
.lesson-actions .btn-icon.active { color: var(--coral); }

/* =========== AI CHAT =========== */
.ai-fab {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--coral);
    color: white;
    font-size: 1.5rem;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(217, 136, 128, 0.4);
    z-index: 200;
    transition: transform 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}
.ai-fab:hover { transform: scale(1.1); }

.ai-chat-overlay {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 0;
    background: var(--bg-white);
    z-index: 300;
    display: flex;
    flex-direction: column;
    transition: height 0.3s ease;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.1);
    overflow: hidden;
}
.ai-chat-overlay.open { height: 70vh; }
@media (max-width: 600px) { .ai-chat-overlay.open { height: 100dvh; border-radius: 0; } }

.ai-chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--gray-border);
}
.ai-chat-header h3 {
    font-family: var(--font-hand);
    color: var(--coral);
    font-size: 1.1rem;
}

.ai-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.ai-msg {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: var(--radius);
    font-size: 0.95rem;
    line-height: 1.5;
    animation: fadeIn 0.2s ease;
}
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.ai-msg.bot {
    background: var(--gray-bg);
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}
.ai-msg.user {
    background: var(--coral);
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}
.ai-msg.loading {
    background: var(--gray-bg);
    align-self: flex-start;
}
.ai-msg.loading::after {
    content: '●●●';
    animation: dots 1.5s infinite;
    letter-spacing: 4px;
}
@keyframes dots {
    0%, 20% { opacity: 0.2; }
    50% { opacity: 1; }
    80%, 100% { opacity: 0.2; }
}

.ai-input-bar {
    display: flex;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid var(--gray-border);
    background: var(--bg-white);
}
.ai-field { border-radius: 24px; padding: 12px 18px; }
.btn-send {
    width: 48px;
    padding: 0;
    border-radius: 50%;
    flex-shrink: 0;
}

/* =========== BOOKMARKS =========== */
.bookmarks-content {
    padding: 16px;
    max-width: var(--max-width);
    margin: 0 auto;
    width: 100%;
}
.bookmark-card {
    background: var(--bg-white);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 12px;
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    transition: transform 0.2s;
}
.bookmark-card:hover { transform: translateY(-1px); }
.bookmark-card h4 { color: var(--coral); font-size: 0.95rem; margin-bottom: 4px; }
.bookmark-card p { color: var(--text-light); font-size: 0.8rem; }

/* =========== LOADING =========== */
.skeleton {
    background: linear-gradient(90deg, var(--gray-bg) 25%, var(--bg-white) 50%, var(--gray-bg) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius);
}
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
.skeleton-text { height: 18px; margin-bottom: 12px; width: 80%; }
.skeleton-title { height: 28px; margin-bottom: 16px; width: 60%; }
.skeleton-block { height: 200px; margin-bottom: 16px; }

/* =========== DESKTOP ADJUSTMENTS =========== */
@media (min-width: 768px) {
    .login-container { padding: 40px; }
    .brand-title { font-size: 3rem; }
    .lesson-content-wrapper { padding: 32px 24px 120px; }
    .lesson-title { font-size: 2.2rem; }
    .lesson-body { font-size: 1.1rem; }
    .otp-digit { width: 56px; height: 64px; font-size: 1.8rem; }
    .ai-chat-overlay.open { 
        height: 500px; 
        width: 400px; 
        left: auto; 
        right: 24px; 
        bottom: 90px;
        border-radius: var(--radius-lg);
    }
    .ai-fab { bottom: 32px; right: 32px; }
    .explain-btn { opacity: 0.6; }
    .explain-btn:hover { opacity: 1; }
}
