/* Styles for the permits map page (karta.html) */

:root {
    --bg: #f6f7fb;
    --panel: #ffffff;
    --border: #d8dee8;
    --text: #152033;
    --muted: #5f6b7a;
    --blue: #2962ff;
    --green: #169c52;
    --red: #d93b3b;
    --shadow: 0 2px 12px rgba(21, 32, 51, 0.10);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: var(--bg);
    color: var(--text);
}

.map-page {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

/* Header */

.map-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 16px 8px;
    background: var(--panel);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.map-header-left {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.back-btn {
    display: inline-block;
    padding: 7px 14px;
    border-radius: 8px;
    background: var(--text);
    color: #fff;
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
    transition: opacity 0.15s ease;
    align-self: flex-start;
}
.back-btn:hover { opacity: 0.82; text-decoration: none; }

.map-header h1 {
    margin: 0;
    font-size: clamp(16px, 2.5vw, 22px);
    line-height: 1.2;
}

.map-subtitle {
    margin: 0;
    font-size: 13px;
    color: var(--muted);
}

.map-meta {
    font-size: 12px;
    color: var(--muted);
    white-space: nowrap;
    padding-top: 4px;
}

/* Controls bar */

.map-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 12px 20px;
    padding: 8px 16px;
    background: var(--panel);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.control-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.control-label {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
    white-space: nowrap;
}

.chip-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.chip {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    border: 1.5px solid var(--border);
    background: transparent;
    color: var(--text);
    transition: background 0.12s, border-color 0.12s, color 0.12s;
    white-space: nowrap;
}

.chip:hover {
    border-color: var(--blue);
    color: var(--blue);
}

.chip.active {
    background: var(--blue);
    border-color: var(--blue);
    color: #fff;
}

/* Map */

#map {
    flex: 1;
    min-height: 0;
    z-index: 0;
}

/* Popup */

.map-popup {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px 20px;
    box-shadow: var(--shadow);
    min-width: 260px;
    max-width: 90vw;
}

.popup-close {
    position: absolute;
    top: 8px;
    right: 10px;
    background: none;
    border: none;
    font-size: 18px;
    color: var(--muted);
    cursor: pointer;
    line-height: 1;
    padding: 0;
}

.popup-close:hover { color: var(--text); }

.popup-content {
    font-size: 14px;
    line-height: 1.6;
}

.popup-title {
    font-weight: 600;
    font-size: 15px;
    margin-bottom: 6px;
}

.popup-row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    border-top: 1px solid var(--border);
    padding-top: 4px;
    margin-top: 4px;
}

.popup-key { color: var(--muted); }
.popup-val { font-weight: 500; text-align: right; }

/* Heatmap legend */

.map-legend {
    position: absolute;
    bottom: 30px;
    right: 12px;
    z-index: 900;
    background: rgba(255,255,255,0.9);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 14px;
    font-size: 12px;
    pointer-events: none;
}

.map-legend-title {
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--text);
}

.legend-gradient {
    width: 120px;
    height: 8px;
    border-radius: 4px;
    margin-bottom: 3px;
}

.legend-labels {
    display: flex;
    justify-content: space-between;
    color: var(--muted);
}

/* Responsive */

@media (max-width: 480px) {
    .map-header { padding: 8px 12px 6px; }
    .map-controls { padding: 6px 12px; gap: 8px 14px; }
    .map-popup { bottom: 12px; padding: 12px 14px; }
}
