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

:root {
    --primary-color: #4F46E5;
    --primary-hover: #4338CA;
    --secondary-color: #10B981;
    --bg-color: #F3F4F6;
    --card-bg: #FFFFFF;
    --text-primary: #111827;
    --text-secondary: #6B7280;
    --border-color: #E5E7EB;
    --danger: #EF4444;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --border-radius: 8px;
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.5;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

.auth-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
}

.card {
    background: var(--card-bg);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-md);
    padding: 30px;
    width: 100%;
}

.auth-card {
    max-width: 400px;
}

.logo-container {
    text-align: center;
    margin-bottom: 20px;
}

.logo-container img {
    max-width: 80px;
    height: auto;
}

.logo-container h1 {
    font-size: 1.5rem;
    color: var(--primary-color);
    margin-top: 10px;
}

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

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.form-control {
    width: 100%;
    padding: 10px 15px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: 1rem;
    font-family: inherit;
    transition: border-color 0.2s;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.btn {
    display: inline-block;
    padding: 10px 20px;
    border: none;
    border-radius: var(--border-radius);
    font-weight: 500;
    font-size: 1rem;
    cursor: pointer;
    text-align: center;
    text-decoration: none;
    transition: background-color 0.2s, transform 0.1s;
    width: 100%;
}

.btn:active {
    transform: translateY(1px);
}

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

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

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

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

.text-center {
    text-align: center;
}

.mt-3 {
    margin-top: 1rem;
}

.alert {
    padding: 15px;
    border-radius: var(--border-radius);
    margin-bottom: 20px;
    font-size: 0.9rem;
}

.alert-error {
    background-color: #FEF2F2;
    color: #991B1B;
    border: 1px solid #F87171;
}

.alert-success {
    background-color: #ECFDF5;
    color: #065F46;
    border: 1px solid #34D399;
}

/* Dashboard Layout */
.dashboard-layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 250px;
    background-color: var(--card-bg);
    border-right: 1px solid var(--border-color);
    padding: 20px 0;
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    padding: 0 20px 20px;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 20px;
}

.sidebar-nav {
    flex: 1;
}

.sidebar-nav a {
    display: block;
    padding: 12px 20px;
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    transition: all 0.2s;
}

.sidebar-nav a:hover, .sidebar-nav a.active {
    background-color: rgba(79, 70, 229, 0.05);
    color: var(--primary-color);
    border-right: 3px solid var(--primary-color);
}

.main-content {
    flex: 1;
    padding: 30px;
    overflow-y: auto;
}

.header-title {
    font-size: 1.8rem;
    margin-bottom: 20px;
    color: var(--text-primary);
}

/* Tables */
table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 20px;
}

th, td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

th {
    background-color: #F9FAFB;
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

tbody tr:hover {
    background-color: #F9FAFB;
}

/* Utilities */
.flex { display: flex; }
.justify-between { justify-content: space-between; }
.items-center { align-items: center; }
.gap-2 { gap: 0.5rem; }
.gap-4 { gap: 1rem; }
.grid { display: grid; }
.grid-cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid-cols-3 { grid-template-columns: repeat(3, 1fr); }

/* Report Card specific styles */
.report-card-container {
    background: white;
    padding: 40px;
    border-radius: 8px;
    box-shadow: 0 0 10px rgba(0,0,0,0.1);
    max-width: 1123px; /* A4 Landscape width */
    min-height: 794px; /* A4 Landscape height */
    margin: 0 auto;
}

.report-header {
    text-align: center;
    border-bottom: 2px solid var(--primary-color);
    padding-bottom: 20px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.student-info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 30px;
}

.student-photo {
    width: 120px;
    height: 120px;
    object-fit: cover;
    border-radius: 8px;
    border: 2px solid var(--border-color);
}

/* Responsive Design */
@media (max-width: 768px) {
    .dashboard-layout {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
        padding: 10px 0;
    }
    
    .sidebar-header {
        padding: 0 15px 10px;
        margin-bottom: 10px;
        text-align: center;
    }
    
    .sidebar-nav {
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .sidebar-nav a {
        padding: 8px 12px;
        font-size: 0.85rem;
        border-right: none !important;
        border-bottom: 2px solid transparent;
        text-align: center;
    }
    
    .sidebar-nav a:hover, .sidebar-nav a.active {
        border-bottom: 2px solid var(--primary-color);
        background-color: transparent;
    }
    
    .main-content {
        padding: 15px;
    }
    
    .grid-cols-2, .grid-cols-3 {
        grid-template-columns: 1fr;
    }
    
    /* Make tables horizontally scrollable on small screens */
    table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
        width: 100%;
    }
    
    /* Form controls in tight spaces */
    .flex.justify-between.items-center {
        flex-direction: column;
        gap: 10px;
        align-items: stretch;
    }
    
    .flex.justify-between.items-center .btn {
        width: 100%;
        max-width: none !important;
    }

    /* Stack filter form vertically on mobile */
    .flex.gap-4.items-center {
        flex-direction: column;
        align-items: stretch;
    }

    /* Make score inputs touch-friendly */
    .form-control.ca1-input,
    .form-control.ca2-input,
    .form-control.exam-input {
        width: 100%;
        min-width: 0;
        font-size: 1rem;
        padding: 10px;
    }

    /* Stack attendance flex rows into single column */
    .flex.gap-4 {
        flex-direction: column;
        gap: 0;
    }

    /* Modal fills screen on mobile */
    .modal-content {
        padding: 20px;
        margin: 10px;
        max-height: 90vh;
        overflow-y: auto;
        max-width: calc(100% - 20px);
    }

    /* Action buttons in table wrap nicely */
    td.flex.gap-2 {
        flex-wrap: wrap;
        gap: 6px;
    }

    /* Reduce card padding on mobile */
    .card {
        padding: 15px;
    }

    .header-title {
        font-size: 1.3rem;
    }

    .mb-3 { margin-bottom: 0.75rem; }

    /* Dashboard stat cards: 3-col → 1-col */
    .grid-cols-3 {
        grid-template-columns: 1fr !important;
    }

    /* Inline add-forms (subjects, classes, top students, broadsheet)
       stack vertically on mobile */
    .flex.gap-4.items-center,
    .flex.items-center.gap-4,
    .flex.items-end.gap-4 {
        flex-direction: column;
        align-items: stretch !important;
    }

    /* Remove fixed max-widths on selects/buttons inside stacked forms */
    .flex.gap-4.items-center select,
    .flex.gap-4.items-center button,
    .flex.items-center.gap-4 select,
    .flex.items-center.gap-4 a,
    .flex.items-end.gap-4 select,
    .flex.items-end.gap-4 button {
        max-width: 100% !important;
        width: 100%;
    }

    /* Approve teachers: password reset inline form stacks */
    form[style*="display:flex"] {
        flex-wrap: wrap;
        gap: 6px;
    }

    /* Broadsheet header (title + print button) wraps */
    .flex.items-center {
        flex-wrap: wrap;
        gap: 10px;
    }

    /* Settings cards: remove max-width so they fill screen */
    .card[style*="max-width"] {
        max-width: 100% !important;
    }

    /* Ensure form-group margins inside stacked forms reset */
    .flex.gap-4.items-center .form-group,
    .flex.items-end.gap-4 .form-group {
        margin-bottom: 0;
        width: 100%;
    }
}
