/**
 * School ERP Pro - Enterprise Design System
 * Light/Dark Mode Variables, Responsive Grid, Components
 */

:root {
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --primary-subtle: #eef2ff;
    --secondary: #64748b;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --info: #06b6d4;

    --bg-body: #f8fafc;
    --bg-surface: #ffffff;
    --bg-card: #ffffff;
    --border-color: #e2e8f0;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;

    --sidebar-width: 260px;
    --sidebar-bg: #0f172a;
    --sidebar-text: #94a3b8;
    --sidebar-text-active: #ffffff;
    --sidebar-link-active-bg: #4f46e5;

    --topbar-height: 64px;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.05);
}

[data-bs-theme="dark"] {
    --bg-body: #090d16;
    --bg-surface: #111827;
    --bg-card: #111827;
    --border-color: #1f2937;
    --text-primary: #f8fafc;
    --text-secondary: #cbd5e1;
    --text-muted: #64748b;

    --sidebar-bg: #0b0f19;
    --primary-subtle: rgba(79, 70, 229, 0.15);
}

* {
    box-sizing: border-box;
}

body {
    background-color: var(--bg-body);
    color: var(--text-primary);
    font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
    font-size: 0.93rem;
    line-height: 1.5;
    margin: 0;
    overflow-x: hidden;
}

/* Layout Structure */
.erp-wrapper {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.erp-sidebar {
    width: var(--sidebar-width);
    background-color: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 1040;
    transition: transform 0.3s ease;
    border-right: 1px solid rgba(255, 255, 255, 0.05);
}

.sidebar-brand {
    height: var(--topbar-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.25rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.brand-link {
    display: flex;
    align-items: center;
    text-decoration: none;
    gap: 0.75rem;
}

.brand-icon {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: linear-gradient(135deg, #4f46e5, #818cf8);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 1.15rem;
}

.brand-title {
    font-weight: 800;
    font-size: 1.1rem;
    color: #ffffff;
    letter-spacing: -0.5px;
    display: block;
    line-height: 1.1;
}

.brand-sub {
    font-size: 0.72rem;
    color: #818cf8;
    font-weight: 600;
    letter-spacing: 0.5px;
}

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

.sidebar-menu::-webkit-scrollbar {
    width: 5px;
}

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

.nav-header {
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.8px;
    color: #475569;
    padding: 0.85rem 0.75rem 0.35rem;
    text-transform: uppercase;
}

.sidebar-menu .nav-link {
    display: flex;
    align-items: center;
    padding: 0.6rem 0.85rem;
    color: var(--sidebar-text);
    border-radius: 8px;
    margin-bottom: 2px;
    font-weight: 500;
    font-size: 0.88rem;
    transition: all 0.2s ease;
    text-decoration: none;
}

.sidebar-menu .nav-link i {
    width: 22px;
    font-size: 1rem;
    margin-right: 0.75rem;
    color: #64748b;
    transition: color 0.2s ease;
}

.sidebar-menu .nav-link:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.05);
}

.sidebar-menu .nav-link:hover i {
    color: #ffffff;
}

.sidebar-menu .nav-link.active {
    color: var(--sidebar-text-active);
    background-color: var(--sidebar-link-active-bg);
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.35);
}

.sidebar-menu .nav-link.active i {
    color: #ffffff;
}

/* Main Area */
.erp-main {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    transition: margin-left 0.3s ease;
}

/* Topbar */
.erp-topbar {
    height: var(--topbar-height);
    background-color: var(--bg-surface);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    position: sticky;
    top: 0;
    z-index: 1020;
    box-shadow: var(--shadow-sm);
}

.topbar-left, .topbar-right {
    display: flex;
    align-items: center;
}

.btn-icon {
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    background: var(--bg-surface);
}

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

.btn-user-dropdown {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.25rem 0.5rem;
    border: none;
    background: transparent;
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, #4f46e5, #06b6d4);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.95rem;
}

.user-name {
    font-weight: 600;
    font-size: 0.88rem;
    color: var(--text-primary);
    display: block;
    line-height: 1.2;
}

.user-role {
    font-size: 0.72rem;
    color: var(--text-muted);
    display: block;
}

/* Content Area */
.erp-content {
    flex: 1;
    background-color: var(--bg-body);
}

.erp-footer {
    background-color: var(--bg-surface);
    border-top: 1px solid var(--border-color);
}

/* Cards & UI Widgets */
.card-stat {
    border: 1px solid var(--border-color);
    border-radius: 14px;
    background-color: var(--bg-card);
    padding: 1.25rem;
    box-shadow: var(--shadow-sm);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

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

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

.stat-icon.primary { background: var(--primary-subtle); color: var(--primary); }
.stat-icon.success { background: rgba(16, 185, 129, 0.12); color: var(--success); }
.stat-icon.warning { background: rgba(245, 158, 11, 0.12); color: var(--warning); }
.stat-icon.danger { background: rgba(239, 68, 68, 0.12); color: var(--danger); }
.stat-icon.info { background: rgba(6, 182, 212, 0.12); color: var(--info); }

.stat-value {
    font-size: 1.65rem;
    font-weight: 700;
    line-height: 1.2;
    color: var(--text-primary);
}

.stat-label {
    font-size: 0.82rem;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Responsive Sidebar Behavior */
@media (max-width: 991.98px) {
    .erp-sidebar {
        transform: translateX(-100%);
    }
    .erp-sidebar.show {
        transform: translateX(0);
    }
    .erp-main {
        margin-left: 0;
    }
    .sidebar-overlay {
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 1030;
    }
}

/* Buttons and Form Enhancements */
.btn-primary {
    background-color: var(--primary);
    border-color: var(--primary);
}

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

.form-control, .form-select {
    border-color: var(--border-color);
    background-color: var(--bg-surface);
    color: var(--text-primary);
    border-radius: 8px;
    padding: 0.55rem 0.85rem;
    font-size: 0.9rem;
}

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

/* DataTables Styling */
.dataTables_wrapper .dataTables_length,
.dataTables_wrapper .dataTables_filter {
    margin-bottom: 1rem;
}

.table {
    border-color: var(--border-color);
    color: var(--text-primary);
}

.table th {
    font-weight: 600;
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    background-color: var(--bg-body);
}

/* Badges */
.badge-status {
    padding: 0.35rem 0.65rem;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.75rem;
}
