/* ============================================================
   School ERP — Main Stylesheet
   Bootstrap 5 base + custom ERP layout + legacy module classes
   ============================================================ */

/* ── Variables ─────────────────────────────────────────────── */
:root {
    --erp-sidebar-width:     250px;
    --erp-sidebar-collapsed: 0px;
    --erp-topbar-height:     56px;
    --erp-primary:           #1a237e;
    --erp-primary-dark:      #0d1757;
    --erp-primary-light:     #e8eaf6;
    --erp-accent:            #5c6bc0;
    --erp-bg:                #f0f2f8;
    --erp-surface:           #ffffff;
    --erp-text:              #2d3748;
    --erp-text-muted:        #718096;
    --erp-border:            #e2e8f0;
    --erp-shadow-sm:         0 1px 3px rgba(0,0,0,.08);
    --erp-shadow-md:         0 4px 12px rgba(0,0,0,.10);
    --erp-radius:            10px;
    --erp-transition:        .22s ease;
}

/* ── Base ───────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--erp-bg);
    color: var(--erp-text);
    min-height: 100vh;
}

/* ── TOP NAVBAR ─────────────────────────────────────────────── */
.erp-topbar {
    height: var(--erp-topbar-height);
    background: var(--erp-primary);
    box-shadow: 0 2px 8px rgba(0,0,0,.18);
    z-index: 1050;
    padding: 0;
}

.erp-brand {
    text-decoration: none;
    color: #fff !important;
    font-weight: 700;
    font-size: 1.05rem;
    letter-spacing: .3px;
}

.erp-brand-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: rgba(255,255,255,.18);
    border-radius: 8px;
    font-size: 1rem;
}

.erp-sidebar-toggle {
    text-decoration: none;
    line-height: 1;
}
.erp-sidebar-toggle:hover i { opacity: .75; }

/* Avatar circle */
.erp-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(255,255,255,.22);
    color: #fff;
    font-weight: 700;
    font-size: .85rem;
    border: 2px solid rgba(255,255,255,.35);
    flex-shrink: 0;
}

/* Dropdown */
.erp-dropdown {
    border: 1px solid var(--erp-border);
    border-radius: var(--erp-radius);
    min-width: 200px;
    padding: 4px 0;
}
.erp-dropdown .dropdown-item { padding: 8px 16px; }
.erp-dropdown .dropdown-item:hover { background: var(--erp-primary-light); }

/* ── SIDEBAR ────────────────────────────────────────────────── */
.erp-sidebar {
    position: fixed;
    top: var(--erp-topbar-height);
    left: 0;
    width: var(--erp-sidebar-width);
    height: calc(100vh - var(--erp-topbar-height));
    background: var(--erp-primary-dark);
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 1040;
    transition: transform var(--erp-transition), width var(--erp-transition);
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,.15) transparent;
}

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

.erp-sidebar-header {
    height: 44px;
    border-bottom: 1px solid rgba(255,255,255,.07);
}

.erp-sidebar-label {
    color: rgba(255,255,255,.35);
    font-size: .68rem;
    letter-spacing: 1px;
}

/* Nav group label */
.erp-nav-group {
    padding: 18px 16px 4px;
    font-size: .68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: rgba(255,255,255,.3);
    pointer-events: none;
}

/* Nav links */
.erp-nav-link {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 10px 18px;
    color: rgba(255,255,255,.72);
    text-decoration: none;
    font-size: .88rem;
    border-left: 3px solid transparent;
    transition: background var(--erp-transition), color var(--erp-transition), border-color var(--erp-transition);
    white-space: nowrap;
}

.erp-nav-link i {
    font-size: 1rem;
    flex-shrink: 0;
    width: 20px;
    text-align: center;
}

.erp-nav-link:hover {
    background: rgba(255,255,255,.07);
    color: #fff;
    border-left-color: var(--erp-accent);
}

.erp-nav-link.active {
    background: rgba(255,255,255,.12);
    color: #fff;
    font-weight: 600;
    border-left-color: #fff;
}

.erp-nav-logout {
    color: rgba(255,100,100,.8) !important;
}
.erp-nav-logout:hover {
    background: rgba(255,80,80,.12) !important;
    color: #ff6b6b !important;
    border-left-color: #ff6b6b !important;
}

/* ── CONTENT WRAPPER ────────────────────────────────────────── */
.erp-content-wrapper {
    margin-left: var(--erp-sidebar-width);
    margin-top: var(--erp-topbar-height);
    min-height: calc(100vh - var(--erp-topbar-height));
    display: flex;
    flex-direction: column;
    transition: margin-left var(--erp-transition);
}

.erp-main {
    flex: 1;
}

/* ── FOOTER ─────────────────────────────────────────────────── */
.erp-footer {
    background: var(--erp-surface);
    border-top: 1px solid var(--erp-border);
    padding: 14px 24px;
    font-size: .82rem;
    color: var(--erp-text-muted);
}

.erp-role-badge {
    background: var(--erp-primary-light);
    color: var(--erp-primary);
    font-size: .72rem;
    padding: 2px 8px;
    border-radius: 20px;
}

/* ── SIDEBAR COLLAPSED (desktop toggle) ─────────────────────── */
body.sidebar-collapsed .erp-sidebar {
    width: 60px;
}
body.sidebar-collapsed .erp-sidebar .erp-nav-link span,
body.sidebar-collapsed .erp-sidebar .erp-nav-group,
body.sidebar-collapsed .erp-sidebar .erp-sidebar-label {
    display: none;
}
body.sidebar-collapsed .erp-sidebar .erp-nav-link {
    justify-content: center;
    padding: 12px;
    border-left: none;
    border-radius: 0;
}
body.sidebar-collapsed .erp-sidebar .erp-nav-link i {
    width: auto;
    font-size: 1.15rem;
}
body.sidebar-collapsed .erp-content-wrapper {
    margin-left: 60px;
}

/* ── MOBILE OVERLAY ─────────────────────────────────────────── */
.erp-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 1039;
}
.erp-overlay.show { display: block; }

/* ── RESPONSIVE ─────────────────────────────────────────────── */
@media (max-width: 991.98px) {
    .erp-sidebar {
        transform: translateX(-100%);
        width: var(--erp-sidebar-width);
    }
    .erp-sidebar.show {
        transform: translateX(0);
    }
    .erp-content-wrapper {
        margin-left: 0 !important;
    }
    body.sidebar-collapsed .erp-sidebar {
        width: var(--erp-sidebar-width);
    }
}

/* ============================================================
   MODULE / PAGE COMPONENTS
   (kept from original + upgraded)
   ============================================================ */

/* ── Page header ── */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--erp-border);
}
.page-header h1 {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--erp-text);
    margin: 0;
}

/* ── Cards ── */
.erp-card {
    background: var(--erp-surface);
    border-radius: var(--erp-radius);
    box-shadow: var(--erp-shadow-sm);
    border: 1px solid var(--erp-border);
    padding: 20px;
}

/* ── Stat cards ── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--erp-surface);
    border-radius: var(--erp-radius);
    padding: 20px 22px;
    box-shadow: var(--erp-shadow-sm);
    border: 1px solid var(--erp-border);
    display: flex;
    align-items: center;
    gap: 16px;
    transition: box-shadow var(--erp-transition), transform var(--erp-transition);
}
.stat-card:hover {
    box-shadow: var(--erp-shadow-md);
    transform: translateY(-2px);
}
.stat-card-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    flex-shrink: 0;
}
.stat-card-icon.blue   { background: #e8eaf6; color: var(--erp-primary); }
.stat-card-icon.green  { background: #e8f5e9; color: #2e7d32; }
.stat-card-icon.orange { background: #fff3e0; color: #e65100; }
.stat-card-icon.red    { background: #ffebee; color: #c62828; }

.stat-card h3 { font-size: .78rem; color: var(--erp-text-muted); margin: 0 0 4px; text-transform: uppercase; letter-spacing: .5px; }
.stat-card p  { font-size: 1.75rem; font-weight: 700; color: var(--erp-text); margin: 0; line-height: 1; }

/* ── Data table ── */
.data-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--erp-surface);
    border-radius: var(--erp-radius);
    overflow: hidden;
    box-shadow: var(--erp-shadow-sm);
    border: 1px solid var(--erp-border);
}
.data-table thead th {
    background: var(--erp-primary);
    color: #fff;
    padding: 11px 16px;
    text-align: left;
    font-size: .8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .5px;
    white-space: nowrap;
}
.data-table tbody td {
    padding: 11px 16px;
    border-bottom: 1px solid var(--erp-border);
    font-size: .88rem;
    vertical-align: middle;
}
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover td { background: var(--erp-primary-light); }

/* ── Buttons ── */
.btn-erp {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 18px;
    background: var(--erp-primary);
    color: #fff;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    text-decoration: none;
    font-size: .88rem;
    font-weight: 500;
    transition: background var(--erp-transition), box-shadow var(--erp-transition);
}
.btn-erp:hover { background: var(--erp-accent); color: #fff; box-shadow: 0 2px 8px rgba(26,35,126,.25); }

/* Legacy .btn kept for backward compat */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 18px;
    background: var(--erp-primary);
    color: #fff !important;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    text-decoration: none;
    font-size: .88rem;
    font-weight: 500;
    transition: background var(--erp-transition);
}
.btn:hover { background: var(--erp-accent); }
.btn-secondary { background: #64748b; }
.btn-secondary:hover { background: #475569; }
.btn-danger-sm {
    color: #c62828;
    font-size: .82rem;
    text-decoration: none;
}
.btn-danger-sm:hover { text-decoration: underline; }

/* ── Forms ── */
.form {
    background: var(--erp-surface);
    padding: 28px;
    border-radius: var(--erp-radius);
    box-shadow: var(--erp-shadow-sm);
    border: 1px solid var(--erp-border);
    display: flex;
    flex-direction: column;
    gap: 14px;
    max-width: 540px;
}
.form input,
.form select,
.form textarea {
    padding: 9px 13px;
    border: 1px solid var(--erp-border);
    border-radius: 6px;
    font-size: .9rem;
    width: 100%;
    transition: border-color var(--erp-transition), box-shadow var(--erp-transition);
}
.form input:focus,
.form select:focus,
.form textarea:focus {
    outline: none;
    border-color: var(--erp-accent);
    box-shadow: 0 0 0 3px rgba(92,107,192,.15);
}

/* ── Auth page ── */
.auth-page {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: linear-gradient(135deg, var(--erp-primary) 0%, var(--erp-accent) 100%);
}
.auth-box {
    background: var(--erp-surface);
    padding: 40px;
    border-radius: 14px;
    box-shadow: 0 8px 32px rgba(0,0,0,.18);
    width: 360px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.auth-box h2 { text-align: center; color: var(--erp-primary); font-weight: 700; }
.auth-box input {
    padding: 10px 13px;
    border: 1px solid var(--erp-border);
    border-radius: 6px;
    font-size: .95rem;
    width: 100%;
}
.auth-box input:focus {
    outline: none;
    border-color: var(--erp-accent);
    box-shadow: 0 0 0 3px rgba(92,107,192,.15);
}
.auth-box button {
    padding: 11px;
    background: var(--erp-primary);
    color: #fff;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    transition: background var(--erp-transition);
}
.auth-box button:hover { background: var(--erp-accent); }

/* ── Alerts ── */
.error   { color: #c62828; background: #ffebee; padding: 11px 14px; border-radius: 6px; border-left: 4px solid #c62828; font-size: .9rem; }
.success { color: #2e7d32; background: #e8f5e9; padding: 11px 14px; border-radius: 6px; border-left: 4px solid #2e7d32; font-size: .9rem; }

/* ── Badges ── */
.badge { padding: 4px 10px; border-radius: 20px; font-size: .75rem; font-weight: 600; }
.badge-present { background: #e8f5e9; color: #2e7d32; }
.badge-absent  { background: #ffebee; color: #c62828; }
.badge-late    { background: #fff8e1; color: #f57f17; }
.badge-holiday { background: #e3f2fd; color: #1565c0; }

/* ── Profile card ── */
.profile-card {
    background: var(--erp-surface);
    padding: 24px;
    border-radius: var(--erp-radius);
    box-shadow: var(--erp-shadow-sm);
    border: 1px solid var(--erp-border);
    max-width: 500px;
    margin-bottom: 20px;
}
.profile-card p {
    padding: 9px 0;
    border-bottom: 1px solid var(--erp-border);
    font-size: .92rem;
    margin: 0;
}
.profile-card p:last-child { border-bottom: none; }

/* ── Legacy container ── */
.container { max-width: 1200px; margin: 0 auto; padding: 0 16px; }
