/* Premium learner theme */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

:root {
    --bg-canvas: #060816;
    --bg-canvas-2: #0b1120;
    --surface: rgba(10, 14, 28, 0.84);
    --surface-strong: rgba(9, 13, 24, 0.94);
    --surface-soft: rgba(15, 23, 42, 0.6);
    --border-subtle: rgba(148, 163, 184, 0.18);
    --border-strong: rgba(94, 230, 255, 0.34);
    --text-primary: #f8fbff;
    --text-secondary: #d6e1f0;
    --text-muted: #93a4bc;
    --brand-primary: #5ee6ff;
    --brand-primary-strong: #1fb6ff;
    --brand-secondary: #8b7cff;
    --brand-warm: #f59e0b;
    --success: #34d399;
    --danger: #fb7185;
    --learning-state-track: #22c55e;
    --learning-state-soon: #f59e0b;
    --learning-state-urgent: #ef4444;
    --learning-state-empty: #64748b;
    --radius-lg: 20px;
    --radius-md: 14px;
    --shadow-soft: 0 20px 45px rgba(2, 6, 23, 0.42);
    --shadow-glow: 0 10px 30px rgba(31, 182, 255, 0.18);
}

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

html {
    color-scheme: dark;
}

img,
video,
iframe {
    max-width: 100%;
}

/* Improve touch target sizes and mobile interaction */
@media (hover: none) and (pointer: coarse) {
    /* Touch device specific styles */
    button, input[type="file"], input[type="url"] {
        min-height: 44px; /* Apple's recommended touch target */
    }
    
    button:active {
        transform: scale(0.98);
    }
}

body {
    font-family: 'Inter', 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
    line-height: 1.6;
    color: var(--text-secondary);
    background:
        radial-gradient(circle at top left, rgba(94, 230, 255, 0.14) 0%, transparent 34%),
        radial-gradient(circle at 82% 18%, rgba(139, 124, 255, 0.16) 0%, transparent 30%),
        linear-gradient(180deg, var(--bg-canvas) 0%, var(--bg-canvas-2) 100%);
    min-height: 100vh;
    overflow-x: hidden;
    letter-spacing: -0.01em;
}

::selection {
    background: rgba(94, 230, 255, 0.3);
    color: var(--text-primary);
}

.skip-link {
    position: absolute;
    left: -9999px;
    top: 0;
    z-index: 10000;
    padding: 10px 14px;
    border-radius: 8px;
    background: #00D4FF;
    color: #04131a;
    font-weight: 700;
    text-decoration: none;
}

.skip-link:focus,
.skip-link:focus-visible {
    left: 12px;
    top: 12px;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[role="button"]:focus-visible {
    outline: 3px solid #00D4FF;
    outline-offset: 2px;
    box-shadow: 0 0 0 2px rgba(10, 10, 15, 0.95);
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2.5rem;
    background: var(--surface-strong);
    backdrop-filter: blur(20px);
    border-radius: 24px;
    border: 1px solid var(--border-subtle);
    box-shadow: var(--shadow-soft), var(--shadow-glow), inset 0 1px 0 rgba(255, 255, 255, 0.06);
    margin-top: 2rem;
    margin-bottom: 2rem;
    position: relative;
}

h1 {
    text-align: center;
    margin-bottom: 2rem;
    color: var(--text-primary);
    font-size: 3rem;
    font-weight: 800;
    letter-spacing: -0.04em;
    background: linear-gradient(135deg, var(--text-primary) 0%, var(--brand-primary) 55%, var(--brand-secondary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: 0 0 30px rgba(94, 230, 255, 0.22);
}

h2 {
    color: var(--text-primary);
    margin-bottom: 1.5rem;
    border-bottom: 1px solid rgba(94, 230, 255, 0.22);
    padding-bottom: 0.75rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.section-kicker {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.35rem 0.7rem;
    border-radius: 999px;
    background: rgba(94, 230, 255, 0.12);
    border: 1px solid rgba(94, 230, 255, 0.24);
    color: var(--brand-primary);
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.surface-card {
    background: linear-gradient(180deg, rgba(10, 14, 28, 0.92) 0%, rgba(8, 11, 20, 0.98) 100%);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-soft);
}

.dashboard-rail {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 0.9rem;
}

.stat-chip {
    padding: 1rem 1.1rem;
    border-radius: var(--radius-md);
    background: rgba(15, 23, 42, 0.72);
    border: 1px solid rgba(148, 163, 184, 0.18);
}

.stat-chip strong {
    display: block;
    font-size: 1rem;
    color: var(--text-primary);
}

.stat-chip span {
    display: block;
    margin-top: 0.25rem;
    color: var(--text-muted);
    font-size: 0.86rem;
}

.learning-state-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    padding: 0.22rem 0.56rem;
    border: 1px solid transparent;
    font-size: 0.72rem;
    letter-spacing: 0.04em;
    font-weight: 700;
    text-transform: uppercase;
}

.learning-state-chip.on-track {
    color: #bbf7d0;
    background: rgba(22, 163, 74, 0.16);
    border-color: rgba(22, 163, 74, 0.4);
}

.learning-state-chip.due-soon {
    color: #fde68a;
    background: rgba(245, 158, 11, 0.14);
    border-color: rgba(245, 158, 11, 0.38);
}

.learning-state-chip.urgent {
    color: #fecaca;
    background: rgba(239, 68, 68, 0.15);
    border-color: rgba(239, 68, 68, 0.4);
}

.learning-state-chip.empty {
    color: #dbe4f1;
    background: rgba(100, 116, 139, 0.16);
    border-color: rgba(100, 116, 139, 0.38);
}

.learning-progress-track {
    width: 100%;
    height: 8px;
    border-radius: 999px;
    background: rgba(148, 163, 184, 0.2);
    overflow: hidden;
}

.learning-progress-fill {
    height: 100%;
    border-radius: inherit;
}

.learning-progress-fill.on-track {
    background: linear-gradient(90deg, #15803d, #22c55e);
}

.learning-progress-fill.due-soon {
    background: linear-gradient(90deg, #d97706, #f59e0b);
}

.learning-progress-fill.urgent {
    background: linear-gradient(90deg, #dc2626, #ef4444);
}

.learning-progress-fill.empty {
    background: linear-gradient(90deg, #64748b, #94a3b8);
}

.section-heading-row {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
}

.section-heading-row .subject-title {
    padding-left: 0;
    margin-bottom: 0;
}

.upload-section {
    margin-bottom: 2rem;
}

.upload-option {
    background: rgba(5, 5, 10, 0.8);
    backdrop-filter: blur(10px);
    padding: 2rem;
    border-radius: 16px;
    margin-bottom: 1.5rem;
    border: 1px solid rgba(0, 191, 255, 0.2);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.upload-option::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, rgba(0, 191, 255, 0.1) 0%, rgba(30, 144, 255, 0.1) 100%);
    opacity: 0;
    transition: opacity 0.4s ease;
    pointer-events: none;
}

.upload-option:hover {
    border-color: rgba(0, 191, 255, 0.6);
    transform: translateY(-4px);
    box-shadow: 
        0 20px 40px rgba(0, 0, 0, 0.5),
        0 8px 16px rgba(0, 191, 255, 0.3);
}

.upload-option:hover::before {
    opacity: 1;
}

.upload-option h3 {
    margin-bottom: 1rem;
    color: #ffffff;
    font-weight: 600;
    position: relative;
    z-index: 1;
}

form {
    display: flex;
    gap: 1rem;
    align-items: center;
    flex-wrap: wrap;
}

input[type="file"], input[type="url"] {
    flex: 1;
    padding: 1rem 1.25rem;
    background: rgba(10, 10, 15, 0.9);
    border: 1px solid rgba(0, 191, 255, 0.3);
    border-radius: 12px;
    font-size: 1rem;
    min-width: 250px;
    color: #e2e8f0;
    backdrop-filter: blur(10px);
    transition: all 0.3s ease;
    font-family: 'Inter', sans-serif;
}

input[type="file"]:focus, input[type="url"]:focus {
    outline: none;
    border-color: rgba(0, 191, 255, 0.8);
    box-shadow: 0 0 0 3px rgba(0, 191, 255, 0.2);
    background: rgba(15, 15, 20, 0.95);
}

input[type="file"]::placeholder, input[type="url"]::placeholder {
    color: rgba(255, 255, 255, 0.6);
}

button {
    background: linear-gradient(135deg, var(--brand-primary) 0%, var(--brand-primary-strong) 56%, var(--brand-secondary) 100%);
    color: #04131a;
    padding: 1rem 2rem;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 700;
    font-family: 'Inter', sans-serif;
    transition: transform 0.25s ease, box-shadow 0.25s ease, opacity 0.25s ease;
    position: relative;
    overflow: hidden;
    backdrop-filter: blur(10px);
    box-shadow: 0 10px 28px rgba(31, 182, 255, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.28);
}

button::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(120deg, transparent 15%, rgba(255, 255, 255, 0.18) 50%, transparent 85%);
    transform: translateX(-120%);
    transition: transform 0.6s ease;
}

button:hover {
    transform: translateY(-2px);
    box-shadow: 0 18px 34px rgba(31, 182, 255, 0.28), 0 8px 16px rgba(6, 8, 22, 0.28);
}

button:hover::before {
    transform: translateX(120%);
}

button:active {
    transform: translateY(0);
}

button:disabled {
    background: rgba(160, 174, 192, 0.3);
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
    opacity: 0.6;
}

.status {
    padding: 1.25rem;
    border-radius: 12px;
    margin-top: 1rem;
    text-align: center;
    font-weight: 600;
    display: none;
    backdrop-filter: blur(10px);
    position: relative;
    overflow: hidden;
}

.status.success {
    background: rgba(72, 187, 120, 0.2);
    color: #68d391;
    border: 1px solid rgba(72, 187, 120, 0.3);
    box-shadow: 0 8px 24px rgba(72, 187, 120, 0.2);
}

.status.error {
    background: rgba(245, 101, 101, 0.2);
    color: #fc8181;
    border: 1px solid rgba(245, 101, 101, 0.3);
    box-shadow: 0 8px 24px rgba(245, 101, 101, 0.2);
}

.status.loading {
    background: rgba(0, 191, 255, 0.2);
    color: #00bfff;
    border: 1px solid rgba(0, 191, 255, 0.3);
    box-shadow: 0 8px 24px rgba(0, 191, 255, 0.2);
}

/* Enhanced Loading animation with glow effect */
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes glow {
    0%, 100% { box-shadow: 0 0 20px rgba(0, 191, 255, 0.5); }
    50% { box-shadow: 0 0 40px rgba(0, 191, 255, 0.8), 0 0 60px rgba(0, 191, 255, 0.6); }
}

.loading::after {
    content: '';
    display: inline-block;
    width: 20px;
    height: 20px;
    margin-left: 12px;
    border: 3px solid transparent;
    border-top: 3px solid #00bfff;
    border-radius: 50%;
    animation: spin 1s linear infinite, glow 2s ease-in-out infinite;
}

/* Responsive design with enhanced dark theme */
@media (max-width: 1024px) {
    .container {
        max-width: 95%;
        margin: 1rem auto;
        padding: 2rem;
        border-radius: 20px;
    }
    
    h1 {
        font-size: 2.5rem;
    }
}

@media (max-width: 768px) {
    body {
        padding: 0.5rem;
        padding-bottom: calc(0.5rem + env(safe-area-inset-bottom, 0px));
    }

    .section-heading-row {
        flex-direction: column;
        align-items: flex-start;
    }

    .dashboard-rail,
    .hero-stats,
    .quick-action-strip,
    .curriculum-summary-strip {
        grid-template-columns: 1fr;
    }
    
    .container {
        margin: 0.5rem;
        padding: 1.5rem;
        border-radius: 16px;
        margin-top: 0.5rem;
        margin-bottom: 0.5rem;
    }
    
    h1 {
        font-size: 2.25rem;
        margin-bottom: 1.5rem;
    }
    
    h2 {
        font-size: 1.5rem;
    }
    
    .upload-option {
        padding: 1.5rem;
        margin-bottom: 1rem;
        border-radius: 12px;
    }
    
    form {
        flex-direction: column;
        gap: 1rem;
    }

    form > * {
        width: 100%;
    }
    
    input[type="file"], input[type="url"] {
        min-width: auto;
        width: 100%;
        padding: 1rem;
        font-size: 1rem;
        border-radius: 10px;
    }
    
    button {
        width: 100%;
        padding: 1.125rem 1rem;
        font-size: 1rem;
        border-radius: 10px;
    }

    .btn-media {
        width: 100% !important;
        margin-right: 0 !important;
    }

    .text-source-item {
        padding: 16px;
    }

    .text-source-title,
    .exercise-label {
        overflow-wrap: anywhere;
    }

    .exercise-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        justify-content: stretch;
    }

    .exercise-card {
        width: 100%;
        min-height: 108px;
        height: auto;
    }

    .classes-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 12px;
        justify-content: stretch;
    }
}

@media (max-width: 480px) {
    .container {
        margin: 0.25rem;
        padding: 1.25rem;
        border-radius: 14px;
    }
    
    h1 {
        font-size: 2rem;
        margin-bottom: 1rem;
    }
    
    .upload-option {
        padding: 1.25rem;
        border-radius: 10px;
    }
    
    .upload-option h3 {
        font-size: 1.1rem;
    }
    
    input[type="file"], input[type="url"] {
        padding: 0.875rem;
        font-size: 0.95rem;
        border-radius: 8px;
    }
    
    button {
        padding: 0.875rem;
        font-size: 0.95rem;
        border-radius: 8px;
    }
    
    .status {
        font-size: 0.9rem;
        padding: 1rem;
        border-radius: 10px;
    }

    .exercise-grid,
    .classes-grid {
        gap: 10px;
    }

    .exercise-card {
        min-height: 100px;
        padding: 0.75rem;
    }

    .text-source-item {
        padding: 14px;
        border-radius: 10px;
    }

    .text-source-title {
        font-size: 1rem;
    }

    .text-source-meta {
        line-height: 1.5;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

@media (max-width: 360px) {
    .container {
        margin: 0.1rem;
        padding: 1rem;
        border-radius: 12px;
    }
    
    h1 {
        font-size: 1.75rem;
    }
    
    .upload-option h3 {
        font-size: 1rem;
    }
}

/* Additional HBO Max-style enhancements */
.container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(0, 191, 255, 0.8), transparent);
}

/* Scrollbar styling for webkit browsers */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: rgba(20, 20, 35, 0.5);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, #00bfff, #1e90ff);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, #1ebfff, #00bfff);
}

/* Video-specific styles */
.btn-media {
    background: linear-gradient(135deg, #e53e3e, #ff6b6b) !important;
    color: white !important;
    border: none !important;
    padding: 8px 16px !important;
    border-radius: 6px !important;
    cursor: pointer !important;
    font-size: 14px !important;
    font-weight: 500 !important;
    transition: all 0.2s ease !important;
    margin-right: 8px !important;
    margin-bottom: 6px !important;
}

.btn-media:hover {
    background: linear-gradient(135deg, #c53030, #e53e3e) !important;
    transform: translateY(-1px) !important;
    box-shadow: 0 4px 12px rgba(229, 62, 62, 0.3) !important;
}

.text-source-item {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 16px;
    transition: all 0.2s ease;
}

.text-source-item:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
}

.text-source-title {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 8px;
    color: #ffffff;
}

.text-source-meta {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.6);
    margin-bottom: 15px;
}

/* Video form styles */
#youtubeSourceForm, #videoFileSourceForm {
    animation: fadeInUp 0.3s ease;
}

#youtubeUrl, #youtubeTitle, #videoFileInput, #videoFileTitle {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    padding: 12px;
    color: #ffffff;
    width: 100%;
    font-size: 14px;
    transition: all 0.2s ease;
}

#youtubeUrl:focus, #youtubeTitle:focus, 
#videoFileInput:focus, #videoFileTitle:focus {
    outline: none;
    border-color: #00bfff;
    background: rgba(0, 191, 255, 0.15);
    box-shadow: 0 0 0 3px rgba(0, 191, 255, 0.2);
}

/* Media exercise card enhanced styling */
#mediaCard {
    background: linear-gradient(135deg, rgba(229, 62, 62, 0.1), rgba(255, 107, 107, 0.05));
    border-color: rgba(229, 62, 62, 0.3);
}

#mediaCard .exercise-icon {
    font-size: 2.5rem;
    text-shadow: 0 2px 4px rgba(229, 62, 62, 0.3);
}

#mediaCard.disabled {
    background: rgba(255, 255, 255, 0.02);
    border-color: rgba(255, 255, 255, 0.05);
    opacity: 0.4;
}

/* Square Exercise Icons */
.exercise-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 150px));
    gap: 1rem;
    margin: 2rem 0;
    justify-content: start;
}

.exercise-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: rgba(5, 5, 10, 0.8);
    border: 1px solid rgba(0, 191, 255, 0.2);
    border-radius: 12px;
    padding: 1rem;
    transition: all 0.3s ease;
    cursor: pointer;
    text-decoration: none;
    color: #e2e8f0;
    width: 120px;
    height: 120px;
    justify-content: center;
}

.exercise-card:hover {
    background: rgba(0, 191, 255, 0.05);
    border-color: rgba(0, 191, 255, 0.4);
    transform: translateY(-2px);
    box-shadow: 0 8px 16px rgba(0, 191, 255, 0.2);
    color: #f1f5f9;
    text-decoration: none;
}

.exercise-icon {
    font-size: 2rem;
    color: #00bfff;
    margin-bottom: 0.5rem;
    text-shadow: 0 2px 4px rgba(0, 191, 255, 0.3);
}

.exercise-label {
    font-size: 0.8rem;
    font-weight: 500;
    text-align: center;
    line-height: 1.2;
    color: inherit;
}

.exercise-card.disabled {
    opacity: 0.4;
    cursor: not-allowed;
    background: rgba(5, 5, 10, 0.4);
    border-color: rgba(255, 255, 255, 0.1);
}

.exercise-card.disabled:hover {
    transform: none;
    box-shadow: none;
    background: rgba(5, 5, 10, 0.4);
    border-color: rgba(255, 255, 255, 0.1);
    color: #e2e8f0;
}

@media (max-width: 768px) {
    .exercise-grid {
        grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
        gap: 0.8rem;
    }
    
    .exercise-card {
        width: 100px;
        height: 100px;
        padding: 0.8rem;
    }
    
    .exercise-icon {
        font-size: 1.5rem;
    }
    
    .exercise-label {
        font-size: 0.75rem;
    }
    
    .classes-grid {
        grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
        gap: 15px;
    }
}

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

/* Curriculum Manager Class Grid Fixes */
.classes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 200px));
    gap: 20px;
    margin-top: 15px;
    justify-content: start;
}

/* Desktop: limit class card width to prevent oversizing */
@media (min-width: 1200px) {
    .classes-grid {
        grid-template-columns: repeat(auto-fit, minmax(180px, 220px));
    }
    
    .exercise-grid {
        grid-template-columns: repeat(auto-fit, minmax(120px, 140px));
        max-width: 800px;
    }
}

/* Tablet responsiveness */
@media (min-width: 768px) and (max-width: 1199px) {
    .classes-grid {
        grid-template-columns: repeat(auto-fit, minmax(160px, 180px));
    }
}