/* ============================================
   SHASHWAT ERP — Panel Layout CSS
   Bootstrap 5 based sidebar + topbar layout
   ============================================ */

:root {
    /* Brand Colors */
    --brand-primary: #4f46e5;
    --brand-primary-light: #6366f1;
    --brand-primary-dark: #3730a3;
    --brand-accent: #06b6d4;

    /* Panel-specific accent colors */
    --panel-superadmin: #7c3aed;
    --panel-admin: #2563eb;
    --panel-student: #059669;
    --panel-staff: #d97706;

    /* Sidebar */
    --sidebar-width: 260px;
    --sidebar-collapsed-width: 0px;
    --sidebar-bg: #1e1b4b;
    --sidebar-text: #c7d2fe;
    --sidebar-text-hover: #ffffff;
    --sidebar-active-bg: rgba(255, 255, 255, 0.1);
    --sidebar-border: rgba(255, 255, 255, 0.06);

    /* Topbar */
    --topbar-height: 60px;
    --topbar-bg: #ffffff;
    --topbar-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);

    /* Content */
    --content-bg: #f1f5f9;

    /* Transitions */
    --transition-speed: 0.3s;
}

/* ── BODY & RESET ── */
body.panel-body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--content-bg);
    margin: 0;
    padding: 0;
    overflow-x: hidden;
}

/* ── SIDEBAR ── */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--sidebar-bg);
    z-index: 1040;
    display: flex;
    flex-direction: column;
    transition: transform var(--transition-speed) ease;
    overflow: hidden;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--sidebar-border);
    min-height: 60px;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
}

.brand-icon {
    font-size: 1.6rem;
    color: var(--brand-accent);
    filter: drop-shadow(0 0 6px rgba(6, 182, 212, 0.4));
}

.brand-text {
    font-family: 'Cinzel', serif;
    font-size: 1.1rem;
    font-weight: 700;
    color: #fff;
    letter-spacing: 0.5px;
    line-height: 1.2;
}

.sidebar-toggle {
    background: none;
    border: none;
    color: var(--sidebar-text);
    font-size: 1.25rem;
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
    transition: all 0.2s;
}

.sidebar-toggle:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.1);
}

/* Sidebar User */
.sidebar-user {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--sidebar-border);
}

.sidebar-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--brand-accent);
}

.sidebar-user-info {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sidebar-user-name {
    font-size: 0.875rem;
    font-weight: 600;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user-role {
    font-size: 0.75rem;
    color: var(--sidebar-text);
    opacity: 0.8;
}

/* Sidebar Navigation */
.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 12px 0;
}

.sidebar-nav::-webkit-scrollbar {
    width: 4px;
}

.sidebar-nav::-webkit-scrollbar-track {
    background: transparent;
}

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

.nav-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.nav-heading {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: rgba(199, 210, 254, 0.5);
    padding: 20px 20px 6px;
    margin: 0;
}

.nav-item .nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 20px;
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 400;
    transition: all 0.2s ease;
    border-left: 3px solid transparent;
    margin: 1px 0;
}

.nav-item .nav-link i {
    font-size: 1.1rem;
    width: 22px;
    text-align: center;
    flex-shrink: 0;
}

.nav-item .nav-link:hover {
    color: var(--sidebar-text-hover);
    background: var(--sidebar-active-bg);
    border-left-color: rgba(6, 182, 212, 0.4);
}

.nav-item .nav-link.active {
    color: #fff;
    background: var(--sidebar-active-bg);
    border-left-color: var(--brand-accent);
    font-weight: 500;
}

/* Sidebar Footer */
.sidebar-footer {
    padding: 12px 20px;
    border-top: 1px solid var(--sidebar-border);
    text-align: center;
}

.sidebar-version {
    font-size: 0.7rem;
    color: rgba(199, 210, 254, 0.4);
}

/* ── MAIN WRAPPER ── */
.main-wrapper {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    transition: margin-left var(--transition-speed) ease;
}

/* ── TOPBAR ── */
.topbar {
    position: sticky;
    top: 0;
    height: var(--topbar-height);
    background: var(--topbar-bg);
    box-shadow: var(--topbar-shadow);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    z-index: 1030;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.topbar-left .sidebar-toggle {
    color: #64748b;
    font-size: 1.4rem;
}

.topbar-left .sidebar-toggle:hover {
    color: #1e293b;
    background: #f1f5f9;
}

.page-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: #1e293b;
    margin: 0;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.topbar-btn {
    background: none;
    border: none;
    color: #64748b;
    font-size: 1.2rem;
    padding: 8px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
}

.topbar-btn:hover {
    background: #f1f5f9;
    color: #1e293b;
}

.notification-badge {
    position: absolute;
    top: 4px;
    right: 4px;
    background: #ef4444;
    color: #fff;
    font-size: 0.6rem;
    font-weight: 700;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.topbar-user-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    background: none;
    border: 1px solid #e2e8f0;
    border-radius: 24px;
    padding: 4px 12px 4px 4px;
    cursor: pointer;
    transition: all 0.2s;
}

.topbar-user-btn:hover {
    border-color: #cbd5e1;
    background: #f8fafc;
}

.topbar-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
}

.topbar-user-name {
    font-size: 0.85rem;
    font-weight: 500;
    color: #334155;
}

/* ── BREADCRUMB ── */
.breadcrumb-bar {
    background: #fff;
    padding: 10px 24px;
    border-bottom: 1px solid #e2e8f0;
}

.breadcrumb-bar .breadcrumb {
    font-size: 0.8rem;
}

/* ── MAIN CONTENT ── */
.main-content {
    padding: 0;
    min-height: calc(100vh - var(--topbar-height));
}

/* ── WELCOME CARD ── */
.welcome-card {
    background: var(--global-btn-bg, linear-gradient(135deg, var(--brand-primary) 0%, var(--brand-primary-light) 100%));
    color: #fff;
    border-radius: 12px;
    padding: 24px 28px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.welcome-content h2 {
    font-size: 1.4rem;
    font-weight: 600;
    margin-bottom: 4px;
}

.welcome-content p {
    font-size: 0.9rem;
    opacity: 0.85;
}

.welcome-date {
    font-size: 0.85rem;
    opacity: 0.8;
    white-space: nowrap;
}

/* Panel-specific welcome card colors removed to allow theme customization */

/* ── STAT CARDS ── */
.stat-card {
    background: #fff;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
    transition: transform 0.2s, box-shadow 0.2s;
    border: 1px solid #f1f5f9;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.08);
}

.stat-card-body {
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
}

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

.stat-card-primary .stat-icon {
    background: rgba(79, 70, 229, 0.1);
    color: var(--brand-primary);
}

.stat-card-success .stat-icon {
    background: rgba(5, 150, 105, 0.1);
    color: #059669;
}

.stat-card-warning .stat-icon {
    background: rgba(217, 119, 6, 0.1);
    color: #d97706;
}

.stat-card-info .stat-icon {
    background: rgba(6, 182, 212, 0.1);
    color: #0891b2;
}

.stat-info {
    flex: 1;
}

.stat-label {
    font-size: 0.78rem;
    color: #64748b;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-value {
    font-size: 1.6rem;
    font-weight: 700;
    color: #1e293b;
    margin: 2px 0 0;
}

.stat-card-footer {
    padding: 10px 20px;
    background: #f8fafc;
    font-size: 0.75rem;
    color: #64748b;
    border-top: 1px solid #f1f5f9;
}

/* ── CARDS ── */
.card {
    border-radius: 12px;
    border: 1px solid #f1f5f9;
}

.card-header {
    padding: 16px 20px;
}

.card-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: #1e293b;
}

/* ── RESPONSIVE ── */
@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.show {
        transform: translateX(0);
    }

    .main-wrapper {
        margin-left: 0;
    }

    .welcome-card {
        flex-direction: column;
        gap: 8px;
        text-align: center;
    }
}

@media (max-width: 575.98px) {
    .topbar {
        padding: 0 12px;
    }

    .page-title {
        font-size: 0.95rem;
    }

    .main-content {
        padding: 0;
    }

    .welcome-content h2 {
        font-size: 1.1rem;
    }

    .stat-card-body {
        padding: 16px;
    }

    .stat-value {
        font-size: 1.3rem;
    }
}

/* ── BACKDROP (mobile) ── */
.sidebar-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1035;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s;
}

.sidebar-backdrop.show {
    opacity: 1;
    visibility: visible;
}

/* ── AUTH PAGES ── */
.auth-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--login-bg, linear-gradient(135deg, #1e1b4b 0%, #312e81 50%, #4f46e5 100%));
    padding: 20px;
}

.auth-card {
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    width: 100%;
    max-width: 420px;
    padding: 40px;
}

.auth-brand {
    text-align: center;
    margin-bottom: 32px;
}

.auth-brand .brand-icon {
    font-size: 2.5rem;
    color: var(--brand-primary);
    display: block;
    margin-bottom: 8px;
}

.auth-brand h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: #1e293b;
    margin: 0;
}

.auth-brand p {
    font-size: 0.85rem;
    color: #64748b;
    margin-top: 4px;
}

.auth-card .form-label {
    font-size: 0.85rem;
    font-weight: 500;
    color: #334155;
}

.auth-card .form-control {
    border-radius: 8px;
    padding: 10px 14px;
    border-color: #e2e8f0;
    font-size: 0.9rem;
}

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

.auth-card .btn-primary {
    background: var(--global-btn-bg, var(--brand-primary));
    border-color: var(--global-btn-bg, var(--brand-primary));
    border-radius: 8px;
    padding: 10px;
    font-weight: 600;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.auth-card .btn-primary:hover {
    background: var(--brand-primary-dark);
    border-color: var(--brand-primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
}

/* ── DATATABLE OVERRIDES ── */
.dataTables_wrapper .dataTables_length select {
    border-radius: 6px;
    border: 1px solid #e2e8f0;
    padding: 4px 2.25rem 4px 8px;
}

.dataTables_wrapper .dataTables_filter input {
    border-radius: 6px;
    border: 1px solid #e2e8f0;
    padding: 4px 8px;
}

.dataTables_wrapper .dataTables_filter input:focus {
    border-color: var(--brand-primary);
    outline: none;
    box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.15);
}

table.dataTable thead th {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #64748b;
    border-bottom: 2px solid #e2e8f0 !important;
}

table.dataTable tbody td {
    font-size: 0.875rem;
    vertical-align: middle;
}

/* ── UTILITY ── */
.text-truncate-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.avatar-sm {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
}

.avatar-md {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
}

.avatar-lg {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    object-fit: cover;
}

.avatar-xl {
    width: 150px;
    height: 150px;
    border-radius: 50%;
    object-fit: cover;
}

/* ── MOBILE BOTTOM NAV ── */
.mobile-bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background: var(--topbar-bg, #fff);
    border-top: 1px solid rgba(0,0,0,0.05);
    display: flex;
    justify-content: space-around;
    padding: 10px 0;
    z-index: 1040;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.05);
}
.mobile-bottom-nav .nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    color: var(--content-icon, #a1a5b7);
    text-decoration: none;
    font-size: 0.7rem;
    font-weight: 500;
    transition: color 0.2s;
}
.mobile-bottom-nav .nav-item i {
    font-size: 1.25rem;
    margin-bottom: 2px;
}
.mobile-bottom-nav .nav-item.active, .mobile-bottom-nav .nav-item:hover {
    color: var(--bs-primary, #009688);
}

@media (max-width: 767.98px) {
    /* Main wrapper and padding */
    .main-content {
        padding-bottom: calc(75px + env(safe-area-inset-bottom, 0px)) !important;
    }
    
    /* Typography scaling for mobile screens (320px - 480px) */
    html, body { font-size: 14px; }
    h1, .h1 { font-size: 1.25rem; }
    h2, .h2 { font-size: 1.15rem; }
    h3, .h3 { font-size: 1.05rem; }
    h4, .h4 { font-size: 1rem; }
    h5, .h5 { font-size: 0.95rem; }
    h6, .h6 { font-size: 0.85rem; }
    
    /* Strict Container Constraints (10-15px padding) */
    .container, .container-fluid {
        padding-left: 12px !important;
        padding-right: 12px !important;
        overflow-x: hidden;
    }
    
    /* Premium Mobile Cards (occupy ~95% width naturally via container padding) */
    .card {
        border-radius: 12px !important;
        box-shadow: 0 4px 12px rgba(0,0,0,0.05) !important;
        margin-bottom: 1rem !important;
        border: none !important;
        width: 100% !important; /* Let container handle the 95% ratio */
    }
    
    .card-header {
        padding: 1rem 1rem 0.5rem !important;
        border-bottom: none !important;
    }
    
    .card-body {
        padding: 1rem !important;
    }

    /* Welcome Card */
    .welcome-card {
        border-radius: 12px;
        padding: 1.2rem 1rem;
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    .welcome-content h2 { font-size: 1.2rem; }
    .welcome-content p { font-size: 0.85rem; }
    
    /* Topbar */
    .topbar {
        padding: 0 12px;
        height: 56px; /* slightly smaller on mobile */
    }
    .page-title {
        font-size: 1.05rem !important;
        font-weight: 600;
    }
    
    /* ID Card Organic Mobile Layout - No Forced Scaling */
    .id-card-wrapper {
        width: 100%;
        max-width: 320px;
        margin: 0 auto;
        display: flex;
        justify-content: center;
        /* Removed hacky scale transforms, letting max-width handle it naturally */
    }
}

