/* Durham Update — style.css */
:root {
    --navy:    #0052a5;
    --navy-dk: #003a75;
    --accent:  #0074d9;
    --red:     #cc0000;
    --bg:      #f2f5f9;
    --surface: #ffffff;
    --border:  #d0d9e8;
    --text:    #1a2640;
    --muted:   #5a6a80;
}

html, body {
    background: linear-gradient(to right, #c5cfe0 0%, var(--bg) 6%, var(--bg) 94%, #c5cfe0 100%);
    height: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    font-family: "IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--text);
    font-size: 15px;
}

/* ── Dark mode ───────────────────────────────────────────── */
body.dark-mode, html.dark-mode {
    background: linear-gradient(to right, #050d1a 0%, #0a1628 6%, #0a1628 94%, #050d1a 100%);
    color: #c8d8f0;
    --bg:      #0a1628;
    --surface: #0f1f38;
    --border:  #1e3558;
    --text:    #c8d8f0;
    --muted:   #6b8bb0;
    --navy:    #4a9eff;
    --accent:  #60b0ff;
}

/* ── Layout ──────────────────────────────────────────────── */
#app-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    width: 92%;
    margin: 0 auto;
}

.container { flex: 1; display: flex; flex-direction: column; }

.page-header {
    width: 100%;
    padding: 10px 0 0 0;
    background: var(--bg);
}

body.dark-mode .page-header { background: var(--bg); }

.main-content {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.footer {
    padding: 14px 0 18px;
    text-align: center;
    font-size: 0.88em;
    border-top: 1px solid var(--border);
}

.footer-disclaimer {
    font-size: 13px;
    color: var(--muted);
    margin-top: 4px;
    max-width: 800px;
    margin-left: auto;
    margin-right: auto;
}

/* ── Header ──────────────────────────────────────────────── */
.header-top {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    align-items: center;
    margin-bottom: 4px;
    padding: 0 8px;
}

.header-bottom {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    padding: 6px 8px;
    border-bottom: 2px solid var(--navy);
}

.title-area { grid-column: 1; }

.logo-name {
    font-size: 20px;
    font-weight: 600;
    letter-spacing: 0.08em;
    line-height: 1;
    color: var(--navy);
}

.logo-tagline {
    font-size: 9px;
    letter-spacing: 0.18em;
    margin-top: 4px;
    color: var(--muted);
}

.clock {
    grid-column: 2;
    justify-self: center;
    font-family: "Roboto Mono", monospace;
    font-size: 32px;
    letter-spacing: 1px;
    white-space: nowrap;
}

body.dark-mode .clock { color: #60b0ff; }

.header-controls {
    grid-column: 3;
    justify-self: end;
    display: flex;
    align-items: center;
    gap: 10px;
    padding-right: 4px;
}

/* ── Buttons ─────────────────────────────────────────────── */
.pill-btn {
    min-width: 70px;
    padding: 5px 14px;
    font-weight: 600;
    border-radius: 999px;
    font-size: 0.9rem;
    text-align: center;
    cursor: pointer;
    display: inline-block;
    text-decoration: none;
    border: 1px solid transparent;
    background: #dde3ee;
    color: var(--text);
}

.pill-btn.active, .pill-btn[data-crime="all"].active { background: var(--navy); color: #fff; }
.pill-btn[data-crime="violent"].active               { background: var(--red);  color: #fff; }

.pill-btn-navy { background: var(--navy); color: #fff; }
.pill-btn-navy:hover { background: var(--navy-dk); color: #fff; }
.pill-btn-blue { background: var(--accent); color: #fff; }
.pill-btn-blue:hover { background: #005bb5; color: #fff; }

body.dark-mode .pill-btn { background: #1a2f50; color: #c8d8f0; border-color: #2a4070; }
body.dark-mode .pill-btn.active,
body.dark-mode .pill-btn[data-crime="all"].active { background: #0052a5; color: #c8d8f0; }
body.dark-mode .pill-btn[data-crime="violent"].active { background: #880000; color: #c8d8f0; }
body.dark-mode .pill-btn-navy { background: #0a3a70; color: #c8d8f0; }
body.dark-mode .pill-btn-blue { background: #0a3a70; color: #c8d8f0; }

/* ── Toggles ─────────────────────────────────────────────── */
.pill-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #dde3ee;
    border-radius: 999px;
    padding: 5px 10px;
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
}
body.dark-mode .pill-toggle { background: #1a2f50; color: #c8d8f0; }

.pill-toggle input[type="checkbox"] { opacity: 0; width: 0; height: 0; position: absolute; }

.slider {
    width: 30px; height: 16px;
    background: #aaa; border-radius: 34px;
    position: relative; transition: background 0.2s;
}
.slider::before {
    content: ""; position: absolute;
    height: 12px; width: 12px; left: 2px; bottom: 2px;
    background: #fff; border-radius: 50%; transition: transform 0.2s;
}
.pill-toggle input:checked + .slider              { background: var(--navy); }
.pill-toggle input:checked + .slider::before      { transform: translateX(14px); }

/* ── Selects ─────────────────────────────────────────────── */
select {
    padding: 5px 8px;
    font-size: 0.9rem;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
}
body.dark-mode select { background: #1a2f50; color: #c8d8f0; border-color: #2a4070; }

.filter-pills { display: flex; gap: 8px; flex-wrap: wrap; }
.date-controls, .zone-controls { display: flex; align-items: center; gap: 8px; }
.range-label { font-size: 12px; color: var(--muted); font-family: "Roboto Mono", monospace; white-space: nowrap; }

/* ── Table ───────────────────────────────────────────────── */
.table-container {
    overflow-y: auto;
    flex: 1;
    min-height: 0;
    position: relative;
}

#events {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 14px;
}

#events th, #events td {
    padding: 6px 10px;
    text-align: left;
    vertical-align: middle;
    border-bottom: 1px solid var(--border);
    overflow-wrap: break-word;
}

#events thead { position: sticky; top: 0; z-index: 100; }
#events thead tr { background: var(--surface); border-top: 2px solid var(--navy); }
#events thead th {
    font-family: "Roboto Mono", monospace;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--muted);
    background: var(--surface);
}
body.dark-mode #events thead th { background: var(--surface); color: #6b8bb0; }

#events tbody tr:hover td { background: rgba(0,82,165,0.04); }
body.dark-mode #events tbody tr:hover td { background: rgba(96,176,255,0.05); }

#events tbody tr.violent-row td { border-left: 3px solid var(--red); }
body.dark-mode #events tbody tr.violent-row td { border-left-color: #ff4444; }

/* Column widths */
.col-date         { width: 110px; }
.col-crime        { width: 22%; }
.col-zone         { width: 70px; }
.col-district     { width: 14%; }
.col-location     { width: auto; }
.col-flags        { width: 60px; text-align: center; }

/* Badges */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-family: "Roboto Mono", monospace;
    font-weight: 600;
    white-space: nowrap;
}
.badge-violent  { background: rgba(204,0,0,0.12);  color: #cc0000; border: 1px solid rgba(204,0,0,0.3); }
.badge-property { background: rgba(0,82,165,0.1);  color: var(--navy); border: 1px solid rgba(0,82,165,0.25); }
body.dark-mode .badge-violent  { background: rgba(255,80,80,0.15); color: #ff6060; border-color: rgba(255,80,80,0.3); }
body.dark-mode .badge-property { background: rgba(96,176,255,0.1); color: #60b0ff; border-color: rgba(96,176,255,0.25); }

.coords { font-family: "Roboto Mono", monospace; font-size: 11px; color: var(--muted); }

/* Load more / status */
#load-more-row td { text-align: center; padding: 14px; }
#load-more-btn {
    padding: 8px 28px;
    background: var(--navy);
    color: #fff;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
}
#load-more-btn:hover { background: var(--navy-dk); }
#load-more-btn:disabled { opacity: 0.5; cursor: default; }

#status-row td { text-align: center; padding: 20px; color: var(--muted); }

@keyframes spin { to { transform: rotate(360deg); } }
.spinner {
    display: inline-block; width: 16px; height: 16px;
    border: 2px solid var(--border); border-top-color: var(--navy);
    border-radius: 50%; animation: spin 0.7s linear infinite;
    vertical-align: middle; margin-right: 8px;
}

/* ── Summary bar + size controls ─────────────────────────── */
.table-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 2px 10px 4px;
}

#summary-bar {
    font-size: 12px;
    color: var(--muted);
    font-family: "Roboto Mono", monospace;
}

.size-controls { display: flex; gap: 4px; }

.size-btn {
    width: 26px; height: 26px;
    border-radius: 5px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--muted);
    font-size: 11px; font-weight: 700;
    cursor: pointer; line-height: 1;
}
.size-btn:hover  { border-color: var(--navy); color: var(--navy); }
.size-btn.active { background: var(--navy); color: #fff; border-color: var(--navy); }
body.dark-mode .size-btn        { background: #1a2f50; color: #6b8bb0; border-color: #2a4070; }
body.dark-mode .size-btn:hover  { color: #60b0ff; border-color: #60b0ff; }
body.dark-mode .size-btn.active { background: #0052a5; color: #fff; }

/* Table font sizes — S is the existing default */
#events.size-s td, #events.size-s th { font-size: 14px; }
#events.size-m td { font-size: 19px; padding: 8px 10px; }
#events.size-m th { font-size: 12px; }
#events.size-l td { font-size: 24px; padding: 10px 10px; }
#events.size-l th { font-size: 13px; }
/* Keep date column compact regardless of size setting */
#events.size-m td.col-date,
#events.size-l td.col-date { font-size: 13px; white-space: nowrap; }

/* ── Radius page ──────────────────────────────────────────── */
#map {
    height: calc(100vh - 220px);
    min-height: 500px;
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 6px;
    z-index: 1;
}

.radius-form {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px 16px;
    margin-bottom: 16px;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.radius-form input[type="text"] {
    flex: 3;
    min-width: 180px;
    padding: 7px 10px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    transition: border-color 0.2s;
}
.radius-form input[type="text"].input-success { border-color: #2a9d2a; box-shadow: 0 0 0 2px rgba(42,157,42,0.15); }
.radius-form input[type="text"].input-error   { border-color: var(--red); box-shadow: 0 0 0 2px rgba(204,0,0,0.15); }
body.dark-mode .radius-form input[type="text"] { background: #0f1f38; color: #c8d8f0; border-color: #2a4070; }

.radius-label {
    display: flex;
    flex-direction: column;
    gap: 3px;
    font-size: 12px;
    color: var(--muted);
    white-space: nowrap;
}
.radius-label input[type="range"] { width: 120px; cursor: pointer; }

.radius-form select {
    padding: 7px 8px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text);
    font-size: 13px;
}
body.dark-mode .radius-form select { background: #0f1f38; color: #c8d8f0; border-color: #2a4070; }

.form-group { display: flex; flex-direction: column; gap: 4px; }
.form-group label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); }
.form-group input, .form-group select {
    padding: 7px 10px; border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--bg); color: var(--text);
    font-size: 14px; width: 100%;
}
body.dark-mode .form-group input,
body.dark-mode .form-group select { background: #0f1f38; color: #c8d8f0; border-color: #2a4070; }

.search-btn {
    padding: 8px 24px; background: var(--navy); color: #fff;
    border: none; border-radius: 6px; cursor: pointer;
    font-size: 15px; font-weight: 600; white-space: nowrap;
}
.search-btn:hover { background: var(--navy-dk); }

#radius-info {
    font-size: 12px; color: var(--muted);
    font-family: "Roboto Mono", monospace;
    margin: 6px 0 10px;
}

#radius-results { margin-top: 16px; }
.results-title {
    font-family: "Roboto Mono", monospace;
    font-size: 12px; text-transform: uppercase; letter-spacing: 1px;
    color: var(--muted); border-bottom: 1px solid var(--border);
    padding-bottom: 6px; margin-bottom: 10px;
}

#results-table {
    width: 100%; border-collapse: collapse; font-size: 21px;
}
#results-table th {
    font-family: "Roboto Mono", monospace; font-size: 12px;
    text-transform: uppercase; letter-spacing: 1px; color: var(--muted);
    text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--border);
}
#results-table td { padding: 11px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
#results-table tr:hover td { background: rgba(0,82,165,0.04); }

.dist-cell { font-family: "Roboto Mono", monospace; font-size: 18px; color: var(--accent); }

/* ── Dark mode scrollbar ──────────────────────────────────── */
body.dark-mode ::-webkit-scrollbar       { width: 10px; }
body.dark-mode ::-webkit-scrollbar-track { background: #0a1628; }
body.dark-mode ::-webkit-scrollbar-thumb { background: #1e3558; border-radius: 6px; }

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 768px) {
    html, body { overflow: auto; }
    #app-container { width: 100%; }
    .page-header { padding: 8px 12px; box-sizing: border-box; }

    .header-top {
        display: flex; flex-direction: column; align-items: center; gap: 6px;
    }
    .header-controls { justify-content: center; flex-wrap: wrap; }
    .header-bottom { flex-direction: column; gap: 8px; padding: 8px; }
    .filter-pills, .date-controls, .zone-controls { justify-content: center; }

    #events thead { display: none; }
    #events, #events tbody, #events tr, #events td { display: block; width: 100%; }
    #events tr { border-bottom: 2px solid var(--border); padding: 8px 12px; }
    #events td { border: none; padding: 2px 0; }

    .table-container { height: auto; overflow-y: visible; }
    .main-content { overflow-y: visible; }

    .radius-form { flex-direction: column; align-items: stretch; }
    .radius-form input[type="text"] { flex: none; width: 100%; }
    .radius-label input[type="range"] { width: 100%; }
    #map { height: 60vh; min-height: 300px; }
}
