/* Finn Home Finder — Clean Nordic Dashboard */

:root {
    --bg: #0f1117;
    --surface: #1a1d27;
    --surface-2: #232733;
    --border: #2e3347;
    --text: #e4e7ef;
    --text-dim: #8b90a5;
    --accent: #4f8ff7;
    --accent-hover: #6aa1ff;
    --green: #22c55e;
    --green-bg: rgba(34, 197, 94, 0.12);
    --yellow: #eab308;
    --yellow-bg: rgba(234, 179, 8, 0.12);
    --red: #ef4444;
    --red-bg: rgba(239, 68, 68, 0.12);
    --radius: 8px;
    --radius-lg: 12px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* Nav */
.nav {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 0 1.5rem;
    position: sticky;
    top: 0;
    z-index: 100;
}
.nav-inner {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 56px;
}
.nav-logo {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--text);
    text-decoration: none;
}
.nav-links {
    display: flex;
    align-items: center;
    gap: 1rem;
}
.nav-links a { color: var(--text-dim); text-decoration: none; font-size: 0.9rem; }
.nav-links a:hover { color: var(--text); }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    padding: 0.5rem 1rem;
    background: var(--surface-2);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.85rem;
    text-decoration: none;
    cursor: pointer;
    transition: background 0.15s;
}
.btn:hover { background: var(--border); }
.btn-sm { padding: 0.35rem 0.75rem; font-size: 0.8rem; }
.btn-accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-accent:hover { background: var(--accent-hover); }

/* Main */
.main {
    max-width: 1600px;
    margin: 0 auto;
    padding: 1rem 1.5rem;
}

/* Stats bar */
.stats-bar {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
    flex-wrap: wrap;
}
.stat {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.5rem 1rem;
    display: flex;
    flex-direction: column;
    min-width: 100px;
}
.stat-num { font-size: 1.3rem; font-weight: 700; }
.stat-label { font-size: 0.7rem; color: var(--text-dim); margin-top: 0.1rem; }
.stat-completed { color: var(--green); }
.stat-running { color: var(--yellow); }
.stat-failed { color: var(--red); }

/* Dashboard layout — calendar full width, details below */
.calendar-section, .listings-section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1rem;
    margin-bottom: 0.75rem;
}
.calendar-section h2, .listings-section h2 {
    font-size: 1rem;
    margin-bottom: 1rem;
    color: var(--text-dim);
    font-weight: 600;
}

/* FullCalendar overrides */
#calendar {
    --fc-border-color: var(--border);
    --fc-page-bg-color: transparent;
    --fc-neutral-bg-color: var(--surface-2);
    --fc-today-bg-color: rgba(79, 143, 247, 0.08);
    --fc-event-text-color: #fff;
}
.fc .fc-toolbar-title { font-size: 1rem !important; color: var(--text); }
.fc .fc-button {
    background: var(--surface-2) !important;
    border-color: var(--border) !important;
    color: var(--text) !important;
    font-size: 0.8rem !important;
}
.fc .fc-button:hover { background: var(--border) !important; }
.fc .fc-button-active { background: var(--accent) !important; border-color: var(--accent) !important; }
.fc .fc-col-header-cell { color: var(--text-dim); font-size: 0.8rem; }
.fc .fc-daygrid-day-number { color: var(--text-dim); font-size: 0.8rem; }
.fc .fc-daygrid-day { cursor: pointer; transition: background 0.15s; }
.fc .fc-daygrid-day:hover { background: rgba(79, 143, 247, 0.05); }
.fc .fc-daygrid-day.day-selected { background: rgba(79, 143, 247, 0.15); }

/* Calendar events — two-line: time + street name */
.fc .fc-event {
    border-radius: 3px;
    padding: 2px 4px;
    cursor: pointer;
    border: none;
    margin-bottom: 1px;
    overflow: hidden;
}
.fc .fc-daygrid-event-dot { display: none; }
.fc .fc-daygrid-event {
    white-space: nowrap;
    overflow: hidden;
}
.fc .fc-daygrid-day-events { padding: 0 2px; }
.fc .fc-daygrid-more-link { font-size: 0.7rem; color: var(--accent); }

/* Single-line event content: time + street */
.ev-time { font-size: 0.7rem; font-weight: 600; opacity: 0.9; margin-right: 3px; }
.ev-street { font-size: 0.65rem; font-weight: 400; opacity: 0.85; }

/* Week view */
.fc .fc-timegrid-event {
    border-radius: 3px;
    border: none;
}
.fc .fc-timegrid-event .ev-time { font-size: 0.65rem; }
.fc .fc-timegrid-event .ev-street { font-size: 0.6rem; }
.fc .fc-timegrid-slot { height: 2.2em; }
.fc .fc-timegrid-axis { font-size: 0.7rem; color: var(--text-dim); }
.fc .fc-timegrid-slot-label { font-size: 0.7rem; color: var(--text-dim); }

/* Day header + actions */
.day-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.5rem;
    gap: 0.5rem;
    flex-wrap: wrap;
}
.day-actions {
    display: flex;
    gap: 0.5rem;
}

.empty-state-inline {
    text-align: center;
    padding: 2rem;
    color: var(--text-dim);
}

/* Listing cards layout */

/* Filter bar */
.filter-bar {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}
.filter-bar select {
    background: var(--surface-2);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.35rem 0.5rem;
    font-size: 0.8rem;
}
.filter-check {
    font-size: 0.8rem;
    color: var(--text-dim);
    display: flex;
    align-items: center;
    gap: 0.35rem;
    cursor: pointer;
}

/* Listing cards */
.listing-cards {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-height: 70vh;
    overflow-y: auto;
}
.card {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    transition: border-color 0.15s;
    margin-bottom: 0.5rem;
}
.card:hover { border-color: var(--accent); }

.card-header {
    display: flex;
    gap: 0.75rem;
    padding: 0.75rem 0.75rem;
    cursor: pointer;
}
.card-img-wrap {
    width: 80px;
    height: 60px;
    border-radius: 6px;
    overflow: hidden;
    flex-shrink: 0;
    background: var(--surface);
}
.card-img-wrap img { width: 100%; height: 100%; object-fit: cover; }
.card-img-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.65rem;
    color: var(--text-dim);
}

.card-summary { flex: 1; min-width: 0; }
.card-summary h3 {
    font-size: 0.85rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.card-address {
    font-size: 0.78rem;
    color: var(--accent);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-decoration: none;
    display: block;
}
a.card-address:hover { color: var(--accent-hover); text-decoration: underline; }
.card-meta {
    display: flex;
    gap: 0.75rem;
    font-size: 0.75rem;
    color: var(--text-dim);
    margin-top: 0.25rem;
}
.card-meta .price { font-weight: 600; }

.card-badges { display: flex; gap: 0.35rem; margin-top: 0.35rem; flex-wrap: wrap; }

/* Badges */
.badge {
    font-size: 0.65rem;
    padding: 0.15rem 0.5rem;
    border-radius: 99px;
    background: var(--surface);
    color: var(--text-dim);
    border: 1px solid var(--border);
}
.score-good { background: var(--green-bg); color: var(--green); border-color: transparent; }
.score-mid { background: var(--yellow-bg); color: var(--yellow); border-color: transparent; }
.score-low { background: rgba(249, 115, 22, 0.12); color: #f97316; border-color: transparent; }
.score-bad { background: var(--red-bg); color: var(--red); border-color: transparent; }
.badge-viewing { background: rgba(79, 143, 247, 0.12); color: var(--accent); border-color: transparent; }

.budget-ok { color: var(--green); }
.budget-over { color: var(--red); }

/* Card body (expandable) */
.card-body {
    display: none;
    padding: 0 0.75rem 0.75rem;
    border-top: 1px solid var(--border);
}
.card.expanded .card-body { display: block; }

.analysis-summary {
    font-size: 0.85rem;
    margin: 0.75rem 0;
    line-height: 1.6;
}
.analysis-cols {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin: 0.75rem 0;
}
.pros h4 { color: var(--green); font-size: 0.8rem; margin-bottom: 0.35rem; }
.cons h4 { color: var(--red); font-size: 0.8rem; margin-bottom: 0.35rem; }
.pros ul, .cons ul { list-style: none; font-size: 0.8rem; }
.pros li::before { content: "+ "; color: var(--green); font-weight: 700; }
.cons li::before { content: "- "; color: var(--red); font-weight: 700; }

.analysis-section { margin: 0.75rem 0; }
.analysis-section h3, .analysis-section h4 {
    font-size: 0.8rem;
    color: var(--accent);
    margin-bottom: 0.25rem;
}
.analysis-section p { font-size: 0.8rem; color: var(--text-dim); }

.no-analysis { font-size: 0.8rem; color: var(--text-dim); padding: 0.75rem 0; }

.recommendation-banner {
    background: rgba(79, 143, 247, 0.08);
    border: 1px solid rgba(79, 143, 247, 0.2);
    border-radius: var(--radius);
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
    font-size: 0.85rem;
    line-height: 1.6;
}
.recommendation-banner strong {
    color: var(--accent);
}
.key-findings-list { list-style: none; font-size: 0.85rem; }
.key-findings-list li { padding: 0.3rem 0; border-bottom: 1px solid var(--border); }
.key-findings-list li::before { content: "\25B6  "; color: var(--accent); font-size: 0.65rem; }

.tg-table { width: 100%; font-size: 0.8rem; border-collapse: collapse; margin-top: 0.25rem; }
.tg-table td { padding: 0.2rem 0.5rem; border-bottom: 1px solid var(--border); }
.tg-table td:first-child { font-weight: 600; width: 120px; color: var(--text); }
.tg-table td:last-child { color: var(--text-dim); }
.tg-table tr.tg-warning td:last-child { color: var(--red); }

.analysis-meta { font-size: 0.7rem; color: var(--text-dim); margin-top: 0.5rem; opacity: 0.6; }

.card-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border);
}

/* Detail page */
.detail-page { max-width: 900px; }

.back-link {
    color: var(--text-dim);
    text-decoration: none;
    font-size: 0.85rem;
    display: inline-block;
    margin-bottom: 1rem;
}
.back-link:hover { color: var(--text); }

.detail-header {
    display: flex;
    gap: 1.5rem;
    margin-bottom: 2rem;
}
.detail-img {
    width: 400px;
    height: 280px;
    object-fit: cover;
    border-radius: var(--radius-lg);
    flex-shrink: 0;
}
.detail-info h1 { font-size: 1.5rem; margin-bottom: 0.25rem; }
.detail-address { color: var(--text-dim); margin-bottom: 1rem; }

.detail-key-facts {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 0.75rem;
    margin-bottom: 1rem;
}
.fact {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.5rem 0.75rem;
}
.fact-label { display: block; font-size: 0.7rem; color: var(--text-dim); }
.fact-value { font-size: 0.95rem; font-weight: 600; }

.detail-actions { display: flex; gap: 0.5rem; }

.detail-section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    margin-bottom: 1rem;
}
.detail-section h2 {
    font-size: 1.1rem;
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.viewings-list { display: flex; flex-direction: column; gap: 0.5rem; }
.viewing-item {
    display: flex;
    gap: 1rem;
    padding: 0.5rem 0.75rem;
    background: var(--surface-2);
    border-radius: var(--radius);
    font-size: 0.85rem;
}
.viewing-date { font-weight: 600; }
.viewing-time { color: var(--text-dim); }

.tg-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.tg-table th { text-align: left; color: var(--text-dim); padding: 0.5rem; border-bottom: 1px solid var(--border); }
.tg-table td { padding: 0.5rem; border-bottom: 1px solid var(--border); }

.analysis-meta {
    display: flex;
    gap: 1rem;
    margin-top: 1rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border);
    font-size: 0.7rem;
    color: var(--text-dim);
}

/* Report page */
.report-page { max-width: 800px; }
.report-page h1 { font-size: 1.3rem; margin-bottom: 1rem; }

.report-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    margin-bottom: 1rem;
}
.report-header {
    display: flex;
    gap: 1rem;
    align-items: center;
    margin-bottom: 1rem;
    font-size: 0.85rem;
    color: var(--text-dim);
}
.report-status {
    font-weight: 700;
    font-size: 0.8rem;
    padding: 0.2rem 0.6rem;
    border-radius: 99px;
}
.status-completed { background: var(--green-bg); color: var(--green); }
.status-running { background: var(--yellow-bg); color: var(--yellow); }
.status-failed { background: var(--red-bg); color: var(--red); }

.report-stats {
    display: flex;
    gap: 2rem;
}
.report-stat { text-align: center; }
.report-stat-num { display: block; font-size: 1.3rem; font-weight: 700; }
.report-stat span { font-size: 0.75rem; color: var(--text-dim); }

.report-error {
    margin-top: 0.75rem;
    padding: 0.5rem 0.75rem;
    background: var(--red-bg);
    border-radius: var(--radius);
    font-size: 0.8rem;
    color: var(--red);
}

/* Today header */
.today-header {
    margin-bottom: 1.5rem;
}
.today-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
}
.today-date {
    color: var(--text-dim);
    font-size: 0.9rem;
    margin-top: 0.15rem;
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    margin-top: 1.5rem;
}
.empty-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}
.empty-state h2 {
    font-size: 1.3rem;
    margin-bottom: 0.5rem;
}
.empty-state p {
    color: var(--text-dim);
    font-size: 0.9rem;
    max-width: 500px;
    margin: 0 auto 0.75rem;
}
.empty-hint {
    margin-top: 1.5rem !important;
}
.empty-state .btn {
    margin-top: 0.5rem;
}
.empty-meta {
    margin-top: 1.5rem !important;
    font-size: 0.75rem !important;
    color: var(--text-dim);
}

/* Responsive */
@media (max-width: 700px) {
    .detail-header { flex-direction: column; }
    .detail-img { width: 100%; height: 200px; }
    .analysis-cols { grid-template-columns: 1fr; }
    .stats-bar { gap: 0.5rem; }
    .stat { min-width: 90px; padding: 0.5rem 0.75rem; }
    .stat-num { font-size: 1.2rem; }
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }
