/* ==========================================================================
   EduManage ERP - Ultra-Modern, Colorful & Responsive Design System
   Designed for High Engagement, Vibrant Visuals & Flawless Mobile Layouts
   ========================================================================== */

:root {
    --sidebar-width: 270px;
    --primary-color: #4f46e5;
    --primary-hover: #4338ca;
    --primary-light: #6366f1;
    --primary-subtle: #eef2ff;
    
    --bg-body: #f8fafc;
    --card-bg: #ffffff;
    --sidebar-bg: #0f172a;
    --sidebar-hover-bg: #1e293b;
    --sidebar-color: #94a3b8;
    --sidebar-active-bg: linear-gradient(135deg, #4f46e5 0%, #6366f1 100%);
    
    --card-border-radius: 18px;
    --top-navbar-height: 72px;
    
    /* Vibrant Rainbow & Status Palette */
    --color-indigo: #4f46e5;
    --color-violet: #8b5cf6;
    --color-blue: #3b82f6;
    --color-cyan: #06b6d4;
    --color-emerald: #10b981;
    --color-amber: #f59e0b;
    --color-orange: #f97316;
    --color-rose: #f43f5e;
    --color-slate: #64748b;
    
    /* Gradients */
    --grad-indigo: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
    --grad-blue: linear-gradient(135deg, #2563eb 0%, #06b6d4 100%);
    --grad-emerald: linear-gradient(135deg, #10b981 0%, #059669 100%);
    --grad-amber: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    --grad-rose: linear-gradient(135deg, #f43f5e 0%, #e11d48 100%);
    --grad-violet: linear-gradient(135deg, #8b5cf6 0%, #6d28d9 100%);
    --grad-dark: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
}

/* Universal text-wrap safety */
*, *::before, *::after {
    box-sizing: border-box;
    overflow-wrap: break-word;
}

body {
    font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--bg-body);
    color: #1e293b;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* ==========================================================================
   1. Modern Sidebar Navigation
   ========================================================================== */

#sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    background-color: var(--sidebar-bg);
    color: #ffffff;
    z-index: 1050;
    overflow-y: auto;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.18);
    border-right: 1px solid rgba(255, 255, 255, 0.06);
}

#sidebar .brand-header {
    padding: 1.35rem 1.25rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

#sidebar .brand-logo {
    width: 44px;
    height: 44px;
    background: var(--grad-indigo);
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.35rem;
    font-weight: 800;
    color: white;
    flex-shrink: 0;
    box-shadow: 0 6px 16px rgba(79, 70, 229, 0.45);
}

#sidebar .nav-section-title {
    padding: 1.2rem 1.25rem 0.4rem;
    font-size: 0.68rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: #64748b;
}

#sidebar ul.nav-links {
    list-style: none;
    padding: 0 0.85rem 2.5rem;
    margin: 0;
}

#sidebar ul.nav-links li a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0.72rem 1rem;
    color: var(--sidebar-color);
    text-decoration: none;
    border-radius: 14px;
    font-size: 0.9rem;
    font-weight: 600;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    margin-bottom: 4px;
}

#sidebar ul.nav-links li a:hover {
    background-color: var(--sidebar-hover-bg);
    color: #ffffff;
    transform: translateX(4px);
}

#sidebar ul.nav-links li a.active {
    background: var(--sidebar-active-bg);
    color: #ffffff;
    font-weight: 700;
    box-shadow: 0 4px 18px rgba(79, 70, 229, 0.45);
}

#sidebar ul.nav-links li a i {
    font-size: 1.15rem;
    width: 22px;
    text-align: center;
    flex-shrink: 0;
}

/* Sidebar Scrollbar */
#sidebar::-webkit-scrollbar {
    width: 4px;
}
#sidebar::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 4px;
}

/* ==========================================================================
   2. Main Layout & Topbar
   ========================================================================== */

#main-wrapper {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

#top-navbar {
    height: var(--top-navbar-height);
    background-color: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(16px);
    border-bottom: 1px solid #e2e8f0;
    padding: 0 1.75rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 1020;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.03);
}

.content-container {
    padding: 1.75rem;
    flex-grow: 1;
}

/* Backdrop */
#sidebarBackdrop {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    z-index: 1040;
    opacity: 0;
    transition: opacity 0.3s ease;
}
#sidebarBackdrop.show {
    display: block;
    opacity: 1;
}

/* Tenant Badge */
.tenant-badge {
    background: linear-gradient(135deg, #eef2ff 0%, #ede9fe 100%);
    border: 1px solid #c7d2fe;
    color: #4338ca;
    padding: 0.45rem 1rem;
    border-radius: 9999px;
    font-size: 0.86rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    max-width: 320px;
    box-shadow: 0 2px 6px rgba(79, 70, 229, 0.08);
}

/* Global Search */
.global-search-wrapper {
    position: relative;
    width: 300px;
}
.global-search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: #94a3b8;
    font-size: 0.9rem;
}
.global-search-input {
    padding-left: 38px !important;
    border-radius: 9999px !important;
    background: #f1f5f9 !important;
    border: 1px solid #e2e8f0 !important;
    font-size: 0.88rem;
    transition: all 0.2s ease;
}
.global-search-input:focus {
    background: #ffffff !important;
    border-color: #6366f1 !important;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.18) !important;
    width: 340px;
}

/* User Profile Badge & Navbar Actions */
.navbar-toggle-btn {
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    color: #334155;
    width: 40px;
    height: 40px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    transition: all 0.2s ease;
}
.navbar-toggle-btn:hover {
    background: #e2e8f0;
    color: #0f172a;
}

.notif-btn {
    width: 40px;
    height: 40px;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #475569;
    font-size: 1.15rem;
    position: relative;
    text-decoration: none;
    transition: all 0.2s ease;
}
.notif-btn:hover {
    background: #e2e8f0;
    color: #0f172a;
}
.notif-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 8px;
    height: 8px;
    background: #ef4444;
    border-radius: 50%;
    box-shadow: 0 0 0 2px #ffffff;
}

.user-profile-badge {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 8px 4px 4px;
    border-radius: 9999px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    text-decoration: none;
    transition: all 0.2s ease;
}
.user-profile-badge:hover {
    background: #f1f5f9;
    border-color: #cbd5e1;
}

.user-avatar-circle {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--grad-indigo);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.95rem;
    object-fit: cover;
    box-shadow: 0 2px 6px rgba(79, 70, 229, 0.3);
}

/* Trend Badges */
.trend-badge {
    font-size: 0.75rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.trend-up {
    background: #dcfce7;
    color: #15803d;
}
.trend-down {
    background: #fee2e2;
    color: #b91c1c;
}


/* ==========================================================================
   3. Cards & Components
   ========================================================================== */

.card-custom {
    background-color: var(--card-bg);
    border: 1px solid #e2e8f0;
    border-radius: var(--card-border-radius);
    box-shadow: 0 4px 20px -2px rgba(0, 0, 0, 0.04), 0 2px 6px -1px rgba(0, 0, 0, 0.02);
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.card-custom:hover {
    box-shadow: 0 12px 28px -4px rgba(0, 0, 0, 0.08), 0 4px 10px -2px rgba(0, 0, 0, 0.04);
}

/* ==========================================================================
   4. Colorful Modern KPI Stat Cards
   ========================================================================== */

.stat-card-modern {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 18px;
    padding: 1.25rem 1.35rem;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.04);
    transition: all 0.25s ease;
    height: 100%;
}
.stat-card-modern:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.08);
}

.stat-icon-modern {
    width: 52px;
    height: 52px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.45rem;
    color: white;
    flex-shrink: 0;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.12);
}

.stat-icon-blue { background: var(--grad-blue); }
.stat-icon-green { background: var(--grad-emerald); }
.stat-icon-amber { background: var(--grad-amber); }
.stat-icon-rose { background: var(--grad-rose); }
.stat-icon-purple { background: var(--grad-violet); }
.stat-icon-indigo { background: var(--grad-indigo); }
.stat-icon-teal { background: linear-gradient(135deg, #0d9488, #0f766e); }
.stat-icon-cyan { background: linear-gradient(135deg, #06b6d4, #0891b2); }
.stat-icon-orange { background: linear-gradient(135deg, #f97316, #ea580c); }


.stat-number {
    font-size: 1.65rem;
    font-weight: 800;
    color: #0f172a;
    line-height: 1.15;
    letter-spacing: -0.02em;
}

.stat-label {
    font-size: 0.86rem;
    color: #64748b;
    font-weight: 600;
}

/* ==========================================================================
   5. Tables & Responsive Grids
   ========================================================================== */

.table-responsive {
    border-radius: 14px;
    border: 1px solid #e2e8f0;
    background: #ffffff;
    -webkit-overflow-scrolling: touch;
}

.table {
    margin-bottom: 0;
    vertical-align: middle;
}

.table thead th {
    background-color: #f8fafc;
    color: #475569;
    font-size: 0.78rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 12px 14px;
    border-bottom: 2px solid #e2e8f0;
    white-space: nowrap;
}

.table tbody td {
    padding: 12px 14px;
    color: #334155;
    font-size: 0.88rem;
    border-bottom: 1px solid #f1f5f9;
}

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

/* ==========================================================================
   6. Buttons & Badges
   ========================================================================== */

.btn {
    font-weight: 600;
    border-radius: 12px;
    padding: 0.55rem 1.25rem;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-primary {
    background: var(--grad-indigo);
    border: none;
    color: #ffffff;
    box-shadow: 0 4px 14px rgba(79, 70, 229, 0.35);
}
.btn-primary:hover {
    background: linear-gradient(135deg, #4338ca 0%, #6d28d9 100%);
    color: #ffffff;
    box-shadow: 0 6px 20px rgba(79, 70, 229, 0.5);
    transform: translateY(-1px);
}

.btn-success {
    background: var(--grad-emerald);
    border: none;
    box-shadow: 0 4px 14px rgba(16, 185, 129, 0.35);
}
.btn-success:hover {
    background: linear-gradient(135deg, #059669 0%, #047857 100%);
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.5);
    transform: translateY(-1px);
}

.btn-warning {
    background: var(--grad-amber);
    border: none;
    color: #ffffff;
    box-shadow: 0 4px 14px rgba(245, 158, 11, 0.35);
}
.btn-warning:hover {
    background: linear-gradient(135deg, #d97706 0%, #b45309 100%);
    color: #ffffff;
    transform: translateY(-1px);
}

.badge {
    font-weight: 700;
    padding: 0.35rem 0.75rem;
    border-radius: 8px;
    font-size: 0.78rem;
    letter-spacing: 0.02em;
}

/* ==========================================================================
   7. Form Controls
   ========================================================================== */

.form-control, .form-select {
    border-radius: 12px;
    border: 1.5px solid #cbd5e1;
    padding: 0.65rem 1rem;
    font-size: 0.92rem;
    transition: all 0.2s ease;
}

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

/* ==========================================================================
   8. Mobile-First Comprehensive Responsive Rules
   ========================================================================== */

@media (max-width: 991.98px) {
    #sidebar {
        transform: translateX(-100%);
    }
    #sidebar.show {
        transform: translateX(0);
    }
    #main-wrapper {
        margin-left: 0 !important;
        width: 100% !important;
    }
    .content-container {
        padding: 1rem 0.75rem !important;
    }
    #top-navbar {
        padding: 0 1rem !important;
    }
    .tenant-badge {
        max-width: 200px;
        font-size: 0.78rem;
        padding: 0.35rem 0.75rem;
    }
}

@media (max-width: 767.98px) {
    .card-custom {
        padding: 1rem !important;
        border-radius: 14px !important;
    }
    
    .stat-card-modern {
        padding: 1rem;
        gap: 12px;
    }
    .stat-icon-modern {
        width: 44px;
        height: 44px;
        font-size: 1.25rem;
        border-radius: 12px;
    }
    .stat-number {
        font-size: 1.35rem;
    }
    .stat-label {
        font-size: 0.78rem;
    }
    
    .table thead th {
        padding: 10px 10px;
        font-size: 0.72rem;
    }
    .table tbody td {
        padding: 10px 10px;
        font-size: 0.82rem;
    }
    
    /* Receipt & Slip card adjustments */
    .receipt-card, .slip-card, .challan-container, .report-card-container {
        padding: 1rem !important;
        margin: 0 !important;
        width: 100% !important;
        border-radius: 14px !important;
    }
    
    /* Nav tabs scrollable on mobile */
    .nav-tabs {
        flex-wrap: nowrap !important;
        overflow-x: auto !important;
        overflow-y: hidden !important;
        white-space: nowrap !important;
        padding-bottom: 4px;
        -webkit-overflow-scrolling: touch;
    }
    .nav-tabs .nav-item {
        flex: 0 0 auto;
    }
    .nav-tabs .nav-link {
        padding: 0.5rem 0.85rem !important;
        font-size: 0.85rem !important;
    }
}

@media (max-width: 480px) {
    body {
        font-size: 0.88rem;
    }
    h1, .h1 { font-size: 1.35rem !important; }
    h2, .h2 { font-size: 1.2rem !important; }
    h3, .h3 { font-size: 1.1rem !important; }
    h4, .h4 { font-size: 1rem !important; }
    h5, .h5 { font-size: 0.92rem !important; }
    
    .btn-lg {
        padding: 0.6rem 1.2rem !important;
        font-size: 0.92rem !important;
    }
}

/* ==========================================================================
   9. Strict Clean Print & PDF Rules (Zero Crookedness or Page Bleeding)
   ========================================================================== */

@page {
    size: A4 portrait;
    margin: 10mm;
}

@media print {
    *, *::before, *::after {
        box-shadow: none !important;
        text-shadow: none !important;
    }
    #sidebar,
    #top-navbar,
    #sidebarBackdrop,
    .no-print,
    .btn,
    .navbar-toggle-btn {
        display: none !important;
    }
    #main-wrapper {
        margin-left: 0 !important;
        width: 100% !important;
    }
    .content-container {
        padding: 0 !important;
        margin: 0 !important;
    }
    body {
        background: #ffffff !important;
        color: #000000 !important;
        padding: 0 !important;
        margin: 0 !important;
    }
    .receipt-card, .slip-card, .challan-container, .report-card-container, .timetable-card {
        border: 1.5px solid #000000 !important;
        box-shadow: none !important;
        padding: 15mm !important;
        max-width: 100% !important;
        width: 100% !important;
        page-break-inside: avoid !important;
    }
    .table-responsive {
        border: none !important;
        overflow: visible !important;
    }
    .table th, .table td {
        border-color: #000000 !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }
}
