/* ==========================================================
   School Management System - Modern, Clean & Beginner-Friendly UI
   ========================================================== */

:root {
    --primary-color: #1e40af;
    --primary-hover: #1d4ed8;
    --sidebar-bg: #0f172a;
    --sidebar-hover: #1e293b;
    --sidebar-active: #2563eb;
    --body-bg: #f8fafc;
    --card-border: #e2e8f0;
    --text-dark: #1e293b;
    --text-muted: #64748b;
    --success: #16a34a;
    --warning: #d97706;
    --danger: #dc2626;
    --info: #0284c7;
}

body {
    background-color: var(--body-bg);
    color: var(--text-dark);
    font-family: 'Poppins', 'Mukta', 'Noto Sans Devanagari', 'Nirmala UI', system-ui, -apple-system, sans-serif;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Sidebar */
.app-wrapper {
    display: flex;
    flex: 1;
    min-height: 100vh;
}

.sidebar {
    width: 260px;
    background-color: var(--sidebar-bg);
    color: #f1f5f9;
    flex-shrink: 0;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    padding: 1.25rem 1.25rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-brand {
    font-size: 1.15rem;
    font-weight: 700;
    color: #ffffff !important;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.sidebar-brand:hover,
.sidebar-brand:focus {
    color: #ffffff !important;
    text-decoration: none;
}

.sidebar-brand div,
.sidebar-brand small,
.sidebar-brand span {
    color: #ffffff !important;
}

.sidebar-menu {
    padding: 0.75rem 0.5rem;
    flex: 1;
    overflow-y: auto;
}

.sidebar-heading {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #94a3b8;
    padding: 0.75rem 0.75rem 0.25rem;
    font-weight: 600;
}

.nav-link-custom {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 0.85rem;
    color: #cbd5e1;
    border-radius: 8px;
    font-size: 0.92rem;
    font-weight: 500;
    text-decoration: none;
    margin-bottom: 3px;
    transition: background-color 0.2s, color 0.2s;
}

.nav-link-custom:hover {
    background-color: var(--sidebar-hover);
    color: #ffffff;
}

.nav-link-custom.active {
    background-color: var(--sidebar-active);
    color: #ffffff;
    font-weight: 600;
}

.nav-link-custom i {
    font-size: 1.15rem;
    width: 22px;
    text-align: center;
}

/* Main Content Area */
.main-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* Top Navbar */
.topbar {
    background: #ffffff;
    border-bottom: 1px solid var(--card-border);
    padding: 0.8rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
}

.content-body {
    padding: 1.75rem;
    flex: 1;
}

/* Dashboard Cards */
.stat-card {
    background: #ffffff;
    border: 1px solid var(--card-border);
    border-radius: 12px;
    padding: 1.25rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
    display: flex;
    align-items: center;
    gap: 1.2rem;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.08);
}

.stat-icon {
    width: 54px;
    height: 54px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6rem;
    flex-shrink: 0;
}

.stat-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    margin-bottom: 0.25rem;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-dark);
    margin-bottom: 0;
    line-height: 1.2;
}

/* Tables */
.table-custom {
    background: #ffffff;
    border: 1px solid var(--card-border);
    border-radius: 10px;
    overflow: hidden;
}

.table-custom thead th {
    background-color: #f1f5f9;
    color: #475569;
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    border-bottom: 1px solid var(--card-border);
    padding: 0.85rem 1rem;
}

.table-custom tbody td {
    padding: 0.85rem 1rem;
    vertical-align: middle;
    border-bottom: 1px solid #f1f5f9;
}

/* Buttons & Badges */
.btn-primary-sms {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
    color: #ffffff;
    font-weight: 600;
    border-radius: 8px;
    padding: 0.5rem 1.1rem;
}

.btn-primary-sms:hover {
    background-color: var(--primary-hover);
    border-color: var(--primary-hover);
    color: #ffffff;
}

.badge-role {
    font-weight: 600;
    font-size: 0.78rem;
    padding: 0.35rem 0.7rem;
    border-radius: 6px;
}

/* Form Styles */
.form-label {
    font-weight: 600;
    font-size: 0.88rem;
    color: #334155;
    margin-bottom: 0.35rem;
}

.form-control, .form-select {
    border-radius: 8px;
    border: 1px solid #cbd5e1;
    padding: 0.55rem 0.85rem;
    font-size: 0.93rem;
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

/* Certificate Styles */
.cert-preview-box {
    background: #fff;
    border: 6px double #334155;
    padding: 40px;
    border-radius: 4px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    position: relative;
    max-width: 850px;
    margin: 0 auto;
}

.cert-header {
    text-align: center;
    border-bottom: 2px solid #cbd5e1;
    padding-bottom: 15px;
    margin-bottom: 25px;
}

.cert-title {
    font-size: 1.8rem;
    font-weight: 800;
    text-transform: uppercase;
    color: #0f172a;
    letter-spacing: 1px;
}

/* ID Card Styles */
.id-card-single {
    width: 320px;
    background: #ffffff;
    border: 1px solid #94a3b8;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    margin: 10px auto;
    font-size: 0.85rem;
    page-break-inside: avoid;
}

.id-card-header {
    background: linear-gradient(135deg, #1e3a8a, #2563eb);
    color: white;
    text-align: center;
    padding: 12px 8px;
}

.id-photo-frame {
    width: 85px;
    height: 100px;
    border: 2px solid #2563eb;
    border-radius: 6px;
    object-fit: cover;
    margin: 10px auto;
    display: block;
    background: #f1f5f9;
}

/* Receipt styles */
.receipt-box {
    max-width: 780px;
    margin: 0 auto;
    background: #ffffff;
    border: 1px solid #cbd5e1;
    padding: 30px;
    border-radius: 8px;
}

/* Footer */
.app-footer {
    background: #ffffff;
    border-top: 1px solid var(--card-border);
    padding: 1rem 1.5rem;
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* ==========================================================
   Mobile & Responsive Drawer System (< 992px)
   ========================================================== */

/* Mobile Backdrop Overlay */
.sidebar-backdrop {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0.65);
    backdrop-filter: blur(2px);
    z-index: 1045;
    opacity: 0;
    transition: opacity 0.25s ease-in-out;
}

.sidebar-backdrop.show {
    display: block;
    opacity: 1;
}

@media (max-width: 991.98px) {
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: 280px;
        max-width: 85vw;
        height: 100vh;
        z-index: 1050;
        transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: none;
    }

    .sidebar.sidebar-open {
        transform: translateX(0);
        box-shadow: 4px 0 28px rgba(0, 0, 0, 0.4);
    }

    .main-wrapper {
        width: 100%;
        min-width: 0;
    }

    .topbar {
        padding: 0.65rem 1rem;
    }

    .content-body {
        padding: 1rem 0.85rem;
    }

    .app-footer {
        padding: 0.85rem 1rem;
        text-align: center;
    }

    /* Prevent mobile input zoom on iOS Safari */
    .form-control, .form-select, input[type="text"], input[type="password"], input[type="date"], select, textarea {
        font-size: 16px !important;
    }

    /* Stat Cards wrap comfortably on small screens */
    .stat-card {
        padding: 1rem;
        gap: 0.85rem;
    }

    .stat-icon {
        width: 48px;
        height: 48px;
        font-size: 1.4rem;
    }

    .stat-value {
        font-size: 1.35rem;
    }

    /* Responsive table containers */
    .table-responsive {
        border-radius: 8px;
        -webkit-overflow-scrolling: touch;
        margin-bottom: 0.75rem;
    }
}

/* Extra small mobile screens (< 576px) */
@media (max-width: 575.98px) {
    .content-body {
        padding: 0.85rem 0.6rem;
    }

    .card-body {
        padding: 0.95rem;
    }

    .btn-sm {
        padding: 0.35rem 0.65rem;
        font-size: 0.82rem;
    }

    .topbar .badge {
        font-size: 0.7rem;
    }
}
