/* =========================================================================
   CHW MIS — Design System
   A clean, professional "government health MIS" look: teal/blue primary,
   amber accent, soft shadows, rounded cards, generous spacing.
   ========================================================================= */

:root {
    --clr-primary-900: #0E3A47;
    --clr-primary-700: #1B7D9C;
    --clr-primary-600: #2090B0;
    --clr-primary-500: #3AA6C4;
    --clr-primary-100: #E7F3F6;

    --clr-accent-700: #C4801E;
    --clr-accent-500: #E8A33D;
    --clr-accent-100: #FBEDD6;

    --clr-success-700: #146648;
    --clr-success-500: #1D8A5E;
    --clr-success-100: #DFF3EA;

    --clr-danger-700: #9C2E2E;
    --clr-danger-500: #C13B3B;
    --clr-danger-100: #FBE6E6;

    --clr-warning-500: #D99A1B;
    --clr-info-500: #2A8FB0;

    --clr-neutral-900: #1F2A30;
    --clr-neutral-700: #4A5A61;
    --clr-neutral-500: #7C8D94;
    --clr-neutral-300: #A9C0C6;
    --clr-neutral-100: #EEF3F4;
    --clr-neutral-50: #F7FAFB;

    --sidebar-width: 260px;
    --sidebar-width-collapsed: 76px;
    --navbar-height: 64px;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow-sm: 0 1px 3px rgba(15, 40, 50, .06), 0 1px 2px rgba(15, 40, 50, .08);
    --shadow-md: 0 4px 14px rgba(15, 40, 50, .08);
}

* { box-sizing: border-box; }

body {
    background: var(--clr-neutral-50);
    color: var(--clr-neutral-900);
    font-family: 'Segoe UI', Roboto, -apple-system, BlinkMacSystemFont, Arial, sans-serif;
    font-size: .925rem;
}

a { text-decoration: none; }
.font-mono { font-variant-numeric: tabular-nums; }
.text-primary-strong { color: var(--clr-primary-700) !important; }

/* ---------------------------------------------------------------------
   Layout: sidebar + navbar + content
   --------------------------------------------------------------------- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-width);
    background: linear-gradient(180deg, var(--clr-primary-900) 0%, #0A2A34 100%);
    color: #fff;
    flex-shrink: 0;
    position: fixed;
    top: 0; bottom: 0; left: 0;
    z-index: 1030;
    overflow-y: auto;
    transition: transform .25s ease, width .25s ease;
}
.sidebar-brand {
    display: flex; align-items: center; gap: .6rem;
    padding: 1.15rem 1.25rem;
    border-bottom: 1px solid rgba(255,255,255,.08);
    color: #fff; font-weight: 700; font-size: 1.05rem;
}
.sidebar-brand i { font-size: 1.5rem; color: var(--clr-accent-500); }
.sidebar-nav { padding: .75rem .6rem 2rem; }
.sidebar-section-label {
    font-size: .68rem; text-transform: uppercase; letter-spacing: .06em;
    color: rgba(255,255,255,.4); padding: 1rem .75rem .35rem;
}
.sidebar-link {
    display: flex; align-items: center; gap: .7rem;
    padding: .62rem .75rem; border-radius: var(--radius-sm);
    color: rgba(255,255,255,.82); font-size: .875rem; font-weight: 500;
    margin-bottom: 2px;
}
.sidebar-link i { font-size: 1.05rem; width: 20px; text-align: center; }
.sidebar-link:hover { background: rgba(255,255,255,.08); color: #fff; }
.sidebar-link.active { background: var(--clr-primary-700); color: #fff; box-shadow: var(--shadow-sm); }
.sidebar-link .badge { margin-left: auto; }

.main-wrap { margin-left: var(--sidebar-width); flex: 1; min-width: 0; transition: margin-left .25s ease; }
body.sidebar-collapsed .sidebar { width: var(--sidebar-width-collapsed); }
body.sidebar-collapsed .main-wrap { margin-left: var(--sidebar-width-collapsed); }
body.sidebar-collapsed .sidebar-brand span,
body.sidebar-collapsed .sidebar-link span,
body.sidebar-collapsed .sidebar-section-label { display: none; }

.topbar {
    height: var(--navbar-height);
    background: #fff;
    border-bottom: 1px solid var(--clr-neutral-100);
    display: flex; align-items: center; gap: 1rem;
    padding: 0 1.25rem;
    position: sticky; top: 0; z-index: 1020;
}
.topbar .search-box { max-width: 360px; flex: 1; position: relative; }
.topbar .search-box input {
    background: var(--clr-neutral-50); border: 1px solid var(--clr-neutral-100);
    border-radius: 999px; padding: .45rem 1rem .45rem 2.25rem; font-size: .85rem; width: 100%;
}
.topbar .search-box i { position: absolute; left: .8rem; top: 50%; transform: translateY(-50%); color: var(--clr-neutral-500); }
.icon-btn {
    width: 38px; height: 38px; border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center;
    color: var(--clr-neutral-700); position: relative; background: transparent; border: none;
}
.icon-btn:hover { background: var(--clr-neutral-100); }
.notif-dot {
    position: absolute; top: 6px; right: 7px; width: 8px; height: 8px;
    background: var(--clr-danger-500); border-radius: 50%; border: 2px solid #fff;
}

.content { padding: 1.5rem; max-width: 1600px; }
.page-header { display: flex; justify-content: space-between; align-items: flex-start; flex-wrap: wrap; gap: .75rem; margin-bottom: 1.25rem; }
.page-header h1 { font-size: 1.4rem; font-weight: 700; margin-bottom: .15rem; color: var(--clr-neutral-900); }

/* ---------------------------------------------------------------------
   Cards / stats
   --------------------------------------------------------------------- */
.card {
    border: 1px solid var(--clr-neutral-100);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}
.card-header {
    background: #fff; border-bottom: 1px solid var(--clr-neutral-100);
    font-weight: 600; font-size: .92rem; padding: .85rem 1.1rem; border-radius: var(--radius) var(--radius) 0 0 !important;
}
.card-body { padding: 1.1rem; }

.stat-card {
    background: #fff; border: 1px solid var(--clr-neutral-100); border-radius: var(--radius);
    padding: 1rem 1.1rem; box-shadow: var(--shadow-sm); position: relative; overflow: hidden;
    height: 100%;
}
.stat-card::before {
    content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--clr-primary-500);
}
.stat-card.success::before { background: var(--clr-success-500); }
.stat-card.accent::before { background: var(--clr-accent-500); }
.stat-card.danger::before { background: var(--clr-danger-500); }
.stat-card .stat-icon {
    width: 38px; height: 38px; border-radius: 10px; background: var(--clr-primary-100);
    color: var(--clr-primary-700); display: flex; align-items: center; justify-content: center;
    font-size: 1.1rem; margin-bottom: .6rem;
}
.stat-card.success .stat-icon { background: var(--clr-success-100); color: var(--clr-success-700); }
.stat-card.accent .stat-icon { background: var(--clr-accent-100); color: var(--clr-accent-700); }
.stat-card.danger .stat-icon { background: var(--clr-danger-100); color: var(--clr-danger-700); }
.stat-card .stat-value { font-size: 1.5rem; font-weight: 800; line-height: 1.1; color: var(--clr-neutral-900); }
.stat-card .stat-label { font-size: .78rem; color: var(--clr-neutral-500); margin-top: .15rem; }

.perf-track { height: 7px; background: var(--clr-neutral-100); border-radius: 99px; overflow: hidden; }
.perf-fill { height: 100%; border-radius: 99px; }

/* ---------------------------------------------------------------------
   Buttons
   --------------------------------------------------------------------- */
.btn-primary, .btn-primary:hover {
    background: var(--clr-primary-700); border-color: var(--clr-primary-700);
}
.btn-primary:hover { background: var(--clr-primary-900); border-color: var(--clr-primary-900); }
.btn-outline-primary { color: var(--clr-primary-700); border-color: var(--clr-primary-700); }
.btn-outline-primary:hover { background: var(--clr-primary-700); border-color: var(--clr-primary-700); }

/* ---------------------------------------------------------------------
   Tables / DataTables tweaks
   --------------------------------------------------------------------- */
.table thead th { font-size: .74rem; text-transform: uppercase; letter-spacing: .03em; color: var(--clr-neutral-500); border-bottom-width: 1px; white-space: nowrap; }
.table td { vertical-align: middle; font-size: .87rem; }
.table-responsive { border-radius: var(--radius-sm); }
.dataTables_wrapper .dataTables_filter input,
.dataTables_wrapper .dataTables_length select { border: 1px solid var(--clr-neutral-100); border-radius: 6px; padding: .3rem .5rem; }
.dt-buttons .btn { margin-right: .3rem; }

.avatar-circle {
    width: 36px; height: 36px; border-radius: 50%; background: var(--clr-primary-100); color: var(--clr-primary-700);
    display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: .8rem; overflow: hidden;
}
.avatar-circle img { width: 100%; height: 100%; object-fit: cover; }

/* ---------------------------------------------------------------------
   Auth pages
   --------------------------------------------------------------------- */
.auth-wrapper { min-height: 100vh; display: flex; }
.auth-side {
    flex: 1.1; background: linear-gradient(135deg, var(--clr-primary-900), var(--clr-primary-700));
    color: #fff; display: none; flex-direction: column; justify-content: center; padding: 4rem;
}
.auth-side p { color: rgba(255,255,255,.82); max-width: 420px; margin-top: .5rem; }
.auth-form-panel { flex: 1; display: flex; align-items: center; justify-content: center; padding: 2rem; background: #fff; }
.auth-card { width: 100%; max-width: 400px; }
@media (min-width: 992px) { .auth-side { display: flex; } }

/* ---------------------------------------------------------------------
   Misc components
   --------------------------------------------------------------------- */
.badge-outline { background: #fff; border: 1px solid var(--clr-neutral-300); color: var(--clr-neutral-700); }
.section-tabs .nav-link { color: var(--clr-neutral-700); font-weight: 600; font-size: .85rem; }
.section-tabs .nav-link.active { color: var(--clr-primary-700); border-bottom: 2px solid var(--clr-primary-700); background: transparent; }
.profile-header { background: #fff; border: 1px solid var(--clr-neutral-100); border-radius: var(--radius); padding: 1.5rem; box-shadow: var(--shadow-sm); }
.profile-photo { width: 92px; height: 92px; border-radius: 50%; object-fit: cover; border: 3px solid var(--clr-primary-100); background: var(--clr-neutral-100); }
.timeline-item { border-left: 2px solid var(--clr-neutral-100); padding: 0 0 1.25rem 1rem; position: relative; }
.timeline-item::before { content: ''; position: absolute; left: -6px; top: 2px; width: 10px; height: 10px; border-radius: 50%; background: var(--clr-primary-500); }
.indicator-category-card { border-left: 3px solid var(--clr-primary-500); }
.kpi-arrow-up { color: var(--clr-success-700); }
.kpi-arrow-down { color: var(--clr-danger-700); }
.deadline-banner { background: var(--clr-accent-100); border: 1px solid var(--clr-accent-500); border-radius: var(--radius-sm); padding: .75rem 1rem; }
.deadline-banner.overdue { background: var(--clr-danger-100); border-color: var(--clr-danger-500); }

/* Sidebar overlay for mobile */
.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 1025; }
body.sidebar-mobile-open .sidebar-overlay { display: block; }

/* ---------------------------------------------------------------------
   Responsive: tablet / mobile
   --------------------------------------------------------------------- */
@media (max-width: 991.98px) {
    .sidebar { transform: translateX(-100%); width: var(--sidebar-width); }
    body.sidebar-mobile-open .sidebar { transform: translateX(0); }
    .main-wrap { margin-left: 0; }
    body.sidebar-collapsed .main-wrap { margin-left: 0; }
    .topbar .search-box { display: none; }
}
@media (max-width: 575.98px) {
    .content { padding: 1rem .75rem; }
    .page-header h1 { font-size: 1.15rem; }
    .stat-card .stat-value { font-size: 1.25rem; }
    .card-body { padding: .85rem; }
    /* Turn wide tables into stacked cards on very small screens when marked */
    .table-mobile-cards thead { display: none; }
    .table-mobile-cards tr { display: block; margin-bottom: .75rem; border: 1px solid var(--clr-neutral-100); border-radius: var(--radius-sm); padding: .5rem .75rem; }
    .table-mobile-cards td { display: flex; justify-content: space-between; gap: .5rem; border: none; padding: .3rem 0; }
    .table-mobile-cards td::before { content: attr(data-label); font-weight: 600; color: var(--clr-neutral-500); font-size: .72rem; text-transform: uppercase; }
}

/* ---------------------------------------------------------------------
   Print styles (report printing, section 20)
   --------------------------------------------------------------------- */
@media print {
    .sidebar, .topbar, .no-print, .btn, .sidebar-overlay { display: none !important; }
    .main-wrap { margin-left: 0 !important; }
    .content { padding: 0 !important; }
    body { background: #fff !important; }
    .card { box-shadow: none !important; border: 1px solid #ccc !important; }
    .print-header { display: flex !important; }
    a[href]::after { content: ""; }
    table { font-size: 11px; }
}
.print-header { display: none; align-items: center; gap: 1rem; border-bottom: 2px solid var(--clr-primary-700); padding-bottom: .75rem; margin-bottom: 1rem; }
.print-header img { height: 52px; }
.print-footer { display: none; }
@media print { .print-footer { display: block; text-align: center; font-size: 10px; color: #888; margin-top: 1rem; } }
