/* ============================================================
   CrimeRadar — Crime Map Page
   ============================================================ */

html, body { height: 100%; }

body.cr-map-page {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

/* Full layout below header */
.cr-map-layout {
    display: flex;
    flex: 1;
    overflow: hidden;
    margin-top: var(--header-h, 68px);
    height: calc(100vh - var(--header-h, 68px));
}

/* ── Sidebar ── */
.cr-map-sidebar {
    width: 360px;
    flex-shrink: 0;
    background: #fff;
    border-right: 1px solid #e2e8f0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 10;
}

.cr-map-sidebar-head {
    padding: 16px;
    border-bottom: 1px solid #e2e8f0;
    position: relative;
}

.cr-map-search-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

.cr-map-search-icon {
    position: absolute;
    left: 14px;
    color: #94a3b8;
    font-size: 0.9rem;
    pointer-events: none;
    z-index: 2;
}

.cr-map-search-input {
    width: 100%;
    padding: 12px 38px 12px 40px;
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    font-size: 0.9rem;
    font-family: 'Inter', system-ui, sans-serif;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    color: #111827;
}

.cr-map-search-input:focus {
    border-color: #0094DD;
    box-shadow: 0 0 0 3px rgba(0,148,221,0.1);
}

.cr-map-search-input::placeholder { color: #9ca3af; }

.cr-map-clear-btn {
    position: absolute;
    right: 10px;
    background: none;
    border: none;
    color: #9ca3af;
    cursor: pointer;
    padding: 4px 8px;
    font-size: 0.85rem;
    line-height: 1;
    transition: color 0.15s;
}

.cr-map-clear-btn:hover { color: #374151; }

/* Suggestions dropdown */
.cr-map-suggestions {
    list-style: none;
    padding: 0;
    margin: 0;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.12);
    position: absolute;
    left: 16px;
    right: 16px;
    top: calc(100% - 2px);
    z-index: 200;
    overflow: hidden;
    display: none;
}

.cr-map-suggestions.open { display: block; }

.cr-map-suggestions li {
    padding: 10px 14px;
    cursor: pointer;
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid #f1f5f9;
    transition: background 0.15s;
}

.cr-map-suggestions li:last-child { border-bottom: none; }
.cr-map-suggestions li:hover,
.cr-map-suggestions li.active { background: #f0f9ff; }

.cr-map-suggestions li i { color: #0094DD; flex-shrink: 0; font-size: 0.85rem; }
.cr-map-suggestions li > span:first-of-type { flex: 1; min-width: 0; }

.sug-name { font-weight: 600; color: #111827; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sug-sub  { color: #6b7280; font-size: 0.78rem; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sug-type { font-size: 0.65rem; font-weight: 700; letter-spacing: 0.02em; text-transform: uppercase; border-radius: 4px; padding: 2px 7px; white-space: nowrap; flex-shrink: 0; color: #fff; background: #0094DD; }
.cr-map-suggestions li[data-type="city"] .sug-type  { background: #16a34a; }
.cr-map-suggestions li[data-type="force"] .sug-type { background: #7c3aed; }
.cr-map-suggestions li[data-type="nb"] .sug-type    { background: #0094DD; }

/* ── Sidebar body ── */
.cr-map-sidebar-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    -webkit-overflow-scrolling: touch;
}

/* Placeholder */
.cr-map-placeholder {
    text-align: center;
    padding: 28px 8px;
}

.cr-map-placeholder-icon {
    width: 64px;
    height: 64px;
    background: var(--blue-light, #e8f5ff);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
    font-size: 1.5rem;
    color: var(--blue, #0094DD);
}

.cr-map-placeholder h3 {
    font-size: 1.1rem;
    font-weight: 700;
    color: #111827;
    margin-bottom: 8px;
}

.cr-map-placeholder p {
    font-size: 0.86rem;
    color: #6b7280;
    line-height: 1.6;
    margin-bottom: 20px;
}

.cr-map-tips {
    display: flex;
    flex-direction: column;
    gap: 8px;
    text-align: left;
    background: #f8fafc;
    border-radius: 10px;
    padding: 14px 16px;
}

.cr-map-tip {
    font-size: 0.82rem;
    color: #475569;
    display: flex;
    align-items: center;
    gap: 10px;
}

.cr-map-tip i {
    color: var(--blue, #0094DD);
    width: 16px;
    text-align: center;
    font-size: 0.85rem;
    flex-shrink: 0;
}

/* Loading */
.cr-map-loading {
    text-align: center;
    padding: 48px 16px;
}

.cr-map-spinner {
    width: 36px;
    height: 36px;
    border: 3px solid #e2e8f0;
    border-top-color: var(--blue, #0094DD);
    border-radius: 50%;
    animation: cr-spin 0.8s linear infinite;
    margin: 0 auto 16px;
}

@keyframes cr-spin { to { transform: rotate(360deg); } }

.cr-map-loading p {
    font-size: 0.88rem;
    color: #6b7280;
    margin: 0;
}

/* ── Result panel ── */
.cr-map-result-header {
    background: var(--dark, #0a0e1a);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 14px;
    color: #fff;
}

.cr-map-result-force {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.72rem;
    color: rgba(255,255,255,0.5);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    font-weight: 600;
}

.cr-map-result-force i { color: var(--blue, #0094DD); }

.cr-map-result-name {
    font-size: 1.3rem;
    font-weight: 800;
    margin-bottom: 2px;
    line-height: 1.2;
}

.cr-map-result-city {
    font-size: 0.82rem;
    color: rgba(255,255,255,0.45);
    margin-bottom: 16px;
}

.cr-map-result-score-row {
    display: flex;
    align-items: center;
    gap: 14px;
}

.cr-map-result-score {
    font-size: 2.8rem;
    font-weight: 800;
    line-height: 1;
}

.cr-map-result-score small {
    font-size: 1rem;
    font-weight: 400;
    color: rgba(255,255,255,0.35);
}

.cr-map-result-score-info { flex: 1; }

.cr-map-result-score-label {
    font-size: 1rem;
    font-weight: 700;
    display: block;
}

.cr-map-result-score-sub {
    font-size: 0.78rem;
    color: rgba(255,255,255,0.45);
}

/* Stats grid */
.cr-map-result-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 14px;
}

.cr-map-result-stat {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 12px 14px;
}

.cr-map-result-stat-num {
    display: block;
    font-size: 1.25rem;
    font-weight: 800;
    color: #111827;
    line-height: 1;
    margin-bottom: 4px;
}

.cr-map-result-stat-lbl {
    font-size: 0.7rem;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

.cr-map-result-trend-up   { color: #dc2626; }
.cr-map-result-trend-down { color: #16a34a; }

/* CTA */
.cr-map-result-cta {
    display: block;
    width: 100%;
    padding: 14px;
    background: var(--blue, #0094DD);
    color: #fff !important;
    border: none;
    border-radius: 10px;
    font-size: 0.95rem;
    font-weight: 700;
    text-align: center;
    cursor: pointer;
    text-decoration: none !important;
    transition: background 0.2s, transform 0.15s;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.cr-map-result-cta:hover {
    background: var(--blue-dark, #0078b8);
    transform: translateY(-1px);
}

.cr-map-result-force-link {
    display: block;
    text-align: center;
    font-size: 0.82rem;
    color: #6b7280;
    text-decoration: none;
    padding: 4px;
    transition: color 0.15s;
}

.cr-map-result-force-link:hover { color: var(--blue, #0094DD); text-decoration: none; }

/* No data / error */
.cr-map-no-data {
    text-align: center;
    padding: 24px 8px;
}

.cr-map-no-data .cr-map-no-data-icon {
    font-size: 2rem;
    margin-bottom: 12px;
    display: block;
}

.cr-map-no-data h4 {
    font-size: 1rem;
    font-weight: 700;
    color: #111827;
    margin-bottom: 8px;
}

.cr-map-no-data p {
    font-size: 0.84rem;
    color: #6b7280;
    margin-bottom: 12px;
    line-height: 1.5;
}

.cr-map-processing-cta {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    background: var(--blue, #0094DD);
    color: #fff !important;
    border-radius: 10px;
    font-size: 0.88rem;
    font-weight: 700;
    text-decoration: none !important;
    transition: background 0.2s;
}

.cr-map-processing-cta:hover { background: var(--blue-dark, #0078b8); }

/* ── Map area ── */
.cr-map-main {
    flex: 1;
    position: relative;
    overflow: hidden;
}

#cr-map-full {
    width: 100%;
    height: 100%;
}

/* Buttons over map */
.cr-locate-btn {
    position: absolute;
    top: 10px;
    right: 16px;
    width: 44px;
    height: 44px;
    background: #fff;
    border: 2px solid rgba(0,0,0,0.15);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1rem;
    color: #374151;
    z-index: 500;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    transition: all 0.2s;
}

.cr-locate-btn:hover {
    background: var(--blue, #0094DD);
    color: #fff;
    border-color: var(--blue, #0094DD);
}

.cr-locate-btn.loading i {
    animation: cr-spin 1s linear infinite;
}

/* ── Mobile ── */
@media (max-width: 768px) {
    body.cr-map-page {
        height: auto;
        min-height: 100vh;
        overflow: auto;
    }

    .cr-map-layout {
        flex-direction: column;
        height: auto;
        min-height: calc(100vh - var(--header-h, 60px));
    }

    .cr-map-sidebar {
        width: 100%;
        height: auto;
        border-right: none;
        border-bottom: 1px solid #e2e8f0;
        overflow: visible;
    }

    .cr-map-sidebar-body {
        max-height: 50vh;
    }

    .cr-map-main {
        height: 55vw;
        min-height: 280px;
        max-height: 400px;
    }
}

/* ── Zone legend ── */
.cr-map-legend {
    background: rgba(255,255,255,0.95);
    backdrop-filter: blur(4px);
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 10px 14px;
    font-family: inherit;
    box-shadow: 0 2px 12px rgba(0,0,0,0.12);
    font-size: 0.72rem;
    min-width: 150px;
}
.cr-map-legend-title {
    font-weight: 700;
    font-size: 0.75rem;
    color: #1f2937;
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}
.cr-map-legend-item {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 2px 0;
    color: #374151;
    font-weight: 500;
}
.cr-map-legend-item span {
    display: inline-block;
    width: 14px;
    height: 14px;
    border-radius: 3px;
    opacity: 0.8;
    flex-shrink: 0;
}
@media (max-width: 768px) {
    .cr-map-legend { font-size: 0.65rem; min-width: 120px; padding: 8px 10px; }
    .cr-map-legend-item span { width: 10px; height: 10px; }
}
