@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
    --primary: #1e4a6d;
    --primary-light: #2c6896;
    --secondary: #2563eb;
    --accent: #3b82f6;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --bg-main: #f8fafc;
    --bg-card: #ffffff;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --sidebar-width: 260px;
    --header-height: 70px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

[data-theme="dark"] {
    --bg-main: #0f172a;
    --bg-card: #1e293b;
    --text-main: #f8fafc; /* Brighter for better visibility */
    --text-muted: #cbd5e1; /* Brighter for better visibility */
    --border: #334155;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.4);
}

[data-theme="dark"] .page-title,
[data-theme="dark"] h3,
[data-theme="dark"] h4,
[data-theme="dark"] h5 {
    color: #f8fafc !important; /* Ensure titles are visible on dark background */
}

[data-theme="dark"] .stat-card {
    background: #1e293b;
    border: 1px solid #334155;
}

[data-theme="dark"] .data-table th {
    background: #243347 !important;
    color: #f1f5f9 !important;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    line-height: 1.5;
    overflow-x: hidden;
}

/* Layout */
.app-container {
    display: flex;
    min-height: 100vh;
}

.main-content {
    flex-grow: 1;
    margin-left: var(--sidebar-width);
    padding: var(--header-height) 2rem 2rem;
    transition: var(--transition);
    min-height: 100vh;
}

.dashboard-content {
    margin-top: 1.5rem; /* Space between header and content cards */
}

@media (max-width: 992px) {
    .main-content {
        margin-left: 0;
        padding: calc(var(--header-height) + 1.5rem) 1.5rem 2rem;
    }
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        z-index: 1000;
        box-shadow: none;
        position: fixed;
        width: 280px;
    }
    .sidebar.active {
        transform: translateX(0);
        box-shadow: 10px 0 30px rgba(0,0,0,0.1);
    }
    #sidebar-close-btn {
        display: block !important;
    }
    .top-navbar {
        width: 100%;
        left: 0;
    }
    .stats-grid {
        grid-template-columns: 1fr 1fr;
    }
}

/* Sidebar Backdrop */
.sidebar-backdrop {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    z-index: 999;
}
.sidebar-backdrop.active {
    display: block;
}

@media (max-width: 576px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
    .top-navbar {
        padding: 0 1rem;
    }
    .nav-user .user-info {
        display: none; /* Hide text info on very small screens to save space */
    }
    .table-header {
        flex-direction: column;
        align-items: stretch;
        gap: 1rem;
    }
    .card-table {
        border-radius: 12px;
    }
    .data-table {
        display: block;
        width: 100%;
        overflow-x: auto;
        white-space: nowrap; /* Prevent wrapping in small cells */
    }
}

/* Polishing & Animations */
.stat-card {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.stat-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(0,0,0,0.1);
}

.btn {
    transition: all 0.2s ease;
}
.btn:active {
    transform: scale(0.98);
}

.badge {
    transition: all 0.2s ease;
}

/* Logout Button Special Style */
.menu-item.logout {
    margin-top: auto;
}

.menu-item.logout .menu-link {
    color: #fca5a5; /* Light red by default */
}

.menu-item.logout .menu-link:hover {
    background: #fee2e2;
    color: #ef4444 !important;
}
/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--primary);
    color: white;
    position: fixed;
    left: 0;
    top: 0;
    display: flex;
    flex-direction: column;
    z-index: 1200; /* Higher than top-navbar */
    transition: var(--transition);
    overflow-y: hidden;
}

/* Hide scrollbar for Chrome, Safari and Opera */
.sidebar::-webkit-scrollbar {
    display: none;
}

/* Hide scrollbar for IE, Edge and Firefox */
.sidebar {
    -ms-overflow-style: none;  /* IE and Edge */
    scrollbar-width: none;  /* Firefox */
}

.sidebar-header {
    padding: 2rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-header i {
    font-size: 1.8rem;
    color: #e0f2fe;
}

.sidebar-header span {
    font-weight: 700;
    font-size: 1.2rem;
    letter-spacing: -0.5px;
}

.sidebar-close-btn {
    display: none;
    width: 35px;
    height: 35px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: none;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.sidebar-close-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.sidebar-menu {
    list-style: none;
    padding: 1.5rem 0.75rem;
    flex-grow: 1;
    overflow-y: auto; /* Only menu items scroll if they don't fit */
}

/* Hide scrollbar for sidebar menu */
.sidebar-menu::-webkit-scrollbar {
    display: none;
}
.sidebar-menu {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.menu-item {
    margin-bottom: 8px;
}

.menu-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 1rem;
    color: rgba(255,255,255,0.7);
    text-decoration: none;
    border-radius: 12px;
    transition: var(--transition);
    font-weight: 500;
}

.menu-link i {
    font-size: 1.1rem;
}

.menu-link:hover, .menu-link.active {
    background: rgba(255,255,255,0.1);
    color: white;
}

.menu-link.active {
    background: var(--accent);
}

/* Sidebar Footer & Developer Panel */
.sidebar-footer {
    padding: 1.25rem;
    margin-top: auto;
    border-top: 1px solid rgba(255,255,255,0.05);
}

.dev-panel {
    padding: 1rem;
    background: rgba(255,255,255,0.03);
    border-radius: 12px;
    border: 1px solid rgba(255,255,255,0.05);
    transition: var(--transition);
}

.dev-panel:hover {
    background: rgba(255,255,255,0.05);
    border-color: rgba(255,255,255,0.1);
}

.dev-social-links a {
    color: white;
    font-size: 1rem;
    opacity: 0.3;
    transition: var(--transition);
}

.dev-social-links a:hover {
    opacity: 1;
    transform: translateY(-2px);
}

/* Footer Copyright */
#footer-copyright {
    margin-top: auto;
    width: 100%;
}

.footer-content {
    padding: 2rem 0;
    border-top: 1px solid var(--border);
    margin-top: 3rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.footer-content b {
    color: var(--primary);
    font-weight: 600;
}

.footer-link {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
    transition: var(--transition);
}

.footer-link:hover {
    color: var(--secondary);
    text-decoration: underline;
}

/* Top Navbar */
.top-navbar {
    height: var(--header-height);
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    position: fixed;
    top: 0;
    right: 0;
    left: var(--sidebar-width);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    z-index: 1100;
    transition: var(--transition);
}

.nav-logo {
    display: none;
}

@media (max-width: 992px) {
    .nav-logo {
        display: block;
    }
}

@media (max-width: 992px) {
    .top-navbar {
        left: 0;
    }
}

.page-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--primary);
}

.nav-user {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--border);
}

.user-info h5 {
    font-size: 0.9rem;
    font-weight: 600;
}

.user-info p {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Theme Toggle Button */
.theme-toggle {
    width: 38px;
    height: 38px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text-main);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    font-size: 1rem;
    margin-right: 1.5rem;
}

.theme-toggle:hover {
    background: #f1f5f9;
}

[data-theme="dark"] .theme-toggle:hover {
    background: #334155;
}

/* Dashboard Cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--bg-card);
    padding: 1.5rem;
    border-radius: 20px;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 1.5rem;
    transition: var(--transition);
}

.stat-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
}

.stat-icon {
    width: 60px;
    height: 60px;
    border-radius: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.icon-blue { background: #eff6ff; color: #2563eb; }
.icon-green { background: #ecfdf5; color: #10b981; }
.icon-red { background: #fef2f2; color: #ef4444; }
.icon-orange { background: #fff7ed; color: #f59e0b; }
.stat-info h4 {
    font-size: 1.5rem;
    font-weight: 700;
}

.stat-info p {
    color: var(--text-muted);
    font-size: 0.875rem;
}

/* Tables */
.card-table {
    background: var(--bg-card);
    border-radius: 20px;
    box-shadow: var(--shadow);
    overflow: hidden;
    margin-bottom: 2rem;
}

.table-header {
    padding: 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border);
}

.search-wrapper {
    position: relative;
    max-width: 300px;
}

.search-wrapper i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.search-input {
    width: 100%;
    padding: 10px 12px 10px 38px;
    border: 1px solid var(--border);
    border-radius: 12px;
    outline: none;
    transition: var(--transition);
}

.search-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.1);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th {
    text-align: left;
    padding: 1rem 1.5rem;
    background: #f8fafc;
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.data-table td {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border);
    font-size: 0.95rem;
}

.data-table tr:last-child td {
    border-bottom: none;
}

/* Badges */
.badge {
    padding: 4px 10px;
    border-radius: 8px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-leader { background: #e0f2fe; color: #0369a1; }
.badge-student { background: #f1f5f9; color: #64748b; }
.badge-paid { background: #dcfce7; color: #15803d; }
.badge-unpaid { background: #fee2e2; color: #b91c1c; }
.badge-payment-admin { background: #f5f3ff; color: #7c3aed; }
.badge-collector { background: #eff6ff; color: #2563eb; }

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.7);
    backdrop-filter: blur(8px);
    display: none;
    justify-content: center;
    align-items: flex-start; /* Change to flex-start to prevent top-hiding on small screens */
    overflow-y: auto; /* Allow scrolling the modal itself */
    padding: 2rem 1rem;
    z-index: 3000; /* Ensure it's above everything including navbar */
}

.modal.active {
    display: flex;
}

.modal-content {
    background: white;
    padding: 2.5rem;
    border-radius: 30px;
    width: 100%;
    max-width: 500px;
    box-shadow: var(--shadow-lg);
    position: relative;
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.modal-header h3 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.modal-close {
    position: absolute;
    right: 2rem;
    top: 2rem;
    cursor: pointer;
    font-size: 1.25rem;
    color: var(--text-muted);
}

/* Buttons */
.btn {
    padding: 12px 24px;
    border-radius: 12px;
    border: none;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
}

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-light); transform: translateY(-2px); }

.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text-main); }
.btn-outline:hover { background: #f1f5f9; }

/* Mobile Toggle Button */
.mobile-toggle {
    display: none;
    background: transparent;
    border: none;
    font-size: 1.5rem;
    color: var(--text-main);
    cursor: pointer;
    margin-right: 1rem;
}

@media (max-width: 992px) {
    .mobile-toggle {
        display: block;
    }
    .sidebar {
        box-shadow: 10px 0 30px rgba(0,0,0,0.2);
    }
}

/* Ensure Dashboard content is responsive */
@media (max-width: 768px) {
    .dashboard-content .d-flex.justify-between {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }
}


/* Modal Content Dark Mode Fix */
[data-theme="dark"] .modal-content {
    background: #1e293b;
    border: 1px solid #334155;
}
[data-theme="dark"] .modal-content input,
[data-theme="dark"] .modal-content select {
    background: #0f172a;
    border-color: #334155;
    color: #f8fafc;
}

/* Utility Styles */
.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }
.mb-4 { margin-bottom: 1rem; }
/* Settings & Interactive UI Enhancements */
.settings-section {
    background: var(--bg-card);
    border-radius: 20px;
    padding: 2.5rem;
    margin-bottom: 2rem;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    transition: var(--transition);
    position: relative;
}

.settings-section:hover {
    box-shadow: var(--shadow-lg);
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.section-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Profiles Avatar */
.profile-avatar-wrapper {
    position: relative;
    width: 140px;
    height: 140px;
    margin: 0 auto 2rem;
}

.avatar-main {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    border: 5px solid var(--bg-main);
    box-shadow: var(--shadow-lg);
    transition: var(--transition);
}

.avatar-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: rgba(0,0,0,0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    opacity: 0;
    cursor: pointer;
    transition: var(--transition);
    font-size: 1.5rem;
}

.profile-avatar-wrapper:hover .avatar-main { transform: scale(1.02); filter: brightness(0.9); }
.profile-avatar-wrapper:hover .avatar-overlay { opacity: 1; }

/* Interactive Forms */
.form-grid-modern {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 2rem;
}

.input-container {
    position: relative;
    margin-bottom: 0.5rem;
}

.input-container i {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    transition: var(--transition);
    pointer-events: none;
}

.modern-input {
    width: 100%;
    padding: 14px 16px 14px 45px;
    border-radius: 12px;
    border: 1.5px solid var(--border);
    background: var(--bg-main);
    color: var(--text-main);
    font-size: 1rem;
    transition: var(--transition);
    font-weight: 500;
}

.modern-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(30, 74, 109, 0.1);
    background: var(--bg-card);
}

.modern-input:focus + i {
    color: var(--primary);
}

.modern-input:disabled {
    cursor: not-allowed;
    background: rgba(var(--bg-main), 0.5);
    border-style: dashed;
    color: var(--text-muted);
}

.modern-input.valid { border-color: var(--success); }
.modern-input.invalid { border-color: var(--danger); }

.floating-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
    display: block;
}

/* Password eye */
.password-toggle {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    cursor: pointer;
    color: var(--text-muted);
    transition: var(--transition);
}
.password-toggle:hover { color: var(--primary); }

/* Password Strength */
.strength-meter {
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    margin-top: 8px;
    overflow: hidden;
}
.strength-bar {
    height: 100%;
    width: 0%;
    transition: width 0.3s ease, background 0.3s ease;
}
.strength-text { font-size: 0.75rem; margin-top: 4px; font-weight: 500; }

/* Buttons Enhancement */
.btn-modern {
    padding: 12px 24px;
    border-radius: 14px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    transition: var(--transition);
    border: none;
    font-size: 0.95rem;
}

.btn-modern.primary { background: var(--primary); color: white; }
.btn-modern.primary:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(30, 74, 109, 0.3); background: var(--primary-light); }

.btn-modern.secondary { background: transparent; border: 2px solid var(--border); color: var(--text-main); }
.btn-modern.secondary:hover { background: var(--bg-main); border-color: var(--primary); }

.btn-edit-badge {
    padding: 6px 14px;
    background: rgba(30, 74, 109, 0.05);
    color: var(--primary);
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 6px;
    border: 1px solid transparent;
}
.btn-edit-badge:hover { background: rgba(30, 74, 109, 0.1); border-color: var(--primary); }

/* Toasts */
.toast-container {
    position: fixed;
    top: 30px;
    right: 30px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.toast {
    min-width: 300px;
    padding: 16px 20px;
    background: var(--bg-card);
    border-left: 5px solid var(--primary);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 12px;
    animation: toastSlideIn 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    transition: var(--transition);
}

.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--danger); }

.toast i { font-size: 1.25rem; }
.toast.success i { color: var(--success); }
.toast.error i { color: var(--danger); }

.toast-content { flex-grow: 1; font-weight: 600; font-size: 0.9rem; }

@keyframes toastSlideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

.toast.fade-out {
    transform: translateX(100%);
    opacity: 0;
}

/* Loading Spinner inside Button */
.spinner {
    width: 18px;
    height: 18px;
    border: 3px solid rgba(255,255,255,0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Animations */
.fade-in { animation: fadeIn 0.3s ease; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.slide-up { animation: slideUp 0.4s ease; }
@keyframes slideUp { from { transform: translateY(15px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* Collapsible Fix */
.collapsible-content {
    max-height: 2000px;
    overflow: hidden;
    transition: max-height 0.4s ease-in-out;
}
.collapsed .collapsible-content { max-height: 0; }
.collapsed .fa-chevron-down { transform: rotate(-90deg); }