/* css/app.css - Keteme Design System */

:root {
    /* Core Brand Tokens */
    --primary: #1865d6;
    --primary-hover: #1251b0;
    --primary-tint: #eef4fd;
    --primary-glow: rgba(24, 101, 214, 0.16);

    --navy: #0a1c30;
    --ink: #111827;
    --ink-muted: #64748b;
    --ink-subtle: #94a3b8;
    --border: #e2e8f0;
    --border-subtle: #f1f5f9;
    --surface: #f8fafc;
    --surface-card: #ffffff;
    --white: #ffffff;

    /* Status Colors */
    --status-open-bg: #fef3c7;
    --status-open-text: #92400e;
    --status-progress-bg: #e0f2fe;
    --status-progress-text: #0369a1;
    --status-resolved-bg: #dcfce7;
    --status-resolved-text: #15803d;
    --status-duplicate-bg: #f1f5f9;
    --status-duplicate-text: #475569;

    /* Category Accents (for visual distinction) */
    --cat-roads: #d97706;
    --cat-roads-bg: #fef3c7;
    --cat-water: #0284c7;
    --cat-water-bg: #e0f2fe;
    --cat-electricity: #ca8a04;
    --cat-electricity-bg: #fef9c3;
    --cat-waste: #059669;
    --cat-waste-bg: #d1fae5;
    --cat-infra: #4f46e5;
    --cat-infra-bg: #eef2ff;
    --cat-safety: #dc2626;
    --cat-safety-bg: #fee2e2;
    --cat-other: #64748b;
    --cat-other-bg: #f1f5f9;

    /* Radii */
    --r-sm: 8px;
    --r-md: 12px;
    --r-lg: 16px;
    --r-xl: 22px;
    --r-full: 9999px;

    /* Elevation */
    --sh-subtle: 0 1px 2px rgba(15, 23, 42, 0.04);
    --sh-sm: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.03);
    --sh-md: 0 4px 16px rgba(15, 23, 42, 0.08), 0 2px 6px rgba(15, 23, 42, 0.04);
    --sh-float: 0 10px 30px rgba(15, 23, 42, 0.12);

    /* Typography */
    --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --font-display: "Manrope", var(--font);

    /* Bootstrap Variable Remapping */
    --bs-primary: var(--primary);
    --bs-primary-rgb: 24, 101, 214;
    --bs-border-radius: var(--r-md);
    --bs-border-radius-sm: var(--r-sm);
    --bs-border-radius-lg: var(--r-lg);
    --bs-border-color: var(--border);
    --bs-body-font-family: var(--font);
    --bs-body-color: var(--ink);
    --bs-body-bg: var(--surface);
    --bs-link-color: var(--primary);
    --bs-link-hover-color: var(--primary-hover);
}

*,
*::before,
*::after {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: var(--font);
    color: var(--ink);
    background-color: var(--surface);
    min-height: 100dvh;
    padding-bottom: 84px; /* Space for fixed bottom navigation */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.001ms !important;
        transition-duration: 0.001ms !important;
    }
}

/* ── Interactive Utility Classes ── */
.touch-press {
    transition:
        transform 0.12s ease,
        opacity 0.12s ease;
}
.touch-press:active {
    transform: scale(0.97);
    opacity: 0.9;
}

.min-w-0 {
    min-width: 0;
}

/* ── Splash Loader ── */
#app-loader {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: var(--navy);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition:
        opacity 0.35s ease,
        visibility 0.35s ease;
}
#app-loader.is-hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}
.loader-ring {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 3px solid rgba(255, 255, 255, 0.15);
    border-top-color: var(--primary);
    animation: loaderSpin 0.75s cubic-bezier(0.68, -0.55, 0.27, 1.55) infinite;
}
.loader-brand {
    margin-top: 16px;
    font-family: var(--font-display);
    font-weight: 800;
    font-size: 22px;
    letter-spacing: -0.5px;
    color: var(--white);
}
@keyframes loaderSpin {
    to {
        transform: rotate(360deg);
    }
}

/* ── Top Bar Header ── */
.app-topbar {
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    padding: 12px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.app-brand {
    font-family: var(--font-display);
    font-weight: 800;
    font-size: 19px;
    letter-spacing: -0.4px;
    color: var(--primary);
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.app-brand-pill {
    font-family: var(--font);
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    background: var(--primary-tint);
    color: var(--primary);
    padding: 2px 7px;
    border-radius: var(--r-full);
}

/* ── Bottom Tab Navigation ── */
.bottom-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1030;
    display: flex;
    background: rgba(255, 255, 255, 0.94);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-top: 1px solid var(--border);
    padding: 6px 12px calc(6px + env(safe-area-inset-bottom, 0));
    user-select: none;
}
.bottom-nav-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 6px 0;
    border: none;
    border-radius: var(--r-md);
    background: transparent;
    color: var(--ink-muted);
    font-size: 11px;
    font-weight: 600;
    transition: all 0.15s ease;
}
.bottom-nav-btn i {
    font-size: 20px;
    line-height: 1;
    transition: transform 0.15s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.bottom-nav-btn.active {
    color: var(--primary);
}
.bottom-nav-btn.active i {
    transform: scale(1.12);
}
.bottom-nav-btn:active {
    transform: scale(0.94);
}

/* ── Section Header & Breadcrumbs ── */
.section-label {
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.4px;
    text-transform: uppercase;
    color: var(--ink-muted);
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 6px;
}
.section-label a {
    color: var(--primary);
    text-decoration: none;
}

/* ── Status Pills & Badges ── */
.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.3px;
    padding: 4px 10px;
    border-radius: var(--r-full);
    line-height: 1.2;
}
.status-pill::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
}
.status-open {
    background: var(--status-open-bg);
    color: var(--status-open-text);
}
.status-open::before {
    background: #d97706;
}

.status-progress {
    background: var(--status-progress-bg);
    color: var(--status-progress-text);
}
.status-progress::before {
    background: #0284c7;
}

.status-resolved {
    background: var(--status-resolved-bg);
    color: var(--status-resolved-text);
}
.status-resolved::before {
    background: #16a34a;
}

.status-duplicate {
    background: var(--status-duplicate-bg);
    color: var(--status-duplicate-text);
}
.status-duplicate::before {
    background: #94a3b8;
}

/* ── Cards & List Items ── */
.card {
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    background: var(--surface-card);
    box-shadow: var(--sh-subtle);
    transition: all 0.15s ease;
}

.report-card {
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    background: var(--surface-card);
    box-shadow: var(--sh-subtle);
    cursor: pointer;
    user-select: none;
    transition:
        transform 0.12s ease,
        border-color 0.15s ease,
        box-shadow 0.15s ease;
}
.report-card:hover {
    border-color: #cbd5e1;
    box-shadow: var(--sh-sm);
}
.report-card:active {
    transform: scale(0.985);
}
.report-card .card-body {
    padding: 14px 16px;
}
.report-card-icon {
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    border-radius: var(--r-md);
    background: var(--primary-tint);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

/* ── Subcity Selector Buttons ── */
.subcity-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    background: var(--surface-card);
    box-shadow: var(--sh-subtle);
    padding: 14px 14px;
    font-weight: 600;
    font-size: 14px;
    color: var(--ink);
    width: 100%;
    text-align: left;
    user-select: none;
    transition:
        transform 0.12s ease,
        border-color 0.15s ease,
        background-color 0.15s ease;
}
.subcity-btn i {
    color: var(--primary);
    font-size: 18px;
}
.subcity-btn span:not(.badge) {
    flex-grow: 1;
}
.subcity-btn:hover {
    border-color: #cbd5e1;
}
.subcity-btn:active {
    transform: scale(0.97);
    background-color: var(--primary-tint);
}
.subcity-btn .badge {
    background: var(--surface);
    color: var(--ink-muted);
    border: 1px solid var(--border);
    font-weight: 700;
    font-size: 11px;
    padding: 4px 8px;
}

/* ── Category Picker Grid ── */
.category-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 16px 10px;
    border: 1.5px solid var(--border);
    border-radius: var(--r-lg);
    background: var(--surface-card);
    color: var(--ink);
    font-weight: 600;
    font-size: 13px;
    text-align: center;
    user-select: none;
    cursor: pointer;
    transition: all 0.15s ease;
}
.category-btn i {
    font-size: 22px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--surface);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--ink-muted);
    transition: all 0.15s ease;
}
.category-btn:active {
    transform: scale(0.96);
}
.category-btn.is-active,
.category-btn.btn-primary {
    border-color: var(--primary);
    background: var(--primary-tint);
    color: var(--primary);
}
.category-btn.is-active i,
.category-btn.btn-primary i {
    background: var(--primary);
    color: var(--white);
}

/* ── Subcategory Chips ── */
.subcategory-chip {
    display: inline-block;
    width: 100%;
    padding: 10px 12px;
    border: 1.5px solid var(--border);
    border-radius: var(--r-md);
    background: var(--surface-card);
    color: var(--ink);
    font-weight: 600;
    font-size: 13px;
    text-align: center;
    cursor: pointer;
    transition: all 0.15s ease;
}
.subcategory-chip.is-active {
    border-color: var(--navy);
    background: var(--navy);
    color: var(--white);
}

/* ── Multi-Step Indicator ── */
.step-indicator {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 4px 14px;
}
.step-dot-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    flex-shrink: 0;
}
.step-dot-wrap span {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.3px;
    text-transform: uppercase;
    color: var(--ink-muted);
    transition: color 0.15s ease;
}
.step-dot {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: 2px solid var(--border);
    background: var(--surface-card);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--ink-muted);
    font-size: 13px;
    font-weight: 700;
    transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.step-dot .bi-check-lg {
    display: none;
    font-size: 14px;
}
.step-dot.active {
    border-color: var(--primary);
    background: var(--white);
    color: var(--primary);
    box-shadow: 0 0 0 4px var(--primary-tint);
}
.step-dot.done {
    border-color: var(--primary);
    background: var(--primary);
    color: var(--white);
}
.step-dot.done .step-num {
    display: none;
}
.step-dot.done .bi-check-lg {
    display: block;
}
.step-dot.active + span,
.step-dot.done + span {
    color: var(--primary);
}
.step-line {
    flex: 1;
    height: 2px;
    background: var(--border);
    margin: -14px 8px 0;
}

/* ── Custom Camera Trigger Card ── */
.camera-trigger-card {
    border: 2px dashed var(--border);
    border-radius: var(--r-xl);
    background: var(--surface-card);
    padding: 28px 16px;
    text-align: center;
    cursor: pointer;
    transition: all 0.15s ease;
    user-select: none;
}
.camera-trigger-card:hover,
.camera-trigger-card:focus-within {
    border-color: var(--primary);
    background: var(--primary-tint);
}
.camera-trigger-card:active {
    transform: scale(0.98);
}
.camera-trigger-icon {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--primary-tint);
    color: var(--primary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 26px;
    margin-bottom: 10px;
}
.camera-preview-wrap {
    position: relative;
    border-radius: var(--r-lg);
    overflow: hidden;
    box-shadow: var(--sh-md);
}
.camera-retake-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(10, 28, 48, 0.75);
    backdrop-filter: blur(8px);
    color: var(--white);
    border: none;
    border-radius: var(--r-full);
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 600;
}

/* ── Form Controls & Floating Elements ── */
.form-label {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    color: var(--ink-muted);
    margin-bottom: 6px;
}
.form-control,
.form-select {
    border: 1.5px solid var(--border);
    border-radius: var(--r-md);
    padding: 10px 14px;
    font-size: 14px;
    background-color: var(--surface-card);
    color: var(--ink);
    transition:
        border-color 0.15s ease,
        box-shadow 0.15s ease;
}
.form-control:focus,
.form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3.5px var(--primary-tint);
}

/* ── Detail Page Top Bar & Timeline ── */
.detail-topbar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 4px 0 14px;
    font-weight: 700;
    font-size: 17px;
    color: var(--ink);
}
.detail-back-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--surface-card);
    color: var(--ink);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: all 0.12s ease;
}
.detail-back-btn:active {
    transform: scale(0.92);
    background: var(--surface);
}

/* Civic Status Timeline */
.timeline-track {
    position: relative;
    padding-left: 24px;
    margin: 16px 0;
}
.timeline-track::before {
    content: "";
    position: absolute;
    left: 7px;
    top: 6px;
    bottom: 6px;
    width: 2px;
    background: var(--border);
}
.timeline-item {
    position: relative;
    margin-bottom: 16px;
}
.timeline-item:last-child {
    margin-bottom: 0;
}
.timeline-node {
    position: absolute;
    left: -24px;
    top: 2px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--surface-card);
    border: 2px solid var(--border);
}
.timeline-item.active .timeline-node {
    border-color: var(--primary);
    background: var(--primary);
}
.timeline-item.done .timeline-node {
    border-color: var(--success);
    background: var(--success);
}

/* ── Leaflet Map Enhancements ── */
.leaflet-container {
    font-family: var(--font) !important;
    border-radius: var(--r-lg);
    border: 1px solid var(--border);
    box-shadow: var(--sh-subtle);
}
.map-locate-btn {
    position: absolute;
    bottom: 20px;
    right: 14px;
    z-index: 1000;
    background: var(--surface-card);
    color: var(--ink);
    border: 1px solid var(--border);
    box-shadow: var(--sh-md);
    border-radius: var(--r-full);
    padding: 8px 14px;
    font-size: 13px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
}
.map-locate-btn:active {
    transform: scale(0.95);
    background: var(--surface);
}
/* ── Subcity Identity Cards ── */
.subcity-card {
    position: relative;
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    background: var(--surface-card);
    padding: 14px 12px;
    overflow: hidden;
    cursor: pointer;
    user-select: none;
    box-shadow: var(--sh-subtle);
    transition:
        transform 0.12s ease,
        border-color 0.15s ease,
        box-shadow 0.15s ease;
}
.subcity-card:active {
    transform: scale(0.97);
    background-color: #fafcff;
}
.subcity-card-title {
    font-weight: 700;
    font-size: 13.5px;
    color: var(--ink);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 2px;
}
.subcity-card-subtitle {
    font-size: 11px;
    color: var(--ink-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.subcity-icon-well {
    width: 34px;
    height: 34px;
    border-radius: var(--r-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
}

/* Subcity Theme Variations */
.theme-emerald {
    background: #dcfce7;
    color: #15803d;
}
.theme-amber {
    background: #fef3c7;
    color: #b45309;
}
.theme-blue {
    background: #e0f2fe;
    color: #0369a1;
}
.theme-indigo {
    background: #eef2ff;
    color: #4f46e5;
}
.theme-slate {
    background: #f1f5f9;
    color: #475569;
}

/* Subtle Background Patterns */
.subcity-card-pattern {
    position: absolute;
    right: -8px;
    bottom: -8px;
    width: 68px;
    height: 68px;
    opacity: 0.05;
    pointer-events: none;
    background-size: contain;
    background-repeat: no-repeat;
}
.pattern-hills {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cpath d='M0 80 Q25 40 50 80 T100 80 L100 100 L0 100 Z' fill='%23000'/%3E%3Cpath d='M20 90 Q50 30 80 90 L100 100 L0 100 Z' fill='%23000'/%3E%3C/svg%3E");
}
.pattern-geometric {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cpolygon points='50,10 90,50 50,90 10,50' fill='none' stroke='%23000' stroke-width='8'/%3E%3Cpolygon points='50,30 70,50 50,70 30,50' fill='%23000'/%3E%3C/svg%3E");
}
.pattern-urban {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Crect x='10' y='30' width='20' height='70' fill='%23000'/%3E%3Crect x='40' y='10' width='25' height='90' fill='%23000'/%3E%3Crect x='75' y='45' width='20' height='55' fill='%23000'/%3E%3C/svg%3E");
}
/* ── Subcity Identity Cards (Compact, No Subtitle) ── */
.subcity-card {
    position: relative;
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    background: var(--surface-card);
    padding: 12px 12px;
    min-height: 86px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    overflow: hidden;
    cursor: pointer;
    user-select: none;
    box-shadow: var(--sh-subtle);
    transition:
        transform 0.12s ease,
        border-color 0.15s ease,
        box-shadow 0.15s ease;
}
.subcity-card:active {
    transform: scale(0.97);
    background-color: #fafcff;
}
.subcity-card-title {
    font-weight: 700;
    font-size: 13.5px;
    color: var(--ink);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 0;
}
.subcity-icon-well {
    width: 32px;
    height: 32px;
    border-radius: var(--r-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
}

/* Toasts (js/toast.js) -- branded variants instead of Bootstrap's defaults */
.toast-keteme {
    border-radius: var(--r-lg);
    box-shadow: 0 8px 24px rgba(10, 28, 48, 0.18);
    color: var(--white);
}
.toast-keteme .toast-body {
    font-size: 14px;
    font-weight: 500;
}
.toast-keteme.toast-info { background-color: var(--primary); }
.toast-keteme.toast-success { background-color: var(--status-resolved-text); }
.toast-keteme.toast-warning { background-color: var(--status-open-text); }
.toast-keteme.toast-error { background-color: #c0392b; }

/* In-page camera overlay (js/camera.js) */
.camera-overlay {
    position: fixed;
    inset: 0;
    background: #000;
    z-index: 1090;
    display: flex;
    align-items: center;
    justify-content: center;
}
.camera-overlay video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.camera-controls {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 16px;
    pointer-events: none;
}
.camera-controls > * {
    pointer-events: auto;
}
.camera-close-btn {
    align-self: flex-end;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: rgba(0, 0, 0, 0.5);
    color: var(--white);
    font-size: 16px;
}
.camera-zoom-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--white);
    background: rgba(0, 0, 0, 0.4);
    border-radius: var(--r-lg);
    padding: 6px 14px;
    margin: 0 auto 12px;
    width: fit-content;
}
.camera-shutter-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 8px;
}
.camera-shutter-btn {
    width: 68px;
    height: 68px;
    border-radius: 50%;
    background: var(--white);
    border: 4px solid rgba(255, 255, 255, 0.4);
    margin: 0 auto;
}
.camera-shutter-btn:active {
    background: var(--border);
}
.camera-torch-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background: rgba(0, 0, 0, 0.5);
    color: var(--white);
    font-size: 16px;
}
.camera-torch-btn.is-active {
    background: var(--cat-electricity, #ca8a04);
    color: #000;
}

