/* ========= THEME (Primary: #334155) ========= */

:root {
    --brand: #334155;
    /* main brand color */
    --brand-600: #2b3b4a;
    --brand-500: #334155;
    --brand-400: #425168;
    --bg-900: #0b0f18;
    /* deep background */
    --bg-800: #121827;
    --bg-700: #1b2433;
    --card: #0f1624;
    --text-100: #e5e7eb;
    --text-200: #cbd5e1;
    --muted: #94a3b8;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
}


/* ========= APP SHELL ========= */


/* Prevent horizontal scrolling on mobile */

*,
*::before,
*::after {
    box-sizing: border-box;
}

html,
body {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
    /* hard stop for any rogue overflow */
}


/* Clip any accidental overflow from inner wrappers */

#main-content,
.app-body {
    overflow-x: clip;
}

body {
    display: flex;
    min-height: 100vh;
    background: var(--bg-900);
    color: var(--text-100);
}


/* Login pages only (do NOT set this on dashboard pages) */

body.login-bg {
    background: linear-gradient(135deg, #141a26, #0f1420);
    display: flex;
    align-items: center;
    justify-content: center;
}


/* Sidebar */

#sidebar {
    width: 260px;
    min-height: 100vh;
    background: linear-gradient(180deg, var(--brand-600), var(--bg-800));
    color: var(--text-100);
    border-right: 1px solid rgba(148, 163, 184, .18);
    position: sticky;
    top: 0;
    z-index: 1030;
}

#sidebar .sidebar-header {
    background: rgba(255, 255, 255, .03);
}

#sidebar .nav-link {
    color: var(--text-200);
    border-radius: .5rem;
    padding: .6rem .75rem;
}

#sidebar .nav-link:hover {
    background: rgba(255, 255, 255, .06);
    color: #fff;
}

#sidebar .nav-link.active {
    background: var(--brand-500);
    color: #fff;
    box-shadow: 0 0 0 1px rgba(255, 255, 255, .08) inset;
}


/* Mobile off-canvas */

.sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .45);
    z-index: 1029;
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s ease;
}

.sidebar-backdrop.show {
    opacity: 1;
    pointer-events: auto;
}


/* Mobile off-canvas (single consistent approach) */

@media (max-width: 991.98px) {
    #sidebar {
        position: fixed;
        left: 0;
        top: 0;
        width: 260px;
        /* match desktop width unless you want 200px */
        height: 100vh;
        transform: translateX(-100%);
        /* fully off-screen without shifting layout */
        transition: transform .25s ease;
        will-change: transform;
        contain: paint;
        /* avoid layout bleed causing overflow */
    }
    #sidebar.active {
        transform: translateX(0);
    }
    body.sb-open {
        overflow: hidden;
    }
}


/* Main content (PAGE should scroll; no inner scrolling) */

#main-content {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 100vh;
    /* keeps footer at bottom when content is short */
    /* let the page scroll; do not clip inner sticky elements/toasts */
    overflow: visible;
    background: linear-gradient(180deg, var(--bg-800), var(--bg-900));
}


/* Top app bar */

.appbar {
    background: linear-gradient(180deg, var(--bg-700), var(--bg-800));
    border-bottom: 1px solid rgba(148, 163, 184, .18);
    position: sticky;
    top: 0;
    z-index: 2;
    border-radius: 5px;
}


/* Inner content area (NO inner scroll) */

.app-body {
    flex: 1 1 auto;
    min-height: auto;
    /* allow content to grow naturally */
    overflow: visible !important;
    /* make page handle scrolling */
    padding: 16px;
    /* reset any previous scrollbar hacks */
    -ms-overflow-style: auto;
    scrollbar-width: auto;
}

.app-body::-webkit-scrollbar {
    width: initial;
    height: initial;
}


/* Cards */

.card.dashboard {
    background: var(--card);
    border: 1px solid rgba(148, 163, 184, .15);
    color: var(--text-100);
}

.stat-card {
    background: #0c1321;
    border: 1px solid rgba(148, 163, 184, .12);
    border-radius: 12px;
    height: 100%;
}

.metric {
    background: #0b1120;
    border: 1px solid rgba(148, 163, 184, .12);
    border-radius: 10px;
    padding: 10px 12px;
}

.metric .label {
    color: var(--muted);
    font-size: .85rem;
}

.metric .value {
    font-weight: 700;
}


/* Badges themed */

.badge-tint {
    border: 1px solid rgba(255, 255, 255, .12);
    border-radius: 999px;
    padding: .25rem .6rem;
    font-size: .75rem;
}

.badge-restaurant {
    background: rgba(59, 130, 246, .15);
    color: #93c5fd;
}

.badge-foodbank {
    background: rgba(16, 185, 129, .15);
    color: #6ee7b7;
}

.badge-link2feed {
    background: rgba(14, 165, 233, .15);
    color: #7dd3fc;
}

.badge-proxy {
    background: rgba(245, 158, 11, .15);
    color: #fcd34d;
}

.badge-surplus {
    background: rgba(148, 163, 184, .15);
    color: #cbd5e1;
}


/* Switches */

.form-switch .form-check-input {
    background-color: #1f2937;
    border-color: #334155;
}

.form-switch .form-check-input:checked {
    background-color: var(--brand-500);
    border-color: var(--brand-500);
}


/* Buttons */

.btn-primary {
    background: var(--brand-500);
    border-color: var(--brand-500);
}

.btn-primary:hover {
    background: var(--brand-600);
    border-color: var(--brand-600);
}

.btn-outline-light {
    color: var(--text-100);
    border-color: rgba(226, 232, 240, .25);
}

.btn-outline-light:hover {
    background: rgba(226, 232, 240, .08);
    border-color: rgba(226, 232, 240, .45);
}


/* Alerts on dark */

.alert {
    border: 1px solid rgba(148, 163, 184, .25);
    color: var(--text-100);
}

.alert-success {
    background: rgba(16, 185, 129, .12);
}

.alert-danger {
    background: rgba(239, 68, 68, .12);
}

.alert-info {
    background: rgba(59, 130, 246, .12);
}


/* Loading skeleton */

.loading-skel {
    background: linear-gradient(90deg, rgba(148, 163, 184, .12) 25%, rgba(148, 163, 184, .22) 37%, rgba(148, 163, 184, .12) 63%);
    background-size: 400% 100%;
    animation: shimmer 1.15s ease-in-out infinite;
    border-radius: 6px;
}

@keyframes shimmer {
    0% {
        background-position: 100% 0
    }
    100% {
        background-position: 0 0
    }
}


/* Dashboard-only: slimmer sidebar */

.dashboard-page #sidebar {
    width: 260px;
    /* was 250px */
}


/* Keep layout tight inside the slimmer rail */

.dashboard-page #sidebar .sidebar-header {
    padding: .85rem .9rem;
}

.dashboard-page #sidebar .nav-link {
    padding: .45rem .8rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    /* trims long labels nicely */
    border-radius: 6px;
}


/* Mobile slide-in must match new width */

@media (max-width: 767.98px) {
    .dashboard-page #sidebar {
        left: -200px;
        /* match width = 200px */
        width: 200px;
    }
    .dashboard-page #sidebar.active {
        left: 0;
    }
}


/* Optional: slightly tighter main-content padding on dashboard */

.dashboard-page #main-content {
    padding: 16px;
}


/* ========= FOOTER ========= */

.footer-bar {
    background: linear-gradient(180deg, var(--bg-700), var(--bg-800));
    color: #fff !important;
    border-radius: 5px 5px 0 0;
    border-top: 1px solid rgba(148, 163, 184, .18);
}


/* Make icons comfy to tap */

.social-link {
    color: rgba(255, 255, 255, .98);
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, .08);
    transition: transform .2s ease, background-color .2s ease, filter .2s ease;
    outline: none;
}

.social-link svg {
    width: 28px;
    height: 28px;
    fill: currentColor;
    pointer-events: none;
}

.social-link:hover,
.social-link:focus-visible {
    transform: translateY(-1px) scale(1.06);
    background: rgba(255, 255, 255, .16);
    filter: drop-shadow(0 2px 6px rgba(255, 255, 255, .25));
}


/* Mobile-first stacking */

@media (max-width: 575.98px) {
    .footer-row {
        flex-direction: column;
        align-items: stretch !important;
        text-align: center;
        gap: 12px;
    }
    .footer-copy {
        font-size: .95rem;
        opacity: .95;
        order: 2;
        /* move text below icons */
    }
    .footer-social {
        order: 1;
        display: grid !important;
        /* grid for even spacing */
        grid-template-columns: repeat( auto-fit, minmax(56px, 1fr));
        gap: 10px;
    }
    .footer-bar .container {
        padding-left: max(16px, env(safe-area-inset-left));
        padding-right: max(16px, env(safe-area-inset-right));
        padding-bottom: max(16px, env(safe-area-inset-bottom));
    }
}


/* Small tablets */

@media (min-width: 576px) and (max-width: 767.98px) {
    .footer-row {
        gap: 12px;
    }
    .footer-social {
        gap: 8px;
    }
}


/* Keep footer text bright */

.footer-bar a,
.footer-bar .footer-copy,
.footer-bar small {
    color: #fff !important;
}

img,
video,
svg,
canvas {
    max-width: 100%;
    height: auto;
}


/* Make cards appear wider on mobile by reducing outer padding + gutters */

@media (max-width: 575.98px) {
    /* 1) Reduce container side padding */
    .container-fluid {
        padding-left: 8px !important;
        padding-right: 8px !important;
    }
    /* 2) Shrink horizontal gutter for this grid */
    #locations-grid {
        --bs-gutter-x: .5rem;
        /* was 1rem from g-3; smaller = wider card */
    }
    /* Optional: let the card bleed a hair to edges for extra visual width */
    #locations-grid .card-compact {
        margin-left: -2px;
        margin-right: -2px;
        border-radius: 14px;
        /* keeps it pretty when it’s wider */
    }
    /* If you also want it to feel 'bigger', increase cover height */
    .card-cover {
        height: 200px;
        /* was 160px on mobile */
    }
    .app-body {
        padding: 0;
        margin-bottom: 5px;
    }
}


/* Fix Bootstrap collapse inside sidebar */

#sidebar .collapse {
    visibility: visible !important;
    /* make it visible again */
}


/* Optional: if you want it to fully hide when closed */

#sidebar .collapse:not(.show) {
    display: none;
    /* default Bootstrap behavior */
}


/* Rotate the arrow icon when submenu is open */

#sidebar a[data-bs-toggle="collapse"] i.bi-chevron-down {
    transition: transform 0.25s ease;
}


/* Closed state (Bootstrap adds .collapsed automatically) */

#sidebar a[data-bs-toggle="collapse"].collapsed i.bi-chevron-down {
    transform: rotate(0deg);
}


/* Open state */

#sidebar a[data-bs-toggle="collapse"]:not(.collapsed) i.bi-chevron-down {
    transform: rotate(180deg);
}

.text-secondary {
    --bs-text-opacity: 1;
    color: rgb(160 168 175) !important;
}