/* Стили изолированы классом .realty-app-wrapper, 
   чтобы не ломать глобальные стили из style.css 
*/

:root {
    --bg-dark: #0f0f13;
    --bg-panel: rgba(20, 20, 25, 0.6);
    --accent: #ffb400;
    --accent-hover: #ffca3a;
    --text-main: #ffffff;
    --text-muted: rgba(255, 255, 255, 0.6);
    --border-glass: rgba(255, 255, 255, 0.08);
    --color-avail: #4facfe;
    --color-occ: #f5576c;
    --color-gang: #cc00ff;
}

body.realty-body {
    background: #121212;
    background-image: 
        radial-gradient(circle at 15% 30%, rgba(255, 180, 0, 0.05) 0%, transparent 50%),
        radial-gradient(circle at 85% 70%, rgba(79, 172, 254, 0.05) 0%, transparent 50%);
    font-family: 'Montserrat', sans-serif;
    color: var(--text-main);
    margin: 0;
    padding-top: 80px; /* Отступ для fixed header из style.css */
}

/* Обёртка приложения */
.realty-app-wrapper {
    min-height: calc(100vh - 80px);
    padding: 30px 20px;
    box-sizing: border-box;
}

.realty-container {
    max-width: 1500px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 25px;
}

/* --- ШАПКА И СТАТИСТИКА --- */
.realty-header-block {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.page-title {
    font-family: 'Druk Wide', sans-serif;
    font-size: clamp(1.8rem, 4vw, 2.5rem);
    margin: 0;
    text-transform: uppercase;
    letter-spacing: -0.5px;
}

.stats-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 15px;
}

.stat-box {
    background: var(--bg-panel);
    border: 1px solid var(--border-glass);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 16px;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 15px;
    transition: transform 0.3s ease, border-color 0.3s ease;
}

.stat-box:hover {
    transform: translateY(-3px);
    border-color: rgba(255, 255, 255, 0.2);
}

.stat-icon {
    width: 50px;
    height: 50px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.05);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: var(--text-main);
}

.stat-icon.avail { color: var(--color-avail); background: rgba(79, 172, 254, 0.1); }
.stat-icon.occ { color: var(--color-occ); background: rgba(245, 87, 108, 0.1); }
.stat-icon.gang { color: var(--color-gang); background: rgba(204, 0, 255, 0.1); }

.stat-val {
    font-family: 'Druk Wide', sans-serif;
    font-size: 1.5rem;
    line-height: 1.2;
}

.stat-name {
    font-size: 0.85rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 500;
}

/* --- КОНТРОЛЫ (Фильтры, Поиск) --- */
.controls-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
    background: var(--bg-panel);
    border: 1px solid var(--border-glass);
    backdrop-filter: blur(10px);
    padding: 15px 20px;
    border-radius: 16px;
}

.filter-group {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.glass-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-muted);
    padding: 10px 20px;
    border-radius: 30px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: 'Montserrat', sans-serif;
}

.glass-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-main);
}

.glass-btn.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #000;
}

.toggles-group {
    display: flex;
    gap: 20px;
}

.toggle-switch {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    user-select: none;
}

.toggle-switch input {
    display: none;
}

.slider {
    position: relative;
    width: 40px;
    height: 20px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    transition: 0.3s;
}

.slider::before {
    content: '';
    position: absolute;
    height: 14px;
    width: 14px;
    left: 3px;
    bottom: 3px;
    background: var(--text-muted);
    border-radius: 50%;
    transition: 0.3s;
}

.toggle-switch input:checked + .slider {
    background: var(--accent);
}

.toggle-switch input:checked + .slider::before {
    transform: translateX(20px);
    background: #000;
}

.label-text {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-muted);
}

.search-wrapper {
    position: relative;
    flex-grow: 1;
    max-width: 300px;
}

.glass-search {
    width: 100%;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 10px 15px 10px 35px;
    border-radius: 30px;
    color: white;
    outline: none;
    font-family: 'Montserrat', sans-serif;
    font-size: 0.9rem;
    transition: border-color 0.3s ease;
    box-sizing: border-box;
}

.glass-search:focus {
    border-color: var(--accent);
}

.search-wrapper i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: rgba(255, 255, 255, 0.4);
}

/* --- ОСНОВНОЙ КОНТЕНТ (Карта + Сайдбар) --- */
.realty-main-content {
    display: grid;
    grid-template-columns: 1fr 380px;
    gap: 25px;
    height: 65vh; /* Фиксированная высота для скролла списка */
    min-height: 500px;
}

/* КАРТА */
.map-section {
    background: #000;
    border-radius: 16px;
    border: 1px solid var(--border-glass);
    overflow: hidden;
    position: relative;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Запрет выделения на карте */
.map-wrapper {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    user-select: none;
    -webkit-user-drag: none;
}

.map-image {
    width: 100%;
    height: 100%;
    object-fit: contain;
    pointer-events: none;
}

.map-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none; /* События клика проходят на дочерние элементы */
}

/* МАРКЕРЫ И ЗОНЫ (Оптимизированные) */
.h-marker {
    position: absolute;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    border: 2px solid rgba(255,255,255,0.8);
    cursor: pointer;
    pointer-events: auto;
    transition: transform 0.2s;
    box-shadow: 0 2px 5px rgba(0,0,0,0.5);
    z-index: 10;
}

.h-marker:hover {
    transform: translate(-50%, -50%) scale(1.8);
    z-index: 100;
}

.h-marker.avail { background: var(--color-avail); }
.h-marker.occ { background: var(--color-occ); border-color: transparent; width: 8px; height: 8px;}
.h-marker.occ:hover { width: 12px; height: 12px; border-color: white;}

.g-zone {
    position: absolute;
    pointer-events: auto;
    cursor: pointer;
    border: 2px solid;
    border-radius: 4px;
    transition: background-color 0.2s, border-width 0.2s;
}

.g-zone:hover {
    border-width: 3px;
    z-index: 50;
    filter: brightness(1.2);
}

/* ГЛОБАЛЬНЫЙ ТУЛТИП (Критично для производительности) */
.glass-tooltip {
    display: none;
    position: absolute;
    background: rgba(15, 15, 19, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    padding: 10px 15px;
    border-radius: 8px;
    color: white;
    font-size: 0.85rem;
    pointer-events: none;
    z-index: 1000;
    white-space: nowrap;
    box-shadow: 0 5px 15px rgba(0,0,0,0.5);
    transform: translate(-50%, -100%);
    margin-top: -10px;
}

.tt-title { font-weight: 700; color: var(--accent); margin-bottom: 5px; }
.tt-row { color: var(--text-muted); margin-bottom: 2px; }
.tt-row span { color: white; font-weight: 500; }

/* БОКОВАЯ ПАНЕЛЬ (Список) */
.sidebar-section {
    background: var(--bg-panel);
    border: 1px solid var(--border-glass);
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    backdrop-filter: blur(10px);
}

.sidebar-header {
    padding: 20px;
    background: rgba(255, 255, 255, 0.03);
    border-bottom: 1px solid var(--border-glass);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sidebar-header h3 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.list-count {
    color: var(--accent);
    font-size: 0.85rem;
    font-weight: 600;
    background: rgba(255, 180, 0, 0.1);
    padding: 4px 10px;
    border-radius: 12px;
}

.houses-list {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    /* Стилизация скроллбара */
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.2) transparent;
}

.houses-list::-webkit-scrollbar { width: 6px; }
.houses-list::-webkit-scrollbar-track { background: transparent; }
.houses-list::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.2); border-radius: 3px; }
.houses-list::-webkit-scrollbar-thumb:hover { background: var(--accent); }

/* Карточка дома в списке (стиль как в music.css) */
.h-card {
    display: flex;
    align-items: center;
    padding: 12px 15px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid transparent;
    border-radius: 12px;
    cursor: pointer;
    transition: background 0.2s, transform 0.2s;
}

.h-card:hover {
    background: rgba(255, 255, 255, 0.06);
    transform: translateY(-2px);
}

.h-card.highlight {
    background: rgba(255, 180, 0, 0.1);
    border-color: rgba(255, 180, 0, 0.3);
}

.hc-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 15px;
    flex-shrink: 0;
    font-size: 1.1rem;
}

.hc-icon.avail { background: rgba(79, 172, 254, 0.15); color: var(--color-avail); }
.hc-icon.occ { background: rgba(245, 87, 108, 0.15); color: var(--color-occ); }

.hc-info {
    flex: 1;
    min-width: 0;
}

.hc-title {
    font-weight: 600;
    font-size: 0.95rem;
    margin-bottom: 3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.hc-owner {
    font-size: 0.8rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.hc-price {
    font-family: 'Druk Wide', sans-serif;
    font-size: 0.85rem;
    color: var(--accent);
    margin-left: 10px;
    white-space: nowrap;
}

.load-more-trigger {
    text-align: center;
    padding: 15px;
    color: var(--text-muted);
    font-size: 0.9rem;
    display: none; /* Показывается через JS когда грузим */
}

/* --- МОДАЛЬНЫЕ ОКНА --- */
.r-modal {
    display: none;
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.8);
    backdrop-filter: blur(5px);
    z-index: 9999;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.r-modal.show {
    display: flex;
    opacity: 1;
}

.r-modal-content {
    background: linear-gradient(135deg, #1a1a1a 0%, #252525 100%);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 20px;
    width: 90%;
    max-width: 450px;
    box-shadow: 0 25px 50px rgba(0,0,0,0.5);
    transform: translateY(20px);
    transition: transform 0.3s ease;
}

.r-modal.show .r-modal-content {
    transform: translateY(0);
}

.r-modal-header {
    padding: 20px 25px;
    border-bottom: 1px solid var(--border-glass);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.r-modal-header h3 { margin: 0; font-family: 'Druk Wide', sans-serif; font-size: 1rem; color: var(--accent); }
.r-modal-close { background: none; border: none; color: var(--text-muted); font-size: 1.2rem; cursor: pointer; transition: 0.2s; }
.r-modal-close:hover { color: white; transform: rotate(90deg); }

.r-modal-body { padding: 25px; }

.info-grid { display: flex; flex-direction: column; gap: 15px; }
.info-row { display: flex; justify-content: space-between; align-items: center; padding-bottom: 10px; border-bottom: 1px solid rgba(255,255,255,0.05); }
.info-row.full { flex-direction: column; align-items: flex-start; gap: 8px; }
.info-row span:first-child { color: var(--text-muted); font-size: 0.9rem; }
.info-row strong { font-size: 1rem; }
.text-accent { color: var(--accent); font-family: 'Druk Wide', sans-serif;}

.badge { padding: 4px 10px; border-radius: 12px; font-size: 0.8rem; font-weight: 600; }
.badge.avail { background: rgba(79, 172, 254, 0.15); color: var(--color-avail); }
.badge.occ { background: rgba(245, 87, 108, 0.15); color: var(--color-occ); }

code { background: rgba(0,0,0,0.5); padding: 8px 12px; border-radius: 8px; color: #00ff88; font-family: monospace; letter-spacing: 1px; width: 100%; box-sizing: border-box; text-align: center; }

.r-modal-footer { margin-top: 25px; display: flex; justify-content: center; }
.glass-btn.primary { background: var(--accent); color: #000; border: none; width: 100%; justify-content: center; padding: 12px; }
.glass-btn.primary:hover { background: var(--accent-hover); transform: translateY(-2px); }

/* --- УВЕДОМЛЕНИЯ --- */
.r-toast {
    position: fixed; top: 100px; right: 20px;
    background: rgba(46, 204, 113, 0.9);
    color: white; padding: 12px 20px; border-radius: 10px;
    backdrop-filter: blur(5px); z-index: 10000;
    transform: translateX(120%); transition: transform 0.3s ease;
    display: flex; align-items: center; gap: 10px; font-weight: 500;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
}
.r-toast.show { transform: translateX(0); }
.r-toast.error { background: rgba(231, 76, 60, 0.9); }

/* --- АДАПТИВНОСТЬ --- */
@media (max-width: 1024px) {
    .realty-main-content {
        grid-template-columns: 1fr;
        height: auto;
    }
    .map-section { height: 500px; }
    .sidebar-section { height: 500px; }
}

@media (max-width: 768px) {
    body.realty-body { padding-top: 60px; }
    .realty-app-wrapper { padding: 15px 10px; }
    .controls-row { flex-direction: column; align-items: stretch; }
    .search-wrapper { max-width: 100%; }
    .map-section, .sidebar-section { height: 400px; }
    .glass-tooltip { display: none !important; /* Отключаем тултип на телефонах, инфа по клику */ }
}