/* ===== СБРОС И БАЗА ===== */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-gradient: linear-gradient(135deg, #6366f1 0%, #8b5cf6 40%, #a855f7 100%);
    --primary: #8b5cf6;
    --primary-soft: #ede9fe;
    --primary-dark: #4c1d95;
    --surface: #ffffff;
    --surface-soft: #f9fafb;
    --border-soft: #e5e7eb;
    --text-main: #111827;
    --text-muted: #6b7280;
    --shadow-soft: 0 18px 45px rgba(15, 23, 42, 0.22);
    --radius-lg: 18px;
    --radius-xl: 24px;
    --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

html, body {
    height: 100%;
}

body {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "SF Pro Display",
                 "Segoe UI", Roboto, sans-serif;
    background: var(--bg-gradient);
    color: var(--text-main);
    display: flex;
    justify-content: center;
    align-items: flex-start;
}

/* ===== ОСНОВНОЙ КОНТЕЙНЕР ===== */

.main-container {
    width: 100%;
    max-width: 1100px;
    padding: 32px 16px 40px;
    margin: 0 auto;
}

/* ===== HEADER ===== */

.header {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    border-radius: var(--radius-xl);
    padding: 26px 32px;
    box-shadow: var(--shadow-soft);
    border: 1px solid rgba(255, 255, 255, 0.7);
    position: relative;
    overflow: hidden;
    animation: headerIn 0.5s ease-out;
}

.header::before,
.header::after {
    content: "";
    position: absolute;
    border-radius: 999px;
    background: radial-gradient(circle at 10% 20%,
                rgba(129, 140, 248, 0.22) 0, transparent 65%);
    opacity: 0.8;
    pointer-events: none;
}

.header::before {
    width: 280px;
    height: 280px;
    top: -120px;
    right: -80px;
    animation: float 10s ease-in-out infinite;
}

.header::after {
    width: 220px;
    height: 220px;
    bottom: -110px;
    left: -60px;
    animation: float 12s ease-in-out infinite reverse;
}

.header-content {
    position: relative;
    z-index: 1;
    text-align: center;
}

.header-content h1 {
    font-weight: 800;
    font-size: 32px;
    letter-spacing: 0.03em;
    background: linear-gradient(120deg, #1f2933, #4c1d95);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 6px;
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.header-content h1 i {
    color: var(--primary);
    font-size: 28px;
    text-shadow: 0 0 18px rgba(129, 140, 248, 0.7);
    animation: iconPulse 2s infinite;
}

.header-content p {
    font-size: 14px;
    color: var(--text-muted);
    letter-spacing: 0.15em;
    text-transform: uppercase;
}

/* ===== ВЫБОР ПЛОЩАДКИ ===== */

.platform-selector-container {
    margin-top: 22px;
    background: rgba(255, 255, 255, 0.96);
    border-radius: var(--radius-xl);
    padding: 18px 22px;
    box-shadow: 0 16px 40px rgba(15, 23, 42, 0.18);
    border: 1px solid rgba(255, 255, 255, 0.85);
    animation: blockIn 0.5s ease-out 0.05s backwards;
}

.platform-selector {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    flex-wrap: wrap;
}

.platform-selector label {
    font-size: 15px;
    color: var(--text-main);
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
}

.platform-selector label i {
    color: var(--primary);
}

/* Кастомный нативный select */

#platformSelect {
    min-width: 220px;
    padding: 10px 42px 10px 14px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.9);
    background:
        radial-gradient(circle at top left, rgba(255,255,255,0.80), transparent 55%),
        rgba(249, 250, 251, 0.98);
    color: var(--text-main);
    font-size: 14px;
    font-weight: 500;
    outline: none;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
    box-shadow: 0 12px 32px rgba(15, 23, 42, 0.18);
    transition: var(--transition);
    background-image:
        url("data:image/svg+xml,%3Csvg width='16' height='16' xmlns='http://www.w3.org/2000/svg' fill='none' stroke='%238b5cf6' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='4 6 8 10 12 6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
}

/* стили пунктов раскрытого списка */
#platformSelect option {
    background-color: #f3f4ff;
    color: #111827;
    padding: 6px 10px;
}

#platformSelect option[value=""] {
    color: #9ca3af;
}

#platformSelect:hover {
    border-color: rgba(139, 92, 246, 0.6);
    box-shadow: 0 16px 40px rgba(79, 70, 229, 0.35);
    transform: translateY(-1px);
}

#platformSelect:focus,
#platformSelect:focus-visible {
    border-color: #8b5cf6;
    box-shadow:
        0 0 0 2px rgba(139, 92, 246, 0.6),
        0 18px 45px rgba(15, 23, 42, 0.32);
}

select::-ms-expand {
    display: none;
}

/* ===== ПОИСК ===== */

.search-container {
    margin-top: 24px;
}

.search-box {
    position: relative;
    max-width: 640px;
    margin: 0 auto;
}

.search-icon {
    position: absolute;
    left: 18px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--primary);
    font-size: 18px;
    opacity: 0.9;
    pointer-events: none;
}

#complexSearch {
    width: 100%;
    padding: 13px 16px 13px 46px;
    border-radius: 999px;
    border: 1px solid rgba(229, 231, 235, 0.9);
    background: rgba(255, 255, 255, 0.96);
    color: var(--text-main);
    font-size: 15px;
    outline: none;
    box-shadow: 0 15px 40px rgba(15, 23, 42, 0.25);
    transition: var(--transition);
}

#complexSearch::placeholder {
    color: #9ca3af;
}

#complexSearch:hover {
    border-color: var(--primary-soft);
    transform: translateY(-1px);
}

#complexSearch:focus {
    border-color: var(--primary);
    background: #ffffff;
    box-shadow:
        0 0 0 1px rgba(129, 140, 248, 0.75),
        0 18px 45px rgba(15, 23, 42, 0.3);
}

/* ===== DROPDOWN С ЖК ===== */

.search-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    background: rgba(249, 250, 251, 0.98);
    border-radius: 18px;
    border: 1px solid rgba(229, 231, 235, 0.9);
    box-shadow: 0 18px 45px rgba(15, 23, 42, 0.28);
    max-height: 420px;
    overflow-y: auto;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-6px) scale(0.98);
    transform-origin: top center;
    transition: var(--transition);
    z-index: 20;
}

/* эта .show используется JS — оставляем строго так */
.search-dropdown.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

.search-dropdown::-webkit-scrollbar {
    width: 8px;
}

.search-dropdown::-webkit-scrollbar-track {
    background: transparent;
}

.search-dropdown::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.9);
    border-radius: 999px;
}

/* элементы в списке ЖК */

.dropdown-item {
    padding: 10px 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    transition: var(--transition);
    border-bottom: 1px solid rgba(229, 231, 235, 0.9);
    background: transparent;
}

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

.dropdown-item strong {
    font-size: 14px;
    color: var(--text-main);
    font-weight: 600;
    display: block;
    margin-bottom: 3px;
}

.dropdown-item mark {
    background: rgba(129, 140, 248, 0.15);
    color: var(--primary-dark);
    border-radius: 4px;
    padding: 0 3px;
}

.region-badge {
    font-size: 11px;
    background: rgba(129, 140, 248, 0.08);
    border-radius: 999px;
    padding: 2px 8px;
    color: var(--primary-dark);
    margin-right: 6px;
}

.dropdown-item small {
    font-size: 11px;
    color: var(--text-muted);
}

.dropdown-item small code {
    background: #eef2ff;
    border-radius: 3px;
    padding: 0 4px;
    font-family: "JetBrains Mono", Consolas, monospace;
    font-size: 11px;
    color: #4c1d95;
}

.dropdown-item.no-results {
    justify-content: center;
    font-style: italic;
}

.dropdown-item:hover {
    background: #eef2ff;
    transform: translateY(-1px);
}

/* ===== РЕЗУЛЬТАТЫ ===== */

.results-container {
    margin-top: 26px;
    min-height: 180px;
}

.loading {
    display: none;
    align-items: center;
    justify-content: center;
    color: #e5e7eb;
    font-size: 14px;
}

.results-content {
    margin-top: 6px;
}

.results-content:empty {
    display: none;
}

/* карточка ЖК с анимацией появления */

.results-content:not(:empty) {
    max-width: 900px;
    margin: 0 auto;
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    border-radius: 22px;
    padding: 24px 26px 26px;
    box-shadow: 0 20px 55px rgba(15, 23, 42, 0.32);
    border: 1px solid rgba(255, 255, 255, 0.7);
    opacity: 0;
    transform: translateY(8px) scale(0.99);
    animation: resultIn 0.35s ease-out forwards;
}

/* шапка карточки */

.complex-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    border-bottom: 1px solid rgba(209, 213, 219, 0.8);
    padding-bottom: 14px;
    margin-bottom: 18px;
}

.complex-header h2 {
    font-size: 22px;
    font-weight: 700;
    background: linear-gradient(120deg, #111827, #4c1d95);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* бейдж платформы */

.platform-badge {
    padding: 6px 12px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: #ffffff;
    box-shadow: 0 8px 20px rgba(15, 23, 42, 0.35);
}

/* цвета по платформам (CIAN голубой) */

.platform-badge.cian {
    background: linear-gradient(135deg, #38bdf8, #0ea5e9);
}
.platform-badge.avito {
    background: linear-gradient(135deg, #22c55e, #0ea5e9);
}
.platform-badge.yandex {
    background: linear-gradient(135deg, #facc15, #f97316);
}

/* блок с основной инфой */

.complex-meta {
    margin-top: 10px;
    padding: 12px 14px;
    border-radius: 14px;
    background: linear-gradient(
        135deg,
        rgba(239, 246, 255, 0.95),
        rgba(238, 242, 255, 0.95)
    );
    border-left: 3px solid #8b5cf6;
    font-size: 13px;
}

.complex-meta p {
    margin: 3px 0;
    color: #111827;
}

.complex-meta strong {
    color: #4c1d95;
    font-weight: 600;
}

.complex-meta code {
    background: #eef2ff;
    border-radius: 4px;
    padding: 1px 6px;
    font-family: "JetBrains Mono", Consolas, monospace;
    font-size: 12px;
}

/* таблица корпусов */

.buildings-section {
    margin-top: 14px;
}

.buildings-section h3 {
    font-size: 15px;
    font-weight: 600;
    color: #111827;
    margin-bottom: 8px;
}

.buildings-table {
    overflow-x: auto;
    border-radius: 14px;
    border: 1px solid rgba(229, 231, 235, 0.9);
    box-shadow: 0 10px 28px rgba(15, 23, 42, 0.18);
}

.buildings-table table {
    width: 100%;
    border-collapse: collapse;
    background: #ffffff;
}

.buildings-table thead {
    background: linear-gradient(120deg, #6366f1, #8b5cf6);
    color: #ffffff;
}

.buildings-table th,
.buildings-table td {
    padding: 8px 10px;
    font-size: 13px;
    text-align: left;
}

.buildings-table th {
    font-weight: 600;
}

.buildings-table tbody tr:nth-child(even) {
    background: #f9fafb;
}

.buildings-table tbody tr:hover {
    background: #eef2ff;
}

.buildings-table code {
    background: #eef2ff;
    border-radius: 4px;
    padding: 1px 6px;
    font-family: "JetBrains Mono", Consolas, monospace;
    font-size: 12px;
}

.buildings-table a {
    color: #4f46e5;
    text-decoration: none;
    position: relative;
}
.buildings-table a::after {
    content: "";
    position: absolute;
    left: 0;
    bottom: -1px;
    width: 0;
    height: 1px;
    background: #4f46e5;
    transition: width 0.2s ease;
}
.buildings-table a:hover::after {
    width: 100%;
}

/* если корпусов нет */

.no-houses {
    text-align: center;
    padding: 24px 8px;
    color: #6b7280;
    font-size: 14px;
}
.no-houses i {
    font-size: 28px;
    opacity: 0.35;
    margin-bottom: 6px;
}

/* ===== АНИМАЦИИ ===== */

@keyframes headerIn {
    from {
        opacity: 0;
        transform: translateY(-18px) scale(0.99);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes blockIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes float {
    0%, 100% {
        transform: translate3d(0, 0, 0);
    }
    50% {
        transform: translate3d(10px, 14px, 0);
    }
}

@keyframes iconPulse {
    0%, 100% {
        transform: translateY(0) scale(1);
        filter: drop-shadow(0 0 6px rgba(129, 140, 248, 0.7));
    }
    50% {
        transform: translateY(-2px) scale(1.06);
        filter: drop-shadow(0 0 14px rgba(129, 140, 248, 1));
    }
}

@keyframes resultIn {
    0% {
        opacity: 0;
        transform: translateY(12px) scale(0.97);
    }
    60% {
        opacity: 1;
        transform: translateY(-2px) scale(1.01);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* ===== АДАПТИВ ===== */

@media (max-width: 768px) {
    .main-container {
        padding: 20px 12px 32px;
    }

    .header {
        padding: 22px 18px;
    }

    .header-content h1 {
        font-size: 24px;
    }

    .platform-selector {
        flex-direction: column;
        align-items: stretch;
    }

    #platformSelect {
        width: 100%;
    }

    .search-box {
        max-width: 100%;
    }

    .results-content:not(:empty) {
        padding: 18px 16px 20px;
    }

    .complex-header {
        flex-direction: column;
        align-items: flex-start;
    }
}
