/* ============================================================
   Генплан Бишкека 2050 — стили интерфейса
   ============================================================ */

:root {
    --green:       #2D7A4F;
    --green-dark:  #1F5C39;
    --green-light: #E8F5EE;
    --text:        #1A1A1A;
    --text-2:      #6B7280;
    --border:      #E5E7EB;
    --bg:          #FFFFFF;
    --bg-2:        #F9FAFB;
    --danger:      #C62828;
    --radius:      10px;
    --shadow:      0 4px 20px rgba(0, 0, 0, 0.10);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    padding: 0;
    font-family: 'Inter', system-ui, sans-serif;
    overflow: hidden;
}

#map {
    position: absolute;
    inset: 0;
    background: var(--bg-2);
}

/* ================== ПАНЕЛЬ УПРАВЛЕНИЯ ================== */
/* Панель — справа: слева у Leaflet элементы зума. */
.controls {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 320px;
    z-index: 1000;
    padding: 16px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: var(--shadow);
    transition: transform 0.35s ease, opacity 0.35s ease;
}
.controls.hidden {
    transform: translateX(calc(100% + 24px));
    opacity: 0;
    pointer-events: none;
}

.panel-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 14px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}
.panel-logo {
    flex-shrink: 0;
    width: 30px;
    height: 30px;
    border-radius: 8px;
    background: var(--green);
    display: flex;
    align-items: center;
    justify-content: center;
}
.panel-logo svg { width: 16px; height: 16px; fill: #fff; }
.panel-title { font-size: 14px; font-weight: 700; color: var(--text); line-height: 1.2; }
.panel-sub   { font-size: 11px; color: var(--text-2); margin-top: 1px; }

.close-panel-btn {
    width: 28px;
    height: 28px;
    min-height: auto;
    margin-left: auto;
    padding: 0;
    flex-shrink: 0;
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-2);
    font-size: 14px;
    box-shadow: none;
}
.close-panel-btn:hover { background: var(--border); color: var(--text); }

/* ================== ПОИСК ================== */
.search-wrap { position: relative; margin-bottom: 10px; }
.search-wrap svg {
    position: absolute;
    left: 11px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    stroke: var(--text-2);
    fill: none;
    stroke-width: 2;
    pointer-events: none;
}
input[type="text"] {
    width: 100%;
    padding: 10px 12px 10px 36px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-2);
    color: var(--text);
    font-size: 13px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s, background 0.2s;
}
input[type="text"]:focus { border-color: var(--green); background: #fff; }
input[type="text"]::placeholder { color: #9CA3AF; }
input[type="text"].error {
    border-color: var(--danger);
    background: rgba(229, 57, 53, 0.08);
}

/* ================== КНОПКИ ================== */
button {
    width: 100%;
    margin: 0;
    padding: 10px 14px;
    border: none;
    border-radius: var(--radius);
    background: var(--green);
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    transition: background 0.18s, transform 0.1s;
}
button:hover  { background: var(--green-dark); }
button:active { transform: scale(0.98); }
button:disabled { opacity: 0.6; cursor: default; transform: none; }

.btn-legend {
    margin-top: 10px;
    background: var(--bg-2);
    color: var(--text);
    border: 1.5px solid var(--border);
    font-weight: 500;
}
.btn-legend:hover {
    background: var(--green-light);
    border-color: var(--green);
    color: var(--green);
}

.divider { border: none; border-top: 1px solid var(--border); margin: 14px 0; }

/* ================== ПРОЗРАЧНОСТЬ ================== */
.opacity-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 7px;
    font-size: 12px;
    color: var(--text-2);
}
.opacity-label .label { font-weight: 500; color: var(--text); }
.opacity-label .value { font-weight: 600; color: var(--text); }

input[type="range"] {
    width: 100%;
    height: 4px;
    border-radius: 4px;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
}
input[type="range"]::-webkit-slider-runnable-track {
    height: 4px;
    border-radius: 4px;
    background: linear-gradient(to right,
        var(--green) 0%, var(--green) var(--val, 70%),
        var(--border) var(--val, 70%));
}
input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    margin-top: -7px;
    border-radius: 50%;
    background: var(--green);
    border: 2px solid #fff;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
    cursor: pointer;
}
input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--green);
    border: 2px solid #fff;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
    cursor: pointer;
}

/* ================== КАРТОЧКА РЕЗУЛЬТАТА ================== */
.result-card {
    display: none;
    position: relative;
    margin-top: 12px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}
.result-card.visible { display: block; }
.result-close {
    position: absolute;
    top: 7px;
    right: 7px;
    z-index: 1;
    width: 30px;
    height: 30px;
    min-height: auto;
    padding: 0;
    margin: 0;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 15px;
    line-height: 1;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
}
.result-close:hover { background: var(--bg-2); }
.result-close:active { transform: scale(0.94); }
.result-addr {
    padding: 11px 44px 11px 12px;
    background: var(--bg-2);
    border-bottom: 1px solid var(--border);
    font-size: 12px;
    color: var(--text-2);
    line-height: 1.4;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.result-zone {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px;
}
.result-swatch {
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    border-radius: 8px;
    border: 1.5px solid rgba(0, 0, 0, 0.08);
}
.result-info { flex: 1; min-width: 0; }
.result-zone-name {
    margin-bottom: 2px;
    font-size: 11px;
    color: var(--text-2);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.result-floors { font-size: 22px; font-weight: 700; line-height: 1; }
.result-floors-label { margin-top: 2px; font-size: 11px; color: var(--text-2); }
.result-warn { margin-top: 4px; font-size: 10px; color: #E65100; }
.result-empty { font-size: 12px; color: var(--text-2); }

/* ================== КНОПКА ПОКАЗА ПАНЕЛИ ================== */
.toggle-btn {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 1001;
    width: 40px;
    height: 40px;
    display: none;
    align-items: center;
    justify-content: center;
    background: #fff;
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.10);
    cursor: pointer;
}
.toggle-btn.visible { display: flex; }

/* ================== ПОДСКАЗКА ЗОНИРОВАНИЯ ================== */
.zone-hint {
    margin-top: 10px;
    padding: 8px 10px;
    border-radius: var(--radius);
    background: #FFF4E5;
    border: 1px solid #FFD9A8;
    font-size: 11px;
    color: #9A5B00;
    line-height: 1.45;
    display: none;
}
.zone-hint.visible { display: block; }

/* ================== ПОПАП LEAFLET ================== */
.gp-popup { font-family: 'Inter', system-ui, sans-serif; min-width: 230px; }
.gp-popup .addr {
    margin-bottom: 10px;
    font-size: 13px;
    font-weight: 600;
    color: #1A1A2E;
    line-height: 1.45;
}
.gp-popup .zone { border-top: 2px solid var(--zone, var(--border)); padding-top: 10px; }
.gp-popup .zone-kicker {
    margin-bottom: 7px;
    font-size: 10px;
    color: #AAA;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.gp-popup .zone-name {
    display: flex;
    align-items: center;
    gap: 7px;
    margin-bottom: 8px;
    font-size: 12px;
    color: #333;
}
.gp-popup .zone-name i {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
    border-radius: 3px;
    background: var(--zone);
    border: 1px solid rgba(0, 0, 0, 0.1);
}
.gp-popup .floors { font-size: 26px; font-weight: 700; line-height: 1; }
.gp-popup .floors-label { margin-top: 3px; font-size: 11px; color: #888; }
.gp-popup .warn { margin-top: 5px; font-size: 10px; color: #E65100; }

.gp-error .title { margin-bottom: 8px; font-size: 13px; font-weight: 600; color: var(--danger); }
.gp-error .body  { font-size: 12px; color: #555; }
.gp-error ul { margin: 8px 0 0; padding: 8px 10px; list-style: none;
               background: #F5F5F5; border-radius: 6px; }
.gp-error li { padding: 2px 0; }
.gp-error button.example {
    width: auto; margin: 0; padding: 0; min-height: auto;
    background: none; color: #1565C0; font-size: 12px; font-weight: 400;
    box-shadow: none;
}
.gp-error button.example:hover { text-decoration: underline; background: none; }
.gp-error .tip { margin-top: 8px; font-size: 11px; color: #AAA; }

/* ================== МОДАЛЬНАЯ ЛЕГЕНДА ================== */
.legend-modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 2000;
    background: rgba(17, 24, 39, 0.5);
    align-items: center;
    justify-content: center;
}
.legend-modal.open { display: flex; }
.legend-box {
    position: relative;
    width: 92vw;
    max-width: 480px;
    max-height: 88vh;
    padding: 24px;
    overflow-y: auto;
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.18);
}
.legend-box h2 {
    margin: 0 0 3px;
    font-size: 15px;
    font-weight: 700;
    color: var(--text);
    text-align: center;
}
.legend-box .sub {
    margin-bottom: 18px;
    font-size: 11px;
    color: var(--text-2);
    text-align: center;
}
.legend-close {
    position: absolute;
    top: 14px;
    right: 14px;
    width: 28px;
    height: 28px;
    min-height: auto;
    padding: 0;
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-2);
    font-size: 16px;
    font-weight: 400;
    box-shadow: none;
}
.legend-close:hover { background: var(--border); color: var(--text); transform: none; }
.legend-section {
    margin: 16px 0 8px;
    padding-bottom: 4px;
    font-size: 10px;
    font-weight: 700;
    color: var(--text-2);
    text-transform: uppercase;
    letter-spacing: 0.7px;
    border-bottom: 1px solid var(--border);
}
.legend-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 0;
    border-bottom: 1px solid var(--bg-2);
}
.legend-row:last-child { border-bottom: none; }
.legend-swatch {
    width: 26px;
    height: 18px;
    flex-shrink: 0;
    border-radius: 4px;
    border: 1px solid rgba(0, 0, 0, 0.10);
}
.legend-name   { flex: 1; font-size: 12px; color: var(--text); line-height: 1.4; }
.legend-floors { font-size: 12px; font-weight: 700; color: var(--green); white-space: nowrap; }
.legend-img-wrap { margin-top: 16px; text-align: center; }
.legend-img-wrap img {
    max-width: 100%;
    border-radius: 8px;
    border: 1px solid var(--border);
}

/* ================== МОБИЛЬНАЯ АДАПТАЦИЯ ================== */
/* Вертикальная раскладка: карта сверху, панель управления — статичным
   блоком под ней. Страница не скроллится внутри себя — встраивающий
   iframe подгоняется по высоте контента (см. GenplanFrame.tsx), поэтому
   скролл один, общий со страницей сайта. --map-h задаёт встраивающая
   страница; 60vh — запасной вариант для открытия напрямую. */
@media (max-width: 640px) {
    /* overflow-y: auto — запасной вариант, если подгонка iframe по контенту
       не сработала (JS выключен). При работающем JS iframe равен высоте
       контента и скроллбар не появляется. */
    html, body {
        overflow-x: hidden;
        overflow-y: auto;
        height: auto;
    }

    #map {
        position: relative;
        inset: auto;
        width: 100%;
        height: var(--map-h, 60vh);
        min-height: 280px;
    }

    .controls {
        position: static;
        transform: none !important;
        width: 100% !important;
        max-height: none;
        opacity: 1 !important;
        pointer-events: auto !important;
        padding: 16px;
        padding-bottom: calc(16px + env(safe-area-inset-bottom));
        border: none;
        border-top: 1px solid var(--border);
        border-radius: 0;
        box-shadow: none;
    }
    .controls.hidden { transform: none !important; opacity: 1 !important; }

    /* кнопки скрытия панели не нужны — она статична под картой */
    .toggle-btn,
    .close-panel-btn { display: none !important; }

    .panel-header { margin-bottom: 10px; padding-bottom: 10px; }
    button { min-height: 48px; padding: 12px 14px; font-size: 14px; }
    /* 16px — чтобы iOS не зумил поле при фокусе */
    input[type="text"] { font-size: 16px; padding: 12px 12px 12px 38px; }

    .result-floors { font-size: 26px; }
}
