/* ==========================================================
   KINE - SYSTÈME DE GESTION SCOLAIRE MODERNE
   Design System & Feuille de Styles CSS
========================================================== */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&display=swap');

:root {
    --primary-color: #4338ca;
    --primary-light: #6366f1;
    --primary-dark: #312e81;
    --primary-subtle: #eef2ff;
    
    --secondary-color: #0f172a;
    --accent-color: #0ea5e9;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    --info-color: #06b6d4;

    --bg-body: #f8fafc;
    --bg-surface: #ffffff;
    --bg-sidebar: #0f172a;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --border-color: #e2e8f0;

    --sidebar-width: 260px;
    --navbar-height: 70px;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 18px;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.05), 0 1px 2px rgba(0,0,0,0.04);
    --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.04);
    --shadow-xl: 0 20px 25px -5px rgba(0,0,0,0.1), 0 8px 10px -6px rgba(0,0,0,0.05);
}

body {
    font-family: 'Plus Jakarta Sans', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--bg-body);
    color: var(--text-main);
    overflow-x: hidden;
    min-height: 100vh;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: #f1f5f9;
}
::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Layout App Container */
.app-wrapper {
    display: flex;
    min-height: 100vh;
    width: 100%;
}

/* Sidebar */
.app-sidebar {
    width: var(--sidebar-width);
    background: linear-gradient(180deg, #0f172a 0%, #1e1b4b 100%);
    color: #f8fafc;
    flex-shrink: 0;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 1040;
    overflow-y: auto;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 4px 0 20px rgba(0,0,0,0.15);
}

.sidebar-brand {
    height: var(--navbar-height);
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    gap: 0.75rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(10px);
}

.sidebar-brand .brand-logo {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: linear-gradient(135deg, #6366f1 0%, #4338ca 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    color: white;
    box-shadow: 0 4px 10px rgba(99, 102, 241, 0.4);
}

.sidebar-brand .brand-text {
    font-size: 1.2rem;
    font-weight: 800;
    letter-spacing: -0.5px;
    color: #ffffff;
    text-decoration: none;
    line-height: 1.2;
}

.sidebar-brand .brand-badge {
    font-size: 0.65rem;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    background: rgba(99, 102, 241, 0.25);
    color: #818cf8;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 700;
}

.sidebar-nav {
    padding: 1.25rem 0.85rem;
}

.nav-section-title {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #64748b;
    font-weight: 700;
    padding: 0.75rem 0.75rem 0.25rem;
    margin-top: 0.5rem;
}

.sidebar-nav .nav-link {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.7rem 0.85rem;
    color: #94a3b8;
    border-radius: var(--radius-md);
    font-size: 0.92rem;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.2s ease;
    margin-bottom: 0.25rem;
}

.sidebar-nav .nav-link i {
    width: 22px;
    font-size: 1.1rem;
    text-align: center;
    transition: transform 0.2s ease;
}

.sidebar-nav .nav-link:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.06);
    transform: translateX(3px);
}

.sidebar-nav .nav-link:hover i {
    transform: scale(1.15);
    color: #818cf8;
}

.sidebar-nav .nav-link.active {
    color: #ffffff;
    background: linear-gradient(90deg, rgba(99, 102, 241, 0.9) 0%, rgba(67, 56, 202, 0.9) 100%);
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.35);
}

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

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

/* Navbar */
.app-navbar {
    height: var(--navbar-height);
    background: #ffffff;
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 1020;
    display: flex;
    align-items: center;
    padding: 0 1.75rem;
    box-shadow: var(--shadow-sm);
}

.navbar-user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #e0e7ff 0%, #c7d2fe 100%);
    color: var(--primary-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1rem;
    border: 2px solid #ffffff;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

/* Page Content */
.app-content {
    padding: 1.75rem;
    flex: 1;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.75rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.page-title {
    font-size: 1.5rem;
    font-weight: 800;
    color: #0f172a;
    letter-spacing: -0.5px;
    margin-bottom: 0.25rem;
}

.page-subtitle {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 0;
}

/* Cards & Widgets */
.card-modern {
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    overflow: hidden;
}

.card-modern:hover {
    box-shadow: var(--shadow-md);
}

.card-header-modern {
    padding: 1.25rem 1.5rem;
    background: transparent;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-weight: 700;
    font-size: 1.05rem;
    color: #0f172a;
}

/* KPI Stat Cards */
.stat-card {
    background: #ffffff;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    padding: 1.5rem;
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    transition: all 0.25s ease;
}

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

.stat-card .stat-icon {
    width: 52px;
    height: 52px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    margin-bottom: 1rem;
}

.stat-card.primary .stat-icon { background: #eef2ff; color: #4f46e5; }
.stat-card.success .stat-icon { background: #ecfdf5; color: #10b981; }
.stat-card.warning .stat-icon { background: #fffbeb; color: #f59e0b; }
.stat-card.danger .stat-icon  { background: #fef2f2; color: #ef4444; }
.stat-card.info .stat-icon    { background: #ecfeff; color: #06b6d4; }

.stat-card .stat-value {
    font-size: 1.85rem;
    font-weight: 800;
    color: #0f172a;
    line-height: 1.2;
    margin-bottom: 0.25rem;
}

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

/* Tables */
.table-modern {
    width: 100%;
    margin-bottom: 0;
}

.table-modern thead th {
    background: #f8fafc;
    color: #475569;
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    padding: 0.9rem 1.2rem;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}

.table-modern tbody td {
    padding: 1rem 1.2rem;
    vertical-align: middle;
    color: #334155;
    font-size: 0.92rem;
    border-bottom: 1px solid #f1f5f9;
}

.table-modern tbody tr {
    transition: background-color 0.15s ease;
}

.table-modern tbody tr:hover {
    background-color: #f8fafc;
}

/* Buttons */
.btn-primary {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
    font-weight: 600;
    border-radius: var(--radius-md);
    padding: 0.6rem 1.25rem;
    transition: all 0.2s ease;
}

.btn-primary:hover, .btn-primary:focus {
    background-color: var(--primary-dark);
    border-color: var(--primary-dark);
    box-shadow: 0 4px 12px rgba(67, 56, 202, 0.3);
}

.btn-rounded {
    border-radius: 50px !important;
}

/* Avatar Chips */
.avatar-chip {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #e2e8f0;
    color: #475569;
    font-weight: 700;
    font-size: 0.85rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

/* Form Controls */
.form-control, .form-select {
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    padding: 0.65rem 1rem;
    font-size: 0.92rem;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary-light);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.15);
}

/* Schedule Grid */
.schedule-table th {
    text-align: center;
    background: #0f172a !important;
    color: white !important;
}
.schedule-cell {
    min-height: 80px;
    padding: 6px;
    vertical-align: top;
    background: #ffffff;
}
.schedule-card {
    background: #f8fafc;
    border-left: 4px solid var(--primary-color);
    border-radius: 6px;
    padding: 6px 10px;
    font-size: 0.82rem;
    box-shadow: var(--shadow-sm);
    margin-bottom: 6px;
}

/* Official Printable Documents (Bulletins, Reçus) */
.doc-print-container {
    background: #ffffff;
    max-width: 860px;
    margin: 0 auto;
    padding: 2.5rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
}

.school-header-logo {
    width: 75px;
    height: 75px;
    object-fit: contain;
    border-radius: 12px;
}

.watermark-stamp {
    position: relative;
}

.watermark-stamp::after {
    content: "OFFICIEL";
    position: absolute;
    top: 40%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(-25deg);
    font-size: 5rem;
    font-weight: 900;
    color: rgba(99, 102, 241, 0.05);
    pointer-events: none;
    user-select: none;
    letter-spacing: 10px;
}

/* Print CSS */
@media print {
    body {
        background: #ffffff !important;
        font-size: 11pt !important;
        color: #000000 !important;
    }
    .app-sidebar, .app-navbar, .no-print, .btn, .btn-close, .alert {
        display: none !important;
    }
    .app-main {
        margin-left: 0 !important;
    }
    .app-content {
        padding: 0 !important;
    }
    .doc-print-container {
        border: none !important;
        box-shadow: none !important;
        padding: 0 !important;
        max-width: 100% !important;
    }
}

/* Responsive Mobile Navigation */
@media (max-width: 991.98px) {
    .app-sidebar {
        transform: translateX(-100%);
    }
    .app-sidebar.show {
        transform: translateX(0);
    }
    .app-main {
        margin-left: 0;
    }
    .sidebar-overlay {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0,0,0,0.5);
        z-index: 1030;
        display: none;
    }
    .sidebar-overlay.show {
        display: block;
    }
}
