/* ===================================
   Watchum design system — components
   =================================== */

/* ===== Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    height: 44px;
    padding: 0 var(--space-5);
    border-radius: var(--radius-md);
    font-family: var(--font-body);
    font-weight: 600;
    font-size: 16px;
    cursor: pointer;
    border: none;
    transition: background 120ms ease, transform 120ms ease;
    text-decoration: none;
    line-height: 1;
}
.btn-primary           { background: var(--interactive-primary); color: var(--text-primary); }
.btn-primary:hover     { background: var(--interactive-primary-hover); }
.btn-primary:active    { background: var(--interactive-primary-pressed); }
.btn-primary:disabled  { background: var(--interactive-primary-pressed); opacity: 0.5; cursor: not-allowed; }
.btn-primary-block     { width: 100%; }

.btn-secondary         { background: transparent; color: var(--accent); border: 1px solid var(--border-default); }
.btn-secondary:hover   { background: rgba(34, 68, 204, 0.12); }

.btn-icon              { width: 44px; height: 44px; padding: 0; background: var(--interactive-primary); color: var(--text-primary); border-radius: var(--radius-md); }
.btn-icon:hover        { background: var(--interactive-primary-hover); }
.btn-icon:active       { background: var(--interactive-primary-pressed); }

/* ===== Cards ===== */
.card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: var(--space-5);
    box-shadow: var(--shadow-card);
}
.card-elevated {
    background: var(--bg-elevated);
    box-shadow: var(--shadow-elevated);
}
.card-hover-lift { transition: background 150ms ease, transform 150ms ease; }
.card-hover-lift:hover {
    background: var(--bg-hover);
    transform: translateY(-2px);
}

/* ===== Navbar ===== */
.site-header {
    position: sticky;
    top: 0;
    z-index: 50;
    background: var(--bg-app);
    width: 100%;
}
.navbar-inner {
    display: flex;
    align-items: center;
    gap: var(--space-6);
    padding-top: var(--space-5);
    padding-bottom: var(--space-5);
}
.navbar-brand          { display: flex; align-items: center; gap: var(--space-2); text-decoration: none; }
.navbar-logo           { height: 28px; width: auto; display: block; }
@media (max-width: 600px) {
    .navbar-logo { height: 24px; }
}
.navbar-brand .wordmark{ font-family: var(--font-display); font-weight: 800; font-size: 22px; letter-spacing: -0.01em; }
.navbar-brand .wordmark .watch { color: var(--text-primary); }
.navbar-brand .wordmark .um    { color: var(--accent); }
.navbar-spacer         { flex: 1; }
.navbar-links          { display: flex; gap: var(--space-6); align-items: center; }
.navbar-links a        { color: var(--text-secondary); text-decoration: none; font-family: var(--font-body); font-size: 15px; }
.navbar-links a:hover, .navbar-links a.active { color: var(--text-primary); }

/* ===== Mobile responsive overrides ===== */
@media (max-width: 600px) {
    /* Toggle group: stack vertically when the buttons can't fit side-by-side */
    .toggle-group {
        flex-direction: column;
        width: 100%;
    }
    .toggle-group button {
        width: 100%;
        justify-content: center;
    }
}

@media (max-width: 768px) {
    .navbar-inner { padding-left: var(--space-4); padding-right: var(--space-4); gap: var(--space-3); }

    /* Hide desktop nav links; the hamburger button (injected by auth.js) toggles them. */
    .navbar-links {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        flex-direction: column;
        align-items: stretch;
        gap: var(--space-1);
        padding: var(--space-3) var(--space-4) var(--space-4);
        background: var(--bg-app);
        border-bottom: 1px solid rgba(255, 255, 255, 0.08);
        box-shadow: 0 12px 40px rgba(0, 0, 0, 0.7);
        z-index: 9001;
    }
    .navbar-links.mobile-open { display: flex; }

    /* Stack the .btn variants full-width inside the mobile menu */
    .navbar-links .btn,
    .navbar-links a,
    .navbar-links button {
        width: 100%;
        justify-content: flex-start;
        padding: 12px var(--space-3);
        font-size: 15px;
        height: auto;
        border-radius: var(--radius-sm);
    }
    .navbar-links .btn-secondary { border: 0; }
    .navbar-links .btn-primary   { margin-top: var(--space-1); }

    /* User menu in mobile (logged-in state) */
    .navbar-links #userMenu {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 0 !important;
        width: 100%;
    }
    .navbar-links #userMenu a,
    .navbar-links #userMenu button {
        text-align: left;
        padding: 12px var(--space-3);
    }
}

/* ===== Search bar (pill) ===== */
.search-bar {
    display: flex; align-items: center; gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    background: var(--bg-card);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    height: 48px;
    min-width: 0;
    box-sizing: border-box;
}
.search-bar input {
    flex: 1; min-width: 0; width: 100%;  /* override <input> default ~20ch min-content */
    background: transparent; border: 0; outline: 0;
    color: var(--text-primary);
    font-family: var(--font-body); font-size: 16px;
}
.search-bar input::placeholder { color: var(--text-muted); }
.search-bar input:disabled     { color: var(--text-muted); }

/* ===== Search pair (zip + street + button) ===== */
.search-pair                { display: grid; gap: var(--space-3); width: 100%; min-width: 0; }
.search-pair .input-row     {
    display: flex; align-items: center;
    padding: var(--space-3) var(--space-4);
    background: var(--bg-card); border: 1px solid var(--border-default);
    border-radius: var(--radius-md); height: 56px;
    min-width: 0;          /* allow flex item to shrink past its content's min-width */
    box-sizing: border-box;
}
.search-pair .input-row input {
    flex: 1; min-width: 0; /* override <input>'s default ~20ch min-content width */
    width: 100%;
    background: transparent; border: 0; outline: 0;
    color: var(--text-primary); font-size: 16px; font-family: var(--font-body);
}
.search-pair .input-row.disabled { opacity: 0.6; border-color: rgba(34, 68, 204, 0.30); }

/* ===== Autocomplete dropdown ===== */
.autocomplete {
    background: var(--bg-card);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-elevated);
    max-height: 320px; overflow-y: auto;
}
.autocomplete-item                        { padding: var(--space-3) var(--space-5); cursor: pointer; }
.autocomplete-item:hover,
.autocomplete-item[aria-selected="true"]  { background: var(--bg-elevated); }
.autocomplete-item-name                   { font-weight: 600; color: var(--text-primary); }
.autocomplete-item-address                { font-size: 13px; color: var(--text-muted); margin-top: 2px; }

/* ===== Hero chip (locale + product line tag) ===== */
.hero-chip {
    display: inline-flex; align-items: center; gap: var(--space-2);
    padding: 10px 18px; border-radius: var(--radius-md);
    background: var(--bg-elevated);
    border: 1px solid var(--accent);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 13px; font-weight: 600;
    letter-spacing: 0.12em; text-transform: uppercase;
}
.hero-chip::before {
    content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--accent);
}

/* ===== Pill / chip ===== */
.chip {
    display: inline-flex; align-items: center;
    padding: 8px 14px; border-radius: var(--radius-md);
    background: var(--bg-elevated); border: 1px solid var(--border-default);
    color: var(--text-primary); font-size: 14px; cursor: pointer;
    text-decoration: none;
    font-family: var(--font-body);
}
.chip:hover { border-color: var(--accent); }

/* ===== Toggle group (segmented) ===== */
.toggle-group {
    display: inline-flex; gap: 4px;
    padding: 4px;
    background: var(--bg-card);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
}
.toggle-group button {
    display: inline-flex; align-items: center; gap: var(--space-2);
    background: transparent; border: 0;
    color: var(--text-muted);
    padding: 10px 18px; border-radius: var(--radius-sm);
    font-family: var(--font-body); font-weight: 600; font-size: 14px;
    cursor: pointer;
    white-space: nowrap;
    flex-shrink: 0;
}
.toggle-group button.active {
    background: var(--interactive-primary);
    color: var(--text-primary);
}

/* ===== Inline accent link ===== */
.link-inline {
    color: var(--accent); font-weight: 600; text-decoration: none;
    display: inline-flex; align-items: center; gap: 6px;
}
.link-inline:hover { color: var(--accent-soft); }

/* ===== Severity badges (functional metadata only) ===== */
.badge        { display: inline-flex; align-items: center; padding: 6px 12px; border-radius: var(--radius-md); font-size: 12px; font-weight: 600; color: var(--white); letter-spacing: 0.04em; }
.badge-high   { background: var(--severity-high); }
.badge-med    { background: var(--severity-med); }
.badge-low    { background: var(--severity-low); }

/* ===== Crime row (CCTV brutalism) =====
   Grid: [1fr label+desc] [auto count]
   Count cell shows the actual number of incidents per category (paid),
   or a ▪ marker for free users (gated). Hairline dividers, hover tint. */
.crime-row {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: var(--space-6);
    padding: var(--space-5) var(--space-4);
    border-bottom: 1px solid var(--border-default);
    transition: background 0.12s ease;
}
.crime-row:last-child { border-bottom: none; }
.crime-row:hover { background: rgba(34, 68, 204, 0.04); }
.crime-row .label {
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: 13px;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--text-primary);
    margin: 0 0 var(--space-2);
}
.crime-row .desc {
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-size: 13px;
    line-height: 1.5;
    margin: 0;
}
.crime-row .count {
    font-family: var(--font-display);
    font-size: 44px;
    line-height: 1;
    color: var(--accent);
    text-transform: uppercase;
    text-align: right;
    min-width: 60px;
}
.crime-row .count.muted {
    font-size: 24px;
    color: var(--text-muted);
}

/* Incident details (toggle + list) must span both grid columns so the
   auto count column never expands to accommodate incident content width. */
.crime-row .detail-toggle,
.crime-row .incident-list {
    grid-column: 1 / -1;
}

/* ===== Report card ===== */
.report-card {
    background: var(--bg-card);
    padding: var(--space-8);
    border: 1px solid var(--border-default);
    box-shadow: var(--shadow-elevated);
    display: grid;
    gap: var(--space-6);
    box-sizing: border-box;
    min-width: 0;
    overflow-x: hidden;     /* clip anything inside that tries to push past the card edge on phones */
}
.report-card > * { min-width: 0; }   /* let any direct child shrink to fit the card */
.report-card .top-row    { display: flex; align-items: center; gap: var(--space-4); flex-wrap: wrap; }
.report-card .top-row .actions { margin-left: auto; display: flex; gap: var(--space-2); }

.report-card .title {
    font-family: var(--font-display);
    font-weight: 400;
    font-size: clamp(40px, 6vw, 72px);
    line-height: 0.95;
    letter-spacing: -0.02em;
    text-transform: uppercase;
    margin: 0;
    color: var(--text-primary);
}
.report-card .address {
    font-family: var(--font-mono);
    font-weight: 600;
    font-size: 12px;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--accent);
    margin: 0;
}
.report-card .stats-line {
    font-family: var(--font-mono);
    color: var(--text-muted);
    font-size: 13px;
    letter-spacing: 0.04em;
    margin: 0;
}

/* HUD-style stats strip — used on report pages above the breakdown */
.report-hud {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1px;
    background: var(--border-default);
    border-top: 1px solid var(--border-default);
    border-bottom: 1px solid var(--border-default);
}
.report-hud .cell {
    background: var(--bg-app);
    padding: var(--space-3) var(--space-4);
}
.report-hud .cell-label {
    font-family: var(--font-mono);
    font-size: 10px;
    letter-spacing: 0.25em;
    text-transform: uppercase;
    color: var(--text-muted);
}
.report-hud .cell-value {
    font-family: var(--font-mono);
    font-size: 13px;
    color: var(--text-primary);
    margin-top: 4px;
}
@media (max-width: 768px) {
    .report-hud { grid-template-columns: repeat(2, 1fr); }
    .crime-row { gap: var(--space-3); padding: var(--space-4) var(--space-3); }
    .crime-row .count { font-size: 32px; min-width: 44px; }
    .crime-row .count.muted { font-size: 18px; }
}

/* Report card sizes down on phones */
@media (max-width: 600px) {
    .report-card {
        padding: var(--space-5);
        word-wrap: break-word;
        overflow-wrap: break-word;
    }
    .report-card .title { font-size: 36px; line-height: 1.05; }
}
.stats-line-emphasis {
    color: var(--accent);
    font-weight: 700;
    font-size: 1.1em;
}

/* ===== Layout container =====
   Use padding-left/right (not the shorthand) so element-specific
   padding-top/bottom set elsewhere (e.g. .navbar-inner) survives the cascade. */
.container {
    width: 100%; max-width: var(--container-max); margin: 0 auto;
    padding-left: var(--container-margin-d);
    padding-right: var(--container-margin-d);
}
@media (max-width: 1024px) {
    .container { padding-left: var(--container-margin-t); padding-right: var(--container-margin-t); }
}
@media (max-width: 600px) {
    .container { padding-left: var(--container-margin-m); padding-right: var(--container-margin-m); }
}

/* ===== Footer ===== */
.site-footer {
    margin-top: 120px; padding: 48px 0;
    background: var(--bg-app);
    border-top: 1px solid var(--bg-elevated);
}
.site-footer .grid {
    display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 48px;
}
@media (max-width: 768px) {
    .site-footer .grid { grid-template-columns: 1fr; gap: 32px; }
}
.site-footer h4   { font-family: var(--font-body); font-weight: 600; font-size: 13px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-muted); margin: 0 0 var(--space-3); }
.site-footer ul   { list-style: none; padding: 0; margin: 0; display: grid; gap: var(--space-2); }
.site-footer a    { color: var(--text-secondary); text-decoration: none; }
.site-footer a:hover { color: var(--text-primary); }
.site-footer .legal { margin-top: 48px; color: var(--text-muted); font-size: 13px; }
