/* Основные стили */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #1a1a2e;
    color: #eee;
    height: 100vh;
    overflow: hidden;
}

/* Контейнер приложения */
.app-container {
    display: flex;
    height: 100vh;
}

/* Боковое меню */
.sidebar {
    width: 350px;
    background: linear-gradient(180deg, #16213e 0%, #0f3460 100%);
    padding: 20px;
    overflow-y: auto;
    border-right: 2px solid #e94560;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.sidebar h1 {
    font-size: 1.5rem;
    color: #e94560;
    text-align: center;
    margin-bottom: 10px;
    border-bottom: 2px solid #e94560;
    padding-bottom: 10px;
}

/* Секции меню */
.menu-section {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    padding: 15px;
    border: 1px solid rgba(233, 69, 96, 0.3);
}

.menu-section h3 {
    font-size: 1rem;
    color: #e94560;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.menu-section h3 i {
    font-size: 0.9rem;
}

/* Выбор проекта */
.project-select {
    width: 100%;
    padding: 10px;
    border-radius: 6px;
    border: 1px solid #e94560;
    background: #1a1a2e;
    color: #fff;
    font-size: 0.9rem;
    cursor: pointer;
    outline: none;
}

.project-select:focus {
    box-shadow: 0 0 10px rgba(233, 69, 96, 0.5);
}

.project-select option {
    background: #1a1a2e;
    color: #fff;
}

/* Поиск по анализам */
.search-wrapper {
    position: relative;
    margin-bottom: 10px;
}

.search-input {
    width: 100%;
    padding: 10px 35px 10px 12px;
    border-radius: 6px;
    border: 1px solid rgba(233, 69, 96, 0.3);
    background: #1a1a2e;
    color: #fff;
    font-size: 0.9rem;
    outline: none;
    transition: all 0.3s;
}

.search-input:focus {
    border-color: #e94560;
    box-shadow: 0 0 10px rgba(233, 69, 96, 0.3);
}

.search-input::placeholder {
    color: #888;
}

.search-icon {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #e94560;
    font-size: 0.9rem;
}

/* Галочки параметров */
.checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.checkbox-item {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    padding: 8px;
    border-radius: 6px;
    transition: background 0.2s;
}

.checkbox-item:hover {
    background: rgba(233, 69, 96, 0.1);
}

.checkbox-item input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: #e94560;
    cursor: pointer;
}

.checkbox-item label {
    cursor: pointer;
    font-size: 0.9rem;
    flex: 1;
}

/* Кнопки */
.btn {
    padding: 12px 20px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.95rem;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-weight: 500;
}

.btn-primary {
    background: linear-gradient(135deg, #e94560 0%, #c73e54 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(233, 69, 96, 0.4);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Основной контент */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Карта */
.map-container {
    flex: 1;
    position: relative;
    min-height: 50%;
}

#map {
    width: 100%;
    height: 100%;
}

/* Информационная панель над картой */
.info-panel {
    background: #16213e;
    padding: 10px 20px;
    border-bottom: 1px solid #e94560;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.info-panel .selected-project {
    color: #e94560;
    font-weight: bold;
}

.info-panel .stats {
    display: flex;
    gap: 20px;
    font-size: 0.9rem;
}

.info-panel .stats span {
    color: #aaa;
}

.info-panel .stats strong {
    color: #fff;
}

/* Таблица под картой */
.table-container {
    height: 300px;
    background: #16213e;
    border-top: 2px solid #e94560;
    overflow: auto;
}

.table-container h3 {
    padding: 15px 20px;
    background: #0f3460;
    color: #e94560;
    font-size: 1rem;
    position: sticky;
    top: 0;
    z-index: 10;
}

.table-header {
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    user-select: none;
    transition: background 0.2s;
}

.table-header:hover {
    background: #1a4a7a;
}

.table-toggle-icon {
    transition: transform 0.3s;
    font-size: 0.9rem;
}

.table-container.collapsed .table-toggle-icon {
    transform: rotate(-90deg);
}

.table-container.collapsed .data-table {
    display: none;
}

.table-container.collapsed {
    height: auto;
    flex: 0 0 auto;
}

data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

data-table thead {
    position: sticky;
    top: 46px;
    z-index: 9;
}

data-table th {
    background: #1a1a2e;
    color: #e94560;
    padding: 12px 10px;
    text-align: left;
    font-weight: 600;
    border-bottom: 2px solid #e94560;
    white-space: nowrap;
}

data-table td {
    padding: 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    color: #ddd;
}

data-table tr:hover td {
    background: rgba(233, 69, 96, 0.1);
}

data-table tr.selected-row td {
    background: rgba(233, 69, 96, 0.2);
}

/* Стили для попапов на карте */
.leaflet-popup-content-wrapper {
    background: #16213e;
    color: #fff;
    border-radius: 8px;
    border: 1px solid #e94560;
}

.leaflet-popup-tip {
    background: #16213e;
}

.popup-content {
    min-width: 200px;
}

.popup-content h4 {
    color: #e94560;
    margin-bottom: 8px;
    font-size: 1rem;
}

.popup-content p {
    margin: 4px 0;
    font-size: 0.85rem;
}

.popup-content .price {
    color: #4ade80;
    font-weight: bold;
}

/* Маркеры на карте - компактные с иконками */
.custom-marker {
    width: 28px !important;
    height: 28px !important;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    color: white;
    border: 2px solid white;
    box-shadow: 0 2px 8px rgba(0,0,0,0.4);
    transition: all 0.2s;
    cursor: pointer;
}

.custom-marker:hover {
    transform: scale(1.15);
    z-index: 1000 !important;
}

/* Исследуемый проект - звезда */
.marker-selected {
    background: linear-gradient(135deg, #FFD700 0%, #FFA500 100%);
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.8);
    border-color: #FFF;
    z-index: 1001 !important;
}

/* Классы жилья - разные цвета */
.marker-elite {
    background: linear-gradient(135deg, #9C27B0 0%, #E91E63 100%);
    box-shadow: 0 2px 8px rgba(156, 39, 176, 0.6);
}

.marker-business {
    background: linear-gradient(135deg, #e94560 0%, #c73e54 100%);
    box-shadow: 0 2px 8px rgba(233, 69, 96, 0.6);
}

.marker-premium {
    background: linear-gradient(135deg, #a855f7 0%, #7c3aed 100%);
    box-shadow: 0 2px 8px rgba(168, 85, 247, 0.6);
}

.marker-comfort {
    background: linear-gradient(135deg, #5DADE2 0%, #3498db 100%);
    box-shadow: 0 2px 8px rgba(93, 173, 226, 0.6);
}

.marker-econom {
    background: linear-gradient(135deg, #58D68D 0%, #27ae60 100%);
    box-shadow: 0 2px 8px rgba(88, 214, 141, 0.6);
}

/* По умолчанию */
.marker-default {
    background: linear-gradient(135deg, #95a5a6 0%, #7f8c8d 100%);
    box-shadow: 0 2px 8px rgba(149, 165, 166, 0.6);
}

/* Легенда карты */
.map-legend {
    position: absolute;
    bottom: 20px;
    right: 20px;
    background: rgba(22, 33, 62, 0.95);
    padding: 15px;
    border-radius: 8px;
    border: 1px solid #e94560;
    z-index: 1000;
    max-height: 400px;
    overflow-y: auto;
    max-width: 280px;
}

.map-legend h4 {
    color: #e94560;
    margin-bottom: 10px;
    font-size: 0.9rem;
    border-bottom: 1px solid rgba(233, 69, 96, 0.3);
    padding-bottom: 8px;
}

.legend-section {
    margin-bottom: 12px;
}

.legend-section-title {
    font-weight: bold;
    color: #fff;
    font-size: 0.85rem;
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.legend-item {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin: 6px 0;
    font-size: 0.8rem;
    padding: 4px 0;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.legend-item:last-child {
    border-bottom: none;
}

.legend-icon {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 9px;
    color: white;
    border: 2px solid white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
    flex-shrink: 0;
    margin-top: 2px;
}

.legend-text {
    color: #ddd;
    line-height: 1.3;
}

.legend-project-name {
    color: #fff;
    font-weight: 500;
}

.legend-icon.marker-selected {
    background: linear-gradient(135deg, #FFD700 0%, #FFA500 100%);
}

.legend-icon.marker-elite {
    background: linear-gradient(135deg, #9C27B0 0%, #E91E63 100%);
}

.legend-icon.marker-business {
    background: linear-gradient(135deg, #e94560 0%, #c73e54 100%);
}

.legend-icon.marker-premium {
    background: linear-gradient(135deg, #a855f7 0%, #7c3aed 100%);
}

.legend-icon.marker-comfort {
    background: linear-gradient(135deg, #5DADE2 0%, #3498db 100%);
}

.legend-icon.marker-econom {
    background: linear-gradient(135deg, #58D68D 0%, #27ae60 100%);
}

/* Загрузка */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #e94560;
    font-size: 1.2rem;
}

.spinner {
    border: 3px solid rgba(233, 69, 96, 0.3);
    border-top: 3px solid #e94560;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    animation: spin 1s linear infinite;
    margin-right: 10px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Скрыть атрибуцию Leaflet */
.leaflet-control-attribution {
    display: none !important;
}

/* Постоянные подписи на маркерах */
.marker-label {
    background: rgba(22, 33, 62, 0.95) !important;
    border: 1px solid #e94560 !important;
    border-radius: 4px !important;
    padding: 4px 8px !important;
    font-size: 11px !important;
    color: #fff !important;
    line-height: 1.4 !important;
    box-shadow: 0 2px 8px rgba(0,0,0,0.5) !important;
    white-space: nowrap !important;
    z-index: 1000 !important;
}

.marker-label strong {
    color: #e94560;
    font-size: 12px;
}

/* Скрываем стрелку tooltip */
.marker-label:before {
    display: none !important;
}

/* Фон подписи */
.leaflet-tooltip-top:before {
    display: none !important;
}

/* Скроллбар */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #1a1a2e;
}

::-webkit-scrollbar-thumb {
    background: #e94560;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #c73e54;
}

/* Адаптивность */
@media (max-width: 1024px) {
    .sidebar {
        width: 300px;
    }
}

@media (max-width: 768px) {
    .app-container {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
        height: auto;
        max-height: 40vh;
        border-right: none;
        border-bottom: 2px solid #e94560;
    }
    
    .table-container {
        height: 200px;
    }
}

/* Скрытые элементы */
.hidden {
    display: none !important;
}

/* Теги/бейджи */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 500;
}

.badge-class-business {
    background: rgba(233, 69, 96, 0.2);
    color: #e94560;
}

.badge-class-comfort {
    background: rgba(93, 173, 226, 0.2);
    color: #5DADE2;
}

.badge-class-premium {
    background: rgba(168, 85, 247, 0.2);
    color: #a855f7;
}
