/* ============================================================
   School Management System - Main Stylesheet
   ============================================================ */

:root {
    --sidebar-width: 260px;
    --sidebar-collapsed-width: 0px;
    --topbar-height: 64px;
    --primary: #4f46e5;
    --primary-dark: #4338ca;
    --primary-light: #eef2ff;
    --secondary: #64748b;
    --success: #22c55e;
    --danger: #ef4444;
    --warning: #f59e0b;
    --info: #3b82f6;
    --dark: #1e293b;
    --light: #f8fafc;
    --border: #e2e8f0;
    --sidebar-bg: #1e293b;
    --sidebar-text: #94a3b8;
    --sidebar-active: #4f46e5;
    --body-bg: #f1f5f9;
    --card-bg: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -2px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -4px rgba(0,0,0,0.1);
    --radius: 8px;
    --radius-lg: 12px;
    --transition: all 0.3s ease;
}

/* ---- Reset & Base ---- */
* { box-sizing: border-box; }

body {
    font-family: var(--font-family);
    background: var(--body-bg);
    color: var(--text-primary);
    margin: 0;
    padding: 0;
    font-size: 14px;
    line-height: 1.6;
    overflow-x: hidden;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    z-index: 1040;
    display: flex;
    flex-direction: column;
    transition: var(--transition);
    overflow: hidden;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    min-height: var(--topbar-height);
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #fff;
    font-size: 24px;
}

.sidebar-brand {
    font-size: 20px;
    font-weight: 700;
    letter-spacing: 1px;
}

.sidebar-close {
    color: var(--sidebar-text);
    display: none;
}

.sidebar-body {
    flex: 1;
    overflow-y: auto;
    padding: 12px 0;
}

.sidebar-body::-webkit-scrollbar { width: 4px; }
.sidebar-body::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 4px; }

.sidebar-footer {
    padding: 12px 20px;
    border-top: 1px solid rgba(255,255,255,0.08);
}

/* Nav Items */
.nav-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.nav-item { margin: 2px 8px; }

.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    color: var(--sidebar-text);
    border-radius: var(--radius);
    transition: var(--transition);
    font-size: 13.5px;
    font-weight: 400;
    white-space: nowrap;
    position: relative;
}

.nav-link:hover {
    color: #fff;
    background: rgba(255,255,255,0.08);
}

.nav-link.active {
    color: #fff;
    background: var(--sidebar-active);
    font-weight: 500;
}

.nav-link i:first-child {
    font-size: 18px;
    width: 22px;
    text-align: center;
    flex-shrink: 0;
}

.nav-arrow {
    margin-left: auto;
    font-size: 12px;
    transition: transform 0.3s ease;
}

.nav-link:not(.collapsed) .nav-arrow {
    transform: rotate(180deg);
}

/* Sub Nav */
.nav-sub {
    list-style: none;
    padding: 4px 0 4px 50px;
    margin: 0;
}

.nav-sub li a {
    display: block;
    padding: 7px 16px;
    color: var(--sidebar-text);
    font-size: 13px;
    border-radius: var(--radius);
    transition: var(--transition);
    position: relative;
}

.nav-sub li a::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 6px;
    height: 6px;
    border-radius: 50%;
    border: 1.5px solid var(--sidebar-text);
    transition: var(--transition);
}

.nav-sub li a:hover,
.nav-sub li a.active {
    color: #fff;
}

.nav-sub li a.active::before {
    background: var(--sidebar-active);
    border-color: var(--sidebar-active);
}

/* Sidebar Overlay */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1035;
    pointer-events: none;
}
.sidebar-overlay.show {
    display: block;
    pointer-events: auto;
}

/* ============================================================
   MAIN CONTENT
   ============================================================ */
.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    transition: var(--transition);
}

/* ============================================================
   TOP NAVBAR
   ============================================================ */
.top-navbar {
    position: sticky;
    top: 0;
    z-index: 1020;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    height: var(--topbar-height);
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
}

.top-navbar .btn-link {
    color: var(--text-secondary);
    text-decoration: none;
    padding: 4px;
}

.top-navbar .btn-link:hover {
    color: var(--text-primary);
}

.sidebar-toggle { display: none; }

.avatar-sm {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary-light);
    color: var(--primary);
    font-size: 20px;
    flex-shrink: 0;
}

.avatar-sm img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.notification-badge {
    font-size: 10px;
    padding: 2px 5px;
}

.breadcrumb { font-size: 12px; }
.breadcrumb-item a { color: var(--text-secondary); }
.breadcrumb-item.active { color: var(--text-secondary); }

/* ============================================================
   PAGE CONTENT
   ============================================================ */
.page-content {
    padding: 24px;
}

/* ============================================================
   CARDS
   ============================================================ */
.card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    margin-bottom: 24px;
}

.card-header {
    background: transparent;
    border-bottom: 1px solid var(--border);
    padding: 16px 20px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-body { padding: 20px; }

/* Stat Cards */
.stat-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    transition: var(--transition);
    box-shadow: var(--shadow-sm);
}

.stat-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.stat-icon {
    width: 52px;
    height: 52px;
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    flex-shrink: 0;
}

.stat-icon.bg-primary-light { background: #eef2ff; color: var(--primary); }
.stat-icon.bg-success-light { background: #f0fdf4; color: var(--success); }
.stat-icon.bg-danger-light { background: #fef2f2; color: var(--danger); }
.stat-icon.bg-warning-light { background: #fffbeb; color: var(--warning); }
.stat-icon.bg-info-light { background: #eff6ff; color: var(--info); }

.stat-details h3 {
    font-size: 24px;
    font-weight: 700;
    margin: 0;
    line-height: 1.2;
}

.stat-details p {
    margin: 0;
    color: var(--text-secondary);
    font-size: 13px;
}

/* ============================================================
   TABLES
   ============================================================ */
.table {
    font-size: 13.5px;
}

.table thead th {
    background: var(--light);
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    border-bottom: 2px solid var(--border);
    padding: 12px 16px;
    white-space: nowrap;
}

.table tbody td {
    padding: 12px 16px;
    vertical-align: middle;
    border-bottom: 1px solid var(--border);
}

.table-hover tbody tr:hover {
    background: var(--light);
}

/* ============================================================
   FORMS
   ============================================================ */
.form-control, .form-select {
    border-radius: var(--radius);
    border-color: var(--border);
    font-size: 14px;
    padding: 8px 14px;
}

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

.form-label {
    font-weight: 500;
    font-size: 13px;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.form-text { font-size: 12px; }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
    border-radius: var(--radius);
    font-size: 13.5px;
    font-weight: 500;
    padding: 8px 16px;
    transition: var(--transition);
}

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

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

.btn-sm { padding: 5px 12px; font-size: 12.5px; }

.btn-icon {
    width: 34px;
    height: 34px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius);
}

/* ============================================================
   BADGES
   ============================================================ */
.badge {
    font-weight: 500;
    font-size: 11.5px;
    padding: 4px 10px;
    border-radius: 6px;
}

/* ============================================================
   ALERTS
   ============================================================ */
.alert {
    border-radius: var(--radius);
    font-size: 14px;
    border: none;
}

/* ============================================================
   LOGIN PAGE
   ============================================================ */
/* ============================================================
   IEMIS NEPAL LOGIN PAGE
   ============================================================ */
.iemis-login-wrapper {
    min-height: 100vh;
    background-color: #063256;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 30px 15px;
    font-family: 'Mukta', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

.iemis-top-header {
    text-align: center;
    margin-bottom: 25px;
}

.iemis-top-title {
    color: #ffffff;
    font-size: 32px;
    font-weight: 700;
    margin: 0;
    letter-spacing: 0.5px;
}

.iemis-card {
    background: #ffffff;
    border-radius: 8px;
    box-shadow: 0 10px 35px rgba(0, 0, 0, 0.3);
    width: 100%;
    max-width: 920px;
    padding: 45px 50px 30px 50px;
}

.iemis-card-body {
    display: flex;
    flex-wrap: wrap;
    align-items: stretch;
}

.iemis-left-col {
    flex: 1 1 380px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding-right: 25px;
}

.iemis-emblem {
    width: 110px;
    height: auto;
    margin-bottom: 14px;
}

.iemis-gov-text {
    color: #1e293b;
    font-weight: 700;
    line-height: 1.5;
    margin-bottom: 12px;
}

.iemis-gov-title {
    font-size: 17px;
}

.iemis-gov-dept {
    font-size: 15.5px;
}

.iemis-gov-subdept {
    font-size: 15.5px;
}

.iemis-gov-location {
    font-size: 14.5px;
    font-weight: 600;
    color: #334155;
}

.iemis-contact-list {
    margin-top: 15px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 13.5px;
}

.iemis-contact-item {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    color: #0284c7;
    font-weight: 500;
}

.iemis-contact-item i {
    font-size: 14px;
    color: #0b3b60;
}

.iemis-contact-item a {
    color: #0284c7;
    text-decoration: none;
    transition: color 0.2s;
}

.iemis-contact-item a:hover {
    color: #0369a1;
    text-decoration: underline;
}

.iemis-divider {
    width: 1.5px;
    background-color: #0b3b60;
    margin: 0 10px;
    align-self: stretch;
}

.iemis-right-col {
    flex: 1 1 380px;
    padding-left: 25px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.iemis-form-title {
    color: #0b3b60;
    font-size: 24px;
    font-weight: 700;
    letter-spacing: 1.5px;
    margin-bottom: 35px;
    text-transform: uppercase;
}

.iemis-form-group {
    position: relative;
    margin-bottom: 28px;
}

.iemis-input {
    width: 100%;
    border: none;
    border-bottom: 2px solid #0b3b60;
    border-radius: 0;
    background: transparent;
    padding: 8px 30px 8px 0;
    font-size: 15px;
    color: #1e293b;
    transition: border-color 0.2s;
}

.iemis-input:focus {
    outline: none;
    border-bottom-color: #1b8bf2;
    box-shadow: none;
}

.iemis-input::placeholder {
    color: #94a3b8;
    font-size: 14px;
}

.iemis-toggle-pw {
    position: absolute;
    right: 0;
    bottom: 10px;
    background: none;
    border: none;
    color: #64748b;
    cursor: pointer;
    padding: 0;
    font-size: 16px;
}

.iemis-forgot-wrap {
    text-align: right;
    margin-top: -12px;
    margin-bottom: 30px;
}

.iemis-forgot-link {
    color: #64748b;
    font-size: 13.5px;
    text-decoration: none;
    font-weight: 500;
}

.iemis-forgot-link:hover {
    color: #1b8bf2;
}

.iemis-btn-submit {
    background-color: #1b8bf2;
    color: #ffffff;
    width: 100%;
    height: 44px;
    border: none;
    border-radius: 4px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s;
}

.iemis-btn-submit:hover {
    background-color: #1372ca;
}

.iemis-btn-submit:active {
    transform: scale(0.99);
}

.iemis-footer-links {
    margin-top: 35px;
    padding-top: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    text-align: center;
}

.iemis-footer-item {
    font-size: 13.5px;
    font-weight: 600;
    color: #0284c7;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-decoration: none;
    transition: color 0.2s;
}

.iemis-footer-item:hover {
    color: #0369a1;
    text-decoration: underline;
}

.iemis-footer-item i {
    color: #0b3b60;
    font-size: 15px;
}

@media (max-width: 820px) {
    .iemis-card {
        padding: 30px 20px;
    }
    .iemis-divider {
        display: none;
    }
    .iemis-left-col {
        padding-right: 0;
        margin-bottom: 35px;
        padding-bottom: 25px;
        border-bottom: 1px solid #e2e8f0;
    }
    .iemis-right-col {
        padding-left: 0;
    }
}

/* ============================================================
   UTILITIES
   ============================================================ */
.text-muted { color: var(--text-secondary) !important; }
.bg-light-custom { background: var(--light); }
.border-custom { border-color: var(--border) !important; }

.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-secondary);
}

.empty-state i {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.empty-state h5 {
    font-weight: 600;
    color: var(--text-primary);
}

.avatar-circle {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
    flex-shrink: 0;
}

.filter-bar {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 16px 20px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-sm);
}

/* Quick Actions */
.quick-action {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px 12px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    transition: var(--transition);
    color: var(--text-primary);
    text-align: center;
    gap: 8px;
    background: var(--card-bg);
}

.quick-action:hover {
    border-color: var(--primary);
    color: var(--primary);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.quick-action i {
    font-size: 28px;
    color: var(--primary);
}

.quick-action span {
    font-size: 12.5px;
    font-weight: 500;
}

/* ============================================================
   RESPONSIVE LAYOUT ENGINE (Mobile, Tablet, Desktop Auto-Fix)
   ============================================================ */

/* Global Anti-Overflow Rules */
html, body {
    max-width: 100%;
    overflow-x: hidden;
    position: relative;
    width: 100%;
}

img, video, iframe, embed, object {
    max-width: 100%;
    height: auto;
}

/* Fluid Container & Main Content Bounds */
.main-content {
    max-width: 100%;
    overflow-x: hidden;
}

/* Enhanced Table Responsiveness */
.table-responsive {
    display: block;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--radius);
    margin-bottom: 1rem;
}

.table-responsive::-webkit-scrollbar {
    height: 6px;
}

.table-responsive::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 3px;
}

.table-responsive::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

.table-responsive::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

.table th, .table td {
    overflow-wrap: break-word;
    word-break: normal;
}

/* Auto-Wrap Action Buttons & Cards */
.btn-group-responsive {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.card-header-responsive {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

/* Modal Responsiveness */
.modal-dialog {
    max-width: 95%;
    margin: 1.75rem auto;
}

@media (min-width: 576px) {
    .modal-dialog {
        max-width: 500px;
    }
    .modal-dialog.modal-lg {
        max-width: 800px;
    }
    .modal-dialog.modal-xl {
        max-width: 1140px;
    }
}

/* Large Screens (Desktop > 992px) */
@media (min-width: 992px) {
    .sidebar {
        transform: translateX(0) !important;
    }
    .sidebar-overlay {
        display: none !important;
    }
}

/* Tablet & Mobile Screens (<= 991.98px) */
@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%);
        width: 280px;
        box-shadow: var(--shadow-lg);
    }

    .sidebar.show {
        transform: translateX(0);
    }

    .sidebar-close { 
        display: block !important; 
    }
    
    .sidebar-overlay.show { 
        display: block !important; 
    }
    
    .sidebar-toggle { 
        display: inline-block !important; 
    }

    .main-content {
        margin-left: 0 !important;
        width: 100% !important;
    }

    .page-content {
        padding: 16px;
    }

    .top-navbar {
        padding: 0 16px;
    }
}

/* Mobile Screens (<= 767.98px) */
@media (max-width: 767.98px) {
    .page-content {
        padding: 12px;
    }

    .top-navbar {
        height: auto;
        min-height: var(--topbar-height);
        padding: 8px 12px;
        flex-wrap: wrap;
        gap: 8px;
    }

    .stat-card {
        padding: 14px;
        gap: 12px;
    }

    .stat-icon {
        width: 42px;
        height: 42px;
        font-size: 18px;
    }

    .stat-details h3 { 
        font-size: 18px; 
    }

    .card-header {
        flex-direction: column;
        gap: 10px;
        align-items: flex-start;
        padding: 12px 14px;
    }

    .card-header > div,
    .card-header > a,
    .card-header > button {
        width: 100%;
    }

    .card-body {
        padding: 14px;
    }

    .filter-bar {
        padding: 12px;
    }

    .form-control, .form-select, .btn {
        font-size: 13px;
    }

    .btn {
        padding: 7px 12px;
    }

    .btn-sm {
        padding: 5px 10px;
        font-size: 12px;
    }

    /* Modal Mobile Adaptations */
    .modal-dialog {
        margin: 0.5rem;
        max-width: calc(100% - 1rem);
    }
    
    .modal-content {
        max-height: 90vh;
        overflow-y: auto;
    }
}

/* Small Mobile Phones (<= 480px) */
@media (max-width: 480px) {
    .page-content {
        padding: 8px;
    }

    .card {
        margin-bottom: 14px;
        border-radius: var(--radius);
    }

    .stat-card {
        flex-direction: column;
        align-items: flex-start;
    }

    .top-navbar .avatar-sm {
        width: 32px;
        height: 32px;
    }
}

/* ============================================================
   PRINT STYLES
   ============================================================ */
@media print {
    .sidebar, .top-navbar, .sidebar-overlay { display: none !important; }
    .main-content { margin-left: 0 !important; width: 100% !important; }
    .page-content { padding: 0 !important; }
    .card { box-shadow: none !important; border: 1px solid #ddd !important; }
    .btn, .filter-bar { display: none !important; }
}

