/* ── HuisHunter Dashboard — Design System ──────────────────────────── */

:root {
    --bg: #F5F5F5;
    --card: #FFFFFF;
    --primary: #2563EB;
    --primary-light: #EFF6FF;
    --primary-hover: #1D4ED8;
    --good: #10B981;
    --good-light: #ECFDF5;
    --fair: #F59E0B;
    --fair-light: #FFFBEB;
    --expensive: #EF4444;
    --expensive-light: #FEF2F2;
    --visited: #6366F1;
    --fav-blue: #3B82F6;
    --fav-purple: #8B5CF6;
    --fav-green: #10B981;
    --fav-orange: #F97316;
    --fav-red: #EF4444;
    --fav-yellow: #EAB308;
    --text: #111827;
    --text-secondary: #6B7280;
    --text-muted: #9CA3AF;
    --border: #E5E7EB;
    --row-hover: #F9FAFB;
    --row-active: #EFF6FF;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
    --shadow-lg: 0 10px 30px rgba(0,0,0,0.1);
    --shadow-popup: 0 8px 30px rgba(0,0,0,0.18);
    --radius: 14px;
    --radius-sm: 8px;
    --radius-pill: 100px;
    --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

    --status-new: #E5E7EB; --status-new-text: #6B7280;
    --status-interested: #DBEAFE; --status-interested-text: #2563EB;
    --status-visit_scheduled: #EDE9FE; --status-visit_scheduled-text: #7C3AED;
    --status-visited: #D1FAE5; --status-visited-text: #059669;
    --status-offer: #FEF3C7; --status-offer-text: #D97706;
    --status-bought: #A7F3D0; --status-bought-text: #047857;
    --status-rejected: #F3F4F6; --status-rejected-text: #9CA3AF;
}

/* ── Reset ─────────────────────────────────────────────────────────── */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; }
body {
    font-family: var(--font);
    font-size: 14px;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}
button { font-family: var(--font); cursor: pointer; border: none; background: none; font-size: inherit; }
input, select, textarea { font-family: var(--font); font-size: 14px; }
a { color: var(--primary); text-decoration: none; }

.screen { width: 100%; height: 100%; }

/* ── Login ─────────────────────────────────────────────────────────── */

.login-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #2563EB11, #6366F111), var(--bg);
}
.login-card {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 48px 40px;
    width: 100%;
    max-width: 380px;
    text-align: center;
}
.login-logo { font-size: 48px; margin-bottom: 8px; }
.login-title { font-size: 24px; font-weight: 700; margin-bottom: 4px; }
.login-subtitle { color: var(--text-muted); margin-bottom: 32px; font-size: 15px; }
.login-error { color: var(--expensive); font-size: 13px; margin-top: 12px; min-height: 20px; }

/* ── Auth Tabs ────────────────────────────────────────────────────── */

.auth-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 24px;
    border-bottom: 2px solid var(--border);
}
.auth-tab {
    flex: 1;
    padding: 10px 0;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-muted);
    border: none;
    background: none;
    cursor: pointer;
    transition: all var(--transition);
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
}
.auth-tab:hover { color: var(--text-secondary); }
.auth-tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

/* ── Inputs ────────────────────────────────────────────────────────── */

.input-group { text-align: left; margin-bottom: 16px; }
.input-group label { display: block; font-size: 13px; font-weight: 600; color: var(--text-secondary); margin-bottom: 6px; }
.input-group input, .input-group textarea, .input-group select {
    width: 100%; padding: 10px 14px;
    border: 1.5px solid var(--border); border-radius: var(--radius-sm);
    background: var(--card); color: var(--text);
    transition: border-color var(--transition); outline: none;
}
.input-group input:focus, .input-group textarea:focus, .input-group select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}
.input-group textarea { resize: vertical; }

/* ── Buttons ───────────────────────────────────────────────────────── */

.btn {
    display: inline-flex; align-items: center; justify-content: center;
    gap: 6px; padding: 10px 20px; border-radius: var(--radius-sm);
    font-weight: 600; font-size: 14px; transition: all var(--transition);
}
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-hover); box-shadow: var(--shadow-sm); }
.btn-ghost { color: var(--text-secondary); background: transparent; }
.btn-ghost:hover { background: var(--border); }
.btn-small { padding: 6px 12px; font-size: 12px; }
.btn-full { width: 100%; }

/* ── Top Bar ───────────────────────────────────────────────────────── */

.topbar {
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 20px; height: 52px;
    background: var(--card); border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-sm); position: relative; z-index: 100;
}
.topbar-left { display: flex; align-items: center; gap: 10px; }
.topbar-logo { font-size: 22px; }
.topbar-title { font-size: 17px; font-weight: 700; }
.topbar-stats { font-size: 12px; color: var(--text-muted); margin-left: 8px; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.topbar-user {
    display: flex; align-items: center; gap: 6px;
    padding: 6px 12px; border-radius: var(--radius-pill);
    background: var(--bg); cursor: pointer; transition: background var(--transition);
}
.topbar-user:hover { background: var(--border); }
.user-emoji { font-size: 16px; }
.user-name { font-size: 13px; font-weight: 500; }

/* ── Split Layout ──────────────────────────────────────────────────── */

.split-layout {
    display: flex;
    height: calc(100vh - 52px);
    overflow: hidden;
}

.split-map {
    flex: 1 1 50%;
    min-width: 0;
    position: relative;
}

.split-list {
    flex: 0 0 420px;
    display: flex;
    flex-direction: column;
    border-left: 1px solid var(--border);
    background: var(--card);
    overflow: hidden;
}

.map-container { width: 100%; height: 100%; }

/* ── List Header ───────────────────────────────────────────────────── */

.list-header {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    background: var(--card);
    flex-shrink: 0;
}

.list-search { margin-bottom: 10px; }

.search-input {
    width: 100%;
    padding: 8px 12px 8px 32px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    outline: none;
    background: var(--bg) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' fill='%239CA3AF' viewBox='0 0 16 16'%3E%3Cpath d='M11.742 10.344a6.5 6.5 0 1 0-1.397 1.398l3.85 3.85a1 1 0 0 0 1.415-1.414l-3.868-3.834zm-5.242.656a5 5 0 1 1 0-10 5 5 0 0 1 0 10z'/%3E%3C/svg%3E") 10px center no-repeat;
    transition: border-color var(--transition);
}
.search-input:focus {
    border-color: var(--primary);
    background-color: var(--card);
}

.list-controls {
    display: flex;
    gap: 8px;
}

.control-select {
    flex: 1;
    padding: 6px 10px;
    border: 1.5px solid var(--border);
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    background: var(--card);
    cursor: pointer;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%239CA3AF'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    padding-right: 24px;
}
.control-select:focus { border-color: var(--primary); }

/* ── List Body (scrollable rows) ───────────────────────────────────── */

.list-body {
    flex: 1;
    overflow-y: auto;
}

.property-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid #F3F4F6;
    cursor: pointer;
    transition: background var(--transition);
}
.property-row:hover { background: var(--row-hover); }
.property-row.highlighted { background: var(--row-active); }
.property-row.selected-compare { background: #EFF6FF; box-shadow: inset 3px 0 0 var(--primary); }

/* Fav button in row */
.row-fav {
    flex-shrink: 0;
    width: 28px; height: 28px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 14px;
    transition: all var(--transition);
    border: 1.5px solid var(--border);
    background: var(--card);
}
.row-fav:hover { border-color: var(--fav-red); transform: scale(1.15); }
.row-fav.is-fav { border-color: transparent; background: var(--fav-red); color: white; }

/* Neighborhood thumbnail */
.row-thumb {
    flex-shrink: 0;
    width: 56px; height: 42px;
    border-radius: 6px;
    object-fit: cover;
    background: linear-gradient(135deg, #DBEAFE, #E0E7FF);
}
.row-thumb-placeholder {
    flex-shrink: 0;
    width: 56px; height: 42px;
    border-radius: 6px;
    background: linear-gradient(135deg, #DBEAFE, #E0E7FF);
    display: flex; align-items: center; justify-content: center;
    font-size: 18px;
}

/* Row info */
.row-info { flex: 1; min-width: 0; }
.row-address {
    font-size: 13px; font-weight: 600;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    margin-bottom: 2px;
}
.row-city { font-size: 11px; color: var(--text-secondary); }

/* Row price */
.row-price {
    flex-shrink: 0;
    text-align: right;
}
.row-price-value { font-size: 14px; font-weight: 700; }
.row-price-m2 { font-size: 10px; color: var(--text-muted); }

/* Row meta pills */
.row-meta {
    flex-shrink: 0;
    display: flex;
    gap: 4px;
}
.row-pill {
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 600;
    background: var(--bg);
    color: var(--text-secondary);
    white-space: nowrap;
}

/* Row verdict + status */
.row-badge {
    flex-shrink: 0;
}

.verdict-dot {
    display: inline-block;
    width: 8px; height: 8px;
    border-radius: 50%;
    margin-right: 2px;
    vertical-align: middle;
}
.verdict-dot-good { background: var(--good); }
.verdict-dot-fair { background: var(--fair); }
.verdict-dot-expensive { background: var(--expensive); }

.status-badge {
    padding: 2px 8px;
    border-radius: var(--radius-pill);
    font-size: 10px;
    font-weight: 600;
}
.status-new { background: var(--status-new); color: var(--status-new-text); }
.status-interested { background: var(--status-interested); color: var(--status-interested-text); }
.status-visit_scheduled { background: var(--status-visit_scheduled); color: var(--status-visit_scheduled-text); }
.status-visited { background: var(--status-visited); color: var(--status-visited-text); }
.status-offer { background: var(--status-offer); color: var(--status-offer-text); }
.status-bought { background: var(--status-bought); color: var(--status-bought-text); }
.status-rejected { background: var(--status-rejected); color: var(--status-rejected-text); }

/* ── Map Pill Markers (Zillow-style) ───────────────────────────────── */

.marker-pill {
    padding: 4px 10px;
    border-radius: 16px;
    font-family: var(--font);
    font-size: 12px;
    font-weight: 700;
    color: white;
    white-space: nowrap;
    box-shadow: 0 2px 8px rgba(0,0,0,0.25);
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    line-height: 1.3;
    text-align: center;
}
.marker-pill:hover {
    transform: scale(1.12);
    box-shadow: 0 4px 14px rgba(0,0,0,0.3);
}
.marker-pill.active {
    transform: scale(1.18);
    box-shadow: 0 4px 14px rgba(0,0,0,0.35);
    z-index: 1000 !important;
}

.marker-good { background: var(--good); }
.marker-fair { background: var(--fair); color: #78350F; }
.marker-expensive { background: var(--expensive); }
.marker-visited { background: var(--visited); }

/* ── Map Popup Card (Funda-style) ──────────────────────────────────── */

.leaflet-popup-content-wrapper {
    border-radius: 12px !important;
    box-shadow: var(--shadow-popup) !important;
    padding: 0 !important;
    overflow: hidden;
}
.leaflet-popup-content {
    margin: 0 !important;
    width: 280px !important;
    font-family: var(--font);
}
.leaflet-popup-tip {
    box-shadow: var(--shadow-popup) !important;
}

.popup-card { display: flex; flex-direction: column; }
.popup-photo {
    width: 100%; height: 120px;
    object-fit: cover; display: block;
}
.popup-photo-placeholder {
    width: 100%; height: 120px;
    background: linear-gradient(135deg, #DBEAFE, #C7D2FE);
    display: flex; align-items: center; justify-content: center;
    font-size: 28px; position: relative;
}
.popup-photo-placeholder .popup-nbh-name {
    position: absolute; bottom: 8px; left: 10px;
    font-size: 10px; font-weight: 600; color: white;
    background: rgba(0,0,0,0.35); padding: 2px 8px; border-radius: 10px;
}
.popup-body { padding: 12px 14px; }
.popup-address { font-size: 14px; font-weight: 700; color: var(--primary); margin-bottom: 2px; }
.popup-city { font-size: 12px; color: var(--text-secondary); margin-bottom: 8px; }
.popup-price { font-size: 16px; font-weight: 700; margin-bottom: 8px; }
.popup-meta {
    display: flex; gap: 12px; font-size: 12px; color: var(--text-secondary); margin-bottom: 10px;
}
.popup-meta span { display: flex; align-items: center; gap: 3px; }
.popup-footer {
    display: flex; align-items: center; justify-content: space-between;
    padding-top: 10px; border-top: 1px solid var(--border);
}
.popup-fav {
    width: 30px; height: 30px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 16px; border: 1.5px solid var(--border);
    transition: all var(--transition); cursor: pointer; background: var(--card);
}
.popup-fav:hover { border-color: var(--fav-red); }
.popup-fav.is-fav { border-color: transparent; background: var(--fav-red); }

/* ── Detail Panel ──────────────────────────────────────────────────── */

.detail-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.3); backdrop-filter: blur(4px);
    z-index: 500; animation: fadeIn 0.2s ease;
}
.detail-panel {
    position: absolute; top: 0; right: 0; width: 480px; max-width: 100%; height: 100%;
    background: var(--card); box-shadow: var(--shadow-lg);
    overflow-y: auto; animation: slideInRight 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.detail-close {
    position: sticky; top: 0; float: right; margin: 16px;
    width: 36px; height: 36px; border-radius: 50%;
    background: var(--bg); font-size: 18px; color: var(--text-secondary);
    z-index: 10; transition: all var(--transition);
}
.detail-close:hover { background: var(--border); color: var(--text); }

.detail-photo-carousel {
    width: 100%; height: 260px; overflow-x: auto;
    scroll-snap-type: x mandatory; display: flex; scroll-behavior: smooth;
}
.detail-photo-carousel img {
    flex: 0 0 100%; width: 100%; height: 260px; object-fit: cover; scroll-snap-align: start;
}
.detail-body { padding: 24px; }
.detail-title { font-size: 20px; font-weight: 700; margin-bottom: 4px; }
.detail-subtitle { color: var(--text-secondary); font-size: 13px; margin-bottom: 20px; }
.detail-stats { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 20px; }
.stat-pill {
    padding: 8px 14px; background: var(--bg); border-radius: var(--radius-sm);
    font-size: 13px; font-weight: 600; text-align: center;
}
.stat-pill small { display: block; font-size: 10px; font-weight: 400; color: var(--text-muted); margin-top: 2px; }
.detail-section { margin-bottom: 24px; }
.detail-section-title {
    font-size: 12px; font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.5px; color: var(--text-muted); margin-bottom: 10px;
}
.detail-row {
    display: flex; justify-content: space-between;
    padding: 6px 0; font-size: 13px; border-bottom: 1px solid #F3F4F6;
}
.detail-row:last-child { border-bottom: none; }
.detail-row-label { color: var(--text-secondary); }
.detail-row-value { font-weight: 500; }
.detail-status-select {
    padding: 8px 14px; border-radius: var(--radius-sm);
    border: 1.5px solid var(--border); font-size: 13px; font-weight: 500;
    width: 100%; margin-bottom: 16px;
}
.detail-favs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.fav-toggle {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 6px 14px; border-radius: var(--radius-pill);
    font-size: 13px; font-weight: 500; border: 1.5px solid var(--border);
    transition: all var(--transition); cursor: pointer;
}
.fav-toggle:hover { border-color: var(--primary); }
.fav-toggle.active { border-color: transparent; color: white; }
.fav-toggle.active[data-emoji="💙"] { background: var(--fav-blue); }
.fav-toggle.active[data-emoji="💜"] { background: var(--fav-purple); }
.fav-toggle.active[data-emoji="💚"] { background: var(--fav-green); }
.fav-toggle.active[data-emoji="🧡"] { background: var(--fav-orange); }
.fav-toggle.active[data-emoji="❤️"] { background: var(--fav-red); }
.fav-toggle.active[data-emoji="💛"] { background: var(--fav-yellow); }
.detail-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 20px; }

.card-verdict {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 3px 10px; border-radius: var(--radius-pill);
    font-size: 12px; font-weight: 600;
}
.verdict-good { background: var(--good-light); color: #059669; }
.verdict-fair { background: var(--fair-light); color: #B45309; }
.verdict-expensive { background: var(--expensive-light); color: #DC2626; }

/* ── Visit Card ────────────────────────────────────────────────────── */

.visit-card { background: var(--bg); border-radius: var(--radius-sm); padding: 14px; margin-bottom: 10px; }
.visit-date { font-weight: 600; font-size: 13px; margin-bottom: 4px; }
.visit-notes { font-size: 12px; color: var(--text-secondary); margin-bottom: 8px; font-style: italic; }
.visit-photos { display: flex; gap: 6px; flex-wrap: wrap; }
.visit-photo-thumb {
    width: 64px; height: 64px; object-fit: cover; border-radius: 6px;
    cursor: pointer; transition: transform var(--transition);
}
.visit-photo-thumb:hover { transform: scale(1.08); }

/* ── Compare Modal ─────────────────────────────────────────────────── */

.compare-container {
    display: flex; gap: 20px; padding: 20px 0; overflow-x: auto;
}
.compare-card {
    flex: 0 0 280px; background: var(--bg);
    border-radius: var(--radius); overflow: hidden;
}
.compare-card-photo { width: 100%; height: 140px; object-fit: cover; }
.compare-card-body { padding: 14px; }
.compare-row {
    display: flex; justify-content: space-between;
    padding: 5px 0; font-size: 12px; border-bottom: 1px solid #E5E7EB;
}
.compare-row:last-child { border-bottom: none; }
.compare-label { color: var(--text-secondary); }
.compare-value { font-weight: 600; }
.compare-better { color: var(--good); }

/* ── Modals ─────────────────────────────────────────────────────────── */

.modal-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.4); backdrop-filter: blur(4px);
    z-index: 600; display: flex; align-items: center; justify-content: center;
    animation: fadeIn 0.2s ease;
}
.modal-card {
    background: var(--card); border-radius: var(--radius);
    box-shadow: var(--shadow-lg); padding: 32px;
    width: 100%; max-width: 400px;
    animation: scaleIn 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}
.modal-card-wide { max-width: 900px; max-height: 80vh; overflow-y: auto; }
.modal-header {
    display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px;
}
.modal-header h2 { font-size: 18px; font-weight: 700; margin: 0; }
.modal-header .detail-close { position: static; float: none; margin: 0; }
.modal-card h2 { font-size: 18px; font-weight: 700; margin-bottom: 4px; }
.modal-subtitle { font-size: 13px; color: var(--text-muted); margin-bottom: 24px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 20px; }

/* ── Emoji Picker ──────────────────────────────────────────────────── */

.emoji-picker { display: flex; gap: 8px; }
.emoji-opt {
    width: 44px; height: 44px; border-radius: var(--radius-sm);
    border: 2px solid var(--border); font-size: 20px;
    display: flex; align-items: center; justify-content: center;
    transition: all var(--transition);
}
.emoji-opt:hover { border-color: var(--primary); }
.emoji-opt.selected { border-color: var(--primary); background: var(--primary-light); }

/* ── Empty State ───────────────────────────────────────────────────── */

.empty-state {
    display: flex; flex-direction: column; align-items: center;
    justify-content: center; padding: 60px 20px; color: var(--text-muted);
}
.empty-state-icon { font-size: 48px; margin-bottom: 16px; }
.empty-state-title { font-size: 16px; font-weight: 600; color: var(--text-secondary); margin-bottom: 4px; }
.empty-state-text { font-size: 13px; text-align: center; max-width: 300px; }

/* ── Animations ────────────────────────────────────────────────────── */

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideInRight { from { transform: translateX(100%); } to { transform: translateX(0); } }
@keyframes scaleIn { from { opacity: 0; transform: scale(0.95); } to { opacity: 1; transform: scale(1); } }

/* ── Scrollbar ─────────────────────────────────────────────────────── */

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #D1D5DB; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #9CA3AF; }

/* ── Responsive ────────────────────────────────────────────────────── */

@media (max-width: 900px) {
    .split-layout { flex-direction: column; }
    .split-map { flex: 0 0 45%; }
    .split-list { flex: 1; border-left: none; border-top: 1px solid var(--border); }
}
@media (max-width: 600px) {
    .topbar-title { display: none; }
    .topbar-stats { display: none; }
    .split-map { flex: 0 0 40%; }
    .detail-panel { width: 100%; }
}
