@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;
    --bg-surface: #ffffff;
    --bg-surface-muted: #f1f5f9;
    --bg-surface-subtle: #f8fafc;
    --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;
    --bg-surface: #1e293b;
    --bg-surface-muted: #243347;
    --bg-surface-subtle: #1a2740;
    --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;
    min-width: 0;
    max-width: 100%;
    overflow-x: auto;
    box-sizing: border-box;
}

.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: 1100;
        box-shadow: none;
        position: fixed;
        width: 280px;
        top: 0;
        height: 100vh;
    }
    .sidebar.active {
        transform: translateX(0);
        box-shadow: 10px 0 30px rgba(0,0,0,0.15);
        z-index: 1100;
    }
    .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: 1090;
}
.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;
    }
    .table-wrapper {
        width: 100%;
        max-width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    .table-wrapper > .data-table {
        display: table;
        width: max-content;
        min-width: 100%;
        overflow: visible;
        white-space: nowrap;
    }
    .card-table > .data-table {
        display: block;
        width: 100%;
        overflow-x: auto;
        white-space: nowrap;
    }
}

/* 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: 1000;
    transition: var(--transition);
    overflow-y: hidden; /* Prevent sidebar itself from scrolling */
}

/* 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-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: 1050;
    transition: var(--transition);
}

@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: transform 0.35s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.35s ease, border-color 0.3s ease;
    min-width: 0;
    border: 1px solid var(--border);
    animation: portalCardIn 0.55s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.stats-grid .stat-card:nth-child(1) { animation-delay: 0.04s; }
.stats-grid .stat-card:nth-child(2) { animation-delay: 0.1s; }
.stats-grid .stat-card:nth-child(3) { animation-delay: 0.16s; }
.stats-grid .stat-card:nth-child(4) { animation-delay: 0.22s; }
.stats-grid .stat-card:nth-child(5) { animation-delay: 0.28s; }
.stats-grid .stat-card:nth-child(6) { animation-delay: 0.34s; }

@keyframes portalCardIn {
    from {
        opacity: 0;
        transform: translateY(16px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.stat-info {
    min-width: 0;
    flex: 1;
}

.stat-card:hover {
    transform: translateY(-6px);
    box-shadow: var(--shadow-lg);
    border-color: color-mix(in srgb, var(--secondary) 35%, var(--border));
}

.dashboard-content {
    animation: portalPageIn 0.45s ease both;
}

@keyframes portalPageIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
    .stat-card,
    .dashboard-content,
    .card-table {
        animation: none !important;
    }
    .stat-card:hover {
        transform: none;
    }
}

.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;
    line-height: 1.3;
    word-wrap: break-word;
    overflow-wrap: anywhere;
}

.card-table {
    background: var(--bg-card);
    border-radius: 20px;
    box-shadow: var(--shadow);
    overflow: hidden;
    margin-bottom: 2rem;
    border: 1px solid var(--border);
    transition: box-shadow 0.3s ease, border-color 0.3s ease;
    animation: portalCardIn 0.6s cubic-bezier(0.22, 1, 0.36, 1) 0.12s both;
}

.card-table:hover {
    box-shadow: var(--shadow-lg);
    border-color: color-mix(in srgb, var(--secondary) 25%, var(--border));
}

.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);
    background: var(--bg-card);
    color: var(--text-main);
}

.search-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.1);
}

/* Filter / search toolbars */
.month-selector,
.portal-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    background: var(--bg-card);
    padding: 16px 20px;
    border-radius: 16px;
    border: 1px solid var(--border);
    margin-bottom: 1.5rem;
}

.month-selector #filters-container,
.portal-toolbar .toolbar-filters-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0;
}

.month-selector .search-wrapper,
.portal-toolbar .search-wrapper {
    flex: 1;
    min-width: 200px;
    max-width: 100%;
}

/* Month label + picker stay together */
.month-field-group {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    flex: 0 1 auto;
    min-width: 0;
}

.month-field-group .toolbar-month-label {
    flex: 0 0 auto;
    margin: 0;
}

.month-field-group input[type="month"],
.month-field-group .month-picker-input {
    flex: 1 1 auto;
    min-width: 130px;
    max-width: 200px;
}

/* Desktop — single horizontal row (filters left, search right) */
@media (min-width: 769px) {
    .month-selector,
    .portal-toolbar {
        flex-wrap: nowrap;
        flex-direction: row;
        align-items: center;
        gap: 1.25rem;
        padding: 1rem 1.5rem;
    }

    .month-selector #filters-container,
    .portal-toolbar .toolbar-filters-row {
        flex-wrap: nowrap;
        flex: 0 1 auto;
        width: auto;
        gap: 12px;
    }

    .month-selector .month-field-group {
        flex: 0 0 auto;
    }

    .month-selector #filters-container select,
    .month-selector #filters-container .convocation-filter-input,
    .month-selector .month-field-group input[type="month"] {
        width: auto !important;
        flex: 0 0 auto;
        min-width: 140px;
        max-width: 220px;
    }

    .month-selector #collector-badge,
    .month-selector #filters-container .badge-collector {
        flex: 0 0 auto;
        white-space: nowrap;
    }

    .month-selector .search-wrapper,
    .portal-toolbar .search-wrapper {
        flex: 1 1 260px;
        max-width: 420px;
        margin-left: auto;
        order: unset;
    }
}

@media (max-width: 768px) {
    .month-selector,
    .portal-toolbar {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
        padding: 14px 16px;
    }

    .month-selector #filters-container,
    .portal-toolbar .toolbar-filters-row {
        width: 100%;
        flex-direction: row;
        flex-wrap: wrap;
    }

    .month-field-group {
        flex: 1 1 100%;
        width: 100%;
        display: flex;
        align-items: center;
        gap: 8px;
    }

    .month-field-group input[type="month"],
    .month-field-group .month-picker-input {
        flex: 1;
        min-width: 0;
        max-width: none;
        width: auto !important;
    }

    .month-selector #filters-container .convocation-filter-input {
        flex: 1 1 100%;
        width: 100% !important;
        font-size: 0.85rem;
    }

    .month-selector .search-wrapper,
    .portal-toolbar .search-wrapper {
        width: 100%;
        max-width: 100%;
        margin-left: 0 !important;
        flex: 1 1 100%;
        order: 10;
    }

    .month-selector .search-wrapper .search-input,
    .portal-toolbar .search-wrapper input {
        width: 100%;
        padding-left: 38px;
    }

    .table-header .d-flex.gap-3,
    .table-header .d-flex.gap-2 {
        flex-direction: column;
        width: 100%;
    }

    .table-header .search-wrapper {
        max-width: 100%;
        width: 100%;
    }

    .table-header .btn {
        width: 100%;
        justify-content: center;
    }
}

/* Notifications bell */
.notifications-wrap {
    position: relative;
    margin-right: 8px;
}

.notifications-btn {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    background: var(--bg-hover, #f1f5f9);
    color: var(--primary);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    position: relative;
    transition: var(--transition);
}

.notifications-btn:hover {
    background: var(--border);
}

.notifications-badge {
    position: absolute;
    top: 2px;
    right: 2px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 999px;
    background: #dc2626;
    color: #fff;
    font-size: 0.65rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}

.notifications-panel {
    display: none;
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    width: min(360px, 92vw);
    max-height: 420px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: 0 16px 40px rgba(15, 23, 42, 0.15);
    z-index: 1200;
    overflow: hidden;
}

.notifications-panel.open {
    display: flex;
    flex-direction: column;
}

.notifications-panel-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
}

.notifications-mark-all {
    border: none;
    background: none;
    color: var(--secondary);
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
}

.notifications-list {
    overflow-y: auto;
    max-height: 340px;
    padding: 8px;
}

.notifications-empty {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85rem;
    padding: 24px 12px;
    margin: 0;
}

.notification-item {
    padding: 12px;
    border-radius: 10px;
    margin-bottom: 6px;
    cursor: pointer;
    border: 1px solid transparent;
    transition: background 0.2s;
}

.notification-item:hover {
    background: var(--bg-hover);
}

.notification-item.unread {
    background: rgba(46, 148, 106, 0.08);
    border-color: rgba(46, 148, 106, 0.2);
}

.notification-title {
    font-weight: 700;
    font-size: 0.85rem;
    color: var(--text-main);
    margin-bottom: 4px;
}

.notification-body {
    font-size: 0.8rem;
    color: var(--text-muted);
    line-height: 1.45;
    word-break: break-word;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

@media (max-width: 768px) {
    .notifications-panel {
        position: fixed;
        top: calc(var(--header-height, 64px) + 8px);
        right: 10px;
        left: 10px;
        width: auto;
        max-height: min(70vh, 480px);
        z-index: 1300;
    }

    .notifications-list {
        max-height: calc(70vh - 56px);
    }

    .nav-right {
        gap: 6px;
    }

    .notifications-btn,
    .theme-toggle {
        width: 36px;
        height: 36px;
        flex-shrink: 0;
    }

    .month-selector #filters-container .badge,
    .month-selector #collector-badge {
        flex: 1 1 100%;
        justify-content: center;
    }

}

input[type="month"].month-picker-input,
.month-picker-input {
    padding-left: 12px;
    min-height: 42px;
}

.badge-collector {
    background: var(--secondary);
    color: #fff;
    font-weight: 600;
}

.notification-time {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 6px;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th {
    text-align: left;
    padding: 1rem 1.5rem;
    background: var(--bg-main);
    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.6);
    backdrop-filter: blur(4px);
    display: none;
    justify-content: center;
    align-items: flex-start; /* Start from top to allow scrolling */
    padding: 3rem 1rem;      /* Vertical padding for scroll space */
    overflow-y: auto;        /* Enable scroll on the overlay */
    z-index: 2000;
}

.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;
    margin: auto; /* Centers horizontally and adds space when scrolling */
    animation: slideUp 0.3s ease-out;
}

@media (max-width: 768px) {
    .modal {
        align-items: flex-start;
        justify-content: center;
        padding: 2.5rem 1rem 1rem;
        overflow-y: auto;
    }
    .modal-content {
        margin: auto;
        padding: 1.5rem;
        border-radius: 20px;
        width: min(500px, calc(100vw - 2rem));
        max-width: calc(100vw - 2rem);
        box-sizing: border-box;
    }
    #student-modal.modal {
        padding: 1rem;
        justify-content: center;
        align-items: center;
        overflow: hidden;
    }

    #student-modal .student-detail-modal-content {
        width: calc(100vw - 2rem) !important;
        max-width: calc(100vw - 2rem) !important;
        max-height: min(90dvh, calc(100dvh - 2rem)) !important;
        margin: 0 auto !important;
    }
    .modal-close {
        right: 1.5rem;
        top: 1.5rem;
        background: var(--bg-card);
        width: 36px;
        height: 36px;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        box-shadow: var(--shadow-md);
        z-index: 100;
        font-size: 1.5rem;
        border: 1px solid var(--border);
    }
}

@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: #475569; /* Darker color for contrast on white background */
    background: #f1f5f9; /* Soft grey background */
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.modal-close:hover {
    background: #e2e8f0;
    color: #0f172a;
    transform: rotate(90deg) scale(1.1);
}

/* Round close buttons (portal + shared) */
.modal-close-btn,
button.modal-close-btn {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 50%;
    background: #f1f5f9;
    color: #475569;
    font-size: 1.35rem;
    line-height: 1;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    flex-shrink: 0;
}

.modal-close-btn:hover {
    background: #e2e8f0;
    color: #0f172a;
    transform: rotate(90deg) scale(1.08);
    border-radius: 50%;
}

/* Visible bar charts */
.bar-container {
    display: flex;
    align-items: flex-end;
    gap: 1rem;
    height: 200px;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--border);
}

.bar-container .bar-item {
    flex: 1;
    height: 100%;
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: stretch;
    gap: 8px;
}

.bar-container .chart-bar-visible,
.bar-container .bar {
    width: 100%;
    min-height: 14px;
    border-radius: 8px 8px 0 0;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.12);
}

.bar-container .bar::after,
.bar-container .chart-bar-visible::after {
    content: attr(data-value);
    position: absolute;
    top: -22px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--text-main);
    white-space: nowrap;
}

.bar-container .bar,
.bar-container .chart-bar-visible {
    position: relative;
}

/* Buttons */
.btn {
    padding: 12px 24px;
    border-radius: 12px;
    border: none;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1; /* Ensures text is perfectly middle-aligned */
    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: var(--bg-surface-muted);
  color: var(--text-main);
  border-color: var(--border);
}

[data-theme="dark"] .btn-outline:hover {
  background: #334155;
  color: #f8fafc;
  border-color: #475569;
}

/* 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;
}

[data-theme="dark"] .search-input,
[data-theme="dark"] input[type="month"],
[data-theme="dark"] input[type="date"],
[data-theme="dark"] input[type="text"],
[data-theme="dark"] input[type="email"],
[data-theme="dark"] input[type="tel"],
[data-theme="dark"] input[type="number"],
[data-theme="dark"] input[type="search"],
[data-theme="dark"] select,
[data-theme="dark"] textarea {
    background: var(--bg-main);
    color: var(--text-main);
    border-color: var(--border);
}

[data-theme="dark"] input[type="month"]::-webkit-calendar-picker-indicator,
[data-theme="dark"] input[type="date"]::-webkit-calendar-picker-indicator {
    filter: invert(0.85);
}

[data-theme="dark"] .badge-leader { background: #0c4a6e; color: #bae6fd; }
[data-theme="dark"] .badge-student { background: #334155; color: #cbd5e1; }
[data-theme="dark"] .badge-paid { background: #14532d; color: #bbf7d0; }
[data-theme="dark"] .badge-unpaid { background: #7f1d1d; color: #fecaca; }

[data-theme="dark"] .report-tab-btn:hover {
    background: #334155;
    color: var(--text-main);
}

/* Locked / read-only form fields (Quran contest admin, etc.) */
.filter-select.input-locked,
input.filter-select.input-locked,
textarea.filter-select.input-locked,
select.filter-select.input-locked {
    background: var(--bg-surface-muted) !important;
    color: var(--text-main) !important;
    cursor: not-allowed;
    opacity: 0.92;
}

/* Light-surface panels — theme-aware text on elevated cards */
.member-employment-panel,
.hsf-program-meta-item,
.hsf-program-place-card,
.hsf-program-venue-card,
.hsf-program-winners-grid > div,
.member-dufcad-row td,
.help-detail-fields td,
.edit-graduated-panel {
    color: var(--text-main);
}

[data-theme="dark"] .member-employment-panel h4,
[data-theme="dark"] .help-detail-reason strong,
[data-theme="dark"] .hsf-program-modal-year {
    color: #93c5fd;
}

[data-theme="dark"] .hsf-program-modal-brand {
    background: linear-gradient(135deg, #1a2740 0%, var(--bg-card) 55%);
}

[data-theme="dark"] .hsf-program-link.is-active,
[data-theme="dark"] .hsf-program-link:hover,
[data-theme="dark"] .hsf-reg-title-btn.is-active,
[data-theme="dark"] .hsf-reg-title-btn.is-active:hover {
    color: #93c5fd;
}

/* 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;
}

/* Auth pages — circular logo (login, forgot password, OTP, reset) */
.login-logo img {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    object-fit: cover;
    filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.1));
}

.auth-logo img {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    object-fit: cover;
    filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.1));
}

.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); }

/* ========================= */
/* PREMIUM INTERACTIVE TOOLTIP */
/* ========================= */

.hsf-tooltip {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.hsf-tooltip .tooltip-text {
  visibility: hidden;
  width: 180px;
  background-color: #0f172a;
  color: #ffffff;
  text-align: center;
  border-radius: 10px;
  padding: 10px 14px;
  position: absolute;
  z-index: 999;
  bottom: 135%; /* Position above the element */
  left: 50%;
  transform: translateX(-50%);
  opacity: 0;
  transition: opacity 0.25s cubic-bezier(0.4, 0, 0.2, 1), transform 0.25s cubic-bezier(0.4, 0, 0.2, 1), visibility 0.25s;
  font-size: 0.85rem;
  font-weight: 500;
  line-height: 1.45;
  box-shadow: var(--shadow-lg), 0 10px 25px -5px rgba(0, 0, 0, 0.3);
  pointer-events: none;
  border: 1px solid rgba(255,255,255,0.1);
}

.hsf-tooltip .tooltip-text::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  margin-left: -6px;
  border-width: 6px;
  border-style: solid;
  border-color: #0f172a transparent transparent transparent;
}

/* Hover & Active triggers */
.hsf-tooltip:hover .tooltip-text {
  visibility: visible;
  opacity: 1;
  transform: translateX(-50%) translateY(-2px);
}