/* --- CSS Variables --- */
:root {
    --bg-color: #F7F9FC;       /* Warm off-white background */
    --card-bg: #FFFFFF;
    --text-main: #2D3748;      /* Deep slate for readability */
    --text-muted: #718096;
    --accent: #319795;         /* Calming teal for progress/active states */
    --accent-bg: #E6FFFA;
    --border: #E2E8F0;
    --radius-lg: 16px;
    --shadow-sm: 0 2px 4px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
}

/* --- Resets & Base --- */
* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    -webkit-tap-highlight-color: transparent;
    padding-bottom: 80px; /* Prevent content from hiding behind bottom nav */
}

/* --- Typography & Header --- */
.app-header {
    background-color: var(--card-bg);
    padding: 20px 16px;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 10;
}

.app-header h1 {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.container {
    padding: 16px;
    max-width: 600px; /* Keeps it readable if opened on desktop */
    margin: 0 auto;
}

/* --- Course Cards --- */
.course-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.course-card {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.course-card:active {
    transform: scale(0.98);
}

.course-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 8px;
    line-height: 1.4;
}

.progress-text {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 12px;
}

/* --- Progress Bar --- */
.progress-track {
    width: 100%;
    height: 8px;
    background-color: var(--bg-color);
    border-radius: 4px;
    overflow: hidden;
}

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

/* --- Bottom Navigation --- */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background: var(--card-bg);
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-around;
    padding: 10px 0 calc(10px + env(safe-area-inset-bottom)); /* iOS safe area */
    z-index: 100;
}

.nav-item {
    background: none;
    border: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    color: var(--text-muted);
    cursor: pointer;
    flex: 1;
}

.nav-item svg {
    width: 24px;
    height: 24px;
}

.nav-item span {
    font-size: 0.75rem;
    font-weight: 500;
}

.nav-item.active {
    color: var(--accent);
}

/* --- Modal Styles --- */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-overlay.hidden {
    display: none !important;
}

.modal-card {
    background: var(--card-bg);
    padding: 30px;
    border-radius: var(--radius-lg);
    text-align: center;
    max-width: 90%;
    width: 320px;
    box-shadow: var(--shadow-md);
}

.modal-icon {
    font-size: 3rem;
    margin-bottom: 15px;
}

.btn-primary {
    background: var(--accent);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    font-weight: 600;
    margin-top: 20px;
    cursor: pointer;
    width: 100%;
}

/* --- Course View Specific Styles --- */

/* Header alignment */
.course-header {
    display: flex;
    align-items: center;
    gap: 16px;
}

.icon-btn {
    background: none;
    border: none;
    cursor: pointer;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    color: var(--text-main);
    transition: background-color 0.2s;
}

.icon-btn:hover {
    background-color: var(--border);
}

.icon-btn svg {
    width: 24px;
    height: 24px;
}

.section-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 24px 0 20px;
    line-height: 1.3;
}

/* --- Segmented Tabs --- */
.tabs-container {
    margin-bottom: 24px;
    overflow-x: auto; /* Allows horizontal scroll on very small screens */
    padding-bottom: 4px;
}

.tabs {
    display: flex;
    background-color: var(--border);
    border-radius: var(--radius-lg);
    padding: 4px;
    gap: 4px;
    min-width: max-content; 
}

.tab-btn {
    background: transparent;
    border: none;
    padding: 10px 16px;
    border-radius: calc(var(--radius-lg) - 4px);
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s ease;
    flex: 1;
    text-align: center;
}

.tab-btn.active {
    background-color: var(--card-bg);
    color: var(--accent);
    box-shadow: var(--shadow-sm);
}

/* --- Tab Content Box --- */
.tab-content {
    background: var(--card-bg);
    padding: 24px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    line-height: 1.6;
    font-size: 1.05rem;
    color: var(--text-main);
    margin-bottom: 40px;
}

/* Format the markdown text generated by marked.js */
.markdown-body p { margin-bottom: 1.2em; }
.markdown-body p:last-child { margin-bottom: 0; }
.markdown-body ul, .markdown-body ol { margin-bottom: 1.2em; padding-left: 20px; }
.markdown-body li { margin-bottom: 0.5em; }
.markdown-body strong { font-weight: 700; }

/* --- Course Navigation (Bottom Bar) --- */
.course-nav {
    justify-content: space-between;
    padding: 16px 24px calc(16px + env(safe-area-inset-bottom));
}

.nav-action-btn {
    padding: 12px 24px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    border: none;
    transition: opacity 0.2s, transform 0.1s;
}

.nav-action-btn:active:not(:disabled) {
    transform: scale(0.98);
}

.nav-action-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.nav-action-btn.primary {
    background-color: var(--accent);
    color: white;
}

.nav-action-btn.secondary {
    background-color: var(--border);
    color: var(--text-main);
}
/* --- Interactive Quiz Styles --- */
.quiz-container {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.quiz-question {
    background: var(--bg-color);
    padding: 20px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
}

.quiz-q-text {
    font-size: 1.05rem;
    font-weight: 600;
    margin-bottom: 16px;
    line-height: 1.4;
}

.quiz-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 16px;
}

.quiz-option {
    display: flex;
    align-items: flex-start;
    padding: 12px 16px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

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

.quiz-option input[type="radio"] {
    margin-top: 4px;
    margin-right: 12px;
    transform: scale(1.2);
    accent-color: var(--accent);
    cursor: pointer;
}

.option-text {
    font-size: 0.95rem;
    line-height: 1.4;
}

.btn-check-answer {
    background: var(--border);
    color: var(--text-main);
    border: none;
    padding: 8px 16px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-check-answer:hover {
    background: #cbd5e1;
}

.quiz-feedback {
    margin-top: 16px;
    padding: 12px;
    border-radius: 8px;
    font-size: 0.95rem;
    line-height: 1.4;
}

.quiz-feedback.hidden {
    display: none;
}

.quiz-feedback.success {
    display: block;
    background: #d1fae5;
    color: #065f46;
    border: 1px solid #34d399;
}

.quiz-feedback.error {
    display: block;
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #f87171;
}

.quiz-feedback.warning {
    display: block;
    background: #fef3c7;
    color: #92400e;
    border: 1px solid #fbbf24;
}
