/* Joseph's Mobile-First Timetable */
:root {
    /* Color System */
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #a5b4fc;
    --secondary: #10b981;
    --accent: #f59e0b;
    --danger: #ef4444;
    --warning: #f97316;
    
    /* Neutral Colors */
    --white: #ffffff;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    
    /* Spacing System */
    --space-xs: 0.25rem;
    --space-sm: 0.5rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2rem;
    
    /* Border Radius */
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
    
    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);
    
    /* Layout */
    --status-height: 80px;
    --tabs-height: 40px;
    --nav-height: 120px;
    --safe-area-top: env(safe-area-inset-top);
    --safe-area-bottom: env(safe-area-inset-bottom);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--gray-50);
    color: var(--gray-800);
    line-height: 1.5;
    height: 100vh;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Day Navigation */
.day-nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    background: var(--white);
    border-bottom: 1px solid var(--gray-200);
    box-shadow: var(--shadow-sm);
    padding-top: var(--safe-area-top);
    height: calc(var(--nav-height) + var(--safe-area-top));
}

/* Status Bar */
.status-bar {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: var(--white);
    padding: 12px 16px;
    height: var(--status-height);
    display: flex;
    flex-direction: column;
    justify-content: center;
    position: relative;
}

.status-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 28px;
    margin-bottom: 4px;
}

.day-name {
    flex: 0 0 auto;
    text-align: left;
    min-width: 80px;
    font-size: 1.125rem;
    color: #ffffff;
    font-weight: 800;
    line-height: 1.1;
    display: flex;
    align-items: center;
    height: 100%;
}

.full-date {
    font-size: 0.75rem;
    color: #ffffff;
    opacity: 0.9;
    font-weight: 500;
    line-height: 1.1;
    flex: 0 0 auto;
    text-align: left;
    min-width: 80px;
    display: flex;
    align-items: center;
    height: 100%;
}

.time {
    flex: 0 0 auto;
    font-size: 1.125rem;
    font-weight: 800;
    color: #ffffff;
    font-variant-numeric: tabular-nums;
    line-height: 1.1;
    text-align: right;
    min-width: 80px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    height: 100%;
}

.current-status {
    flex: 1;
    font-weight: 600;
    font-size: 0.9375rem;
    text-align: center;
    line-height: 1.1;
    padding: 0 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #ffffff;
}

.status-text {
    line-height: 1.1;
    color: #ffffff;
}

.status-row-2 {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    position: relative;
    height: 16px;
}

.next-class {
    font-size: 0.75rem;
    color: #ffffff;
    opacity: 0.85;
    line-height: 1;
    font-weight: 500;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
}

.progress-bar {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: rgba(255, 255, 255, 0.2);
}

.progress-fill {
    height: 100%;
    background: var(--accent);
    width: 0%;
    transition: width 0.3s ease;
}

.day-tabs {
    display: flex;
    height: var(--tabs-height);
    background: var(--white);
}

.day-tab {
    flex: 1;
    background: none;
    border: none;
    padding: var(--space-sm);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    height: 100%;
}

.day-tab:hover {
    background: var(--gray-50);
}

.day-tab.active {
    background: var(--primary);
    color: #ffffff;
}

.day-tab.today:not(.active) {
    background: var(--primary-light);
    color: var(--primary-dark);
    font-weight: 600;
}

.day-short {
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.day-date {
    font-size: 0.5625rem;
    opacity: 0.8;
    font-variant-numeric: tabular-nums;
}

/* Main Content */
.main-content {
    margin-top: calc(var(--nav-height) + var(--safe-area-top));
    margin-bottom: var(--safe-area-bottom);
    padding: 0;
    height: calc(100vh - var(--nav-height) - var(--safe-area-top) - var(--safe-area-bottom));
    display: flex;
    flex-direction: column;
}

/* Day Schedule */
.day-schedule {
    background: var(--gray-50);
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

.no-school {
    padding: var(--space-xl);
    text-align: center;
    color: var(--gray-500);
    display: flex;
    flex-direction: column;
    justify-content: center;
    background: var(--white);
    flex: 1;
}

.no-school-icon {
    font-size: 3rem;
    margin-bottom: var(--space-md);
}

/* Period Items */
.period-item {
    padding: var(--space-lg);
    border-bottom: 1px solid var(--gray-200);
    background: var(--white);
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    transition: all 0.2s ease;
    position: relative;
    flex: 1;
    min-height: 0;
}

.period-item:last-child {
    border-bottom: none;
}

.period-item.current {
    background: linear-gradient(135deg, var(--secondary) 0%, rgba(16, 185, 129, 0.2) 100%);
    position: relative;
}

.period-item.current::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: var(--secondary);
}

.period-item.next {
    background: linear-gradient(135deg, var(--accent) 0%, rgba(245, 158, 11, 0.1) 100%);
    position: relative;
}

.period-item.next::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: var(--accent);
}

.period-item.completed {
    opacity: 0.6;
    background: var(--gray-100);
}

.period-item.break-lunch {
    background: var(--gray-100);
}

.period-item.break-lunch.current {
    background: linear-gradient(135deg, var(--secondary) 0%, rgba(16, 185, 129, 0.2) 100%);
    position: relative;
}

.period-item.break-lunch.current::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: var(--secondary);
}

/* Period Time */
.period-time {
    min-width: 55px;
    text-align: center;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.time-start {
    font-weight: 700;
    font-size: 0.875rem;
    color: var(--gray-800);
    font-variant-numeric: tabular-nums;
    line-height: 1;
}

.time-end {
    font-size: 0.625rem;
    color: var(--gray-500);
    font-variant-numeric: tabular-nums;
}

.period-number {
    background: var(--primary);
    color: var(--white);
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    font-size: 0.6875rem;
    font-weight: 800;
    min-width: 28px;
    text-align: center;
    line-height: 1;
    margin-top: 2px;
}
/* Period Details */
.period-details {
    flex: 1;
    min-width: 0;
}


.subject-name {
    font-weight: 600;
    font-size: 0.8125rem;
    color: var(--gray-800);
    line-height: 1.2;
    margin-bottom: var(--space-xs);
}

.period-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 1px;
    font-size: 0.75rem;
    color: var(--gray-500);
}

.teacher, .room {
    display: flex;
    align-items: center;
    gap: 2px;
}

.break-duration {
    color: var(--secondary);
    font-weight: 500;
}

/* Period Status */
.period-status {
    text-align: right;
    flex-shrink: 0;
}

.status-badge {
    display: inline-block;
    padding: var(--space-xs) var(--space-sm);
    border-radius: var(--radius-md);
    font-size: 0.5625rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    line-height: 1;
}

.status-badge.current {
    background: var(--secondary);
    color: var(--white);
}

.status-badge.next {
    background: var(--accent);
    color: var(--white);
}

.status-badge.upcoming {
    background: var(--gray-200);
    color: var(--gray-600);
}

.status-badge.completed {
    background: var(--gray-300);
    color: var(--gray-600);
}

.time-remaining {
    font-size: 0.60rem;
    color: var(--gray-500);
    margin-top: var(--space-xs);
    font-variant-numeric: tabular-nums;
}

/* Settings */
.settings-btn {
    position: fixed;
    bottom: calc(var(--space-lg) + var(--safe-area-bottom));
    right: var(--space-lg);
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--primary);
    color: var(--white);
    border: none;
    font-size: 1.125rem;
    cursor: pointer;
    box-shadow: var(--shadow-lg);
    transition: all 0.2s ease;
    z-index: 1000;
}

.settings-btn:hover {
    transform: scale(1.1);
    background: var(--primary-dark);
}

.settings-panel {
    position: fixed;
    top: 0;
    right: -100%;
    width: 100%;
    max-width: 320px;
    height: 100vh;
    background: var(--white);
    box-shadow: var(--shadow-lg);
    transition: right 0.3s ease;
    z-index: 1001;
    display: flex;
    flex-direction: column;
}

.settings-panel.open {
    right: 0;
}

.settings-header {
    padding: var(--space-lg);
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: calc(var(--space-lg) + var(--safe-area-top));
}

.settings-header h3 {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--gray-800);
}

.close-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--gray-100);
    border: none;
    font-size: 1.125rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.close-btn:hover {
    background: var(--gray-200);
}

.settings-body {
    padding: var(--space-lg);
    flex: 1;
    overflow-y: auto;
}

.setting-group {
    margin-bottom: var(--space-lg);
}

.setting-group label {
    display: block;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: var(--space-sm);
    font-size: 0.875rem;
}

.setting-group select {
    width: 100%;
    padding: var(--space-sm) var(--space-md);
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-md);
    background: var(--white);
    font-size: 0.875rem;
    transition: all 0.2s ease;
}

.setting-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

/* Dark Theme */
.dark-theme {
    /* Dark theme color palette */
    --white: #1e293b;
    --gray-50: #0f172a;
    --gray-100: #1e293b;
    --gray-200: #334155;
    --gray-300: #475569;
    --gray-400: #64748b;
    --gray-500: #94a3b8;
    --gray-600: #cbd5e1;
    --gray-700: #e2e8f0;
    --gray-800: #f1f5f9;
    --gray-900: #f8fafc;
    
    /* Adjusted colors for better dark theme contrast */
    --primary: #6366f1;
    --primary-dark: #4338ca;
    --primary-light: #8b5cf6;
    --secondary: #10b981;
    --accent: #f59e0b;
}

.dark-theme .day-tab.today:not(.active) {
    background: rgba(99, 102, 241, 0.2);
    color: var(--primary-light);
    font-weight: 600;
}

.dark-theme .period-item.current {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.3) 0%, rgba(16, 185, 129, 0.1) 100%);
}

.dark-theme .period-item.next {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.3) 0%, rgba(245, 158, 11, 0.1) 100%);
}

.dark-theme .period-item.break-lunch {
    background: var(--gray-100);
}

.dark-theme .period-item.break-lunch.current {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.3) 0%, rgba(16, 185, 129, 0.1) 100%);
}

.dark-theme .period-item.completed {
    opacity: 0.5;
    background: var(--gray-200);
}

.dark-theme .status-badge.upcoming {
    background: var(--gray-300);
    color: var(--gray-600);
}

.dark-theme .status-badge.completed {
    background: var(--gray-400);
    color: var(--gray-700);
}

.dark-theme .close-btn {
    background: var(--gray-200);
    color: var(--gray-700);
}

.dark-theme .close-btn:hover {
    background: var(--gray-300);
}

.dark-theme .setting-group select {
    background: var(--gray-100);
    border-color: var(--gray-300);
    color: var(--gray-800);
}

.dark-theme .setting-group select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.dark-theme body {
    background: var(--gray-50);
}

/* Responsive Adjustments */
@media (max-width: 480px) {
    .period-item {
        padding: var(--space-md);
        gap: var(--space-sm);
    }
    
    .period-meta {
        font-size: 0.6875rem;
        flex-direction: column;
        align-items: flex-start;
        gap: 1px;
    }
    
    .current-status {
        font-size: 0.875rem;
        padding: 0 4px;
    }
    
    .time {
        font-size: 1.0625rem;
    }
    
    .day-name {
        font-size: 1rem;
    }
    
    .full-date {
        font-size: 0.6875rem;
    }
    
    .next-class {
        font-size: 0.6875rem;
    }
}

@media (max-width: 360px) {
    .day-short {
        font-size: 0.5625rem;
    }
    
    .day-date {
        font-size: 0.5rem;
    }
    
    .time {
        font-size: 1rem;
    }
    
    .day-name {
        font-size: 0.9375rem;
    }
    
    .full-date {
        font-size: 0.625rem;
    }
    
    .period-item {
        padding: var(--space-sm) var(--space-md);
    }
    
    .subject-name {
        font-size: 0.6875rem;
    }
    
    .period-time {
        min-width: 50px;
    }
    
    .time-start {
        font-size: 0.6875rem;
    }
    
    .time-end {
        font-size: 0.5625rem;
    }
    
    .current-status {
        font-size: 0.8125rem;
        padding: 0 2px;
    }
    
    .next-class {
        font-size: 0.625rem;
    }
    
    .period-meta {
        font-size: 0.625rem;
    }
}

/* Landscape orientation adjustments */
@media (orientation: landscape) and (max-height: 500px) {
    :root {
        --status-height: 60px;
        --tabs-height: 35px;
        --nav-height: 95px;
    }
    
    .day-nav {
        height: calc(var(--nav-height) + var(--safe-area-top));
    }
    
    .status-bar {
        padding: 8px var(--space-md);
        height: var(--status-height);
    }
    
    .day-tabs {
        height: var(--tabs-height);
    }
    
    .time {
        font-size: 0.9375rem;
    }
    
    .day-name {
        font-size: 0.875rem;
    }
    
    .full-date {
        font-size: 0.625rem;
    }
    
    .current-status {
        font-size: 0.8125rem;
        padding: 0 4px;
    }
    
    .next-class {
        font-size: 0.625rem;
    }
    
    .day-short {
        font-size: 0.5625rem;
    }
    
    .day-date {
        font-size: 0.5rem;
    }
    
    .period-item {
        padding: var(--space-sm) var(--space-md);
    }
    
    .subject-name {
        font-size: 0.6875rem;
    }
    
    .period-meta {
        font-size: 0.625rem;
    }
}

/* Auto dark mode */
@media (prefers-color-scheme: dark) {
    body:not(.light-theme) {
        /* Dark theme color palette */
        --white: #1e293b;
        --gray-50: #0f172a;
        --gray-100: #1e293b;
        --gray-200: #334155;
        --gray-300: #475569;
        --gray-400: #64748b;
        --gray-500: #94a3b8;
        --gray-600: #cbd5e1;
        --gray-700: #e2e8f0;
        --gray-800: #f1f5f9;
        --gray-900: #f8fafc;
        
        /* Adjusted colors for better dark theme contrast */
        --primary: #6366f1;
        --primary-dark: #4338ca;
        --primary-light: #8b5cf6;
        --secondary: #10b981;
        --accent: #f59e0b;
    }
    
    body:not(.light-theme) .day-tab.today:not(.active) {
        background: rgba(99, 102, 241, 0.2);
        color: var(--primary-light);
        font-weight: 600;
    }
    
    body:not(.light-theme) .period-item.current {
        background: linear-gradient(135deg, rgba(16, 185, 129, 0.3) 0%, rgba(16, 185, 129, 0.1) 100%);
    }
    
    body:not(.light-theme) .period-item.next {
        background: linear-gradient(135deg, rgba(245, 158, 11, 0.3) 0%, rgba(245, 158, 11, 0.1) 100%);
    }
    
    body:not(.light-theme) .period-item.break-lunch {
        background: var(--gray-100);
    }
    
    body:not(.light-theme) .period-item.break-lunch.current {
        background: linear-gradient(135deg, rgba(16, 185, 129, 0.3) 0%, rgba(16, 185, 129, 0.1) 100%);
    }
    
    body:not(.light-theme) .period-item.completed {
        opacity: 0.5;
        background: var(--gray-200);
    }
    
    body:not(.light-theme) .status-badge.upcoming {
        background: var(--gray-300);
        color: var(--gray-600);
    }
    
    body:not(.light-theme) .status-badge.completed {
        background: var(--gray-400);
        color: var(--gray-700);
    }
    
    body:not(.light-theme) .close-btn {
        background: var(--gray-200);
        color: var(--gray-700);
    }
    
    body:not(.light-theme) .close-btn:hover {
        background: var(--gray-300);
    }
    
    body:not(.light-theme) .setting-group select {
        background: var(--gray-100);
        border-color: var(--gray-300);
        color: var(--gray-800);
    }
    
    body:not(.light-theme) .setting-group select:focus {
        border-color: var(--primary);
        box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
    }
    
    body:not(.light-theme) {
        background: var(--gray-50);
    }
}