/* =============================================================================
   School Management System & Result Card Styling
   Govt. Girls High School Shaher Sultan
   ============================================================================= */

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

/* Fallback Urdu Font */
@font-face {
    font-family: 'Jameel Noori Nastaleeq';
    src: local('Jameel Noori Nastaleeq'), local('Nafees Nastaleeq'), local('Urdu Typesetting');
}

:root {
    /* Color Palette */
    --primary: #1e3a8a;       /* Deep Navy */
    --primary-light: #3b82f6; /* Bright Blue */
    --primary-dark: #172554;  /* Very Dark Navy */
    --accent: #d97706;        /* Warm Gold */
    --accent-hover: #b45309;  /* Darker Gold */
    --accent-light: #fef3c7;  /* Light Gold Tint */
    --background: #f8fafc;    /* Clean Slate White */
    --surface: #ffffff;       /* Pure White Card */
    --sidebar-bg: #0f172a;    /* Slate 900 for dark sidebar */
    
    /* Text Colors */
    --text-main: #0f172a;
    --text-muted: #64748b;
    --text-light: #94a3b8;
    --text-white: #ffffff;
    
    /* Status Colors */
    --success: #10b981;
    --success-light: #d1fae5;
    --error: #ef4444;
    --error-light: #fee2e2;
    --warning: #f59e0b;
    --info: #06b6d4;
    
    /* Layout Tokens */
    --sidebar-width: 260px;
    --header-height: 70px;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
    
    /* Font Families */
    --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
    --font-heading: 'Outfit', sans-serif;
    --font-urdu: 'Jameel Noori Nastaleeq', 'Noto Nastaliq Urdu', serif;
}

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

body {
    font-family: var(--font-sans);
    background-color: var(--background);
    color: var(--text-main);
    line-height: 1.5;
    overflow-x: hidden;
}

a {
    color: inherit;
    text-decoration: none;
}

input, select, textarea, button {
    font-family: inherit;
    font-size: inherit;
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-heading);
    font-weight: 700;
}

/* Urdu Text Support */
.urdu-text {
    font-family: var(--font-urdu);
    direction: rtl;
    font-size: 1.25rem;
    line-height: 1.8;
}

/* Scrollbar Customization */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* =============================================================================
   Login Layout (Index.php)
   ============================================================================= */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at top right, var(--primary-light), var(--primary-dark));
    padding: 20px;
}

.login-card {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    width: 100%;
    max-width: 420px;
    padding: 40px;
    border-radius: var(--radius-lg);
    border: 1px fill rgba(255, 255, 255, 0.4);
    box-shadow: var(--shadow-lg);
    text-align: center;
}

.login-logo {
    width: 85px;
    height: 85px;
    margin: 0 auto 20px;
}

.login-header h1 {
    font-size: 1.6rem;
    color: var(--primary-dark);
    margin-bottom: 8px;
}

.login-header p {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 30px;
}

.login-form .form-group {
    margin-bottom: 20px;
    text-align: left;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 6px;
}

.input-icon-wrapper {
    position: relative;
}

.input-icon-wrapper input, 
.input-icon-wrapper select,
.custom-input {
    width: 100%;
    padding: 12px 16px;
    border: 1.5px solid #cbd5e1;
    border-radius: var(--radius-md);
    outline: none;
    transition: all 0.2s ease;
    background-color: var(--surface);
}

.input-icon-wrapper input:focus,
.custom-input:focus {
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.btn-primary {
    width: 100%;
    background-color: var(--primary);
    color: var(--text-white);
    padding: 12px 24px;
    border: none;
    border-radius: var(--radius-md);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: var(--shadow-sm);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-primary:hover {
    background-color: var(--primary-dark);
    transform: translateY(-1px);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-accent {
    background-color: var(--accent);
    color: var(--text-white);
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-md);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: var(--shadow-sm);
}

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

.btn-secondary {
    background-color: #e2e8f0;
    color: #334155;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-md);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-secondary:hover {
    background-color: #cbd5e1;
}

/* =============================================================================
   App Shell (Header & Sidebar)
   ============================================================================= */
.app-wrapper {
    display: flex;
    min-height: 100vh;
}

/* Sidebar Styling */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--sidebar-bg);
    color: var(--text-white);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 100;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-header {
    height: var(--header-height);
    display: flex;
    align-items: center;
    padding: 0 24px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    gap: 12px;
}

.sidebar-logo {
    width: 38px;
    height: 38px;
}

.sidebar-title h2 {
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.sidebar-title p {
    font-size: 0.65rem;
    color: var(--accent);
    font-weight: 600;
}

.sidebar-nav {
    flex: 1;
    padding: 24px 16px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    border-radius: var(--radius-md);
    color: var(--text-light);
    font-weight: 500;
    transition: all 0.2s ease;
    gap: 12px;
}

.nav-item svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    stroke: currentColor;
}

.nav-item:hover {
    background-color: rgba(255, 255, 255, 0.05);
    color: var(--text-white);
}

.nav-item.active {
    background-color: var(--primary);
    color: var(--text-white);
    border-left: 4px solid var(--accent);
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

/* Main Content Area */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0; /* Prevents flex children from breaking grid layout width */
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Header styling */
.main-header {
    height: var(--header-height);
    background-color: var(--surface);
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
    position: sticky;
    top: 0;
    z-index: 90;
    box-shadow: var(--shadow-sm);
}

.header-search {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-muted);
}

.header-user {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--primary-light);
}

.user-info {
    text-align: right;
}

.user-info .name {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-main);
}

.user-info .role {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: capitalize;
}

/* Page Container */
.page-container {
    padding: 32px;
    flex: 1;
    max-width: 1400px;
    width: 100%;
    margin: 0 auto;
}

.page-title-block {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}

.page-title-block h1 {
    font-size: 1.75rem;
    color: var(--primary-dark);
}

.page-title-block p {
    color: var(--text-muted);
    font-size: 0.95rem;
}

/* =============================================================================
   Dashboard Widgets
   ============================================================================= */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}

.stat-card {
    background-color: var(--surface);
    padding: 24px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: relative;
    overflow: hidden;
}

.stat-card::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 4px;
    background-color: var(--primary-light);
}

.stat-card.accent::after {
    background-color: var(--accent);
}

.stat-card.success::after {
    background-color: var(--success);
}

.stat-card.info::after {
    background-color: var(--info);
}

.stat-card-details h3 {
    font-size: 0.85rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.stat-card-details .number {
    font-size: 2rem;
    font-family: var(--font-heading);
    color: var(--text-main);
    line-height: 1.1;
}

.stat-card-icon {
    width: 50px;
    height: 50px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary-light);
    background-color: rgba(59, 130, 246, 0.1);
}

.stat-card.accent .stat-card-icon {
    color: var(--accent);
    background-color: rgba(217, 119, 6, 0.1);
}

.stat-card.success .stat-card-icon {
    color: var(--success);
    background-color: rgba(16, 185, 129, 0.1);
}

.stat-card.info .stat-card-icon {
    color: var(--info);
    background-color: rgba(6, 182, 212, 0.1);
}

.stat-card-icon svg {
    width: 24px;
    height: 24px;
}

/* =============================================================================
   Card and Table Styles
   ============================================================================= */
.card {
    background-color: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: 28px;
    margin-bottom: 28px;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    border-bottom: 1px solid #e2e8f0;
    padding-bottom: 15px;
}

.card-header h2 {
    font-size: 1.25rem;
    color: var(--primary-dark);
}

/* Data Tables */
.table-responsive {
    width: 100%;
    overflow-x: auto;
}

.table-custom {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

.table-custom th {
    background-color: #f1f5f9;
    padding: 14px 18px;
    font-weight: 600;
    color: #475569;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 2px solid #e2e8f0;
}

.table-custom td {
    padding: 14px 18px;
    border-bottom: 1px solid #f1f5f9;
    color: var(--text-main);
    font-size: 0.95rem;
}

.table-custom tr:hover td {
    background-color: #f8fafc;
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 50px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

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

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

.badge.warning {
    background-color: #fef3c7;
    color: #d97706;
}

/* Forms styling */
.row {
    display: flex;
    flex-wrap: wrap;
    margin: 0 -10px;
}

.col {
    flex: 1;
    padding: 0 10px;
    min-width: 250px;
}

.col-3 { width: 25%; }
.col-4 { width: 33.33%; }
.col-6 { width: 50%; }
.col-12 { width: 100%; }

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

.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 6px;
}

/* Custom Alert Notifications */
.alert {
    padding: 16px 20px;
    border-radius: var(--radius-md);
    margin-bottom: 24px;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 12px;
}

.alert-success {
    background-color: var(--success-light);
    color: #065f46;
    border: 1px solid #a7f3d0;
}

.alert-error {
    background-color: var(--error-light);
    color: #991b1b;
    border: 1px solid #fecaca;
}

/* =============================================================================
   Interactive Marks Entry Spreadsheet Grid
   ============================================================================= */
.marks-entry-table {
    border: 1px solid #cbd5e1;
    border-radius: var(--radius-md);
    overflow: hidden;
}

.marks-entry-table input[type="number"] {
    width: 90px;
    padding: 8px 12px;
    border: 1.5px solid #cbd5e1;
    border-radius: var(--radius-sm);
    text-align: center;
    font-weight: 600;
    outline: none;
    transition: all 0.2s ease;
}

.marks-entry-table input[type="number"]:focus {
    border-color: var(--primary-light);
    background-color: #eff6ff;
}

.marks-entry-table input[type="number"].is-invalid {
    border-color: var(--error);
    background-color: var(--error-light);
}

.marks-entry-row-active td {
    background-color: #f0fdf4 !important;
}

/* =============================================================================
   Result Card Design (Web View & Print Layout)
   ============================================================================= */
.result-card-container {
    max-width: 850px;
    margin: 0 auto;
    background-color: var(--surface);
    box-shadow: var(--shadow-lg);
    border-radius: var(--radius-md);
    padding: 15px;
    border: 1px solid #e2e8f0;
}

.print-actions {
    max-width: 850px;
    margin: 0 auto 20px;
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

.report-card-outer {
    border: 6px double #1e293b;
    padding: 24px;
    background-color: #ffffff;
    color: #000000;
    position: relative;
}

.report-card-header {
    display: flex;
    align-items: center;
    border-bottom: 3px double #1e293b;
    padding-bottom: 16px;
    margin-bottom: 20px;
}

.school-logo-print {
    width: 95px;
    height: 95px;
    flex-shrink: 0;
}

.school-title-section {
    flex: 1;
    text-align: center;
    padding: 0 16px;
}

.school-title-section .urdu-name {
    font-family: var(--font-urdu);
    font-size: 2.1rem;
    font-weight: bold;
    margin-bottom: 4px;
    line-height: 1.4;
    color: #0f172a;
}

.school-title-section .english-name {
    font-family: var(--font-heading);
    font-size: 1.45rem;
    font-weight: 800;
    color: #1e3a8a;
    letter-spacing: 0.5px;
}

.school-title-section .school-sub {
    font-size: 0.85rem;
    color: #475569;
    font-weight: 500;
}

.report-card-title {
    background-color: #1e3a8a;
    color: #ffffff;
    text-align: center;
    padding: 8px;
    font-family: var(--font-heading);
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: 1px;
    margin-bottom: 20px;
    border-radius: 4px;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
}

.student-meta-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 20px;
}

.student-meta-table td {
    padding: 8px 12px;
    border: 1px solid #cbd5e1;
    font-size: 0.9rem;
    color: #0f172a;
}

.student-meta-table td.label-cell {
    font-weight: 700;
    background-color: #f8fafc;
    width: 18%;
    color: #334155;
}

.student-meta-table td.value-cell {
    width: 32%;
}

.marks-table-printed {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 24px;
}

.marks-table-printed th {
    background-color: #1e3a8a;
    color: #ffffff;
    padding: 10px 14px;
    font-weight: 700;
    font-size: 0.85rem;
    text-align: center;
    border: 1px solid #1e3a8a;
    text-transform: uppercase;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
}

.marks-table-printed td {
    padding: 10px 14px;
    border: 1px solid #94a3b8;
    font-size: 0.9rem;
    text-align: center;
    color: #0f172a;
}

.marks-table-printed td.subject-name {
    text-align: left;
    font-weight: 600;
    background-color: #f8fafc;
}

.marks-table-printed tr.summary-row td {
    font-weight: 700;
    background-color: #f1f5f9;
    font-size: 0.95rem;
    border-top: 2px solid #1e293b;
}

/* Result status highlight in print */
.result-status-badge {
    font-weight: 800;
    font-size: 1rem;
}
.result-status-badge.pass {
    color: #047857;
}
.result-status-badge.fail {
    color: #b91c1c;
}

/* Grades scale overview footer */
.report-card-footer {
    display: flex;
    gap: 20px;
    margin-top: 20px;
}

.grades-legend {
    flex: 1;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    padding: 10px;
}

.grades-legend h4 {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
    text-align: center;
    color: #475569;
}

.grades-legend-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 4px 10px;
    font-size: 0.75rem;
    text-align: center;
}

.legend-item {
    border-bottom: 1px dashed #cbd5e1;
    padding: 2px 0;
}

/* Signature block */
.signature-section {
    width: 100%;
    display: flex;
    justify-content: space-between;
    margin-top: 50px;
    border-top: 1.5px dashed #94a3b8;
    padding-top: 8px;
}

.sig-box {
    width: 25%;
    text-align: center;
    font-size: 0.85rem;
    font-weight: 600;
    color: #334155;
}

.sig-line {
    height: 35px;
}

/* =============================================================================
   Responsive Design & Print Adjustments
   ============================================================================= */
@media (max-width: 991px) {
    :root {
        --sidebar-width: 0px;
    }
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.open {
        transform: translateX(0);
        width: 260px;
        box-shadow: 10px 0 30px rgba(0,0,0,0.25);
    }
    .main-content {
        margin-left: 0;
    }
    .sidebar-toggle-btn {
        display: block !important;
    }
}

.sidebar-toggle-btn {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-main);
    padding: 8px;
}
.sidebar-toggle-btn svg {
    width: 24px;
    height: 24px;
}

/* PRINT MEDIA QUERIES */
@media print {
    /* Hide all browser interface and non-print items */
    body, html {
        background: #ffffff !important;
        color: #000000 !important;
        margin: 0 !important;
        padding: 0 !important;
        width: 100% !important;
        font-size: 10pt !important;
    }
    
    .sidebar,
    .main-header,
    .print-actions,
    .alert,
    .no-print,
    .sidebar-toggle-btn,
    .sidebar-footer {
        display: none !important;
    }
    
    .main-content {
        margin-left: 0 !important;
        padding: 0 !important;
    }
    
    .page-container {
        padding: 0 !important;
        margin: 0 !important;
        max-width: 100% !important;
    }
    
    .result-card-container {
        border: none !important;
        box-shadow: none !important;
        padding: 0 !important;
        max-width: 100% !important;
        background: transparent !important;
    }

    /* Set up A4 print layout properties */
    @page {
        size: A4 portrait;
        margin: 12mm 10mm 12mm 10mm;
    }
    
    .report-card-outer {
        border: 5px double #000000 !important;
        padding: 20px !important;
        page-break-inside: avoid;
        break-inside: avoid;
    }

    .report-card-title {
        background-color: #1e3a8a !important;
        color: #ffffff !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    .marks-table-printed th {
        background-color: #1e3a8a !important;
        color: #ffffff !important;
        border: 1px solid #1e3a8a !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }
    
    /* Page Break for bulk printing */
    .page-break {
        page-break-after: always !important;
        break-after: page !important;
    }
}
