/* ============================================================
   Inmuebles Chile — Design System
   Iteración 1: tokens, tipografía, cards, sidebar
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
    --brand:        #6366f1;
    --brand-600:    #4f46e5;
    --brand-glow:   rgba(99, 102, 241, 0.30);

    --ink:          #1f2937;
    --ink-soft:     #6b7280;
    --ink-faint:    #9ca3af;

    --bg:           #f5f7fb;
    --card:         #ffffff;
    --line:         #ecedf3;

    --good:         #10b981;
    --warn:         #f59e0b;
    --bad:          #ef4444;

    --sidebar-1:    #1a1a2e;
    --sidebar-2:    #16213e;

    --radius:       14px;
    --radius-sm:    10px;
    --shadow-sm:    0 1px 2px rgba(16,24,40,.04), 0 1px 3px rgba(16,24,40,.06);
    --shadow-md:    0 6px 16px rgba(16,24,40,.08);
    --shadow-lg:    0 14px 34px rgba(16,24,40,.14);
}

/* ---------- Base ---------- */
html, body {
    background: var(--bg) !important;
    color: var(--ink);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

h1, h2, h3, h4, h5, h6 {
    font-weight: 700;
    letter-spacing: -0.015em;
    color: var(--ink);
}

.text-muted { color: var(--ink-soft) !important; }

/* ---------- Cards ---------- */
.card {
    border: 1px solid var(--line) !important;
    border-radius: var(--radius) !important;
    box-shadow: var(--shadow-sm) !important;
    transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
    background: var(--card);
}
.card.shadow-sm:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md) !important;
    border-color: #e2e4ee !important;
}

/* KPI cards: realzar el número y dar un acento superior */
.kpi-card {
    position: relative;
    overflow: hidden;
}
.kpi-card::before {
    content: "";
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--brand), #8b5cf6);
    opacity: .9;
}
.kpi-card .kpi-value {
    font-size: 1.65rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    line-height: 1.1;
    color: var(--ink);
}
.kpi-card .kpi-label {
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--ink-faint);
    font-weight: 600;
}
.kpi-card .kpi-icon {
    font-size: 1.15rem;
    line-height: 1;
    opacity: .9;
}

/* ---------- Sidebar ---------- */
#sidebar {
    background: linear-gradient(180deg, var(--sidebar-1) 0%, var(--sidebar-2) 100%) !important;
    box-shadow: 4px 0 24px rgba(16,24,40,.10);
    border-right: 1px solid rgba(255,255,255,.04);
}
#sidebar::-webkit-scrollbar { width: 7px; }
#sidebar::-webkit-scrollbar-track { background: transparent; }
#sidebar::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,.12);
    border-radius: 4px;
}
#sidebar::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,.22); }

.sidebar-link {
    position: relative;
    border-radius: 9px;
    margin: 2px 12px;
    font-weight: 500;
    font-size: .92rem;
    transition: background .15s ease, color .15s ease, padding-left .15s ease;
}
.sidebar-link:hover {
    background: rgba(255,255,255,0.07) !important;
    color: #fff !important;
}
.sidebar-link.active {
    background: linear-gradient(90deg, var(--brand-glow), rgba(99,102,241,.08)) !important;
    color: #fff !important;
    font-weight: 600;
}
.sidebar-link.active::before {
    content: "";
    position: absolute;
    left: -12px; top: 50%;
    transform: translateY(-50%);
    height: 60%; width: 3px;
    border-radius: 0 3px 3px 0;
    background: var(--brand);
}

/* ---------- Sidebar histórico (stats) ---------- */
.side-group {
    text-transform: uppercase;
    letter-spacing: .06em;
    font-size: 10px;
    font-weight: 700;
    color: #7a809c;
    margin: 2px 0 6px;
}
.side-stat {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 3px 0;
    font-size: 12px;
}
.side-stat .s-label { color: #9aa0b5; }
.side-stat .s-value {
    color: #fff;
    font-weight: 600;
    background: rgba(255,255,255,.06);
    padding: 1px 8px;
    border-radius: 6px;
    font-variant-numeric: tabular-nums;
}

/* ---------- Form controls in sidebar ---------- */
#sidebar .form-control,
#sidebar .form-select {
    border-radius: var(--radius-sm) !important;
    font-size: .85rem;
}
#sidebar .form-control::placeholder { color: #8b8ba7; }

/* ---------- Buttons ---------- */
.btn {
    border-radius: var(--radius-sm) !important;
    font-weight: 600;
    transition: transform .12s ease, box-shadow .12s ease, filter .12s ease;
}
.btn-primary {
    background: var(--brand) !important;
    border-color: var(--brand) !important;
}
.btn-primary:hover {
    filter: brightness(1.05);
    box-shadow: 0 6px 16px var(--brand-glow);
    transform: translateY(-1px);
}

/* ---------- Badges / pills ---------- */
.badge { border-radius: 8px; font-weight: 600; letter-spacing: .01em; }

/* ---------- Alerts ---------- */
.alert { border-radius: var(--radius) !important; border: none; }

/* ---------- Modal ---------- */
.modal-content {
    border-radius: var(--radius) !important;
    border: none !important;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}
.modal-header { border-bottom: 1px solid var(--line); }

/* ---------- Accent cards (left stripe) ---------- */
.accent-good { border-left: 4px solid var(--good) !important; }
.accent-warn { border-left: 4px solid var(--warn) !important; }
.accent-brand { border-left: 4px solid var(--brand) !important; }

/* ---------- Plotly graph cards ---------- */
.js-plotly-plot { border-radius: var(--radius); }

/* ---------- Section header ---------- */
.section-head {
    display: flex;
    align-items: center;
    gap: .55rem;
    margin-bottom: 1.4rem;
}
.section-head .section-title {
    font-size: 1.4rem;
    font-weight: 800;
    margin: 0;
}
.section-head .section-sub {
    font-size: .85rem;
    color: var(--ink-soft);
    margin: 0;
}

/* ---------- Opportunity cards: badges alineados ---------- */
.opp-badges {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
}
/* neutraliza los me-1 individuales: el gap del contenedor gobierna el espaciado */
.opp-badges > .badge,
.opp-badges > span { margin-right: 0 !important; }
.opp-badges .badge { padding: .32em .6em; }

/* ---------- Opportunity cards: franja lateral por score ---------- */
.opp-card {
    border-left: 4px solid var(--line) !important;
}
.opp-card--good { border-left-color: var(--good) !important; }
.opp-card--warn { border-left-color: var(--warn) !important; }
.opp-card--bad  { border-left-color: var(--bad)  !important; }
.opp-card:hover { transform: translateY(-2px); }

/* ============================================================
   Carousels (funcional — no tocar alturas)
   ============================================================ */
.opp-carousel .carousel-item img {
    object-fit: cover;
    height: 170px;
    width: 100%;
}
.detail-carousel .carousel-item img {
    object-fit: cover;
    height: 340px;
    width: 100%;
}
.opp-carousel,
.opp-carousel .carousel-inner,
.opp-carousel .carousel-item {
    height: 170px;
}
.detail-carousel,
.detail-carousel .carousel-inner,
.detail-carousel .carousel-item {
    height: 340px;
}
.opp-carousel img,
.detail-carousel img { border-radius: var(--radius-sm); }
