/* FSBO Finder — Map-First Dark Theme */

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #1a1a2e;
    color: #e2e8f0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

/* Filter Bar */
#filter-bar {
    background: #242438;
    padding: 8px 16px;
    display: flex;
    align-items: center;
    gap: 20px;
    border-bottom: 1px solid #334155;
    flex-shrink: 0;
}

#filter-bar h1 {
    font-size: 16px;
    font-weight: 700;
    color: #38bdf8;
    white-space: nowrap;
}

.filters {
    display: flex;
    align-items: center;
    gap: 14px;
}

.filters label {
    font-size: 11px;
    color: #94a3b8;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.filters .checkbox-label {
    flex-direction: row;
    align-items: center;
    gap: 5px;
    cursor: pointer;
}

.filters input[type="number"] {
    background: #1a1a2e;
    border: 1px solid #334155;
    color: #e2e8f0;
    padding: 3px 6px;
    border-radius: 4px;
    font-size: 12px;
    width: 60px;
}

.filters input[type="checkbox"] {
    accent-color: #38bdf8;
}

/* Legend */
.legend {
    display: flex;
    gap: 12px;
    margin-left: auto;
    font-size: 11px;
    color: #94a3b8;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 4px;
}

.legend-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

/* Map — full remaining space */
#map {
    flex: 1;
    width: 100%;
}

/* Leaflet popup overrides */
.leaflet-popup-content-wrapper {
    background: #242438 !important;
    color: #e2e8f0 !important;
    border-radius: 8px !important;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5) !important;
}

.leaflet-popup-tip {
    background: #242438 !important;
}

.leaflet-popup-content {
    margin: 12px !important;
    font-size: 13px;
    line-height: 1.6;
}

.popup-title {
    font-size: 14px;
    font-weight: 700;
    color: #38bdf8;
    margin-bottom: 4px;
}

.popup-owner {
    color: #94a3b8;
    margin-bottom: 6px;
}

.popup-scores {
    display: flex;
    gap: 6px;
    margin-bottom: 8px;
}

.popup-detail {
    font-size: 12px;
    color: #cbd5e1;
    margin-bottom: 2px;
}

.popup-detail strong {
    color: #94a3b8;
}

.score-badge {
    display: inline-block;
    padding: 1px 7px;
    border-radius: 3px;
    font-size: 11px;
    font-weight: 700;
}

.score-hot {
    background: #7f1d1d;
    color: #fca5a5;
}

.score-warm {
    background: #713f12;
    color: #fde68a;
}

.score-cool {
    background: #1e3a5f;
    color: #93c5fd;
}

.badge-absentee {
    background: #4c1d95;
    color: #c4b5fd;
    font-size: 10px;
    padding: 1px 6px;
    border-radius: 3px;
    font-weight: 600;
}

.badge-agency {
    background: #064e3b;
    color: #6ee7b7;
    font-size: 10px;
    padding: 1px 6px;
    border-radius: 3px;
    font-weight: 600;
    cursor: help;
}

.signal-tag {
    display: inline-block;
    background: #334155;
    color: #94a3b8;
    padding: 1px 6px;
    border-radius: 3px;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

/* AI Chat Panel — floats above the stats bar */
#chat-panel {
    position: absolute;
    bottom: 36px; /* sits just above the stats bar */
    left: 50%;
    transform: translateX(-50%);
    width: min(640px, calc(100vw - 32px));
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 6px;
    pointer-events: none; /* let map clicks through when panel is idle */
}

#chat-answer {
    background: #1e2235;
    border: 1px solid #334155;
    border-radius: 8px;
    padding: 10px 14px;
    font-size: 13px;
    line-height: 1.55;
    color: #e2e8f0;
    pointer-events: auto;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.55);
    white-space: pre-wrap;
}

#chat-answer .chat-filter-tag {
    display: block;
    background: #1e3a5f;
    color: #93c5fd;
    font-size: 10px;
    padding: 1px 7px;
    border-radius: 3px;
    margin-bottom: 5px;
    font-weight: 600;
    letter-spacing: 0.2px;
    text-transform: uppercase;
    width: fit-content;
}

#chat-answer .chat-match-count {
    color: #38bdf8;
    font-weight: 700;
}

#chat-answer.chat-hidden {
    display: none;
}

#chat-form {
    display: flex;
    gap: 6px;
    pointer-events: auto;
}

#chat-input {
    flex: 1;
    background: #1a1a2e;
    border: 1px solid #475569;
    color: #e2e8f0;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 13px;
    outline: none;
    transition: border-color 0.15s;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.5);
}

#chat-input::placeholder {
    color: #475569;
}

#chat-input:focus {
    border-color: #38bdf8;
}

#chat-submit {
    background: #38bdf8;
    color: #0f172a;
    border: none;
    border-radius: 6px;
    padding: 8px 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
    flex-shrink: 0;
}

#chat-submit:hover {
    background: #7dd3fc;
}

#chat-submit:disabled {
    background: #334155;
    color: #64748b;
    cursor: not-allowed;
}

/* Stats Bar */
#stats-bar {
    background: #242438;
    padding: 6px 16px;
    display: flex;
    gap: 20px;
    font-size: 11px;
    color: #64748b;
    border-top: 1px solid #334155;
    flex-shrink: 0;
}

#stats-bar strong {
    color: #e2e8f0;
}

#stats-bar .hot {
    color: #f87171;
}

#stats-bar .warm {
    color: #fbbf24;
}

/* GHL Push Button */
.ghl-btn {
    background: #1e40af;
    color: #bfdbfe;
    border: none;
    border-radius: 4px;
    padding: 5px 12px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.4px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    width: 100%;
}

.ghl-btn:hover:not(:disabled) {
    background: #2563eb;
    color: #eff6ff;
}

.ghl-btn:disabled {
    cursor: default;
    opacity: 0.85;
}

/* Mesa boundary label */
.mesa-label {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    color: #64748b !important;
    font-size: 13px !important;
    font-weight: 600 !important;
    letter-spacing: 3px !important;
    text-transform: uppercase !important;
}
.mesa-label::before {
    display: none !important;
}

/* Properties button in header */
#properties-btn {
    background: #334155;
    color: #e2e8f0;
    border: 1px solid #475569;
    padding: 4px 12px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
}
#properties-btn:hover { background: #475569; }

/* Slide-out panels */
#detail-panel, #list-panel {
    position: fixed;
    top: 38px;
    right: 0;
    width: 340px;
    bottom: 28px;
    background: #1a1a2e;
    border-left: 1px solid #334155;
    z-index: 1100;
    display: flex;
    flex-direction: column;
    transition: transform 0.25s ease;
    box-shadow: -4px 0 20px rgba(0,0,0,0.5);
    overflow: hidden;
}
.panel-hidden { transform: translateX(340px); }
.panel-visible { transform: translateX(0); }

/* Detail panel header */
#detail-header, #list-header {
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid #334155;
    flex-shrink: 0;
    background: #242438;
}
#detail-title, #list-header span:first-child {
    font-size: 14px;
    font-weight: 700;
    color: #38bdf8;
    flex: 1;
}
#detail-close, #list-close {
    background: none;
    border: none;
    color: #64748b;
    font-size: 22px;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
}
#detail-close:hover, #list-close:hover { color: #e2e8f0; }

/* Detail content */
#detail-content {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    font-size: 13px;
    line-height: 1.6;
    color: #e2e8f0;
}

.detail-section {
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid #334155;
}
.detail-section:last-child { border-bottom: none; }

.detail-section-title {
    font-size: 11px;
    font-weight: 700;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 6px;
}

.detail-row {
    display: flex;
    justify-content: space-between;
    padding: 2px 0;
}
.detail-label { color: #94a3b8; }
.detail-value { color: #f1f5f9; font-weight: 500; text-align: right; }

/* List panel */
#list-count-badge {
    background: #38bdf8;
    color: #0f172a;
    padding: 1px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 700;
}

#list-search {
    padding: 8px 12px;
    border-bottom: 1px solid #334155;
    flex-shrink: 0;
}
#list-search input {
    width: 100%;
    background: #1a1a2e;
    border: 1px solid #334155;
    color: #e2e8f0;
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 12px;
}

#list-content {
    flex: 1;
    overflow-y: auto;
}

.list-item {
    padding: 8px 12px;
    border-bottom: 1px solid #242438;
    cursor: pointer;
    transition: background 0.1s;
}
.list-item:hover { background: #242438; }
.list-item-address {
    font-size: 12px;
    font-weight: 600;
    color: #f1f5f9;
    margin-bottom: 2px;
}
.list-item-meta {
    font-size: 11px;
    color: #94a3b8;
    display: flex;
    gap: 8px;
}

/* Panel scrollbar */
#detail-content::-webkit-scrollbar, #list-content::-webkit-scrollbar { width: 5px; }
#detail-content::-webkit-scrollbar-track, #list-content::-webkit-scrollbar-track { background: #1a1a2e; }
#detail-content::-webkit-scrollbar-thumb, #list-content::-webkit-scrollbar-thumb { background: #334155; border-radius: 3px; }

/* List tabs */
#list-tabs {
    display: flex;
    border-bottom: 1px solid #334155;
    flex-shrink: 0;
}
.list-tab {
    flex: 1;
    padding: 8px 4px;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: #64748b;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.list-tab:hover { color: #94a3b8; }
.list-tab.active {
    color: #38bdf8;
    border-bottom-color: #38bdf8;
}

/* Clickable legend filters */
.legend-filter {
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 3px;
    transition: background 0.15s;
}
.legend-filter:hover {
    background: #334155;
}
.legend-filter.active {
    background: #334155;
    outline: 1px solid #64748b;
}
