/* ═══════════════════════════════════════════════════════════════════════════
   Patrick County Alerts — Main Stylesheet
   Dark theme, mobile-first, print-aware
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Reset & Base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    /* Palette */
    --bg:           #0d1117;
    --surface:      #161b22;
    --surface2:     #1c2128;
    --border:       #30363d;
    --border-light: #21262d;
    --text:         #e6edf3;
    --text-muted:   #8b949e;
    --text-subtle:  #6e7681;

    /* Brand */
    --accent:       #f0883e;
    --accent-dark:  #c06020;
    --accent-glow:  rgba(240,136,62,.18);

    /* Severity */
    --critical:     #ff4444;
    --high:         #ff8800;
    --moderate:     #ffcc00;
    --low:          #3fb950;

    /* Status */
    --active:       #ff4444;
    --monitoring:   #58a6ff;
    --resolved:     #3fb950;
    --false-alarm:  #8b949e;

    /* UI */
    --blue:         #58a6ff;
    --green:        #3fb950;
    --red:          #ff4444;
    --yellow:       #ffcc00;
    --purple:       #bc8cff;

    /* Layout */
    --header-h:     64px;
    --sidebar-w:    280px;
    --radius:       8px;
    --radius-lg:    12px;
    --shadow:       0 4px 16px rgba(0,0,0,.4);
    --transition:   .2s ease;
}

html { font-size: 16px; scroll-behavior: smooth; }

body {
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.6;
    min-height: 100vh;
}

a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

img { max-width: 100%; height: auto; }

/* ── Scrollbar ────────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-subtle); }

/* ── Typography ───────────────────────────────────────────────────────────── */
h1, h2, h3, h4, h5, h6 { font-weight: 600; line-height: 1.3; }
h1 { font-size: 1.75rem; }
h2 { font-size: 1.4rem; }
h3 { font-size: 1.15rem; }
h4 { font-size: 1rem; }
p  { margin-bottom: .75rem; }
p:last-child { margin-bottom: 0; }

/* ── Header ───────────────────────────────────────────────────────────────── */
.site-header {
    height: var(--header-h);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    position: sticky;
    top: 0;
    z-index: 100;
    gap: 1rem;
}
.site-header .logo {
    display: flex;
    align-items: center;
    gap: .6rem;
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text);
    text-decoration: none;
    flex-shrink: 0;
}
.site-header .logo i { color: var(--accent); font-size: 1.3rem; }
.site-header .logo span.county { color: var(--accent); }
.site-header nav { margin-left: auto; display: flex; align-items: center; gap: .5rem; }
.site-header nav a {
    color: var(--text-muted);
    padding: .4rem .75rem;
    border-radius: var(--radius);
    font-size: .9rem;
    transition: background var(--transition), color var(--transition);
}
.site-header nav a:hover, .site-header nav a.active {
    background: var(--surface2);
    color: var(--text);
    text-decoration: none;
}
.live-badge {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    background: rgba(255,68,68,.15);
    color: var(--red);
    border: 1px solid rgba(255,68,68,.3);
    padding: .25rem .6rem;
    border-radius: 20px;
    font-size: .78rem;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
}
.live-badge .pulse {
    width: 7px; height: 7px;
    background: var(--red);
    border-radius: 50%;
    animation: pulse 1.5s ease-in-out infinite;
}
@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50%       { opacity: .5; transform: scale(1.4); }
}

/* ── Layout ───────────────────────────────────────────────────────────────── */
.page-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1.5rem;
}
.two-col {
    display: grid;
    grid-template-columns: 1fr var(--sidebar-w);
    gap: 1.5rem;
    align-items: start;
}
@media (max-width: 900px) {
    .two-col { grid-template-columns: 1fr; }
}

/* ── Cards ────────────────────────────────────────────────────────────────── */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}
.card-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: .6rem;
    font-weight: 600;
}
.card-body { padding: 1.25rem; }

/* ── Incident Cards ───────────────────────────────────────────────────────── */
.incident-list { display: flex; flex-direction: column; gap: .75rem; }

.incident-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: border-color var(--transition), transform var(--transition);
    cursor: pointer;
}
.incident-card:hover {
    border-color: var(--accent);
    transform: translateY(-1px);
}
.incident-card.severity-critical { border-left: 4px solid var(--critical); }
.incident-card.severity-high     { border-left: 4px solid var(--high); }
.incident-card.severity-moderate { border-left: 4px solid var(--moderate); }
.incident-card.severity-low      { border-left: 4px solid var(--low); }

.incident-card-inner { padding: 1rem 1.25rem; }

.incident-meta {
    display: flex;
    align-items: center;
    gap: .5rem;
    flex-wrap: wrap;
    margin-bottom: .5rem;
}
.incident-title {
    font-size: 1.05rem;
    font-weight: 600;
    margin-bottom: .35rem;
    color: var(--text);
}
.incident-desc {
    color: var(--text-muted);
    font-size: .9rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.incident-footer {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-top: .75rem;
    font-size: .82rem;
    color: var(--text-subtle);
    flex-wrap: wrap;
}
.incident-footer i { margin-right: .25rem; }

/* ── Badges ───────────────────────────────────────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    padding: .2rem .55rem;
    border-radius: 20px;
    font-size: .78rem;
    font-weight: 600;
    white-space: nowrap;
}

/* Severity */
.badge-critical  { background: rgba(255,68,68,.15);  color: var(--critical);  border: 1px solid rgba(255,68,68,.3); }
.badge-high      { background: rgba(255,136,0,.15);  color: var(--high);      border: 1px solid rgba(255,136,0,.3); }
.badge-moderate  { background: rgba(255,204,0,.15);  color: var(--moderate);  border: 1px solid rgba(255,204,0,.3); }
.badge-low       { background: rgba(63,185,80,.15);  color: var(--low);       border: 1px solid rgba(63,185,80,.3); }

/* Status */
.badge-active     { background: rgba(255,68,68,.15);  color: var(--active);    border: 1px solid rgba(255,68,68,.3); }
.badge-monitoring { background: rgba(88,166,255,.15); color: var(--blue);      border: 1px solid rgba(88,166,255,.3); }
.badge-resolved   { background: rgba(63,185,80,.15);  color: var(--resolved);  border: 1px solid rgba(63,185,80,.3); }
.badge-false_alarm{ background: rgba(139,148,158,.15);color: var(--false-alarm);border: 1px solid rgba(139,148,158,.3); }

/* Category */
.badge-category { background: rgba(240,136,62,.12); color: var(--accent); border: 1px solid rgba(240,136,62,.25); }

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .45rem;
    padding: .55rem 1.1rem;
    border-radius: var(--radius);
    font-size: .9rem;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: opacity var(--transition), background var(--transition);
    text-decoration: none;
    white-space: nowrap;
}
.btn:hover { opacity: .85; text-decoration: none; }
.btn:active { opacity: .7; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.btn-primary   { background: var(--accent); color: #fff; }
.btn-secondary { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }
.btn-danger    { background: rgba(255,68,68,.15); color: var(--red); border: 1px solid rgba(255,68,68,.3); }
.btn-success   { background: rgba(63,185,80,.15); color: var(--green); border: 1px solid rgba(63,185,80,.3); }
.btn-ghost     { background: transparent; color: var(--text-muted); border: 1px solid transparent; }
.btn-ghost:hover { background: var(--surface2); color: var(--text); }
.btn-sm { padding: .35rem .75rem; font-size: .82rem; }
.btn-lg { padding: .75rem 1.5rem; font-size: 1rem; }
.btn-icon { padding: .5rem; min-width: 36px; }

/* ── Forms ────────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 1rem; }
.form-label {
    display: block;
    font-size: .88rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: .4rem;
}
.form-label .required { color: var(--red); margin-left: .2rem; }
.form-control {
    width: 100%;
    padding: .6rem .85rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: .95rem;
    font-family: inherit;
    transition: border-color var(--transition), box-shadow var(--transition);
    outline: none;
}
.form-control:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}
.form-control::placeholder { color: var(--text-subtle); }
textarea.form-control { resize: vertical; min-height: 100px; }
select.form-control { cursor: pointer; appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%238b949e' d='M6 8L1 3h10z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right .75rem center; padding-right: 2.5rem; }
.form-hint { font-size: .82rem; color: var(--text-subtle); margin-top: .3rem; }
.form-error { font-size: .82rem; color: var(--red); margin-top: .3rem; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 600px) { .form-row { grid-template-columns: 1fr; } }

/* ── Alerts / Toasts ──────────────────────────────────────────────────────── */
.alert {
    padding: .85rem 1.1rem;
    border-radius: var(--radius);
    border: 1px solid;
    font-size: .92rem;
    display: flex;
    align-items: flex-start;
    gap: .65rem;
    margin-bottom: 1rem;
}
.alert i { flex-shrink: 0; margin-top: .1rem; }
.alert-success { background: rgba(63,185,80,.1);  border-color: rgba(63,185,80,.3);  color: var(--green); }
.alert-danger  { background: rgba(255,68,68,.1);  border-color: rgba(255,68,68,.3);  color: var(--red); }
.alert-warning { background: rgba(255,204,0,.1);  border-color: rgba(255,204,0,.3);  color: var(--yellow); }
.alert-info    { background: rgba(88,166,255,.1); border-color: rgba(88,166,255,.3); color: var(--blue); }

/* Toast notifications */
#toast-container {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: .5rem;
    pointer-events: none;
}
.toast {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: .75rem 1.1rem;
    font-size: .9rem;
    display: flex;
    align-items: center;
    gap: .6rem;
    box-shadow: var(--shadow);
    pointer-events: all;
    animation: slideIn .25s ease;
    max-width: 360px;
}
.toast.success { border-left: 3px solid var(--green); }
.toast.error   { border-left: 3px solid var(--red); }
.toast.info    { border-left: 3px solid var(--blue); }
.toast.warning { border-left: 3px solid var(--yellow); }
@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to   { transform: translateX(0);    opacity: 1; }
}

/* ── Map ──────────────────────────────────────────────────────────────────── */
#map, .map-container {
    width: 100%;
    height: 400px;
    border-radius: var(--radius-lg);
    overflow: hidden;
    border: 1px solid var(--border);
    background: var(--surface2);
}
#pick-map {
    background: var(--surface2);
}
.leaflet-container { background: #0d1117 !important; }
.leaflet-popup-content-wrapper {
    background: var(--surface) !important;
    color: var(--text) !important;
    border: 1px solid var(--border) !important;
    border-radius: var(--radius) !important;
    box-shadow: 0 4px 20px rgba(0,0,0,.5) !important;
}
.leaflet-popup-tip { background: var(--surface) !important; }
.leaflet-popup-content { margin: .6rem .8rem !important; font-size: .9rem; }
.leaflet-popup-close-button { color: var(--text-subtle) !important; }
.leaflet-popup-close-button:hover { color: var(--text) !important; }
/* Hide Leaflet attribution on small maps for cleanliness */
#pick-map .leaflet-control-attribution { font-size: .6rem; opacity: .6; }

/* Address geocoding search row */
.map-address-row {
    display: flex;
    gap: .5rem;
    margin-bottom: .5rem;
}
.map-address-row .form-control {
    flex: 1;
}
#geocode-btn {
    white-space: nowrap;
    flex-shrink: 0;
}

/* ── Responding Units Picker (admin) ──────────────────────────────────────── */
.units-search-wrap {
    margin-bottom: .5rem;
}
.units-picker {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    max-height: 280px;
    overflow-y: auto;
    padding: .5rem .25rem;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}
.units-picker::-webkit-scrollbar { width: 5px; }
.units-picker::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.units-group {
    margin-bottom: .25rem;
}
.units-group-label {
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--text-subtle);
    padding: .4rem .75rem .2rem;
    display: flex;
    align-items: center;
    gap: .4rem;
}
.unit-item {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .35rem .75rem;
    border-radius: var(--radius-sm, 4px);
    cursor: pointer;
    transition: background .15s;
    user-select: none;
}
.unit-item:hover {
    background: var(--surface3, rgba(255,255,255,.05));
}
.unit-item input[type="checkbox"] {
    display: none;
}
.unit-check-box {
    width: 16px;
    height: 16px;
    border: 2px solid var(--border);
    border-radius: 3px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .15s, border-color .15s;
    background: var(--surface);
}
.unit-item input[type="checkbox"]:checked + .unit-check-box {
    background: var(--accent);
    border-color: var(--accent);
}
.unit-item input[type="checkbox"]:checked + .unit-check-box::after {
    content: '';
    display: block;
    width: 5px;
    height: 9px;
    border: 2px solid #fff;
    border-top: none;
    border-left: none;
    transform: rotate(45deg) translate(-1px, -1px);
}
.unit-label {
    font-size: .875rem;
    color: var(--text);
    line-height: 1.3;
}
.unit-item:hover .unit-label {
    color: var(--text);
}

/* ── Units Manager Table (admin settings) ────────────────────────────────── */
.units-manager-table {
    width: 100%;
}
.units-manager-group-header {
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--text-subtle);
    padding: .6rem 1rem .3rem;
    display: flex;
    align-items: center;
    gap: .4rem;
    border-top: 1px solid var(--border);
}
.units-manager-group-header:first-child {
    border-top: none;
}
.unit-manager-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: .55rem 1rem;
    border-bottom: 1px solid rgba(255,255,255,.04);
    transition: background .12s;
}
.unit-manager-row:hover {
    background: var(--surface2);
}
.unit-manager-row.unit-row-inactive {
    opacity: .45;
}
.unit-manager-info {
    display: flex;
    flex-direction: column;
    gap: .1rem;
    min-width: 0;
}
.unit-manager-name {
    font-size: .875rem;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.unit-manager-short {
    font-size: .75rem;
}
.unit-manager-actions {
    display: flex;
    gap: .25rem;
    flex-shrink: 0;
}

/* ── Responding Units Display (public incident page) ─────────────────────── */
.responding-units-grid {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
}
.responding-unit-badge {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: .4rem .75rem;
    font-size: .875rem;
    color: var(--text);
    transition: border-color .15s, background .15s;
}
.responding-unit-badge:hover {
    background: var(--surface3, rgba(255,255,255,.05));
    border-color: var(--accent);
}
.responding-unit-badge i {
    font-size: .85rem;
    flex-shrink: 0;
}

/* ── Incident Updates Timeline ────────────────────────────────────────────── */
.updates-timeline { display: flex; flex-direction: column; gap: 0; }
.update-item {
    display: flex;
    gap: 1rem;
    padding-bottom: 1.25rem;
    position: relative;
}
.update-item:not(:last-child)::before {
    content: '';
    position: absolute;
    left: 15px;
    top: 32px;
    bottom: 0;
    width: 2px;
    background: var(--border);
}
.update-dot {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .8rem;
    border: 2px solid;
    position: relative;
    z-index: 1;
}
.update-dot.info      { background: rgba(88,166,255,.15);  border-color: var(--blue);   color: var(--blue); }
.update-dot.update    { background: rgba(240,136,62,.15);  border-color: var(--accent); color: var(--accent); }
.update-dot.resolved  { background: rgba(63,185,80,.15);   border-color: var(--green);  color: var(--green); }
.update-dot.escalated { background: rgba(255,68,68,.15);   border-color: var(--red);    color: var(--red); }
.update-dot.warning   { background: rgba(255,204,0,.15);   border-color: var(--yellow); color: var(--yellow); }
.update-content { flex: 1; padding-top: .35rem; }
.update-meta { font-size: .8rem; color: var(--text-subtle); margin-bottom: .35rem; }
.update-message { font-size: .95rem; color: var(--text); }

/* ── Sidebar Widgets ──────────────────────────────────────────────────────── */
.sidebar { display: flex; flex-direction: column; gap: 1rem; }
.widget { }
.widget-title {
    font-size: .85rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--text-subtle);
    margin-bottom: .75rem;
    display: flex;
    align-items: center;
    gap: .4rem;
}
.filter-group { display: flex; flex-direction: column; gap: .4rem; }
.filter-btn {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .5rem .75rem;
    border-radius: var(--radius);
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-muted);
    font-size: .9rem;
    cursor: pointer;
    width: 100%;
    text-align: left;
    transition: all var(--transition);
}
.filter-btn:hover { background: var(--surface2); color: var(--text); border-color: var(--border); }
.filter-btn.active { background: var(--accent-glow); color: var(--accent); border-color: rgba(240,136,62,.3); }
.filter-btn .count {
    margin-left: auto;
    background: var(--surface2);
    color: var(--text-subtle);
    font-size: .78rem;
    padding: .1rem .4rem;
    border-radius: 10px;
    min-width: 22px;
    text-align: center;
}

/* ── Stats Bar ────────────────────────────────────────────────────────────── */
.stats-bar {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1.5rem;
}
.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1rem 1.25rem;
    flex: 1;
    min-width: 120px;
    display: flex;
    flex-direction: column;
    gap: .25rem;
}
.stat-card .stat-value { font-size: 1.6rem; font-weight: 700; }
.stat-card .stat-label { font-size: .8rem; color: var(--text-muted); }
.stat-card.critical .stat-value { color: var(--critical); }
.stat-card.active   .stat-value { color: var(--active); }
.stat-card.resolved .stat-value { color: var(--resolved); }
.stat-card.total    .stat-value { color: var(--accent); }

/* ── Modals ───────────────────────────────────────────────────────────────── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.7);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition);
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 640px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow);
    transform: translateY(20px);
    transition: transform var(--transition);
}
.modal-overlay.open .modal { transform: translateY(0); }
.modal-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.modal-header h3 { font-size: 1.1rem; }
.modal-body { padding: 1.5rem; }
.modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: .75rem;
}

/* ── Tables ───────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th { background: var(--surface2); color: var(--text-muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; font-weight: 600; padding: .65rem 1rem; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: .75rem 1rem; border-bottom: 1px solid var(--border-light); vertical-align: middle; }
tr:hover td { background: rgba(255,255,255,.02); }
tr:last-child td { border-bottom: none; }

/* ── Pagination ───────────────────────────────────────────────────────────── */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .4rem;
    margin-top: 1.5rem;
}
.page-btn {
    min-width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius);
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text-muted);
    font-size: .9rem;
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
    padding: 0 .5rem;
}
.page-btn:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }
.page-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.page-btn:disabled { opacity: .4; cursor: not-allowed; }

/* ── Loading Spinner ──────────────────────────────────────────────────────── */
.spinner {
    width: 36px; height: 36px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin .7s linear infinite;
    margin: 2rem auto;
    display: block;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-muted);
}
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-muted);
}
.empty-state i { font-size: 2.5rem; opacity: .3; margin-bottom: .75rem; display: block; }

/* ── Share Bar ────────────────────────────────────────────────────────────── */
.share-bar {
    display: flex;
    align-items: center;
    gap: .6rem;
    flex-wrap: wrap;
    margin-top: 1rem;
}
.share-bar .share-label { font-size: .85rem; color: var(--text-muted); font-weight: 600; }
.share-btn {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    padding: .4rem .85rem;
    border-radius: var(--radius);
    font-size: .85rem;
    font-weight: 600;
    text-decoration: none;
    transition: opacity var(--transition);
}
.share-btn:hover { opacity: .8; text-decoration: none; }
.share-btn.facebook { background: #1877f2; color: #fff; }
.share-btn.twitter  { background: #1da1f2; color: #fff; }
.share-btn.copy     { background: var(--surface2); color: var(--text); border: 1px solid var(--border); cursor: pointer; }

/* ── Admin Sidebar ────────────────────────────────────────────────────────── */
.admin-layout {
    display: grid;
    grid-template-columns: var(--sidebar-w) 1fr;
    min-height: calc(100vh - var(--header-h));
}
.admin-sidebar {
    background: var(--surface);
    border-right: 1px solid var(--border);
    padding: 1.5rem 0;
    position: sticky;
    top: var(--header-h);
    height: calc(100vh - var(--header-h));
    overflow-y: auto;
}
.admin-nav { list-style: none; }
.admin-nav li a {
    display: flex;
    align-items: center;
    gap: .65rem;
    padding: .65rem 1.25rem;
    color: var(--text-muted);
    font-size: .95rem;
    transition: background var(--transition), color var(--transition);
    text-decoration: none;
    border-left: 3px solid transparent;
}
.admin-nav li a:hover {
    background: var(--surface2);
    color: var(--text);
    text-decoration: none;
}
.admin-nav li a.active {
    background: var(--accent-glow);
    color: var(--accent);
    border-left-color: var(--accent);
}
.admin-nav li a i { width: 18px; text-align: center; }
.admin-content { padding: 1.5rem; overflow-y: auto; }

@media (max-width: 768px) {
    .admin-layout { grid-template-columns: 1fr; }
    .admin-sidebar { display: none; }
    /* Mobile sidebar overlay when open */
    .admin-sidebar.mobile-open {
        display: flex !important;
        flex-direction: column;
        position: fixed;
        inset: 0;
        z-index: 300;
        height: 100vh;
        width: 100vw;
        max-width: 320px;
        background: var(--surface);
        border-right: 1px solid var(--border);
        padding: 0;
        box-shadow: 4px 0 32px rgba(0,0,0,.6);
        overflow-y: auto;
        top: 0;
        left: 0;
        animation: slideInLeft .2s ease;
    }
    @keyframes slideInLeft {
        from { transform: translateX(-100%); opacity: 0; }
        to   { transform: translateX(0);    opacity: 1; }
    }
    /* Backdrop when sidebar is open */
    .sidebar-backdrop {
        display: block !important;
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,.6);
        z-index: 299;
        backdrop-filter: blur(2px);
    }
}

/* Hide sidebar backdrop by default */
.sidebar-backdrop { display: none; }

/* Mobile sidebar header */
.mobile-sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.mobile-sidebar-header .sidebar-title {
    font-size: .9rem;
    font-weight: 700;
    color: var(--text);
}
.mobile-sidebar-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.1rem;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    line-height: 1;
}
.mobile-sidebar-close:hover { color: var(--text); background: var(--surface2); }

/* Make admin-sidebar nav fill height on mobile */
.admin-sidebar.mobile-open .admin-nav { flex: 1; }
.admin-sidebar.mobile-open .admin-nav li a {
    padding: 1rem 1.25rem;
    font-size: 1rem;
    border-left: 3px solid transparent;
}

/* ── Incident Detail Page ─────────────────────────────────────────────────── */
.incident-detail-header {
    margin-bottom: 1.5rem;
}
.incident-detail-header .incident-title {
    font-size: 1.5rem;
    margin: .5rem 0 .75rem;
}
.incident-detail-header .meta-row {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
    align-items: center;
    margin-bottom: .75rem;
}
.detail-section {
    margin-bottom: 1.5rem;
}
.detail-section h4 {
    font-size: .85rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--text-subtle);
    margin-bottom: .75rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: .4rem;
}
.detail-section p {
    color: var(--text-muted);
    line-height: 1.7;
}
.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: .75rem;
}
.info-item { }
.info-item .info-label { font-size: .8rem; color: var(--text-subtle); margin-bottom: .2rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.info-item .info-value { font-size: .95rem; color: var(--text); }

/* ── Footer ───────────────────────────────────────────────────────────────── */
.site-footer {
    border-top: 1px solid var(--border);
    padding: 1.25rem 1.5rem;
    text-align: center;
    font-size: .85rem;
    color: var(--text-subtle);
    margin-top: 3rem;
}
.site-footer a { color: var(--text-muted); }
.site-footer a:hover { color: var(--text); }

/* ── Utility ──────────────────────────────────────────────────────────────── */
.d-flex       { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1  { gap: .5rem; }
.gap-2  { gap: 1rem; }
.flex-1 { flex: 1; }
.mt-1   { margin-top: .5rem; }
.mt-2   { margin-top: 1rem; }
.mt-3   { margin-top: 1.5rem; }
.mb-1   { margin-bottom: .5rem; }
.mb-2   { margin-bottom: 1rem; }
.mb-3   { margin-bottom: 1.5rem; }
.text-muted   { color: var(--text-muted); }
.text-subtle  { color: var(--text-subtle); }
.text-accent  { color: var(--accent); }
.text-success { color: var(--green); }
.text-danger  { color: var(--red); }
.text-sm  { font-size: .85rem; }
.text-xs  { font-size: .78rem; }
.fw-600   { font-weight: 600; }
.w-100    { width: 100%; }
.hidden   { display: none !important; }
.sr-only  { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }

/* ── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
    .page-container { padding: 1rem; }
    .site-header { padding: 0 1rem; }
    .site-header .logo span.site-name { display: none; }
    h1 { font-size: 1.4rem; }
    .stats-bar { flex-direction: column; }
    .stat-card { min-width: unset; }
    #toast-container { right: .75rem; bottom: .75rem; }
    .modal { border-radius: var(--radius) var(--radius) 0 0; }
}

/* ── Visitor Counter ─────────────────────────────────────────────────────────── */
.visitor-counter {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: .72rem;
    font-weight: 600;
    color: var(--text-muted);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 4px 10px;
    white-space: nowrap;
    cursor: default;
    flex-shrink: 0;
}
.visitor-counter i {
    font-size: .55rem;
    color: var(--green);
    animation: visitorPulse 2s ease-in-out infinite;
}
@keyframes visitorPulse {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.4; }
}

/* ── Scanner Bar ─────────────────────────────────────────────────────────────── */
/* Hide native audio element - we use custom controls */
#scanner-audio { display: none !important; }

.scanner-bar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 0 1.25rem;
    height: 52px;
    display: flex;
    align-items: center;
    position: sticky;
    top: 56px;
    z-index: 90;
    transition: background 0.3s;
}
.scanner-bar.playing {
    background: #0d1b2a;
    border-bottom-color: #1f4068;
}
.scanner-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    gap: 12px;
}
.scanner-left {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    flex: 1;
}
.scanner-play-btn {
    flex-shrink: 0;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 2px solid var(--border);
    background: var(--surface2);
    color: var(--text);
    font-size: .85rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all .15s;
}
.scanner-play-btn:hover {
    border-color: var(--blue);
    color: var(--blue);
    background: rgba(88,166,255,.1);
}
.scanner-bar.playing .scanner-play-btn {
    border-color: #58a6ff;
    color: #58a6ff;
    background: rgba(88,166,255,.15);
}
.scanner-info {
    min-width: 0;
    flex: 1;
}
.scanner-title {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: .8rem;
    font-weight: 700;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.scanner-live-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--border);
    flex-shrink: 0;
    transition: background .3s;
}
.scanner-live-dot.active {
    background: #f85149;
    box-shadow: 0 0 0 0 rgba(248,81,73,.6);
    animation: scannerPulse 1.2s ease-out infinite;
}
@keyframes scannerPulse {
    0%   { box-shadow: 0 0 0 0 rgba(248,81,73,.6); }
    70%  { box-shadow: 0 0 0 6px rgba(248,81,73,0); }
    100% { box-shadow: 0 0 0 0 rgba(248,81,73,0); }
}
.scanner-sub {
    font-size: .7rem;
    color: var(--text-muted);
    margin-top: 1px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.scanner-right {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

/* Audio visualizer bars */
.scanner-visualizer {
    display: flex;
    align-items: center;
    gap: 2px;
    height: 20px;
}
.scanner-visualizer span {
    display: block;
    width: 3px;
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    transition: background .3s;
}
.scanner-visualizer.active span {
    background: #58a6ff;
    animation: vizBar .8s ease-in-out infinite alternate;
}
.scanner-visualizer.active span:nth-child(1) { animation-duration: .7s; }
.scanner-visualizer.active span:nth-child(2) { animation-duration: .5s; animation-delay: .1s; }
.scanner-visualizer.active span:nth-child(3) { animation-duration: .9s; animation-delay: .2s; }
.scanner-visualizer.active span:nth-child(4) { animation-duration: .6s; animation-delay: .05s; }
.scanner-visualizer.active span:nth-child(5) { animation-duration: .8s; animation-delay: .15s; }
@keyframes vizBar {
    from { height: 3px;  }
    to   { height: 18px; }
}

/* Volume control */
.scanner-volume {
    display: flex;
    align-items: center;
    gap: 6px;
}
.scanner-vol-icon {
    font-size: .8rem;
    color: var(--text-muted);
    width: 14px;
    text-align: center;
    flex-shrink: 0;
}
.scanner-vol-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 80px;
    height: 4px;
    border-radius: 2px;
    background: var(--border);
    outline: none;
    cursor: pointer;
}
.scanner-vol-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #58a6ff;
    cursor: pointer;
    border: none;
    box-shadow: 0 0 4px rgba(88,166,255,.5);
}
.scanner-vol-slider::-moz-range-thumb {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #58a6ff;
    cursor: pointer;
    border: none;
}

/* Scanner responsive */
@media (max-width: 600px) {
    .scanner-bar { height: 48px; padding: 0 .75rem; top: 52px; }
    .scanner-vol-slider { width: 55px; }
    .scanner-visualizer { display: none; }
    .visitor-counter { display: none; }
}
@media (max-width: 400px) {
    .scanner-volume { display: none; }
}
