/* ============================================================
   Стили интерактивной карты СНТ «Огонек»
   ============================================================ */

:root {
    --color-bg: #f0f2f5;
    --color-header: #2c3e50;
    --color-header-text: #ecf0f1;
    --color-panel: #ffffff;
    --color-border: #dde1e6;
    --color-primary: #2e7d32;
    --color-primary-hover: #1b5e20;
    --color-danger: #c62828;
    --color-warning: #f9a825;
    --color-text: #212121;
    --color-text-secondary: #616161;
    --sidebar-width: 340px;
    --header-height: 56px;
    --radius: 8px;
    --shadow: 0 2px 8px rgba(0,0,0,0.10);
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--color-bg);
    color: var(--color-text);
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

/* ---------- Header ---------- */
.header {
    height: var(--header-height);
    background: var(--color-header);
    color: var(--color-header-text);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    z-index: 100;
    box-shadow: 0 1px 4px rgba(0,0,0,0.15);
    flex-shrink: 0;
}

.header__title {
    font-size: 18px;
    font-weight: 600;
    letter-spacing: 0.3px;
}

.header__count {
    font-size: 13px;
    opacity: 0.85;
    background: rgba(255,255,255,0.15);
    padding: 4px 12px;
    border-radius: 12px;
}

/* ---------- Sidebar ---------- */
.sidebar {
    position: absolute;
    top: var(--header-height);
    left: 10px;
    width: var(--sidebar-width);
    max-height: calc(100vh - var(--header-height) - 20px);
    z-index: 90;
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 10px;
}

/* ---------- Search Panel ---------- */
.search-panel {
    background: var(--color-panel);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow);
}

.search-panel__title {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--color-header);
}

.search-panel__tabs {
    display: flex;
    gap: 0;
    margin-bottom: 12px;
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid var(--color-border);
}

.search-panel__tab {
    flex: 1;
    padding: 8px 6px;
    border: none;
    background: #f5f5f5;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    color: var(--color-text-secondary);
    transition: all 0.2s;
}

.search-panel__tab.active {
    background: var(--color-primary);
    color: #fff;
}

.search-panel__tab:hover:not(.active) {
    background: #e8e8e8;
}

.search-panel__input-wrap {
    position: relative;
    margin-bottom: 10px;
}

.search-panel__input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

.search-panel__input:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(46,125,50,0.12);
}

.search-panel__suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid var(--color-border);
    border-top: none;
    border-radius: 0 0 6px 6px;
    max-height: 180px;
    overflow-y: auto;
    z-index: 200;
    display: none;
}

.search-panel__suggestions.visible {
    display: block;
}

.search-panel__suggestion {
    padding: 8px 12px;
    cursor: pointer;
    font-size: 13px;
    transition: background 0.15s;
}

.search-panel__suggestion:hover {
    background: #e8f5e9;
}

.search-panel__btn {
    width: 100%;
    padding: 10px;
    background: var(--color-primary);
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}

.search-panel__btn:hover {
    background: var(--color-primary-hover);
}

.search-panel__error {
    color: var(--color-danger);
    font-size: 13px;
    margin-top: 8px;
    min-height: 20px;
}

/* ---------- Legend ---------- */
.legend {
    background: var(--color-panel);
    border-radius: var(--radius);
    padding: 14px 16px;
    box-shadow: var(--shadow);
}

.legend__title {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 10px;
    color: var(--color-header);
}

.legend__item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    margin-bottom: 6px;
    color: var(--color-text-secondary);
}

.legend__color {
    width: 18px;
    height: 18px;
    border-radius: 4px;
    flex-shrink: 0;
    border: 2px solid transparent;
}

.legend__color--green {
    background: rgba(0,170,0,0.4);
    border-color: #008800;
}

.legend__color--red {
    background: rgba(221,0,0,0.5);
    border-color: #AA0000;
}

.legend__color--yellow {
    background: rgba(255,215,0,0.7);
    border-color: #FFA500;
}

/* ---------- Map ---------- */
.map-container {
    position: absolute;
    top: var(--header-height);
    left: 0;
    right: 0;
    bottom: 0;
    background: #e8e8e8;
}

.map-container__loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    z-index: 10;
    color: var(--color-text-secondary);
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--color-border);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 12px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ---------- Layer Toggle ---------- */
.layer-toggle {
    position: absolute;
    top: calc(var(--header-height) + 10px);
    right: 10px;
    z-index: 80;
    display: flex;
    gap: 0;
    border-radius: 6px;
    overflow: hidden;
    box-shadow: var(--shadow);
}

.layer-toggle__btn {
    padding: 7px 14px;
    border: none;
    background: rgba(255,255,255,0.92);
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    color: var(--color-text-secondary);
    transition: all 0.2s;
}

.layer-toggle__btn.active {
    background: var(--color-primary);
    color: #fff;
}

.layer-toggle__btn:hover:not(.active) {
    background: rgba(255,255,255,1);
}

/* ---------- Mobile Info Panel ---------- */
.mobile-info {
    background: var(--color-panel);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow);
    position: relative;
}

.mobile-info__content {
    font-size: 13px;
    line-height: 1.6;
}

.mobile-info__content strong {
    color: var(--color-header);
}

.mobile-info__content a {
    color: var(--color-primary);
    text-decoration: none;
}

.mobile-info__content a:hover {
    text-decoration: underline;
}

.mobile-info__close {
    position: absolute;
    top: 8px;
    right: 8px;
    background: none;
    border: none;
    font-size: 16px;
    cursor: pointer;
    color: var(--color-text-secondary);
}

/* ---------- Mobile Search Button ---------- */
.mobile-search-btn {
    display: none;
    position: absolute;
    bottom: 20px;
    right: 20px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: var(--color-primary);
    color: #fff;
    border: none;
    font-size: 22px;
    cursor: pointer;
    z-index: 85;
    box-shadow: 0 3px 10px rgba(0,0,0,0.25);
}

/* ---------- Responsive ---------- */
@media (max-width: 768px) {
    :root {
        --sidebar-width: 100%;
    }

    .sidebar {
        left: 0;
        right: 0;
        width: 100%;
        margin-top: 0;
        max-height: none;
        flex-direction: column-reverse;
        gap: 6px;
        bottom: 0;
        top: auto;
    }

    .search-panel {
        border-radius: var(--radius) var(--radius) 0 0;
        padding: 12px;
    }

    .search-panel__title {
        font-size: 13px;
        margin-bottom: 8px;
    }

    .legend {
        display: none;
    }

    .layer-toggle {
        top: calc(var(--header-height) + 10px);
        right: 10px;
    }

    .mobile-search-btn {
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .sidebar .search-panel {
        display: none;
    }

    .sidebar.open .search-panel {
        display: block;
    }

    .header__title {
        font-size: 15px;
    }
}

@media (max-width: 480px) {
    :root {
        --header-height: 48px;
    }

    .header {
        padding: 0 12px;
    }

    .header__title {
        font-size: 14px;
    }

    .layer-toggle__btn {
        padding: 6px 10px;
        font-size: 11px;
    }
}

/* ---------- Yandex Maps overrides ---------- */
.ymaps3x0--balloon {
    font-family: inherit !important;
}

.ymaps3x0--balloon__content {
    font-size: 13px !important;
    line-height: 1.5 !important;
}

/* ---------- Balloon content styling ---------- */
.balloon-content {
    font-size: 13px;
    line-height: 1.6;
    min-width: 200px;
}

.balloon-content h4 {
    margin-bottom: 8px;
    color: #2c3e50;
    font-size: 15px;
}

.balloon-content p {
    margin-bottom: 4px;
}

.balloon-content a {
    color: #2e7d32;
    text-decoration: none;
}

.balloon-content a:hover {
    text-decoration: underline;
}

.balloon-content .debt {
    color: #c62828;
    font-weight: 500;
}
