/* BakuML — bina.az-inspired marketplace styling */

:root {
    --navy: #1a3a5c;
    --navy-dark: #122a44;
    --blue: #2980b9;
    --blue-light: #3498db;
    --green: #27ae60;
    --green-light: #2ecc71;
    --orange: #f39c12;
    --red: #e74c3c;
    --gray-100: #f8f9fa;
    --gray-200: #e9ecef;
    --gray-300: #dee2e6;
    --gray-500: #6c757d;
    --gray-700: #495057;
    --gray-900: #212529;
    --radius: 8px;
    --shadow: 0 2px 8px rgba(0,0,0,0.08);
    --shadow-hover: 0 4px 16px rgba(0,0,0,0.12);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    color: var(--gray-900);
    background: var(--gray-100);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Navbar */
.navbar {
    background: var(--navy);
    color: white;
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}
.nav-inner {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 24px;
    height: 56px;
    display: flex;
    align-items: center;
    gap: 32px;
}
.nav-logo {
    text-decoration: none;
    font-size: 22px;
    font-weight: 700;
}
.logo-baku { color: white; }
.logo-ml { color: var(--blue-light); }
.nav-links { display: flex; gap: 4px; }
.nav-link {
    color: rgba(255,255,255,0.75);
    text-decoration: none;
    padding: 8px 16px;
    border-radius: 6px;
    font-weight: 500;
    font-size: 14px;
    transition: all 0.15s;
}
.nav-link:hover { color: white; background: rgba(255,255,255,0.1); }
.nav-link.active { color: white; background: rgba(255,255,255,0.15); }

/* Main content */
.main-content {
    flex: 1;
    max-width: 1400px;
    width: 100%;
    margin: 0 auto;
    padding: 24px;
}

/* Footer */
.footer {
    background: var(--navy-dark);
    color: rgba(255,255,255,0.6);
    padding: 16px 24px;
    font-size: 13px;
    text-align: center;
}
.footer-inner { max-width: 1400px; margin: 0 auto; }
.footer-sep { margin: 0 8px; opacity: 0.4; }

/* Listing grid page layout */
.listing-page { display: flex; gap: 24px; }
.filter-sidebar {
    width: 260px;
    flex-shrink: 0;
    background: white;
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    height: fit-content;
    position: sticky;
    top: 80px;
}
.listing-main { flex: 1; min-width: 0; }

/* Filters */
.filter-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--navy);
}
.filter-group { margin-bottom: 16px; }
.filter-label {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--gray-500);
    margin-bottom: 6px;
    display: block;
}
.filter-select, .filter-input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--gray-300);
    border-radius: 6px;
    font-size: 14px;
    background: white;
    color: var(--gray-900);
}
.filter-select:focus, .filter-input:focus {
    outline: none;
    border-color: var(--blue);
}
.filter-row {
    display: flex;
    gap: 8px;
}
.filter-row .filter-input { width: 50%; }

.filter-btn {
    width: 100%;
    padding: 10px;
    background: var(--navy);
    color: white;
    border: none;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    font-size: 14px;
    margin-top: 8px;
}
.filter-btn:hover { background: var(--navy-dark); }

/* Sort bar */
.sort-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}
.results-count {
    font-size: 14px;
    color: var(--gray-500);
}
.sort-select {
    padding: 6px 12px;
    border: 1px solid var(--gray-300);
    border-radius: 6px;
    font-size: 13px;
    background: white;
}

/* Card grid */
.card-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}
@media (max-width: 1024px) { .card-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 640px) {
    .card-grid { grid-template-columns: 1fr; }
    .listing-page { flex-direction: column; }
    .filter-sidebar { width: 100%; position: static; }
}

/* Listing card */
.listing-card {
    background: white;
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: box-shadow 0.2s, transform 0.2s;
    cursor: pointer;
    text-decoration: none;
    color: inherit;
    display: block;
}
.listing-card:hover {
    box-shadow: var(--shadow-hover);
    transform: translateY(-2px);
}
.card-image {
    width: 100%;
    height: 180px;
    background: var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--gray-500);
    font-size: 13px;
    position: relative;
    overflow: hidden;
}
.card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.card-score {
    position: absolute;
    top: 8px;
    right: 8px;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 700;
    color: white;
}
.score-high { background: var(--green); }
.score-mid { background: var(--orange); }
.score-low { background: var(--red); }

.card-body { padding: 14px; }
.card-price {
    font-size: 20px;
    font-weight: 700;
    color: var(--navy);
    margin-bottom: 4px;
}
.card-price-m2 {
    font-size: 13px;
    color: var(--gray-500);
    margin-bottom: 8px;
}
.card-specs {
    display: flex;
    gap: 12px;
    font-size: 13px;
    color: var(--gray-700);
    margin-bottom: 8px;
}
.card-specs span { white-space: nowrap; }
.card-district {
    font-size: 13px;
    color: var(--gray-500);
}
.card-analytics {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--gray-200);
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}
.card-tag {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 10px;
    background: var(--gray-100);
    color: var(--gray-700);
    white-space: nowrap;
}
.tag-positive { background: #e8f5e9; color: #2e7d32; }
.tag-negative { background: #fce4ec; color: #c62828; }
.tag-neutral { background: #e3f2fd; color: #1565c0; }

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    gap: 4px;
    margin-top: 24px;
}
.page-btn {
    padding: 8px 14px;
    border: 1px solid var(--gray-300);
    background: white;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    color: var(--gray-700);
}
.page-btn:hover { background: var(--gray-100); }
.page-btn.active {
    background: var(--navy);
    color: white;
    border-color: var(--navy);
}
.page-btn:disabled { opacity: 0.4; cursor: default; }

/* Detail page */
.detail-page { display: flex; gap: 24px; }
.detail-main { flex: 1; min-width: 0; }
.detail-sidebar {
    width: 380px;
    flex-shrink: 0;
}
@media (max-width: 900px) {
    .detail-page { flex-direction: column; }
    .detail-sidebar { width: 100%; }
}

.gallery-wrapper { margin-bottom: 20px; }
.detail-gallery {
    background: var(--gray-200);
    border-radius: var(--radius);
    height: 450px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--gray-500);
    overflow: hidden;
    position: relative;
}
.detail-gallery img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #000;
}
.gallery-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0,0,0,0.5);
    color: white;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    font-size: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    z-index: 2;
}
.gallery-btn:hover { background: rgba(0,0,0,0.8); }
.gallery-prev { left: 12px; }
.gallery-next { right: 12px; }
.gallery-counter {
    position: absolute;
    bottom: 12px;
    right: 12px;
    background: rgba(0,0,0,0.6);
    color: white;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 13px;
    z-index: 2;
}
.gallery-thumbs {
    display: flex;
    gap: 6px;
    margin-top: 8px;
    overflow-x: auto;
    padding-bottom: 4px;
}
.gallery-thumb {
    width: 72px;
    height: 54px;
    object-fit: cover;
    border-radius: 4px;
    cursor: pointer;
    opacity: 0.5;
    transition: opacity 0.2s;
    flex-shrink: 0;
    border: 2px solid transparent;
}
.gallery-thumb:hover { opacity: 0.8; }
.gallery-thumb.active { opacity: 1; border-color: var(--blue); }

.detail-info {
    background: white;
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
}
.detail-price {
    font-size: 28px;
    font-weight: 700;
    color: var(--navy);
    margin-bottom: 4px;
}
.detail-price-m2 {
    font-size: 15px;
    color: var(--gray-500);
    margin-bottom: 16px;
}
.detail-specs-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 16px;
}
.spec-item {
    padding: 12px;
    background: var(--gray-100);
    border-radius: 6px;
}
.spec-label {
    font-size: 11px;
    text-transform: uppercase;
    color: var(--gray-500);
    margin-bottom: 4px;
}
.spec-value { font-size: 16px; font-weight: 600; }

.detail-map-mini {
    height: 200px;
    border-radius: 6px;
    margin-top: 16px;
}

/* Analytics sidebar */
.analytics-panel {
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}
.analytics-header {
    background: var(--navy);
    color: white;
    padding: 16px 20px;
    font-weight: 600;
    font-size: 15px;
}
.analytics-body { padding: 20px; }

.score-dial {
    text-align: center;
    margin-bottom: 20px;
}
.score-number {
    font-size: 48px;
    font-weight: 700;
    line-height: 1;
}
.score-label {
    font-size: 13px;
    color: var(--gray-500);
    margin-top: 4px;
}

.analytics-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid var(--gray-200);
    font-size: 14px;
}
.analytics-row:last-child { border-bottom: none; }
.analytics-row-label { color: var(--gray-500); }
.analytics-row-value { font-weight: 600; }

.price-bar {
    margin: 16px 0;
    height: 8px;
    background: var(--gray-200);
    border-radius: 4px;
    position: relative;
}
.price-bar-fill {
    height: 100%;
    border-radius: 4px;
    background: linear-gradient(90deg, var(--green), var(--orange), var(--red));
}
.price-bar-marker {
    position: absolute;
    top: -4px;
    width: 3px;
    height: 16px;
    background: var(--navy);
    border-radius: 1px;
    transform: translateX(-50%);
}
.price-bar-labels {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: var(--gray-500);
    margin-top: 4px;
}

.analytics-section {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--gray-200);
}
.analytics-section-title {
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--gray-500);
    margin-bottom: 10px;
}

/* Map page */
.map-page { display: flex; height: calc(100vh - 56px - 60px); margin: -24px; }
.map-sidebar {
    width: 300px;
    background: white;
    padding: 20px;
    overflow-y: auto;
    box-shadow: 2px 0 8px rgba(0,0,0,0.08);
    z-index: 500;
}
.map-container {
    flex: 1;
    min-width: 0;
}
#map { width: 100%; height: 100%; }

@media (max-width: 768px) {
    .map-page { flex-direction: column; }
    .map-sidebar { width: 100%; height: auto; max-height: 200px; }
}

/* Loading spinner */
.loading {
    text-align: center;
    padding: 60px 20px;
    color: var(--gray-500);
}
.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--gray-200);
    border-top-color: var(--blue);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 12px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Empty state */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--gray-500);
}
.empty-state p { margin-top: 8px; font-size: 14px; }

/* Legend for map */
.map-legend {
    margin-top: 16px;
    padding: 12px;
    background: var(--gray-100);
    border-radius: 6px;
}
.legend-gradient {
    height: 12px;
    border-radius: 3px;
    margin-bottom: 4px;
}
.legend-labels {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: var(--gray-500);
}

/* Back link */
.back-link {
    display: inline-block;
    margin-bottom: 16px;
    color: var(--blue);
    text-decoration: none;
    font-size: 14px;
}
.back-link:hover { text-decoration: underline; }
