/* ==========================================================================
   1. БАЗОВІ НАЛАШТУВАННЯ
   ========================================================================== */
*, *::before, *::after {
    box-sizing: border-box;
}

html, body {
    height: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden;
    font-family: 'Inter', sans-serif;
    background: #0a0a0a;
    color: #e5e7eb;
}

/* Кастомний скроллбар */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: #111;
}
::-webkit-scrollbar-thumb {
    background: #374151;
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
    background: #4b5563;
}

/* ==========================================================================
   2. КАРТА ТА ОВЕРЛЕЇ
   ========================================================================== */
#map {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    background: #000;
}

.overlay {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 10;
}
.overlay > * {
    pointer-events: auto;
}

/* ==========================================================================
   Стилі для попапів (MapLibre / Leaflet)
   ========================================================================== */
.custom-popup {
    font-family: 'Inter', sans-serif;
    color: #111;
    font-size: 14px;
    line-height: 1.4;
}
.custom-popup-title {
    font-size: 1.15em;
    font-weight: 700;
    display: block;
    margin-bottom: 4px;
}
.custom-popup-divider {
    border: 0;
    border-top: 1px solid #d1d5db;
    margin: 6px 0;
}
.custom-popup-date {
    color: #6b7280;
    font-size: 0.85em;
    display: block;
}
.custom-popup-settlement {
    display: block;
    font-size: 0.85em;     /* Уменьшенный шрифт */
    color: #6b7280;        /* Тот самый красивый серый цвет */
    font-weight: 400;      /* Убираем жирность, если она наследуется */
}

/* Закруглення білої картки MapLibre */
.maplibregl-popup-content {
    border-radius: 14px !important; /* Можеш змінити на 16px або 18px для більшого закруглення */
    padding: 16px !important;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4) !important;
}

.maplibregl-popup-close-button {
    font-size: 16px;
    right: 8px;
    top: 6px;
    color: #6b7280;
}
.maplibregl-popup-close-button:hover {
    background-color: transparent !important;
    color: #111;
}

/* ========================================================================
   Ліцензійна угода
   ======================================================================== */
.license-page {
    min-height: 100%;
    height: auto;
    overflow-x: hidden;
    overflow-y: auto;
    padding: 48px 20px;
    background: radial-gradient(ellipse at top, #172033 0, #0a0a0a 58%);
}

.license-document {
    width: min(100%, 860px);
    margin: 0 auto;
}

.license-header {
    margin-bottom: 28px;
    text-align: center;
}

.license-home-link {
    color: #60a5fa;
    font-size: 0.9rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-decoration: none;
    text-transform: uppercase;
}

.license-home-link:hover,
.license-content a:hover {
    color: #93c5fd;
}

.license-header h1 {
    margin: 16px 0 6px;
    color: #f9fafb;
    font-size: clamp(1.8rem, 5vw, 2.6rem);
    line-height: 1.2;
}

.license-updated {
    margin: 0;
    color: #9ca3af;
}

.license-content {
    padding: clamp(22px, 5vw, 44px);
    border: 1px solid rgba(156, 163, 175, 0.16);
    border-radius: 16px;
    background: rgba(17, 24, 39, 0.88);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.28);
    color: #d1d5db;
    font-size: 1rem;
    line-height: 1.75;
}

.license-content > p:first-child {
    margin-top: 0;
    color: #f3f4f6;
    font-size: 1.05rem;
}

.license-content section {
    margin-top: 34px;
}

.license-content h2 {
    margin: 0 0 14px;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(156, 163, 175, 0.2);
    color: #f9fafb;
    font-size: 1.25rem;
    line-height: 1.4;
}

.license-content p {
    margin: 0 0 14px;
}

.license-content strong {
    color: #f3f4f6;
}

.license-content ul {
    margin: -4px 0 16px;
    padding-left: 24px;
}

.license-content li + li {
    margin-top: 6px;
}

.license-content a {
    color: #60a5fa;
    overflow-wrap: anywhere;
}

@media (max-width: 600px) {
    .license-page {
        padding: 28px 12px;
    }

    .license-content {
        border-radius: 12px;
        font-size: 0.95rem;
    }
}

/* ==========================================================================
   3. ПЛАВАЮЧІ ЕЛЕМЕНТИ (UI CONTROLS)
   ========================================================================== */
/* Date Switcher */
.date-switch {
    position: absolute;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    background: rgba(17, 24, 39, 0.85);
    backdrop-filter: blur(8px);
    padding: 6px 12px;
    border-radius: 6px;
    border: 1px solid #374151;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.5);
    z-index: 100;
}
.date-btn {
    background: #1f2937;
    border: 1px solid #374151;
    color: #d1d5db;
    border-radius: 4px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}
.date-btn:hover {
    background: #374151;
    color: #fff;
}
.map-date {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.9rem;
    min-width: 95px;
    text-align: center;
    font-weight: 500;
    margin: 0 12px;
    color: #f3f4f6;
}

/* Floating Action Button (FAB) */
.fab {
    position: absolute;
    top: 24px;
    right: 24px;
    width: 48px;
    height: 48px;
    border-radius: 8px;
    background: #1f2937;
    color: #e5e7eb;
    border: 1px solid #374151;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    cursor: pointer;
    z-index: 110;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}
.fab:hover {
    background: #374151;
    border-color: #4b5563;
}

/* Telegram Toast */
#tg-toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 320px;
    background: #1f2937;
    border-left: 4px solid #3b82f6;
    color: #e5e7eb;
    padding: 16px;
    border-radius: 4px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
    z-index: 130;
    font-size: 0.9rem;
    display: none;
    align-items: flex-start;
    justify-content: space-between;
}
.tg-content a {
    color: #60a5fa;
    text-decoration: none;
    font-weight: 600;
}
.tg-content a:hover {
    text-decoration: underline;
}
#tg-toast-close {
    background: none;
    border: none;
    color: #9ca3af;
    cursor: pointer;
    font-size: 1.1rem;
    padding: 0;
    margin-left: 10px;
}
#tg-toast-close:hover {
    color: #fff;
}

/* ==========================================================================
   4. БОКОВА ПАНЕЛЬ (СПИСОК)
   ========================================================================== */
.list-panel {
    position: fixed;
    background: rgba(17, 24, 39, 0.95);
    backdrop-filter: blur(12px);
    box-shadow: -4px 0 25px rgba(0, 0, 0, 0.7);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 120;
    display: flex;
    flex-direction: column;
}

/* Адаптивність панелі */
@media (min-width: 901px) {
    .list-panel {
        top: 0;
        bottom: 0;
        right: 0;
        width: 420px;
        transform: translateX(0);
        border-left: 1px solid #374151;
    }
    .list-panel.hidden {
        transform: translateX(100%) !important;
    }
}

@media (max-width: 900px) {
    .list-panel {
        left: 0;
        right: 0;
        bottom: 0;
        height: 85vh;
        border-top: 1px solid #374151;
        border-radius: 12px 12px 0 0;
        transform: translateY(0);
    }
    .list-panel.hidden {
        transform: translateY(100%) !important;
    }
    .fab {
        top: 16px;
        right: 16px;
    }
}

/* Шапка панелі */
.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid #374151;
    background: #111827;
    flex-shrink: 0;
}
.header-title {
    display: flex;
    align-items: center;
    gap: 10px;
}
.status-indicator {
    width: 8px;
    height: 8px;
    background: #ef4444;
    border-radius: 50%;
    box-shadow: 0 0 8px #ef4444;
}
.panel-header h2 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #f3f4f6;
}
.close-btn {
    background: none;
    border: none;
    color: #9ca3af;
    font-size: 1.5rem;
    cursor: pointer;
    transition: color 0.2s;
}
.close-btn:hover {
    color: #ef4444;
}

/* Пошук */
.search-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 12px 20px;
    border-bottom: 1px solid #374151;
    flex-shrink: 0;
    background: #111827;
}

#searchInput {
    display: block;
    width: 100%;
    box-sizing: border-box; /* Явно заставляем браузер учитывать внутренние отступы в 100% ширины */
    padding: 10px 14px;
    background: #1f2937;
    border: 1px solid #4b5563;
    border-radius: 6px; /* Делаем 6px, чтобы совпадало с выпадающим списком */
    color: #e5e7eb;
    font-family: inherit;
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.2s;
    margin: 0; /* Сбрасываем дефолтные отступы браузера */
}

#searchInput:focus {
    border-color: #60a5fa;
}

/* Таблиця */
.table-wrapper {
    flex: 1 1 auto;
    overflow-y: auto;
    background: #111827;
}
.houses-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}
.houses-table th,
.houses-table td {
    padding: 10px 16px;
    border-bottom: 1px solid #1f2937;
    text-align: left;
}
.houses-table th {
    background: #1f2937;
    position: sticky;
    top: 0;
    z-index: 5;
    font-weight: 600;
    color: #9ca3af;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    box-shadow: 0 1px 0 #374151;
}
.houses-table tr {
    cursor: pointer;
    transition: background 0.15s;
}
.houses-table tr:hover {
    background: #1f2937;
}

/* Специфічні стилі контенту таблиці */
.houses-table td:nth-child(2),
.houses-table td:nth-child(4) {
    font-family: 'JetBrains Mono', monospace;
    color: #9ca3af;
}
.empty-table-msg {
    text-align: center;
    padding: 2rem !important;
    color: #9ca3af;
}
.street-old {
    display: block;
    font-size: 0.85em;
    color: #6b7280;
    margin-top: 2px;
}
.status-cell {
    font-weight: 500;
}
.status-damaged {
    color: #f59e0b;
}
.status-destroyed {
    color: #ef4444;
}

/* Стилі для випадаючого списку населеного пункту */
.settlement-select {
    display: block;
    width: 100%;
    box-sizing: border-box;
    padding: 10px 36px 10px 14px;

    background-color: #1f2937;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%239ca3af' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 14px center;
    background-size: 16px;

    border: 1px solid #4b5563;
    border-radius: 6px;
    color: #e5e7eb;
    margin: 0 0 10px 0;
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    outline: none;
    cursor: pointer;
    transition: border-color 0.2s;

    appearance: none;
    -webkit-appearance: none;
}

.settlement-select:focus {
    border-color: #60a5fa;
}

.settlement-select option {
    background: #1f2937;
    color: #e5e7eb;
}

/* Підпис міста під вулицею в таблиці */
.settlement-label {
    display: block;
    font-size: 0.8em;
    color: #9ca3af;
    margin-top: 2px;
}

/* Адаптивність Toast для мобільних */
@media (max-width: 500px) {
    #tg-toast {
        bottom: 90px;
        right: 16px;
        left: 16px;
        width: auto;
    }
}

/* ==========================================================================
   5. ЛІВЕ ГОЛОВНЕ МЕНЮ
   ========================================================================== */
/* Кнопка "гамбургер" */
.menu-btn {
    position: absolute;
    top: 24px;
    left: 24px;
    width: 48px;
    height: 48px;
    border-radius: 8px;
    background: #1f2937;
    color: #e5e7eb;
    border: 1px solid #374151;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    cursor: pointer;
    z-index: 110;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}
.menu-btn:hover {
    background: #374151;
    border-color: #4b5563;
}

/* Сама боковая панель */
.side-menu {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 320px;
    background: rgba(17, 24, 39, 0.95);
    backdrop-filter: blur(12px);
    border-right: 1px solid #374151;
    box-shadow: 4px 0 25px rgba(0, 0, 0, 0.7);
    z-index: 140; /* Выше всех остальных элементов интерфейса */
    transform: translateX(0);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
}

/* Класс для скрытия меню за левый край экрана */
.side-menu.hidden-menu {
    transform: translateX(-100%);
}

/* Шапка лівого меню */
.menu-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid #374151;
    background: #111827;
    flex-shrink: 0;
}

.menu-header h2 {
    margin: 0;
    font-size: 1.2rem; /* Увеличили заголовок для лучших пропорций */
    font-weight: 600;
    letter-spacing: 0.5px;
    color: #f3f4f6;
}

#close-menu-btn {
    background: none;
    border: none;
    color: #9ca3af;
    font-size: 1.5rem;
    cursor: pointer;
    transition: color 0.2s;
    padding: 0;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}
#close-menu-btn:hover {
    color: #ef4444;
}

/* Контент внутри меню */
.menu-content {
    padding: 20px 0; /* Отступ сверху перед соцсетями */
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    flex: 1 1 auto;
}

/* БЛОК СОЦСЕТЕЙ (Стиль DeepState) */
.social-block {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 0 20px 16px 20px; /* Отступы по бокам и снизу */
    background: #1f2937;
    border: 1px solid #374151;
    border-radius: 8px;
    overflow: hidden; /* Чтобы углы кнопок не вылезали за рамку */
}

.social-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px 0;
    transition: background 0.2s;
    text-decoration: none;
}
.social-btn:hover {
    background: #374151;
}

.social-divider {
    width: 1px;
    height: 24px;
    background: #374151;
}

/* ПУНКТЫ МЕНЮ */
.menu-item {
    display: flex;
    align-items: center;
    padding: 12px 20px; /* Уменьшили высоту строки (было 14px) */
    color: #d1d5db;
    text-decoration: none;
    font-size: 0.95rem; /* Сделали шрифт чуть меньше (был 1rem) */
    font-weight: 500;
    transition: background 0.2s, padding-left 0.2s;
}
.menu-item:hover {
    background: #1f2937;
    color: #fff;
    border-left: 3px solid #60a5fa;
    padding-left: 17px;
}

.menu-icon {
    margin-right: 14px;
    color: #9ca3af;
    display: flex; /* Центрирует SVG внутри спана */
    align-items: center;
}

/* Заголовок для будущих секций (например, донатов) */
.menu-section-title {
    margin: 24px 20px 8px 20px;
    font-size: 0.8rem;
    text-transform: uppercase;
    color: #6b7280;
    font-weight: 600;
    letter-spacing: 0.05em;
}

/* Адаптив для мобильных телефонов (Синхронізовано з правою панеллю) */
@media (max-width: 900px) {
    .side-menu {
        width: 100%; /* На мобільних меню на весь екран */
        border-right: none;
    }
    .menu-btn {
        top: 16px;
        left: 16px;
    }
}

/* Custom settlement dropdown */
.custom-select-wrapper {
    position: relative;
    z-index: 10;
    width: 100%;
    user-select: none;
}

.custom-select-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-sizing: border-box;
    width: 100%;
    padding: 10px 14px;
    border: 1px solid #4b5563;
    border-radius: 6px;
    background: #1f2937;
    color: #e5e7eb;
    font: inherit;
    font-size: 0.95rem;
    text-align: left;
    cursor: pointer;
}

.custom-select-trigger:hover,
.custom-select-wrapper.open .custom-select-trigger {
    border-color: #60a5fa;
    background: #26364b;
}

.custom-select-trigger .arrow {
    flex: 0 0 8px;
    width: 8px;
    height: 8px;
    margin: -4px 2px 0 12px;
    border-bottom: 2px solid #9ca3af;
    border-left: 2px solid #9ca3af;
    transform: rotate(-45deg);
    transition: transform 0.2s;
}

.custom-select-wrapper.open .arrow {
    margin-top: 4px;
    transform: rotate(135deg);
}

.custom-options {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    left: 0;
    z-index: 1000;
    display: none;
    max-height: 280px;
    overflow-y: auto;
    border: 1px solid #4b5563;
    border-radius: 6px;
    background: #1f2937;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
}

.custom-select-wrapper.open .custom-options {
    display: block;
}

.custom-option {
    padding: 10px 14px;
    border-bottom: 1px solid #374151;
    cursor: pointer;
}

.custom-option:last-child {
    border-bottom: 0;
}

.custom-option:hover {
    background: #374151;
}

.custom-option.selected {
    padding-left: 11px;
    border-left: 3px solid #60a5fa;
    background: rgba(59, 130, 246, 0.1);
}

.option-title {
    color: #f3f4f6;
    font-size: 0.95rem;
    font-weight: 500;
}

.option-subtitle {
    margin-top: 4px;
    color: #9ca3af;
    font-size: 0.75rem;
    line-height: 1.3;
}

.custom-options::-webkit-scrollbar {
    width: 6px;
}

.custom-options::-webkit-scrollbar-thumb {
    border-radius: 3px;
    background: #4b5563;
}
