/* public/assets/styles.css */
/* Light, clean UI – incident dashboard & map */

:root {
    --bg-page: #f3f4f6;
    --bg-surface: #ffffff;
    --bg-header: #ffffff;
    --border-subtle: #e5e7eb;
    --border-strong: #d1d5db;
    --primary: #2563eb;
    --primary-soft: #eff6ff;
    --primary-strong: #1d4ed8;
    --accent: #0ea5e9;
    --danger: #b91c1c;
    --danger-soft: #fee2e2;
    --text-main: #111827;
    --text-muted: #6b7280;
    --radius-lg: 14px;
    --radius-pill: 999px;
    --shadow-soft: 0 4px 14px rgba(15, 23, 42, 0.08);
    --font-sans: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-sans);
    background: var(--bg-page);
    color: var(--text-main);
}

/* Layout shell */

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

/* widened main area so index doesn’t feel tiny */
.app-main {
    flex: 1;
    max-width: 1360px;
    margin: 24px auto 32px;
    padding: 0 24px;
}

/* Top bar */

.topbar {
    position: sticky;
    top: 0;
    z-index: 40;
    background: var(--bg-header);
    border-bottom: 1px solid var(--border-subtle);
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
}

.topbar-inner {
    max-width: 1360px;
    margin: 0 auto;
    padding: 10px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.topbar-left,
.topbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--text-main);
}

.brand-badge {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    background: linear-gradient(135deg, #2563eb, #0ea5e9);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 16px;
    color: white;
}

.brand-title {
    font-weight: 600;
    font-size: 17px;
}

.brand-sub {
    font-size: 11px;
    color: var(--text-muted);
}

/* Nav links & buttons */

.topbar a {
    text-decoration: none;
}

.nav-links,
.nav-auth {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.nav-link {
    font-size: 13px;
    border-radius: var(--radius-pill);
    border: 1px solid transparent;
    padding: 6px 12px;
    background: transparent;
    color: var(--text-muted);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    transition: 0.15s ease-out;
}

.nav-link:hover {
    background: #e5e7eb;
    color: var(--text-main);
}

.nav-link--primary {
    border-color: rgba(37, 99, 235, 0.15);
    background: var(--primary-soft);
    color: var(--primary-strong);
}

.nav-link--primary:hover {
    background: #dbeafe;
    border-color: rgba(37, 99, 235, 0.35);
}

/* ====== "More" dropdown in header ====== */

.nav-more {
    position: relative;
}

.nav-more-btn {
    background: transparent;
    border-radius: var(--radius-pill);
    border: 1px solid transparent;
    padding: 6px 12px;
    font-size: 13px;
    color: var(--text-muted);
    display: inline-flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    transition: 0.15s ease-out;
}

.nav-more-btn:hover {
    background: #e5e7eb;
    color: var(--text-main);
}

.nav-more-menu {
    position: absolute;
    top: 32px;
    left: 0;
    min-width: 160px;
    background: var(--bg-surface);
    border-radius: 10px;
    border: 1px solid var(--border-subtle);
    box-shadow: var(--shadow-soft);
    padding: 6px 0;
    display: none;
    z-index: 50;
}

.nav-more-menu.show {
    display: block;
}

.nav-more-menu a {
    display: block;
    padding: 7px 12px;
    font-size: 13px;
    color: var(--text-main);
    text-decoration: none;
}

.nav-more-menu a:hover {
    background: #f3f4f6;
}

/* Buttons */

.btn {
    font-size: 13px;
    border-radius: var(--radius-pill);
    border: 1px solid transparent;
    padding: 8px 16px;
    cursor: pointer;
    transition: 0.15s ease-out;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    text-decoration: none;
}

.btn-primary {
    background: var(--primary);
    color: #ffffff;
    border-color: var(--primary);
}

.btn-primary:hover {
    background: var(--primary-strong);
}

.btn-secondary {
    background: #ffffff;
    border-color: var(--border-subtle);
    color: var(--text-main);
}

.btn-secondary:hover {
    background: #f9fafb;
    border-color: var(--border-strong);
}

/* User pill */

.user-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: #f3f4f6;
    border-radius: var(--radius-pill);
    border: 1px solid var(--border-subtle);
    padding: 4px 10px;
    font-size: 12px;
    color: var(--text-main);
}

.user-pill-role {
    border-radius: 999px;
    padding: 2px 8px;
    font-size: 10px;
    border: 1px solid var(--border-subtle);
    text-transform: uppercase;
    color: var(--text-muted);
}

/* Cards */

.card {
    background: var(--bg-surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-subtle);
    box-shadow: var(--shadow-soft);
    padding: 20px 22px;
    margin-bottom: 22px;
}

.card--full-width {
    padding: 14px 22px 16px;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 10px;
    margin-bottom: 12px;
}

.card-title {
    font-size: 21px;
    font-weight: 600;
}

.card-subtitle {
    font-size: 13px;
    color: var(--text-muted);
}

/* Filter bar */

.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 16px;
    align-items: flex-end;
}

.filter-group label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    display: block;
    margin-bottom: 4px;
}

.filter-group select,
.filter-group input[type="text"] {
    background: #ffffff;
    border-radius: 999px;
    border: 1px solid var(--border-subtle);
    padding: 8px 13px;
    font-size: 13px;
    color: var(--text-main);
    min-width: 160px;
    outline: none;
    transition: 0.15s ease-out;
}

.filter-group select:focus,
.filter-group input[type="text"]:focus {
    border-color: rgba(37, 99, 235, 0.6);
    box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.18);
}

/* Incident list */

.incident-grid {
    display: grid;
    gap: 10px;
}

.incident-card {
    display: flex;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 10px;
    background: #ffffff;
    border: 1px solid var(--border-subtle);
    transition: 0.15s ease-out;
}

.incident-card:hover {
    border-color: rgba(37, 99, 235, 0.4);
    box-shadow: 0 3px 10px rgba(15, 23, 42, 0.08);
}

.incident-card-main {
    flex: 1;
    min-width: 0;
}

.incident-card-title {
    font-size: 15px;
    font-weight: 500;
    margin-bottom: 4px;
}

.incident-card-title a {
    color: var(--text-main);
    text-decoration: none;
}

.incident-card-title a:hover {
    text-decoration: underline;
}

.incident-card-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    font-size: 11px;
    color: var(--text-muted);
}

.incident-card-secondary {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 6px;
    font-size: 11px;
    color: var(--text-muted);
    min-width: 150px;
}

/* FAVOURITE STAR */

.fav-form {
    margin: 0;
}

.fav-button {
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    padding: 0;
    color: #d1d5db;
    transition: color 0.15s ease-out, transform 0.1s ease-out;
}

.fav-button:hover {
    color: #fbbf24;
    transform: translateY(-1px);
}

.fav-button--active {
    color: #f59e0b;
}

/* Badges */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border-radius: 999px;
    padding: 2px 8px;
    font-size: 10px;
    border: 1px solid var(--border-subtle);
    background: #f3f4f6;
}

.badge-dot {
    width: 6px;
    height: 6px;
    border-radius: 999px;
}

.badge-status-verified {
    border-color: #16a34a;
    background: #dcfce7;
    color: #166534;
}

.badge-status-unverified {
    border-color: #e11d48;
    background: #ffe4e6;
    color: #9f1239;
}

.badge-status-closed {
    border-color: #9ca3af;
    background: #f3f4f6;
    color: #4b5563;
}

.badge-severity {
    border-color: #cbd5f5;
}

.badge-severity-low {
    background: #ecfdf3;
    color: #166534;
}

.badge-severity-medium {
    background: #fef9c3;
    color: #854d0e;
}

.badge-severity-high {
    background: #ffedd5;
    color: #9a3412;
}

.badge-severity-critical {
    background: #fee2e2;
    color: #b91c1c;
    border-color: #b91c1c;
}

.badge-source {
    background: #eef2ff;
    border-color: #6366f1;
    color: #4338ca;
}

/* CATEGORY BADGES */

.category-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 10px;
    border: 1px solid var(--border-subtle);
    background: #f9fafb;
    color: var(--text-muted);
}

.category-badge--rtc {
    background: #fee2e2;
    border-color: #dc2626;
    color: #b91c1c;
}

.category-badge--breakdown {
    background: #fef3c7;
    border-color: #d97706;
    color: #92400e;
}

.category-badge--roadworks {
    background: #ffedd5;
    border-color: #ea580c;
    color: #9a3412;
}

.category-badge--closure {
    background: #fee2e2;
    border-color: #b91c1c;
    color: #7f1d1d;
}

.category-badge--fire {
    background: #ffedd5;
    border-color: #fb923c;
    color: #9a3412;
}

.category-badge--police {
    background: #e0f2fe;
    border-color: #2563eb;
    color: #1d4ed8;
}

.category-badge--medical {
    background: #ecfdf3;
    border-color: #0f766e;
    color: #115e59;
}

.category-badge--weather {
    background: #e0f2fe;
    border-color: #0ea5e9;
    color: #0369a1;
}

.category-badge--other {
    background: #f3f4f6;
    border-color: #9ca3af;
    color: #4b5563;
}

/* Map layout – base */

.map-wrapper {
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid var(--border-subtle);
    box-shadow: var(--shadow-soft);
}

/* default map height when not on dedicated map page */
#map {
    height: 60vh;
}

/* MAP CONTROLS / COUNTERS */

.map-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
    font-size: 12px;
    margin-top: -4px;
    margin-bottom: 4px;
}

.map-controls-label {
    font-size: 12px;
    color: var(--text-muted);
    margin-right: 2px;
}

.pill-toggle {
    border-radius: 999px;
    border: 1px solid var(--border-subtle);
    background: #ffffff;
    padding: 4px 10px;
    font-size: 11px;
    cursor: pointer;
    color: var(--text-muted);
    transition: 0.15s ease-out;
}

.pill-toggle:hover {
    background: #f3f4f6;
}

.pill-toggle--active {
    background: var(--primary-soft);
    color: var(--primary-strong);
    border-color: rgba(37, 99, 235, 0.35);
}

.map-counters {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 6px;
    font-size: 11px;
}

.counter-chip {
    border-radius: 999px;
    border: 1px solid var(--border-subtle);
    background: #f9fafb;
    padding: 3px 9px;
    color: var(--text-muted);
}

.counter-chip strong {
    color: var(--text-main);
}

.counter-chip--verified {
    border-color: #16a34a;
    background: #dcfce7;
}

.counter-chip--unverified {
    border-color: #e11d48;
    background: #ffe4e6;
}

/* Incident detail */

.incident-layout {
    display: grid;
    gap: 16px;
}

@media (min-width: 900px) {
    .incident-layout {
        grid-template-columns: minmax(0, 2.2fr) minmax(260px, 1fr);
    }
}

.incident-section {
    margin-bottom: 16px;
}

.incident-meta-list {
    list-style: none;
    padding: 0;
    margin: 0;
    font-size: 13px;
}

.incident-meta-list li {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    border-bottom: 1px dotted var(--border-subtle);
}

.incident-meta-key {
    color: var(--text-muted);
}

/* MINI INCIDENT MAP */

.incident-map-container {
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid var(--border-subtle);
}

#incident-map {
    height: 220px;
}

/* Lists (updates, comments) */

.list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.list-item {
    padding: 8px 0;
    border-bottom: 1px dotted var(--border-subtle);
    font-size: 13px;
}

.list-item-meta {
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 4px;
}

/* Forms */

.form-stack {
    display: grid;
    gap: 12px;
}

.form-field label {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    display: block;
    margin-bottom: 4px;
}

.form-field input[type="text"],
.form-field input[type="email"],
.form-field input[type="password"],
.form-field textarea,
.form-field select {
    width: 100%;
    background: #ffffff;
    border-radius: 10px;
    border: 1px solid var(--border-subtle);
    padding: 8px 11px;
    font-size: 13px;
    color: var(--text-main);
    outline: none;
    transition: 0.15s ease-out;
}

.form-field textarea {
    resize: vertical;
    min-height: 80px;
}

.form-field input:focus,
.form-field textarea:focus,
.form-field select:focus {
    border-color: rgba(37, 99, 235, 0.6);
    box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.18);
}

/* Auth container – wider so login/register aren’t tiny */

.auth-container {
    max-width: 520px;
    margin: 40px auto 0;
}

.auth-note {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 6px;
}

/* Alerts */

.alert {
    padding: 8px 10px;
    border-radius: 10px;
    font-size: 13px;
    margin-bottom: 10px;
    border: 1px solid transparent;
}

.alert-error {
    background: var(--danger-soft);
    border-color: #fecaca;
    color: #991b1b;
}

.alert-success {
    background: #dcfce7;
    border-color: #bbf7d0;
    color: #166534;
}

/* Tables (admin pages etc.) */

table {
    border-collapse: collapse;
    width: 100%;
    font-size: 13px;
    background: #ffffff;
}

th,
td {
    padding: 8px 10px;
    border-bottom: 1px solid var(--border-subtle);
}

th {
    text-align: left;
    font-weight: 500;
    color: var(--text-muted);
    background: #f9fafb;
}

/* Footer */

.app-footer {
    text-align: center;
    padding: 14px 0 26px;
    font-size: 11px;
    color: var(--text-muted);
}

/* INCIDENT MAP ICONS (Leaflet divIcons) */

.incident-icon {
    position: relative;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: #4b5563;
    border: 2px solid #ffffff;
    box-shadow: 0 2px 4px rgba(15, 23, 42, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
}

.incident-icon__emoji {
    line-height: 1;
}

.incident-icon::after {
    content: "";
    position: absolute;
    bottom: -6px;
    left: 50%;
    transform: translateX(-50%);
    border-width: 6px 4px 0 4px;
    border-style: solid;
    border-color: #4b5563 transparent transparent transparent;
}

.incident-icon--rtc {
    background: #dc2626;
}
.incident-icon--rtc::after {
    border-top-color: #dc2626;
}

.incident-icon--breakdown {
    background: #d97706;
}
.incident-icon--breakdown::after {
    border-top-color: #d97706;
}

.incident-icon--roadworks {
    background: #ea580c;
}
.incident-icon--roadworks::after {
    border-top-color: #ea580c;
}

.incident-icon--closure {
    background: #b91c1c;
}
.incident-icon--closure::after {
    border-top-color: #b91c1c;
}

.incident-icon--fire {
    background: #fb923c;
}
.incident-icon--fire::after {
    border-top-color: #fb923c;
}

.incident-icon--police {
    background: #2563eb;
}
.incident-icon--police::after {
    border-top-color: #2563eb;
}

.incident-icon--medical {
    background: #0f766e;
}
.incident-icon--medical::after {
    border-top-color: #0f766e;
}

.incident-icon--weather {
    background: #0ea5e9;
}
.incident-icon--weather::after {
    border-top-color: #0ea5e9;
}

.incident-icon--adverse_weather {
    background: #0284c7;
}
.incident-icon--adverse_weather::after {
    border-top-color: #0284c7;
}

.incident-icon--other {
    background: #6b7280;
}
.incident-icon--other::after {
    border-top-color: #6b7280;
}

.incident-icon--unverified {
    opacity: 0.75;
}
.incident-icon--verified {
    opacity: 1;
}

/* =========================
   FULL-SCREEN MAP PAGE
   ========================= */

/* normal content constraints don’t apply on map page */
.map-page .app-main {
    max-width: none;
    margin: 0;
    padding: 0;
}

/* fixed full-screen map layer (under the header) */
.map-page .map-fullscreen {
    position: fixed;
    top: 56px;            /* height of the topbar; tweak if slightly off */
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1;
    background: #e5e7eb;  /* fallback while tiles load */
}

/* map fills that layer completely */
.map-page #map {
    width: 100%;
    height: 100%;
}

/* hide the normal footer behind the fixed map */
.map-page .app-footer {
    display: none;
}


/* left overlay sidebar with key / filters / counters */
.map-sidebar-overlay {
    position: absolute;
    top: 12px;
    left: 12px;
    width: 310px;
    max-width: 80vw;
    background: var(--bg-surface);
    border-radius: 12px;
    border: 1px solid var(--border-subtle);
    box-shadow: var(--shadow-soft);
    padding: 12px 14px 14px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 6px;
    overflow-y: auto;
    max-height: calc(100% - 24px);
    transition: transform 0.2s ease-out, opacity 0.2s ease-out;
}

/* collapsed state – slide offscreen */
.map-sidebar-overlay--collapsed {
    transform: translateX(-115%);
    opacity: 0;
    pointer-events: none;
}

/* small title inside sidebar */
.map-sidebar-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 2px;
}

.map-sidebar-subtitle {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 4px;
}

/* put legend badges on one row */
.map-sidebar-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 4px;
}

/* reuse existing map-controls / map-counters inside sidebar */
.map-sidebar-overlay .map-controls {
    margin-top: 6px;
    margin-bottom: 2px;
}

.map-sidebar-overlay .map-counters {
    margin-top: 4px;
}

/* Toggle button that sits next to sidebar edge */
.map-sidebar-toggle {
    position: absolute;
    top: 16px;
    left: 332px; /* sidebar width + padding */
    z-index: 1001;
    border-radius: 999px;
    border: 1px solid var(--border-subtle);
    background: #ffffff;
    padding: 4px 8px;
    font-size: 11px;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(15, 23, 42, 0.15);
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.map-sidebar-toggle span {
    font-size: 12px;
}

/* when sidebar collapsed, move toggle to left edge */
.map-sidebar-overlay--collapsed + .map-sidebar-toggle {
    left: 12px;
}

/* small screens: make sidebar narrower */
@media (max-width: 640px) {
    .map-sidebar-overlay {
        width: 260px;
    }
    .map-sidebar-toggle {
        left: 282px;
    }
}
