:root {
    --bg-main: #f8fafc; /* Slate 50 - Very clean light background */
    --sidebar-bg: #ffffff; /* Crisp white sidebar */
    --card-bg: #ffffff; /* Solid white cards for best contrast */
    --card-border: #e2e8f0; /* Slate 200 border */
    --primary-color: #4f46e5; /* Modern Indigo */
    --primary-glow: rgba(79, 70, 229, 0.12);
    --secondary-color: #0ea5e9; /* Sky Blue */
    --secondary-glow: rgba(14, 165, 233, 0.08);
    --accent-color: #db2777; /* Rose/Pink accent */
    --text-main: #0f172a; /* Slate 900 for headings */
    --text-body: #334155; /* Slate 700 for labels & text */
    --text-muted: #64748b; /* Slate 500 for captions */
    --success-color: #10b981;
    --danger-color: #ef4444;
}

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

body {
    background-color: var(--bg-main);
    color: var(--text-body);
    font-family: 'Inter', sans-serif;
    min-height: 100vh;
    padding: 0;
    margin: 0;
    overflow-x: hidden;
    position: relative;
}

/* Background gradient accent wash */
.glow-bg {
    position: absolute;
    top: -15%;
    left: -15%;
    width: 60%;
    height: 60%;
    background: radial-gradient(circle, rgba(99, 102, 241, 0.08) 0%, rgba(255,255,255,0) 70%);
    z-index: -1;
    pointer-events: none;
    filter: blur(100px);
}

.container {
    max-width: 1400px;
    margin: 0 auto;
}

/* Glassmorphism Card style */
.glass {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 24px;
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.03), 0 1px 3px rgba(15, 23, 42, 0.02);
}

/* Tab Contents with spacious padding */
.tab-content {
    display: none;
    padding: 10px 0 0 0;
}

.tab-content.active {
    display: block;
    animation: fadeIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

.tab-header {
    margin-bottom: 32px;
}

.tab-header h2 {
    font-family: 'Outfit', sans-serif;
    font-size: 1.8rem;
    font-weight: 700;
    margin-bottom: 8px;
    color: var(--text-main);
}

.tab-header p {
    color: var(--text-muted);
    font-size: 0.95rem;
    line-height: 1.5;
}

/* Grids and Layouts with massive breathing room */
.grid-2col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 32px;
}

@media (max-width: 768px) {
    .grid-2col {
        grid-template-columns: 1fr;
        gap: 24px;
    }
}

/* Forms & Cards Styling */
.form-container, .list-container {
    background: #ffffff;
    border: 1px solid var(--card-border);
    border-radius: 20px;
    padding: 32px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.01);
}

h3 {
    font-family: 'Outfit', sans-serif;
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 24px;
    color: var(--text-main);
    border-left: 4px solid var(--primary-color);
    padding-left: 12px;
}

.form-group {
    margin-bottom: 24px;
}

.form-group-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

label {
    display: block;
    margin-bottom: 8px;
    color: var(--text-body);
    font-size: 0.9rem;
    font-weight: 600;
}

input, select {
    width: 100%;
    background-color: #ffffff;
    border: 1px solid #cbd5e1; /* Slate 300 */
    border-radius: 12px;
    color: var(--text-main);
    padding: 12px 16px;
    font-family: inherit;
    font-size: 0.95rem;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    outline: none;
}

input:focus, select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

/* Buttons with modern shapes and hover states */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 24px;
    font-family: 'Outfit', sans-serif;
    font-weight: 600;
    font-size: 0.95rem;
    border-radius: 12px;
    border: 1px solid #cbd5e1;
    background: #ffffff;
    color: var(--text-body);
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    text-align: center;
    outline: none;
}

.btn:hover {
    background: #f8fafc;
    color: var(--text-main);
    border-color: #94a3b8;
}

.btn.primary {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: #ffffff;
    border: none;
}

.btn.primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px var(--primary-glow);
}

.btn.action-btn {
    background: linear-gradient(135deg, var(--accent-color) 0%, var(--primary-color) 100%);
    color: #ffffff;
    font-size: 1.15rem;
    padding: 16px 40px;
    border-radius: 16px;
    border: none;
    box-shadow: 0 4px 16px rgba(219, 39, 119, 0.2);
    margin-top: 20px;
}

.btn.action-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(219, 39, 119, 0.35);
}

/* Teachers list in 2 columns with generous gap */
.teachers-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
    margin-top: 24px;
}

@media (max-width: 900px) {
    .teachers-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }
}

.item-card {
    background: #ffffff;
    border: 1px solid var(--card-border);
    border-radius: 16px;
    padding: 20px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.015);
    transition: all 0.2s ease;
}

.item-card:hover {
    border-color: #cbd5e1;
    box-shadow: 0 4px 15px rgba(15, 23, 42, 0.03);
}

.item-info h4 {
    font-family: 'Outfit', sans-serif;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-main);
}

.item-info p {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-top: 4px;
}

.actions {
    display: flex;
    gap: 12px;
}

.action-link {
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--primary-color);
    transition: all 0.2s ease;
    padding: 6px 12px;
    border-radius: 8px;
    background: var(--primary-glow);
}

.action-link:hover {
    background: rgba(79, 70, 229, 0.2);
}

.action-link.delete {
    color: var(--danger-color);
    background: rgba(239, 68, 68, 0.08);
}

.action-link.delete:hover {
    background: rgba(239, 68, 68, 0.15);
}

/* Badges */
.badge {
    background-color: var(--primary-glow);
    color: var(--primary-color);
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
    border: 1px solid rgba(79, 70, 229, 0.2);
}

/* Clean Tables with Slate borders and clean whitespace */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    border: 1px solid var(--card-border);
    border-radius: 16px;
    margin-top: 20px;
    background: #ffffff;
}

.schedule-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.schedule-table th, .schedule-table td {
    padding: 16px 20px;
    text-align: center;
    border-bottom: 1px solid var(--card-border);
}

.schedule-table th {
    background: #f8fafc; /* Slate 50 */
    color: var(--text-body);
    font-weight: 700;
    font-family: 'Outfit', sans-serif;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 2px solid var(--card-border);
}

.schedule-table tbody tr {
    transition: background-color 0.15s ease;
}

.schedule-table tbody tr:nth-child(even) {
    background-color: #f8fafc;
}

.schedule-table tbody tr:hover {
    background-color: #f1f5f9;
}

/* Grid Matrix Matrix entries */
.matrix-table input[type="number"] {
    width: 65px;
    padding: 8px;
    text-align: center;
    font-size: 0.9rem;
    border-radius: 8px;
}

/* Filter controls bar styling */
.filters-bar {
    display: flex;
    gap: 20px;
    background: #f8fafc;
    padding: 16px 24px;
    border-radius: 16px;
    border: 1px solid var(--card-border);
    align-items: center;
    margin-bottom: 24px;
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.filter-group label {
    margin: 0;
    white-space: nowrap;
}

.filter-group select {
    min-width: 180px;
    padding: 8px 12px;
}

/* Generated schedule slots cards */
.schedule-slot {
    background: #ffffff;
    border: 1px solid var(--card-border);
    border-radius: 12px;
    padding: 10px 14px;
    box-shadow: 0 2px 4px rgba(15, 23, 42, 0.01);
    transition: all 0.2s ease;
    text-align: left;
}

.schedule-slot:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(15, 23, 42, 0.03);
}

.slot-subject {
    font-weight: 700;
    color: var(--text-main);
    font-size: 0.95rem;
}

.slot-teacher {
    color: var(--text-muted);
    font-size: 0.8rem;
    margin-top: 4px;
}

.slot-classroom {
    display: inline-block;
    background-color: var(--primary-glow);
    color: var(--primary-color);
    font-size: 0.7rem;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 4px;
    margin-top: 6px;
    border: 1px solid rgba(79, 70, 229, 0.15);
}

/* App Layout & Light Sidebar */
.app-layout {
    display: flex;
    min-height: 100vh;
    background-color: var(--bg-main);
}

.sidebar {
    width: 280px;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--card-border);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 32px 24px;
    position: fixed;
    height: 100vh;
    z-index: 100;
    box-shadow: 4px 0 30px rgba(15, 23, 42, 0.015);
}

.sidebar-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 8px 24px 8px;
    border-bottom: 1px solid var(--card-border);
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 24px;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.95rem;
    font-weight: 600;
    border-radius: 14px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    background: transparent;
    border: none;
    text-align: left;
    width: 100%;
    outline: none;
}

.sidebar-link:hover {
    color: var(--text-main);
    background: #f1f5f9; /* Soft gray hover */
}

.sidebar-link.active {
    color: #ffffff;
    background: var(--primary-color);
    box-shadow: 0 4px 15px var(--primary-glow);
}

.sidebar-link .icon {
    font-size: 1.3rem;
}

.main-content {
    flex: 1;
    margin-left: 280px;
    padding: 48px; /* Spacious margins */
    min-height: 100vh;
    overflow-y: auto;
    width: calc(100% - 280px);
}

/* Variant tabs buttons */
.variants-tabs {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.variant-tab-btn {
    background: #ffffff;
    border: 1px solid var(--card-border);
    color: var(--text-body);
    padding: 10px 20px;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9rem;
    transition: all 0.2s ease;
}

.variant-tab-btn:hover {
    color: var(--text-main);
    background: #f8fafc;
}

.variant-tab-btn.active {
    background: var(--primary-color);
    color: #ffffff;
    border-color: var(--primary-color);
    box-shadow: 0 4px 12px var(--primary-glow);
}

/* Warnings and Compromises alerts */
.compromises-box {
    background: rgba(245, 158, 11, 0.08);
    border: 1px solid rgba(245, 158, 11, 0.25);
    border-radius: 14px;
    padding: 20px;
    margin-bottom: 24px;
    color: #b45309; /* Dark Amber */
}

.compromises-box h4 {
    margin-top: 0;
    margin-bottom: 12px;
    color: #d97706;
    font-size: 1.05rem;
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
}

.compromises-box ul {
    margin: 0;
    padding-left: 20px;
    font-size: 0.9rem;
    line-height: 1.6;
}

.compromises-success {
    background: rgba(16, 185, 129, 0.08);
    border: 1px solid rgba(16, 185, 129, 0.25);
    border-radius: 14px;
    padding: 20px;
    margin-bottom: 24px;
    color: #065f46; /* Dark Green */
}

.compromises-success h4 {
    margin: 0;
    color: #059669;
    font-size: 1.05rem;
    font-weight: 700;
}

/* Spinner and loader wrapper */
.loader-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
    gap: 16px;
    color: var(--text-body);
}

.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--card-border);
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.error-box {
    background: rgba(239, 68, 68, 0.08);
    border: 1px solid rgba(239, 68, 68, 0.25);
    border-radius: 14px;
    padding: 20px;
    color: #991b1b;
    margin-bottom: 24px;
    font-size: 0.95rem;
    line-height: 1.5;
}

.hidden {
    display: none !important;
}

/* Responsive collapse classes */
@media (max-width: 1024px) {
    .sidebar {
        width: 80px;
        padding: 24px 12px;
    }
    .sidebar .sidebar-header h2,
    .sidebar .sidebar-logo-text,
    .sidebar .nav-text,
    .sidebar #user-profile-sidebar {
        display: none;
    }
    .sidebar-header {
        justify-content: center;
        padding: 8px 0;
    }
    .sidebar-link {
        justify-content: center;
        padding: 12px;
        border-radius: 12px;
    }
    .main-content {
        margin-left: 80px;
        padding: 32px;
        width: calc(100% - 80px);
    }
}

/* Modal dialog styling */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.2s ease;
}

.modal-content {
    background: #ffffff;
    border: 1px solid var(--card-border);
    border-radius: 20px;
    padding: 32px;
    width: 100%;
    max-width: 480px;
    box-shadow: 0 20px 50px rgba(15, 23, 42, 0.15);
    position: relative;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.close-modal {
    font-size: 1.8rem;
    cursor: pointer;
    color: var(--text-muted);
    transition: color 0.15s ease;
    line-height: 1;
}

.close-modal:hover {
    color: var(--text-main);
}

/* Classes and Classrooms grid layout in 2 columns */
.classes-grid, .classrooms-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
    margin-top: 12px;
}

@media (max-width: 768px) {
    .classes-grid, .classrooms-grid {
        grid-template-columns: 1fr;
    }
}

/* Danger / Delete general button style */
.btn.delete, .btn.danger {
    background: rgba(239, 68, 68, 0.08);
    color: var(--danger-color);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.btn.delete:hover, .btn.danger:hover {
    background: rgba(239, 68, 68, 0.15);
    color: var(--danger-color);
    border-color: rgba(239, 68, 68, 0.3);
}

/* Collapsible sidebar layout overrides */
.sidebar {
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1), padding 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.main-content {
    transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1), width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar.collapsed {
    width: 80px;
    padding: 24px 12px;
}

.sidebar.collapsed .sidebar-header h2,
.sidebar.collapsed .sidebar-logo-text,
.sidebar.collapsed .nav-text,
.sidebar.collapsed #user-profile-sidebar {
    display: none !important;
}

.sidebar.collapsed .sidebar-header {
    justify-content: center !important;
    padding: 8px 0;
}

.sidebar.collapsed .sidebar-link {
    justify-content: center;
    padding: 12px;
    border-radius: 12px;
}

.sidebar.collapsed + .main-content {
    margin-left: 80px;
    width: calc(100% - 80px);
}
