/* CSS Variables for 2025 Modern Theme */
:root {
    --bg-primary: #ffffff;
    --bg-secondary: #fafbfc;
    --bg-tertiary: #f4f6f8;
    --bg-accent: #f0f4ff;
    --text-primary: #0d0d0d;
    --text-secondary: #525252;
    --text-muted: #737373;
    --border-color: #e4e4e7;
    --border-subtle: #f4f4f5;
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-light: #dbeafe;
    --success: #059669;
    --success-light: #d1fae5;
    --error: #dc2626;
    --error-light: #fee2e2;
    --warning: #d97706;
    --warning-light: #fef3c7;
    --info: #0891b2;
    --info-light: #cffafe;
    --action: #ea580c;
    --action-hover: #c2410c;
    --action-light: #fff7ed;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
}

[data-theme="dark"] {
    --bg-primary: #0a0a0a;
    --bg-secondary: #141414;
    --bg-tertiary: #1f1f1f;
    --bg-accent: #1a1f2e;
    --text-primary: #fafafa;
    --text-secondary: #a3a3a3;
    --text-muted: #737373;
    --border-color: #262626;
    --border-subtle: #1f1f1f;
    --primary: #3b82f6;
    --primary-hover: #60a5fa;
    --primary-light: #1e3a8a;
    --success: #10b981;
    --success-light: #064e3b;
    --error: #ef4444;
    --error-light: #7f1d1d;
    --warning: #f59e0b;
    --warning-light: #78350f;
    --info: #06b6d4;
    --info-light: #164e63;
    --action: #f97316;
    --action-hover: #fb923c;
    --action-light: #431407;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.3);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.3), 0 2px 4px -2px rgb(0 0 0 / 0.3);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.3), 0 4px 6px -4px rgb(0 0 0 / 0.3);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.4), 0 8px 10px -6px rgb(0 0 0 / 0.4);
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-secondary);
    color: var(--text-primary);
    line-height: 1.6;
    transition: background-color 0.2s ease, color 0.2s ease;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.container {
    max-width: 1600px;
    margin: 0 auto;
    padding: 0 2rem;
}

/* Header */
header {
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
    padding: 1.25rem 0;
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(10px);
    background: rgba(255, 255, 255, 0.8);
}

[data-theme="dark"] header {
    background: rgba(10, 10, 10, 0.8);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

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

header h1 a {
    color: var(--text-primary);
    text-decoration: none;
    background: linear-gradient(135deg, var(--primary) 0%, #7c3aed 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.header-actions {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.dashboard-nav {
    display: flex;
    gap: 0.5rem;
}

.dashboard-nav a {
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.9rem;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-md);
    transition: all 0.2s ease;
    position: relative;
}

.dashboard-nav a:hover {
    color: var(--primary);
    background: var(--bg-accent);
}

/* Theme Toggle */
.btn-icon {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0.625rem;
    cursor: pointer;
    font-size: 1.25rem;
    transition: all 0.2s ease;
    box-shadow: var(--shadow-sm);
}

.btn-icon:hover {
    background: var(--bg-primary);
    border-color: var(--primary);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

/* Main Content */
main {
    padding: 3rem 0;
    min-height: calc(100vh - 200px);
}

h2 {
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin-bottom: 1.5rem;
    color: var(--text-primary);
}

h3 {
    font-size: 1.25rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    color: var(--text-primary);
}

/* Flash Messages */
.flash-message {
    background: var(--primary);
    color: white;
    padding: 1rem 1.5rem;
    margin-bottom: 1.5rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.flash-message.flash-error {
    background: var(--error);
}

.flash-message.flash-success {
    background: var(--success);
}

.flash-close {
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    float: right;
    opacity: 0.8;
    transition: opacity 0.2s;
}

.flash-close:hover {
    opacity: 1;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.625rem 1rem;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 0.875rem;
    text-decoration: none;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: var(--shadow-sm);
    max-width: 100%;
    text-align: center;
}

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

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: var(--bg-primary);
    border-color: var(--primary);
}

.btn-small {
    padding: 0.375rem 0.75rem;
    font-size: 0.8125rem;
    white-space: nowrap;
}

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

.btn-danger:hover {
    background: #b91c1c;
}

.btn-copy {
    padding: 0.4rem 0.95rem;
    font-size: 0.85rem;
    background: var(--primary-light);
    color: var(--primary);
    border: 1px solid var(--primary);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: 700;
    box-shadow: var(--shadow-sm);
}

.btn-copy:hover {
    background: var(--primary);
    color: white;
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-ghost {
    background: var(--action-light);
    color: var(--action);
    border: 1px solid var(--action);
    padding: 0.3rem 0.55rem;
    font-size: 0.78rem;
    font-weight: 600;
    border-radius: var(--radius-sm);
    transition: all 0.2s ease;
}

.btn-ghost:hover {
    background: var(--action);
    color: white;
    border-color: var(--action-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

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

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2.5rem;
}

.stat-card {
    background: linear-gradient(135deg, var(--bg-primary) 0%, var(--bg-tertiary) 100%);
    padding: 2rem;
    border-radius: var(--radius-xl);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-md);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--primary), #7c3aed);
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-xl);
}

.stat-card h3, .stat-card h4 {
    font-size: 2.5rem;
    background: linear-gradient(135deg, var(--primary) 0%, #7c3aed 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 0.5rem;
    font-weight: 800;
}

.stat-card p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
}

.stat-card small {
    color: var(--text-muted);
    font-size: 0.8125rem;
}

/* Sections */
.section {
    background: var(--bg-primary);
    padding: 2rem;
    border-radius: var(--radius-xl);
    border: 1px solid var(--border-color);
    margin-bottom: 2.5rem;
    box-shadow: var(--shadow-md);
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid var(--border-subtle);
}

.section-actions {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

/* Tables */
.data-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.875rem;
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.data-table th {
    background: var(--bg-tertiary);
    padding: 0.75rem 0.9rem;
    text-align: left;
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.8125rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.data-table td {
    padding: 0.65rem 0.7rem;
    border-bottom: 1px solid var(--border-subtle);
}

.data-table tr {
    transition: background 0.2s ease;
}

.data-table tbody tr:hover {
    background: var(--bg-accent);
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

.archived-row {
    opacity: 0.5;
}

.table-responsive {
    width: 100%;
    overflow-x: auto;
    overflow-y: visible;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    background: var(--bg-primary);
    box-shadow: var(--shadow-sm);
    padding-bottom: 1rem;
}

.table-responsive .data-table {
    min-width: 720px;
}

.roster-table {
    table-layout: fixed;
    font-size: 0.82rem;
}

.roster-table th {
    white-space: normal;
    word-break: keep-all;
    line-height: 1.3;
    font-size: 0.85rem;
}

.roster-table td {
    white-space: normal;
    word-break: break-word;
}

.roster-table .action-buttons {
    min-width: 200px;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    align-items: stretch;
}

.roster-table .select-small {
    min-width: 0;
    width: 100%;
}

.nowrap {
    white-space: nowrap;
}

.date-text {
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.01em;
    display: inline-block;
    white-space: nowrap;
}

.wrap {
    white-space: normal;
    word-break: break-word;
}

.actions-cell {
    position: relative;
    padding-right: 1.5rem !important;
    min-width: 140px;
}

.action-menu {
    position: relative;
    display: inline-block;
}

.action-menu-toggle {
    min-width: 110px;
    background: var(--action-light);
    color: var(--action);
    border: 1px solid var(--action);
    box-shadow: var(--shadow-sm);
    border-radius: var(--radius-md);
    padding: 0.375rem 0.625rem;
    font-size: 0.8125rem;
    font-weight: 600;
    white-space: nowrap;
    transition: all 0.2s ease;
}

.action-menu-toggle:hover {
    background: var(--action);
    color: white;
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.action-menu-dropdown {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    padding: 0.625rem;
    min-width: 160px;
    width: max-content;
    max-width: 200px;
    display: none;
    z-index: 100;
    overflow: visible;
}

.action-menu-dropdown.floating {
    position: fixed;
    left: auto;
    right: auto;
}

.action-menu-dropdown.open-up {
    top: auto;
    bottom: calc(100% + 6px);
}

.action-menu-dropdown.open {
    display: grid;
    gap: 0.5rem;
}

.action-menu-dropdown form {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    width: 100%;
}

.action-menu-dropdown .btn-small {
    width: 100%;
    justify-content: center;
    border: 1px solid var(--border-color);
    white-space: nowrap;
    padding: 0.5rem 0.75rem;
    font-size: 0.8125rem;
    overflow: visible;
    text-overflow: clip;
}

.action-menu-row {
    flex-direction: column;
    align-items: stretch;
}

.action-menu-row .select-small {
    width: 100%;
}

.lesson-cell {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    position: relative;
    padding-right: 1.5rem !important;
    min-width: 200px;
}

.lesson-toggle {
    align-self: flex-start;
    min-width: auto;
}

.lesson-title {
    font-weight: 600;
}

.lesson-edit-panel {
    display: none;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-secondary);
    box-shadow: var(--shadow-sm);
    gap: 0.5rem;
    position: absolute;
    z-index: 20;
    margin-top: 6px;
    min-width: 220px;
    max-width: 320px;
}

.lesson-edit-panel.open {
    display: grid;
}

.lesson-edit-panel.floating {
    position: fixed;
    left: auto;
    right: auto;
    margin-top: 0;
}

.lesson-edit-panel form {
    display: grid;
    gap: 0.5rem;
}

.lesson-edit-panel label {
    font-size: 0.82rem;
    color: var(--text-secondary);
}
/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.375rem 0.875rem;
    border-radius: var(--radius-md);
    font-size: 0.8125rem;
    font-weight: 600;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.badge-success {
    background: var(--success-light);
    color: var(--success);
    border-color: var(--success);
}

.badge-error {
    background: var(--error-light);
    color: var(--error);
    border-color: var(--error);
}

.badge-warning {
    background: var(--warning-light);
    color: var(--warning);
    border-color: var(--warning);
}

.badge-info {
    background: var(--info-light);
    color: var(--info);
    border-color: var(--info);
}

/* Learner Card */
.learner-card {
    background: var(--bg-primary);
    border-radius: var(--radius-xl);
    padding: 2.5rem;
    max-width: 850px;
    margin: 2rem auto;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-xl);
    overflow-x: hidden;
}

.lesson-header {
    margin-bottom: 2.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 2px solid var(--border-subtle);
}

.lesson-badge {
    display: inline-block;
    padding: 0.5rem 1.25rem;
    border-radius: var(--radius-lg);
    font-size: 0.875rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary) 0%, #7c3aed 100%);
    color: white;
    margin-bottom: 1rem;
    box-shadow: var(--shadow-md);
}

.lesson-badge.success {
    background: linear-gradient(135deg, var(--success) 0%, #059669 100%);
}

.lesson-badge.correct {
    background: linear-gradient(135deg, #10b981 0%, #047857 100%);
}

.lesson-badge.incorrect {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
}

.question-text {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 2rem;
    line-height: 1.5;
}

.options-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 2rem;
}

.option-item {
    display: block;
    padding: 1.25rem;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all 0.2s ease;
    background: var(--bg-primary);
}

.option-item:hover {
    border-color: var(--primary);
    background: var(--bg-accent);
    transform: translateX(4px);
}

.option-item:has(input:checked) {
    border-color: var(--primary);
    background: var(--primary-light);
    box-shadow: var(--shadow-md);
}

.option-item input {
    margin-right: 1rem;
    accent-color: var(--primary);
}

.option-label {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 500;
}

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

/* Forms */
.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.625rem;
    color: var(--text-primary);
    font-size: 0.9rem;
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-primary);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.9375rem;
    transition: all 0.2s ease;
}

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

.form-group small {
    color: var(--text-muted);
    font-size: 0.8125rem;
    margin-top: 0.375rem;
    display: block;
}

.form-actions {
    display: flex;
    gap: 1rem;
    margin-top: 2rem;
    width: 100%;
    max-width: 100%;
}

.form-actions .btn {
    flex: 1;
    min-width: 0;
}

/* Microlearning */
.video-container {
    position: relative;
    padding-bottom: 56.25%;
    height: 0;
    overflow: hidden;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
}

.video-container iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.text-content {
    padding: 2rem;
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    border-left: 4px solid var(--primary);
}

.summary-box {
    margin-top: 2rem;
    padding: 1.5rem;
    background: var(--bg-accent);
    border-left: 4px solid var(--primary);
    border-radius: var(--radius-md);
}

.summary-box h4 {
    margin-bottom: 0.5rem;
    color: var(--primary);
}

.attempts-summary {
    margin-top: 2rem;
}

.attempt-item {
    display: flex;
    justify-content: space-between;
    padding: 1rem;
    margin-bottom: 0.75rem;
    border-radius: var(--radius-md);
    background: var(--bg-secondary);
    border-left: 4px solid transparent;
}

.attempt-item.correct {
    border-left-color: var(--success);
    background: var(--success-light);
}

.attempt-item.incorrect {
    border-left-color: var(--error);
    background: var(--error-light);
}

/* Lessons Grid */
.lessons-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1.5rem;
}

.lesson-card {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    padding: 1.75rem;
    cursor: grab;
    transition: all 0.3s ease;
    box-shadow: var(--shadow-md);
}

.lesson-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-xl);
    border-color: var(--primary);
}

.lesson-card:active {
    cursor: grabbing;
}

.lesson-order {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    background: linear-gradient(135deg, var(--primary) 0%, #7c3aed 100%);
    color: white;
    border-radius: 50%;
    text-align: center;
    font-weight: 700;
    margin-bottom: 1rem;
    box-shadow: var(--shadow-md);
}

.lesson-preview {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin: 1rem 0;
    line-height: 1.6;
}

.lesson-meta {
    display: flex;
    gap: 0.625rem;
    margin: 1rem 0;
}

.lesson-actions {
    display: flex;
    gap: 0.625rem;
    margin-top: 1.25rem;
}

/* Charts */
.charts-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(450px, 1fr));
    gap: 2rem;
    margin-bottom: 2.5rem;
}

.chart-container {
    background: var(--bg-primary);
    padding: 2rem;
    border-radius: var(--radius-xl);
    border: 1px solid var(--border-color);
    height: 450px;
    box-shadow: var(--shadow-md);
}

.chart-container h3 {
    margin-bottom: 1.5rem;
}

.chart-container canvas {
    max-height: 340px;
}

/* Filters */
.filters-form {
    display: flex;
    gap: 1rem;
    margin-bottom: 2.5rem;
    flex-wrap: wrap;
    background: var(--bg-primary);
    padding: 1.5rem;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}

.filter-group label {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.filter-group input,
.filter-group select {
    padding: 0.625rem 1rem;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 0.9375rem;
    transition: all 0.2s;
}

.filter-group input:focus,
.filter-group select:focus {
    border-color: var(--primary);
    outline: none;
}

/* Alerts */
.alert {
    padding: 1.25rem 1.5rem;
    border-radius: var(--radius-lg);
    margin-bottom: 1.5rem;
    border-left: 4px solid;
}

.alert-info {
    background: var(--info-light);
    border-color: var(--info);
    color: var(--text-primary);
}

.alert-warning {
    background: var(--warning-light);
    border-color: var(--warning);
    color: var(--text-primary);
}

/* Footer */
footer {
    background: var(--bg-primary);
    border-top: 1px solid var(--border-color);
    padding: 3rem 0;
    margin-top: 5rem;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* Utility Classes */
.text-muted {
    color: var(--text-muted);
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.section, .stat-card, .lesson-card {
    animation: fadeIn 0.4s ease;
}

/* Responsive */
@media (max-width: 768px) {
    .container {
        padding: 0 1rem;
    }

    .dashboard-nav {
        flex-direction: column;
        gap: 0.375rem;
    }

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

    .charts-row {
        grid-template-columns: 1fr;
    }

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

    .filters-form {
        flex-direction: column;
    }

    .learner-card {
        padding: 2rem 1.5rem;
    }

    h2 {
        font-size: 1.75rem;
    }
}

@media (max-width: 1024px) {
    .section-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }

    .section-actions {
        width: 100%;
        justify-content: space-between;
        flex-wrap: wrap;
    }

    .action-buttons {
        width: max-content;
    }
}

@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }

    .dashboard-nav {
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .dashboard-nav a {
        white-space: nowrap;
    }

    .section {
        padding: 1.5rem;
    }

    .data-table, .data-table thead, .data-table tbody, .data-table th, .data-table td, .data-table tr {
        display: block;
    }

    .data-table thead {
        display: none;
    }

    .data-table tr {
        margin-bottom: 1rem;
        border: 1px solid var(--border-subtle);
        border-radius: var(--radius-md);
        overflow: hidden;
    }

    .data-table td {
        padding: 0.75rem 1rem;
        border-bottom: 1px solid var(--border-subtle);
    }

    .data-table td:last-child {
        border-bottom: none;
    }

    .data-table td::before {
        content: attr(data-label);
        display: block;
        font-weight: 700;
        color: var(--text-secondary);
        margin-bottom: 0.35rem;
        font-size: 0.8rem;
        letter-spacing: 0.02em;
    }

    .action-buttons {
        flex-direction: column;
        align-items: stretch;
    }

    .action-buttons form {
        width: 100%;
    }

    .btn-small, .btn-danger, .select-small {
        width: 100%;
    }

    .learner-card {
        margin: 1rem auto;
        padding: 1.5rem 1rem;
    }

    .question-text {
        font-size: 1.1rem;
    }

    .option-item {
        padding: 1rem;
    }

    .form-actions {
        flex-direction: column;
    }

    .form-actions .btn {
        width: 100%;
        justify-content: center;
        font-size: 0.8125rem;
        padding: 0.75rem 0.875rem;
    }
}

@media (max-width: 560px) {
    .container {
        padding: 0 0.75rem;
    }

    .header-actions {
        width: 100%;
        justify-content: space-between;
    }

    .learner-card {
        box-shadow: var(--shadow-md);
    }

    .option-label {
        align-items: flex-start;
    }

    .lesson-badge {
        width: 100%;
        text-align: center;
    }
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary);
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    pointer-events: none;
}

.toast {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1rem 1.25rem;
    box-shadow: var(--shadow-xl);
    display: flex;
    align-items: center;
    gap: 0.875rem;
    min-width: 320px;
    max-width: 450px;
    pointer-events: auto;
    opacity: 0;
    transform: translateX(400px);
    transition: all 0.3s ease;
}

.toast-show {
    opacity: 1;
    transform: translateX(0);
}

.toast-hide {
    opacity: 0;
    transform: translateX(400px);
}

.toast-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    font-weight: 700;
    font-size: 1.125rem;
}

.toast-message {
    flex: 1;
    color: var(--text-primary);
    font-weight: 500;
}

.toast-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    transition: color 0.2s;
}

.toast-close:hover {
    color: var(--text-primary);
}

.toast-success {
    border-left: 4px solid var(--success);
}

.toast-success .toast-icon {
    background: var(--success-light);
    color: var(--success);
}

.toast-error {
    border-left: 4px solid var(--error);
}

.toast-error .toast-icon {
    background: var(--error-light);
    color: var(--error);
}

.toast-warning {
    border-left: 4px solid var(--warning);
}

.toast-warning .toast-icon {
    background: var(--warning-light);
    color: var(--warning);
}

.toast-info {
    border-left: 4px solid var(--info);
}

.toast-info .toast-icon {
    background: var(--info-light);
    color: var(--info);
}

/* Loading Spinner */
.spinner {
    display: inline-block;
    width: 1rem;
    height: 1rem;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.btn-loading {
    opacity: 0.7;
    cursor: not-allowed;
}

.btn-loading .spinner {
    margin-right: 0.5rem;
}

/* Skeleton Loaders */
.skeleton-row td {
    padding: 1rem;
}

.skeleton-line {
    height: 1rem;
    background: linear-gradient(
        90deg,
        var(--bg-tertiary) 0%,
        var(--bg-secondary) 50%,
        var(--bg-tertiary) 100%
    );
    background-size: 200% 100%;
    border-radius: var(--radius-sm);
    animation: shimmer 1.5s ease-in-out infinite;
}

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

/* Page Transitions */
body {
    transition: opacity 0.2s ease;
}

.page-transitioning {
    opacity: 0.7;
}

.page-load-progress {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: linear-gradient(90deg, var(--primary), #7c3aed);
    transform-origin: left;
    animation: progressBar 1s ease-in-out forwards;
    z-index: 9999;
}

@keyframes progressBar {
    0% {
        transform: scaleX(0);
    }
    50% {
        transform: scaleX(0.7);
    }
    100% {
        transform: scaleX(1);
    }
}

/* Action Buttons */
.action-buttons {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.select-small {
    padding: 0.375rem 0.625rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 0.8125rem;
    cursor: pointer;
    transition: all 0.2s;
}

.select-small:focus {
    outline: none;
    border-color: var(--primary);
}

.select-small:hover {
    border-color: var(--primary);
}

/* Automation Info */
.automation-info {
    padding: 1.5rem;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
}

.automation-info p {
    margin-bottom: 0.75rem;
    color: var(--text-secondary);
}

.automation-info p:last-child {
    margin-bottom: 0;
}

/* Mobile Toast Adjustments */
@media (max-width: 768px) {
    .toast-container {
        left: 1rem;
        right: 1rem;
    }

    .toast {
        min-width: auto;
        max-width: 100%;
    }

    .toast-show {
        transform: translateY(0);
    }

    .toast {
        transform: translateY(-100px);
    }

    .toast-hide {
        transform: translateY(-100px);
    }
}

/* Help/Support Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 10000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.modal.show {
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 1;
}

.modal-content {
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    transform: scale(0.9);
    transition: transform 0.3s ease;
}

.modal.show .modal-content {
    transform: scale(1);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h2 {
    margin: 0;
    font-size: 1.5rem;
    color: var(--text-primary);
}

.modal-close {
    background: none;
    border: none;
    font-size: 2rem;
    line-height: 1;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 0;
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    transition: all 0.2s;
}

.modal-close:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.modal-body {
    padding: 1.5rem;
}

.modal-body p {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
}

.contact-info {
    margin-bottom: 1.5rem;
}

.contact-info h3 {
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    margin-top: 1rem;
}

.contact-info p {
    margin-bottom: 0;
    font-size: 1rem;
    color: var(--text-primary);
}

.contact-info a {
    color: var(--primary);
    text-decoration: none;
}

.contact-info a:hover {
    text-decoration: underline;
}

.tips-section {
    background: var(--bg-secondary);
    padding: 1rem;
    border-radius: var(--radius-md);
}

.tips-section h3 {
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
}

.tips-section ul {
    margin: 0;
    padding-left: 1.25rem;
    color: var(--text-secondary);
}

.tips-section li {
    margin-bottom: 0.5rem;
}

.tips-section li:last-child {
    margin-bottom: 0;
}

/* ===================================================================
   LESSON RESTRUCTURING STYLES
   ================================================================ */

/* Scenario Section */
.scenario-section {
    background: var(--bg-accent);
    border-left: 4px solid var(--primary);
    padding: 1.25rem;
    margin-bottom: 1.5rem;
    border-radius: var(--radius-md);
}

.scenario-section h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--primary);
    margin-bottom: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.scenario-text {
    color: var(--text-primary);
    line-height: 1.7;
    white-space: pre-wrap;
}

/* Question Header */
.question-header h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--primary);
    margin-bottom: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

/* Rationale with preserved whitespace */
.rationale-section {
    margin-bottom: 2rem;
}

.rationale-section h4 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

.rationale-text {
    white-space: pre-wrap;
    word-wrap: break-word;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 1rem;
    line-height: 1.7;
    color: var(--text-primary);
    background: var(--bg-tertiary);
    padding: 1.25rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    margin: 0;
}

/* References Section */
.references-section {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 2px solid var(--border-color);
}

.references-section h4 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.75rem;
}

.references-content {
    color: var(--text-secondary);
    line-height: 1.7;
    white-space: pre-wrap;
}

/* Video Section */
.video-section {
    margin: 2rem 0;
}

.video-section h4 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

/* Content Type Badge */
.content-type-badge {
    display: inline-block;
    font-size: 0.75rem;
    font-weight: 500;
    padding: 0.25rem 0.75rem;
    background: var(--primary-light);
    color: var(--primary);
    border-radius: var(--radius-sm);
    margin-left: 0.5rem;
    vertical-align: middle;
}

/* Form field visibility */
.form-group.video-field {
    transition: opacity 0.2s ease;
}

/* Attempt indicator - small grey text above title */
.attempt-indicator {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin: 0 0 0.25rem 0;
    font-weight: 400;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
