/*
|--------------------------------------------------------------------------
| Dashboard Layout
|--------------------------------------------------------------------------
| Sidebar, app shell, stat cards, and data tables used across the
| admin, barangay, and citizen consoles.
*/

.app-shell {
    display: flex;
    min-height: 100vh;
}

/* --------------------------------------------------------------------
   Sidebar
   -------------------------------------------------------------------- */

.app-sidebar {
    width: 220px;
    flex-shrink: 0;
    background: linear-gradient(195deg, var(--maroon-800) 0%, var(--maroon-900) 65%, #2c0916 100%);
    color: #fff;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow: hidden;
    transition: width 0.2s ease, opacity 0.15s ease;
    box-shadow: 2px 0 16px rgba(36, 16, 22, 0.15);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 1.1rem 1rem;
    border-bottom: 1px solid rgba(212, 160, 23, 0.2);
    white-space: nowrap;
}

.sidebar-brand img {
    width: 32px;
    height: 32px;
    object-fit: contain;
    flex-shrink: 0;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

.sidebar-brand .brand-title {
    font-family: var(--font-display);
    font-weight: 700;
    color: var(--gold-light);
    font-size: 1.05rem;
    letter-spacing: 0.02em;
    line-height: 1.1;
    margin: 0;
}

.sidebar-brand .brand-subtitle {
    font-size: 0.58rem;
    letter-spacing: 0.1em;
    color: rgba(255, 255, 255, 0.65);
    text-transform: uppercase;
}

.sidebar-nav {
    flex: 1;
    padding: 0.75rem 0.65rem;
}

.sidebar-nav .nav-link {
    color: rgba(255, 255, 255, 0.8);
    border-radius: 0.5rem;
    padding: 0.55rem 0.75rem;
    margin-bottom: 0.2rem;
    display: flex;
    align-items: center;
    gap: 0.65rem;
    font-size: 0.86rem;
    font-weight: 500;
    white-space: nowrap;
    border-left: 2px solid transparent;
    transition: background-color 0.15s ease, transform 0.15s ease, border-color 0.15s ease;
}

.sidebar-nav .nav-link i {
    font-size: 0.98rem;
    width: 1.1rem;
    text-align: center;
}

.sidebar-nav .nav-link:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    transform: translateX(2px);
    border-left-color: rgba(212, 160, 23, 0.5);
}

.sidebar-nav .nav-link.active {
    background: linear-gradient(135deg, var(--gold-light), var(--gold) 65%);
    color: var(--maroon-900);
    font-weight: 700;
    border-left-color: #fff;
    box-shadow: 0 3px 10px rgba(212, 160, 23, 0.4);
}

/* Sidebar items with a report-list dropdown (currently just Reports) */

.nav-link-group {
    display: flex;
    align-items: stretch;
    gap: 0.15rem;
}

.nav-link-group .nav-link {
    flex: 1;
    margin-bottom: 0;
}

.nav-link-caret {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 1.9rem;
    background: transparent;
    border: none;
    border-radius: 0.5rem;
    color: rgba(255, 255, 255, 0.65);
    margin-bottom: 0.2rem;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.nav-link-caret:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
}

.nav-link-caret i {
    font-size: 0.8rem;
    transition: transform 0.2s ease;
}

.nav-link-caret[aria-expanded="true"] i {
    transform: rotate(180deg);
}

.sidebar-subnav {
    display: flex;
    flex-direction: column;
    padding: 0.15rem 0 0.35rem 1.6rem;
}

.sidebar-subnav-link {
    color: rgba(255, 255, 255, 0.65);
    font-size: 0.8rem;
    padding: 0.35rem 0.6rem;
    border-radius: 0.4rem;
    white-space: nowrap;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.sidebar-subnav-link:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
}

/* --------------------------------------------------------------------
   Sidebar collapse
   -------------------------------------------------------------------- */

.sidebar-toggle {
    text-align: center;
    padding: 0.6rem;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    background: transparent;
    border-left: none;
    border-right: none;
    border-bottom: none;
    width: 100%;
}

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

.sidebar-expand-tab {
    display: none;
    position: fixed;
    top: 14px;
    left: 0;
    z-index: 1030;
    background: var(--maroon-700);
    color: #fff;
    border: none;
    border-radius: 0 0.5rem 0.5rem 0;
    width: 24px;
    height: 38px;
    align-items: center;
    justify-content: center;
}

.sidebar-expand-tab:hover {
    background: var(--maroon-600);
}

@media (min-width: 992px) {
    .app-shell.sidebar-collapsed .app-sidebar {
        width: 0;
        opacity: 0;
        pointer-events: none;
    }

    .app-shell.sidebar-collapsed .sidebar-expand-tab {
        display: flex;
    }
}

/* --------------------------------------------------------------------
   Main content
   -------------------------------------------------------------------- */

.app-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.app-content {
    padding: 1.5rem;
}

.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
}

.page-header h1 {
    font-size: 1.65rem;
    font-weight: 700;
    margin-bottom: 0.1rem;
}

.page-header p {
    color: var(--text-muted);
    margin-bottom: 0;
    font-size: 0.9rem;
}

/* --------------------------------------------------------------------
   Stat Cards
   -------------------------------------------------------------------- */

.stat-card {
    background: var(--surface);
    border-radius: 1rem;
    box-shadow: var(--shadow-md);
    padding: 1.15rem;
    height: 100%;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    border-top: 3px solid var(--border-color);
}

.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
    border-top-color: var(--gold);
}

.stat-card:hover .icon-square {
    transform: scale(1.08);
}

.stat-card .stat-value {
    font-family: var(--font-body);
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: -0.01em;
    font-feature-settings: "tnum" 1;
    margin: 0.6rem 0 0.1rem;
}

.stat-card .stat-label {
    color: var(--text-muted);
    font-size: 0.82rem;
    font-weight: 500;
}

/* --------------------------------------------------------------------
   Panels / Data tables
   -------------------------------------------------------------------- */

.panel {
    background: var(--surface);
    border-radius: 1rem;
    box-shadow: var(--shadow-md);
    overflow: hidden;
}

.panel .panel-header {
    padding: 1.1rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
}

.data-table {
    width: 100%;
    margin-bottom: 0;
}

.data-table thead th {
    background: var(--cream-dark);
    color: var(--text-muted);
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.75rem 1.25rem;
    border-bottom: 2px solid var(--gold);
    white-space: nowrap;
}

.data-table tbody tr {
    transition: background-color 0.12s ease;
}

.data-table tbody tr:hover {
    background-color: var(--cream-dark);
}

.data-table tbody td {
    padding: 0.7rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
    font-size: 0.86rem;
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

.filter-pill {
    border: 1px solid var(--border-color);
    background: var(--surface);
    border-radius: 999px;
    padding: 0.35rem 0.9rem;
    font-size: 0.82rem;
    color: var(--text-muted);
    font-weight: 600;
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.filter-pill:hover {
    border-color: var(--maroon-500);
    color: var(--maroon-600);
}

.filter-pill.active {
    background: linear-gradient(135deg, var(--maroon-600), var(--maroon-800));
    border-color: var(--maroon-800);
    color: #fff;
    box-shadow: 0 2px 8px rgba(74, 15, 34, 0.25);
}

.filter-tabs {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* --------------------------------------------------------------------
   Approval Workflow chips
   -------------------------------------------------------------------- */

.workflow-track {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.6rem;
}

.workflow-step {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.45rem 0.8rem;
    border-radius: 0.6rem;
    font-weight: 600;
    font-size: 0.82rem;
    white-space: nowrap;
}

.workflow-step.current {
    outline: 2px solid var(--gold);
    outline-offset: 2px;
}

.workflow-arrow {
    color: var(--text-muted);
}

.step-citizen { background: var(--soft-pink); color: var(--soft-pink-icon); }
.step-barangay_staff { background: var(--soft-blue); color: var(--soft-blue-icon); }
.step-barangay_captain { background: var(--soft-green); color: var(--soft-green-icon); }
.step-city_officer { background: var(--soft-purple); color: var(--soft-purple-icon); }
.step-mayor { background: var(--soft-gold); color: var(--soft-gold-icon); }
.step-provincial_admin { background: #d7f0f5; color: #1a7f96; }
.step-national_admin { background: var(--soft-pink); color: var(--soft-pink-icon); }

/* --------------------------------------------------------------------
   Sidebar off-canvas (mobile)
   -------------------------------------------------------------------- */

.app-topbar .mobile-sidebar-toggle {
    display: none;
}

.sidebar-backdrop {
    display: none;
}

@media (max-width: 991.98px) {
    .app-sidebar {
        position: fixed;
        left: -220px;
        z-index: 1040;
        transition: left 0.2s ease;
    }

    .app-sidebar.show {
        left: 0;
    }

    .app-content {
        padding: 1rem;
    }

    .sidebar-expand-tab {
        display: none !important;
    }

    .app-topbar .mobile-sidebar-toggle {
        display: inline-flex;
    }

    /* Dims and blocks the page behind an open mobile sidebar; tapping it
       closes the sidebar, same as the collapse chevron inside it. */
    .sidebar-backdrop.show {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(20, 6, 12, 0.45);
        z-index: 1035;
    }
}

/* --------------------------------------------------------------------
   Mobile card tables
   -------------------------------------------------------------------- */
/* Opt-in (.mobile-card-table, alongside .data-table) for tables with
   enough columns that .table-responsive's horizontal scroll leaves most
   of the row hidden off-screen with no hint more content exists. Below
   the breakpoint each row becomes its own card and each cell's column
   header is repeated inline via its data-label attribute, so every field
   stays visible without scrolling. */

@media (max-width: 767.98px) {

    .mobile-card-table thead {
        display: none;
    }

    .mobile-card-table, .mobile-card-table tbody, .mobile-card-table tr, .mobile-card-table td {
        display: block;
        width: 100%;
    }

    .mobile-card-table tbody tr {
        border: 1px solid var(--border-color);
        border-radius: 0.75rem;
        margin: 0.75rem;
        box-shadow: var(--shadow-sm);
    }

    .mobile-card-table tbody tr:hover {
        background-color: transparent;
    }

    .mobile-card-table td {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 0.75rem;
        padding: 0.6rem 1rem;
        border-bottom: 1px solid var(--border-color);
        text-align: right;
        white-space: normal;
    }

    .mobile-card-table tr td:last-child {
        border-bottom: none;
    }

    .mobile-card-table td[data-label]::before {
        content: attr(data-label);
        flex-shrink: 0;
        font-size: 0.7rem;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: 0.04em;
        color: var(--text-muted);
        text-align: left;
    }

    .mobile-card-table td.empty-state {
        text-align: center;
        padding: 1.25rem;
    }

    .mobile-card-table td.empty-state::before {
        content: none;
    }
}
