:root {
    --background-dark: #0a0a0a;
    --background-light: #1a1a1a;
    --text-color: #e0e0e0;
    --text-color-muted: #a0a0a0;
    --accent-color: #3a3a3a;
    --accent-color-dark: #2a2a2a;
    --accent-color-darker: #1a1a1a;
    --border-color: #faf8f8;
    --negative-balance: #5e2a2d;
    /* Card colors for mixed dark/light UI components */
    --card-bg: #ffffff;
    --card-text-color: #222222;
}

/*=============================================*/
/* Preloader Styles */
/*=============================================*/

#preloader {
    position: fixed;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: #1a1a1a;
    /* Adjust to match your theme */
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

/* Additional styling for SVG loader if needed */
.svg-loader svg {
    animation: rotate 2s linear infinite;
}

@keyframes rotate {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* ============================================ */
body {
    font-family: 'Arial', sans-serif;
    color: var(--text-color);
    background-color: var(--background-dark);
}

.wrapper {
    display: flex;
    width: 100%;
    align-items: stretch;
}

#sidebar {
    min-width: 250px;
    max-width: 250px;
    background: var(--background-light);
    color: var(--text-color);
    transition: all 0.3s;
    position: fixed;
    top: 0;
    left: -250px;
    height: 100%;
    z-index: 1001;
}

#sidebar.active {
    left: 0;
}

#sidebar .sidebar-header {
    padding: 20px;
    background: var(--accent-color);
    color: var(--text-color);
}

#sidebar ul.components {
    padding: 20px 0;
    border-bottom: 1px solid var(--border-color);
}

#sidebar ul li a {
    padding: 10px;
    font-size: 1.1em;
    display: block;
    color: var(--text-color-muted);
    transition: all 0.3s;
}

#sidebar ul li a:hover {
    color: var(--text-color);
    background: var(--accent-color-darker);
}

#sidebar ul li.active>a,
a[aria-expanded="true"] {
    color: var(--text-color);
    background: var(--accent-color);
}

#sidebar ul ul a {
    font-size: 0.9em !important;
    padding-left: 30px !important;
}

#content {
    width: 100%;
    padding: 20px;
    min-height: 100vh;
    transition: all 0.3s;
}

.navbar {
    background-color: var(--background-light) !important;
    border-bottom: 1px solid var(--border-color);
}

.navbar-light .navbar-nav .nav-link {
    color: var(--text-color-muted);
}

.navbar-light .navbar-nav .nav-link:hover,
.navbar-light .navbar-nav .nav-link:focus {
    color: var(--text-color);
}

.navbar-light .navbar-nav .active>.nav-link {
    color: var(--text-color);
}

.line {
    width: 100%;
    height: 1px;
    border-bottom: 1px solid var(--border-color);
    margin: 40px 0;
}

.btn-dark {
    background-color: var(--accent-color);
    border-color: var(--accent-color);
    color: var(--text-color);
}

.btn-dark:hover {
    background-color: var(--accent-color-dark);
    border-color: var(--accent-color-dark);
}

/* Ensure cards with a light background show dark, readable text in dark mode */
.card {
    background-color: var(--card-bg);
    color: var(--card-text-color);
}

/* Card children should inherit readable text color; target common elements */
.card .card-body,
.card .card-title,
.card .list-unstyled,
.card p,
.card label,
.card small {
    color: var(--card-text-color);
}

/* Ensure form inputs inside cards have proper styling */
.card .form-control {
    background-color: #ffffff;
    color: var(--card-text-color);
    border: 1px solid #ced4da;
}

.card .form-control:focus {
    background-color: #ffffff;
    color: var(--card-text-color);
    border-color: #80bdff;
    outline: 0;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

/* Ensure form text/help text in cards is readable */
.card .form-text {
    color: #6c757d;
}

/* Enhanced card styling for better visibility */
.card.shadow-sm {
    box-shadow: 0 0.125rem 0.5rem rgba(0, 0, 0, 0.15) !important;
    border: none;
    border-radius: 0.5rem;
    overflow: hidden;
}

.card-header {
    border-bottom: 2px solid rgba(0, 0, 0, 0.1);
    padding: 1rem 1.25rem;
}

.card-header h5 {
    font-weight: 600;
    font-size: 1.1rem;
}

/* List group styling for better readability */
.list-group-item {
    border-left: none;
    border-right: none;
    padding: 0.9rem 0;
    background-color: transparent;
}

.list-group-item:first-child {
    border-top: none;
}

.list-group-item:last-child {
    border-bottom: none;
}

/* Badge styling for statistics */
.badge-pill {
    padding: 0.4rem 0.8rem;
    font-size: 0.9rem;
    font-weight: 600;
}

/* Form control enhancements */
.form-control-lg {
    font-size: 1.1rem;
    padding: 0.75rem 1rem;
}

/* Button enhancements */
.btn-lg {
    padding: 0.75rem 1.5rem;
    font-size: 1.1rem;
    font-weight: 500;
}

.btn-block+.btn-block {
    margin-top: 0.75rem;
}

/* Alert improvements */
.alert {
    border-radius: 0.5rem;
    border: none;
}

.alert-success {
    background-color: #d4edda;
    color: #155724;
}

.table {
    color: var(--text-color);
}

.table-striped tbody tr:nth-of-type(odd) {
    background-color: var(--background-light);
}

.table-bordered {
    border-color: var(--border-color);
}

.table thead th {
    background-color: var(--accent-color);
    border-color: var(--border-color);
    color: var(--text-color);
}

.negative-balance {
    background-color: var(--negative-balance) !important;
}

.member-link {
    text-decoration: none;
    color: var(--text-color);
}

.member-link:hover {
    text-decoration: underline;
}

.navbar-toggler {
    color: var(--text-color);
    border: none;
    font-size: 24px;
    padding: 5px 10px;
}

.navbar-toggler:hover {
    color: var(--text-color);
}

/* ============================================ */
/* Styles moved from nextday.php */
/* ============================================ */

.table thead th {
    border-bottom-color: var(--border-color);
}

.table-bordered td,
.table-bordered th {
    border-color: var(--border-color);
}

/* ============================================ */
/* Styles moved from member.php */
/* ============================================ */

.action-buttons .btn {
    margin-right: 10px;
}

/* ============================================ */
/* Styles moved from logs.php */
/* ============================================ */

.fund-added {
    background-color: #d4edda !important;
    /* Light green background */
    color: black;
    border-color: black;
}

.fund-deducted {
    background-color: #f8d7da !important;
    /* Light red background */
    color: black;
}

/* ============================================ */
/* Styles moved from filterhistory2.php */
/* ============================================ */

.main-row-highlight {
    background-color: var(--main-row-highlight);
    color: #ffffff;
}

.table-highlighted {
    background-color: var(--highlighted-background);
    border: 1px solid var(--highlighted-border);
}

.table-highlighted thead {
    background-color: var(--highlighted-border);
    color: #ffffff;
}

.breakdown-table {
    display: none;
}

.main-row-highlight {
    background-color: rgba(58, 123, 213, 0.15) !important;
    transition: background-color 0.2s ease;
}

.main-row-highlight:hover {
    background-color: rgba(58, 123, 213, 0.25) !important;
}

.table-highlighted {
    background-color: var(--background-light);
    border: 1px solid var(--border-color);
    margin: 0.5rem 0;
}

.table-highlighted thead {
    background-color: var(--accent-color);
    color: var(--text-color);
}

.table-highlighted tbody tr {
    background-color: var(--background-dark);
}

/* ============================================ */
/* Styles moved from hardnote.php */
/* ============================================ */

.table-responsive {
    overflow-x: auto;
    /* Enable horizontal scrolling */
    overflow-y: auto;
    /* Enable vertical scrolling */
    max-height: 500px;
    /* Adjust to your desired table height */
}

.sticky-col {
    position: sticky;
    left: 0;
    /* Keeps it on the left side */
    background-color: #f8f9fa;
    /* Optional: Match table header background */
    z-index: 2;
    /* Ensure it appears above other cells */
    border-right: 1px solid #dee2e6;
    /* Optional: Add a separator */
}

.sticky-header {
    position: sticky;
    top: 0;
    /* Stick to the top of the table container */
    z-index: 2;
    /* Ensure it appears above the rest of the rows */
    background-color: #343a40;
    /* Match table header background */
    color: #ffffff;
    /* Match table header text color */
}

/* ============================================ */
/* Styles moved from index.php */
/* ============================================ */

.table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.table-container table {
    min-width: 100%;
}

/* Mobile Responsive Styles */
@media (max-width: 768px) {
    .container {
        padding-left: 10px;
        padding-right: 10px;
        margin-top: 1rem !important;
    }

    h2 {
        font-size: 1.5rem;
        margin-bottom: 0.75rem;
    }

    h4,
    h5 {
        font-size: 1.1rem;
    }

    /* Breadcrumb responsive */
    .breadcrumb {
        padding: 0.5rem 0.75rem;
        font-size: 0.8rem;
        flex-wrap: wrap;
        margin-bottom: 1rem;
        background-color: var(--accent-color);
    }

    .breadcrumb-item {
        padding: 0.15rem 0;
    }

    .breadcrumb-item a {
        color: var(--text-color);
        text-decoration: none;
    }

    .breadcrumb-item+.breadcrumb-item {
        padding-left: 0.25rem;
    }

    .breadcrumb-item+.breadcrumb-item::before {
        padding-right: 0.25rem;
        font-size: 0.75rem;
    }

    .breadcrumb-item.active {
        color: var(--text-color-muted);
    }
}

@media (max-width: 640px) {

    .table-container th,
    .table-container td {
        padding: 0.5rem 0.25rem;
        font-size: 0.875rem;
    }

    /* Week navigation for small screens - keep horizontal */
    .week-navigation {
        display: grid;
        grid-template-columns: auto 1fr auto;
        align-items: center;
        gap: 0.5rem;
        margin-bottom: 1rem !important;
    }

    .week-navigation .btn-nav {
        padding: 0.5rem 0.75rem;
        font-size: 0.85rem;
        display: flex;
        align-items: center;
        justify-content: center;
        white-space: nowrap;
    }

    .week-display {
        text-align: center;
        font-size: 0.75rem;
        line-height: 1.3;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
    }

    .week-display .week-start,
    .week-display .week-end {
        display: block;
    }

    .week-display .week-dash {
        display: block;
        margin: 0.1rem 0;
        opacity: 0.7;
        font-size: 0.7rem;
    }

    /* Table responsive improvements */
    .table {
        font-size: 0.85rem;
    }

    .table thead th {
        padding: 0.5rem 0.25rem;
        font-size: 0.8rem;
    }

    .table tbody td {
        padding: 0.5rem 0.25rem;
        font-size: 0.85rem;
    }

    .table tfoot td {
        padding: 0.5rem 0.25rem;
        font-size: 0.85rem;
    }

    /* Button improvements for small screens */
    .btn-sm {
        padding: 0.25rem 0.4rem;
        font-size: 0.75rem;
    }

    /* Heading adjustments */
    h2 {
        font-size: 1.3rem;
        margin-bottom: 1rem;
    }

    h4 {
        font-size: 1rem;
        margin-top: 1.5rem;
        margin-bottom: 0.75rem;
    }

    h5 {
        font-size: 0.95rem;
        margin-top: 1.5rem;
        margin-bottom: 0.75rem;
    }
}

@media (max-width: 480px) {

    /* Extra small screens */
    .container {
        padding-left: 5px;
        padding-right: 5px;
    }

    .week-display {
        font-size: 0.7rem;
    }

    .week-navigation .btn-nav {
        padding: 0.4rem 0.5rem;
        font-size: 0.75rem;
    }

    .week-navigation .btn-nav i {
        font-size: 0.8rem;
    }

    .table {
        font-size: 0.75rem;
    }

    .table thead th,
    .table tbody td,
    .table tfoot td {
        padding: 0.4rem 0.2rem;
        font-size: 0.75rem;
    }

    h2 {
        font-size: 1.2rem;
    }

    .breadcrumb {
        font-size: 0.75rem;
    }
}

.meal-badge {
    padding: 0.1em 0.5em;
    font-size: 0.75em;
    font-weight: 600;
    border-radius: 9999px;
    display: inline-block;
    margin-right: 0.25em;
}

.balance-badge {
    padding: 0.25em 0.5em;
    font-size: 1em;
    font-weight: 400;
    border-radius: 9999px;
    display: inline-block;
}

/* Overlay used to detect outside clicks for sidebar */
.overlay {
    position: fixed;
    inset: 0;
    /* top:0; right:0; bottom:0; left:0; */
    background: rgba(0, 0, 0, 0);
    /* transparent when inactive */
    visibility: hidden;
    opacity: 0;
    transition: background 0.2s ease, opacity 0.2s ease, visibility 0.2s;
    z-index: 1000;
    /* below the sidebar (1001) but above the content */
    pointer-events: none;
    /* don't block clicks when inactive */
}

.overlay.active {
    background: rgba(0, 0, 0, 0.45);
    visibility: visible;
    opacity: 1;
    pointer-events: auto;
    /* allow overlay to receive clicks when active */
}

/* -------------------------------------------------- */
/* Ensure table header borders use #dee2e6             */
/* This is intentionally specific so it overrides     */
/* other theme rules that set different border colors. */
/* -------------------------------------------------- */
.table thead th,
.table-bordered thead th,
.table-bordered th {
    border-color: #dee2e6 !important;
    border-bottom-color: #dee2e6 !important;
}