/**
 * School Management System - Premium Design System
 * Color Palette, Typography, Spacing, Components
 */

/* =====================================================
   FONTS
   ===================================================== */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Poppins:wght@400;500;600;700&display=swap');

/* Kalpurush for Bangla/Assamese */
@font-face {
    font-family: 'Kalpurush';
    src: url('../fonts/Kalpurush.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

/* =====================================================
   CSS VARIABLES (Design Tokens)
   ===================================================== */
:root {
    /* Primary Colors */
    --primary: #2C3E91;
    --primary-light: #4A5FCF;
    --primary-dark: #1A2766;
    
    /* Accent Colors */
    --accent: #00A8D8;
    --accent-light: #33C4EC;
    --accent-dark: #0088B3;
    
    /* Gold Highlight */
    --gold: #F4B400;
    --gold-light: #FFD54F;
    
    /* Background Colors */
    --bg-page: #F7F9FC;
    --bg-card: #FFFFFF;
    --bg-sidebar: #0B1733;
    --bg-dark: #0B1220;
    
    /* Text Colors */
    --text-primary: #0B1733;
    --text-secondary: #6B7280;
    --text-muted: #9CA3AF;
    --text-light: #E6EEF8;
    
    /* Semantic Colors */
    --success: #16A34A;
    --success-light: #22C55E;
    --warning: #F59E0B;
    --warning-light: #FBBF24;
    --danger: #EF4444;
    --danger-light: #F87171;
    --info: #3B82F6;
    
    /* Borders */
    --border-color: #E5E7EB;
    --border-light: #F3F4F6;
    
    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    --shadow-xl: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    
    /* Border Radius */
    --radius-sm: 6px;
    --radius: 8px;
    --radius-md: 10px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --radius-full: 9999px;
    
    /* Spacing */
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 20px;
    --space-6: 24px;
    --space-8: 32px;
    --space-10: 40px;
    --space-12: 48px;
    
    /* Typography */
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-heading: 'Poppins', var(--font-sans);
    --font-bangla: 'Kalpurush', 'Noto Sans Bengali', sans-serif;
    
    /* Font Sizes */
    --text-xs: 12px;
    --text-sm: 14px;
    --text-base: 16px;
    --text-lg: 18px;
    --text-xl: 20px;
    --text-2xl: 24px;
    --text-3xl: 28px;
    --text-4xl: 32px;
    
    /* Line Heights */
    --leading-tight: 1.25;
    --leading-normal: 1.5;
    --leading-relaxed: 1.625;
    
    /* Transitions */
    --transition-fast: 150ms ease;
    --transition: 200ms ease;
    --transition-slow: 300ms ease;
    
    /* Layout */
    --sidebar-width: 260px;
    --sidebar-collapsed: 70px;
    --topbar-height: 64px;
    --content-max-width: 1400px;
}

/* Dark Mode */
[data-theme="dark"] {
    --bg-page: #0B1220;
    --bg-card: #0F1724;
    --text-primary: #E6EEF8;
    --text-secondary: #9CA3AF;
    --border-color: #1F2937;
    --border-light: #374151;
}

/* =====================================================
   RESET & BASE
   ===================================================== */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-sans);
    font-size: var(--text-base);
    line-height: var(--leading-normal);
    color: var(--text-primary);
    background-color: var(--bg-page);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Bangla/Assamese text */
.bn, .as, [lang="bn"], [lang="as"] {
    font-family: var(--font-bangla);
}

a {
    color: var(--accent);
    text-decoration: none;
    transition: color var(--transition);
}

a:hover {
    color: var(--accent-dark);
}

img {
    max-width: 100%;
    height: auto;
}

/* =====================================================
   TYPOGRAPHY
   ===================================================== */
h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-heading);
    font-weight: 600;
    line-height: var(--leading-tight);
    color: var(--text-primary);
}

h1 { font-size: var(--text-4xl); }
h2 { font-size: var(--text-2xl); }
h3 { font-size: var(--text-xl); }
h4 { font-size: var(--text-lg); }
h5 { font-size: var(--text-base); }
h6 { font-size: var(--text-sm); }

.page-title {
    font-size: var(--text-2xl);
    font-weight: 600;
    margin-bottom: var(--space-6);
}

.section-title {
    font-size: var(--text-lg);
    font-weight: 600;
    margin-bottom: var(--space-4);
}

/* =====================================================
   LAYOUT
   ===================================================== */
.admin-wrapper {
    display: flex;
    min-height: 100vh;
}

.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: var(--space-6);
    padding-top: calc(var(--topbar-height) + var(--space-6));
    transition: margin-left var(--transition);
}

.sidebar-collapsed .main-content {
    margin-left: var(--sidebar-collapsed);
}

.container {
    max-width: var(--content-max-width);
    margin: 0 auto;
    padding: 0 var(--space-4);
}

/* Grid System */
.grid {
    display: grid;
    gap: var(--space-6);
}

.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

@media (max-width: 1200px) {
    .grid-4 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
    .main-content { margin-left: 0; padding: var(--space-4); }
}

/* =====================================================
   CARDS
   ===================================================== */
.card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: var(--space-6);
    transition: transform var(--transition), box-shadow var(--transition);
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-4);
    padding-bottom: var(--space-4);
    border-bottom: 1px solid var(--border-light);
}

.card-title {
    font-size: var(--text-lg);
    font-weight: 600;
}

.card-body {
    padding: 0;
}

/* KPI Cards */
.kpi-card {
    display: flex;
    align-items: flex-start;
    gap: var(--space-4);
}

.kpi-icon {
    width: 56px;
    height: 56px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
}

.kpi-icon.primary { background: rgba(44, 62, 145, 0.1); color: var(--primary); }
.kpi-icon.accent { background: rgba(0, 168, 216, 0.1); color: var(--accent); }
.kpi-icon.success { background: rgba(22, 163, 74, 0.1); color: var(--success); }
.kpi-icon.warning { background: rgba(245, 158, 11, 0.1); color: var(--warning); }
.kpi-icon.danger { background: rgba(239, 68, 68, 0.1); color: var(--danger); }

.kpi-content {
    flex: 1;
}

.kpi-value {
    font-size: var(--text-3xl);
    font-weight: 700;
    color: var(--text-primary);
}

.kpi-label {
    font-size: var(--text-sm);
    color: var(--text-secondary);
}

/* Glass Effect */
.glass {
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

/* =====================================================
   BUTTONS
   ===================================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-5);
    font-size: var(--text-sm);
    font-weight: 500;
    border-radius: var(--radius);
    border: none;
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--accent);
    color: white;
}

.btn-primary:hover {
    background: var(--accent-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow);
}

.btn-secondary {
    background: transparent;
    color: var(--primary);
    border: 1px solid var(--primary);
}

.btn-secondary:hover {
    background: var(--primary);
    color: white;
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-danger:hover {
    background: var(--danger-light);
}

.btn-success {
    background: var(--success);
    color: white;
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
}

.btn-ghost:hover {
    background: var(--bg-page);
    color: var(--text-primary);
}

.btn-icon {
    width: 40px;
    height: 40px;
    padding: 0;
    border-radius: var(--radius);
}

.btn-sm {
    padding: var(--space-2) var(--space-3);
    font-size: var(--text-xs);
}

.btn-lg {
    padding: var(--space-4) var(--space-6);
    font-size: var(--text-base);
}

/* Floating Action Button */
.fab {
    position: fixed;
    bottom: var(--space-8);
    right: var(--space-8);
    width: 56px;
    height: 56px;
    border-radius: var(--radius-full);
    background: var(--accent);
    color: white;
    font-size: 24px;
    box-shadow: var(--shadow-lg);
    z-index: 100;
}

.fab:hover {
    transform: scale(1.1);
    box-shadow: var(--shadow-xl);
}

/* =====================================================
   FORMS
   ===================================================== */
.form-group {
    margin-bottom: var(--space-5);
}

.form-label {
    display: block;
    margin-bottom: var(--space-2);
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--text-primary);
}

.form-label .required {
    color: var(--danger);
}

.form-control {
    width: 100%;
    padding: var(--space-3) var(--space-4);
    font-size: var(--text-base);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    background: var(--bg-card);
    color: var(--text-primary);
    transition: border-color var(--transition), box-shadow var(--transition);
}

.form-control:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(0, 168, 216, 0.1);
}

.form-control::placeholder {
    color: var(--text-muted);
}

.form-control.is-invalid {
    border-color: var(--danger);
}

.form-helper {
    font-size: var(--text-xs);
    color: var(--text-secondary);
    margin-top: var(--space-1);
}

.form-error {
    font-size: var(--text-xs);
    color: var(--danger);
    margin-top: var(--space-1);
}

textarea.form-control {
    min-height: 120px;
    resize: vertical;
}

select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%236B7280' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10l-5 5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 40px;
}

/* Checkbox & Radio */
.form-check {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    cursor: pointer;
}

.form-check-input {
    width: 18px;
    height: 18px;
    accent-color: var(--accent);
}

/* File Upload */
.file-upload {
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-lg);
    padding: var(--space-8);
    text-align: center;
    cursor: pointer;
    transition: all var(--transition);
}

.file-upload:hover {
    border-color: var(--accent);
    background: rgba(0, 168, 216, 0.05);
}

/* =====================================================
   TABLES
   ===================================================== */
.table-wrapper {
    overflow-x: auto;
}

.table {
    width: 100%;
    border-collapse: collapse;
}

.table th,
.table td {
    padding: var(--space-4);
    text-align: left;
    border-bottom: 1px solid var(--border-light);
}

.table th {
    font-weight: 600;
    font-size: var(--text-sm);
    color: var(--text-secondary);
    background: var(--bg-page);
    position: sticky;
    top: 0;
}

.table tbody tr {
    transition: background var(--transition);
}

.table tbody tr:hover {
    background: rgba(0, 168, 216, 0.02);
}

.table .actions {
    display: flex;
    gap: var(--space-2);
}

/* =====================================================
   BADGES
   ===================================================== */
.badge {
    display: inline-flex;
    align-items: center;
    padding: var(--space-1) var(--space-3);
    font-size: var(--text-xs);
    font-weight: 500;
    border-radius: var(--radius-full);
}

.badge-primary { background: rgba(44, 62, 145, 0.1); color: var(--primary); }
.badge-success { background: rgba(22, 163, 74, 0.1); color: var(--success); }
.badge-warning { background: rgba(245, 158, 11, 0.1); color: var(--warning); }
.badge-danger { background: rgba(239, 68, 68, 0.1); color: var(--danger); }
.badge-info { background: rgba(59, 130, 246, 0.1); color: var(--info); }

/* =====================================================
   ALERTS
   ===================================================== */
.alert {
    padding: var(--space-4);
    border-radius: var(--radius);
    margin-bottom: var(--space-4);
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
}

.alert-success { background: rgba(22, 163, 74, 0.1); border-left: 4px solid var(--success); }
.alert-warning { background: rgba(245, 158, 11, 0.1); border-left: 4px solid var(--warning); }
.alert-danger { background: rgba(239, 68, 68, 0.1); border-left: 4px solid var(--danger); }
.alert-info { background: rgba(59, 130, 246, 0.1); border-left: 4px solid var(--info); }

/* =====================================================
   MODALS
   ===================================================== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(11, 23, 51, 0.5);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition);
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: var(--bg-card);
    border-radius: var(--radius-xl);
    max-width: 560px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    transform: scale(0.95);
    transition: transform var(--transition);
}

.modal-overlay.active .modal {
    transform: scale(1);
}

.modal-header {
    padding: var(--space-5) var(--space-6);
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-title {
    font-size: var(--text-lg);
    font-weight: 600;
}

.modal-close {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    cursor: pointer;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-body {
    padding: var(--space-6);
}

.modal-footer {
    padding: var(--space-4) var(--space-6);
    border-top: 1px solid var(--border-light);
    display: flex;
    justify-content: flex-end;
    gap: var(--space-3);
}

/* =====================================================
   TOASTS
   ===================================================== */
.toast-container {
    position: fixed;
    top: var(--space-6);
    right: var(--space-6);
    z-index: 1100;
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

.toast {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: var(--space-4);
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: var(--space-3);
    min-width: 300px;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* =====================================================
   AVATARS
   ===================================================== */
.avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    object-fit: cover;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    border: 2px solid var(--bg-card);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    flex-shrink: 0;
}

.avatar img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    display: block;
}

.avatar-sm { width: 32px; height: 32px; font-size: 12px; }
.avatar-lg { width: 64px; height: 64px; font-size: 24px; }
.avatar-xl { width: 96px; height: 96px; font-size: 36px; }

/* =====================================================
   LOADING / SPINNER
   ===================================================== */
.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-light);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

/* Lottie Container */
.lottie-loader {
    width: 150px;
    height: 150px;
}

/* =====================================================
   PAGINATION
   ===================================================== */
.pagination {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    margin-top: var(--space-6);
}

.pagination a,
.pagination span {
    padding: var(--space-2) var(--space-4);
    border-radius: var(--radius);
    font-size: var(--text-sm);
}

.pagination a {
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.pagination a:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.pagination .active {
    background: var(--primary);
    color: white;
}

/* =====================================================
   UTILITIES
   ===================================================== */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--text-secondary); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }

.mb-0 { margin-bottom: 0; }
.mb-2 { margin-bottom: var(--space-2); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); }

.mt-4 { margin-top: var(--space-4); }
.mt-6 { margin-top: var(--space-6); }

.p-4 { padding: var(--space-4); }
.p-6 { padding: var(--space-6); }

.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: var(--space-2); }
.gap-4 { gap: var(--space-4); }

.hidden { display: none; }
.visible { display: block; }

/* =====================================================
   RESPONSIVE
   ===================================================== */
@media (max-width: 768px) {
    :root {
        --sidebar-width: 0;
    }
    
    .hide-mobile { display: none !important; }
    
    .card { padding: var(--space-4); }
    
    .modal { width: 95%; }
}

@media (min-width: 769px) {
    .hide-desktop { display: none !important; }
}
