/* ============================================================
   LA ESQUINA CRM — Estilos v2
   Paleta alineada con identidad del proyecto
   ============================================================ */

:root {
    --bg:           #0E1A1F;
    --bg-card:      #15282E;
    --bg-card-hover:#1F3942;
    --bg-input:     #FAF7F0;
    --border:       #2A4148;
    --text:         #F5EBD7;
    --text-muted:   #8FA5AD;
    --primary:      #C9A961;
    --primary-dark: #B89244;
    --primary-soft: rgba(201, 169, 97, 0.15);
    --success:      #6EAA8C;
    --danger:       #C75D5D;
    --warning:      #D4915A;
    --info:         #5A8AB5;
    --hot:          #B84C4C;
    --warm:         #D4915A;
    --cold:         #5A8AB5;
    --tepid:        #C9A961;
    --cool:         #6B7B82;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }

h1 { font-family: 'Cormorant Garamond', Georgia, serif; font-weight: 600; letter-spacing: 0.5px; }

/* ============ LOGIN ============ */
.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    background:
        radial-gradient(ellipse at top, rgba(201, 169, 97, 0.08) 0%, transparent 50%),
        linear-gradient(180deg, #0E1A1F 0%, #050D11 100%);
}

.login-card {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 48px 40px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 30px 80px rgba(0,0,0,0.6);
    border: 1px solid var(--border);
}

.login-logo {
    text-align: center;
    margin-bottom: 32px;
}

.login-logo img,
.login-logo-img {
    max-width: 280px;
    width: 100%;
    height: auto;
    margin-bottom: 12px;
    display: block;
    margin-left: auto;
    margin-right: auto;
}

.login-tagline {
    font-family: 'Cormorant Garamond', Georgia, serif;
    color: var(--text);
    font-size: 14px;
    font-style: italic;
    margin-bottom: 16px;
    opacity: 0.8;
}

.login-subtitle {
    color: var(--primary);
    font-size: 11px;
    margin-top: 4px;
    text-transform: uppercase;
    letter-spacing: 3px;
    font-weight: 600;
}

.logo-symbol, .logo-symbol-sm {
    background: var(--primary);
    color: var(--bg);
    font-weight: 700;
    font-family: 'Cormorant Garamond', Georgia, serif;
    border-radius: 8px;
    align-items: center;
    justify-content: center;
    letter-spacing: 1px;
}

.logo-symbol {
    width: 72px;
    height: 72px;
    font-size: 28px;
    margin: 0 auto 16px;
    display: inline-flex;
}

.logo-symbol-sm {
    width: 36px;
    height: 36px;
    font-size: 14px;
    display: inline-flex;
}

.topbar-logo {
    height: 56px;
    width: auto;
    display: block;
}

.login-footer {
    text-align: center;
    color: var(--text-muted);
    font-size: 10px;
    margin-top: 28px;
    text-transform: uppercase;
    letter-spacing: 2px;
}

/* ============ FORMS ============ */
.form-group { margin-bottom: 16px; }

.form-group label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.8px;
}

input[type=text], input[type=email], input[type=password],
input[type=date], input[type=number], select, textarea {
    width: 100%;
    background: var(--bg-input);
    color: #1F2937;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 10px 12px;
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.15s, box-shadow 0.15s;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-soft);
}

textarea { resize: vertical; min-height: 60px; }

/* ============ BOTONES ============ */
.btn {
    display: inline-block;
    padding: 10px 22px;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    text-decoration: none;
    font-family: inherit;
    letter-spacing: 0.3px;
}

.btn-primary { background: var(--primary); color: var(--bg); }
.btn-primary:hover { background: var(--primary-dark); transform: translateY(-1px); }

.btn-secondary {
    background: var(--bg-card);
    color: var(--text);
    border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--bg-card-hover); border-color: var(--primary); }

.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #B04848; }

.btn-block { width: 100%; padding: 12px; }
.btn-sm { padding: 5px 12px; font-size: 12px; }

.alert-error {
    background: rgba(199, 93, 93, 0.15);
    border: 1px solid var(--danger);
    color: #F0B0B0;
    padding: 12px;
    border-radius: 6px;
    margin-bottom: 16px;
    font-size: 13px;
}

/* ============ TOPBAR ============ */
.topbar {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 64px;
    position: sticky;
    top: 0;
    z-index: 50;
}

.topbar-brand {
    color: var(--primary);
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-size: 20px;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.login-brand {
    color: var(--primary);
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-size: 28px;
    font-weight: 600;
    letter-spacing: 1.5px;
    margin: 8px 0 4px;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.topnav { display: flex; gap: 4px; }

.navlink {
    padding: 8px 18px;
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 500;
    border-radius: 6px;
    transition: all 0.15s;
}

.navlink:hover { background: var(--bg-card-hover); color: var(--text); }

.navlink.active {
    background: var(--primary);
    color: var(--bg);
    font-weight: 600;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-badge {
    background: var(--bg-card-hover);
    color: var(--primary);
    padding: 6px 14px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    border: 1px solid var(--border);
}

.btn-logout {
    color: var(--text-muted);
    font-size: 12px;
    padding: 6px 10px;
    border-radius: 4px;
}
.btn-logout:hover { color: var(--danger); }

/* ============ MAIN ============ */
.main {
    padding: 28px;
    max-width: 1400px;
    margin: 0 auto;
}

.view { display: none; }
.view.active { display: block; }

.view-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 28px;
    flex-wrap: wrap;
    gap: 12px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}

.view-header h1 {
    color: var(--primary);
    font-size: 30px;
    font-weight: 600;
}

.subtitle {
    color: var(--text-muted);
    font-size: 13px;
    margin-top: 4px;
    line-height: 1.6;
}

.view-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

/* ============ CARDS ============ */
.card {
    background: var(--bg-card);
    border-radius: 10px;
    padding: 22px;
    border: 1px solid var(--border);
    margin-bottom: 16px;
}

.card h3 {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--primary);
    margin-bottom: 18px;
    font-weight: 600;
}

.grid-2 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
    gap: 16px;
    margin-bottom: 16px;
}

/* ============ KPI CARDS ============ */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 28px;
}

.kpi-card {
    background: var(--bg-card);
    border-radius: 10px;
    padding: 22px;
    border: 1px solid var(--border);
    border-left: 4px solid var(--primary);
    transition: all 0.2s;
}

.kpi-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.3);
}

.kpi-card.kpi-success { border-left-color: var(--success); }
.kpi-card.kpi-hot     { border-left-color: var(--hot); }
.kpi-card.kpi-warn    { border-left-color: var(--warning); }

.kpi-label {
    color: var(--text-muted);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    font-weight: 600;
    margin-bottom: 10px;
}

.kpi-value {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-size: 36px;
    font-weight: 600;
    color: var(--text);
    line-height: 1.1;
    letter-spacing: 0.5px;
}

.kpi-sub {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 6px;
    font-style: italic;
}

/* ============ TABLAS ============ */
.table-wrap { overflow-x: auto; }

.data-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-card);
    border-radius: 8px;
    overflow: hidden;
}

.data-table th {
    background: var(--bg-card-hover);
    color: var(--primary);
    text-transform: uppercase;
    font-size: 10px;
    letter-spacing: 1.2px;
    text-align: left;
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    font-weight: 600;
}

.data-table td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
    color: var(--text);
}

.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--bg-card-hover); }

.data-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.data-table th.num { text-align: right; }

/* Links de contacto en columna Contacto del listado */
.contact-link {
    display: inline-block;
    color: var(--accent, #A6855A);
    text-decoration: none;
    font-size: 12px;
    line-height: 1.4;
    margin-top: 2px;
    transition: color 0.15s ease;
}
.contact-link:hover {
    color: var(--text, #1a1a1a);
    text-decoration: underline;
}

/* ============ BADGES ============ */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
    letter-spacing: 0.3px;
}

.badge-sena      { background: rgba(110, 170, 140, 0.2); color: #A5D4BC; }
.badge-caliente  { background: rgba(184, 76, 76, 0.25);  color: #F0B0B0; }
.badge-tibio     { background: rgba(212, 145, 90, 0.25); color: #F4C49B; }
.badge-frio      { background: rgba(90, 138, 181, 0.25); color: #A5C5E3; }
.badge-curiosidad{ background: rgba(201, 169, 97, 0.25); color: #E5CD96; }

.badge-combo {
    background: var(--hot);
    color: white;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* ============ FORMULARIO ============ */
.form-grid {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 28px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 16px;
}

.form-row { display: flex; flex-direction: column; }
.form-row-full { grid-column: 1 / -1; }

.form-row label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-muted);
    margin-bottom: 6px;
    font-weight: 600;
}

.req { color: var(--danger); }

.hint {
    color: var(--text-muted);
    font-size: 11px;
    margin-top: 4px;
    font-style: italic;
}

.form-actions {
    grid-column: 1 / -1;
    display: flex;
    gap: 12px;
    align-items: center;
    margin-top: 12px;
    border-top: 1px solid var(--border);
    padding-top: 20px;
}

.form-msg { font-size: 13px; font-weight: 600; flex: 1; }
.form-msg.success { color: var(--success); }
.form-msg.error   { color: var(--danger); }

/* ============ FILTROS ============ */
.search-input, .filter {
    background: var(--bg-card);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 8px 12px;
    font-size: 13px;
}

.search-input { min-width: 240px; }

.search-input:focus, .filter:focus {
    outline: none;
    border-color: var(--primary);
}

/* ============ EMPTY STATE ============ */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
    background: var(--bg-card);
    border-radius: 10px;
    border: 1px dashed var(--border);
    font-size: 14px;
    font-style: italic;
}

/* ============ MODAL ============ */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(5, 13, 17, 0.8);
    z-index: 100;
    align-items: center;
    justify-content: center;
    padding: 20px;
    backdrop-filter: blur(4px);
}

.modal.show { display: flex; }

.modal-card {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 32px;
    max-width: 700px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    border: 1px solid var(--border);
    box-shadow: 0 30px 80px rgba(0,0,0,0.6);
}

.modal-card h3 {
    color: var(--primary);
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-size: 24px;
    margin-bottom: 8px;
    font-weight: 600;
}

/* ============ RESPONSIVE ============ */
@media (max-width: 768px) {
    .topbar { flex-wrap: wrap; height: auto; padding: 10px 14px; gap: 10px; }
    .topnav { order: 3; width: 100%; overflow-x: auto; }
    .navlink { padding: 6px 12px; font-size: 12px; white-space: nowrap; }
    .topbar-logo { height: 42px; }
    .main { padding: 14px; }
    .view-header h1 { font-size: 24px; }
    .kpi-value { font-size: 28px; }
    .form-grid { padding: 18px; }
    .data-table th, .data-table td { padding: 8px; font-size: 12px; }
    .login-card { padding: 32px 24px; }
    .login-logo img { max-width: 220px; }
}

/* ============ Progress Bars (mapa de calor) ============ */
.progress-track {
    width: 100%;
    height: 22px;
    background: rgba(245, 235, 215, 0.08);
    border-radius: 11px;
    overflow: hidden;
    position: relative;
    border: 1px solid rgba(245, 235, 215, 0.1);
}
.progress-fill {
    height: 100%;
    border-radius: 11px;
    transition: width 0.5s ease;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-right: 8px;
    font-size: 11px;
    font-weight: 600;
    color: #0E1A1F;
    min-width: 24px;
}
.progress-fill.is-green  { background: linear-gradient(90deg, #6EAA8C 0%, #87C29D 100%); }
.progress-fill.is-yellow { background: linear-gradient(90deg, #D4915A 0%, #E0A874 100%); }
.progress-fill.is-red    { background: linear-gradient(90deg, #C75D5D 0%, #D87474 100%); }
.progress-fill.is-empty  { background: rgba(245, 235, 215, 0.15); color: var(--text-muted); }
.progress-label {
    position: absolute;
    top: 0;
    left: 12px;
    line-height: 22px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text);
    text-shadow: 0 1px 2px rgba(0,0,0,0.4);
}

/* ============ MASTERPLAN INTERACTIVO ============ */
.masterplan-wrapper {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    padding: 0;
    position: relative;
}
.masterplan-stage {
    position: relative;
    width: 100%;
    line-height: 0;
    user-select: none;
}
.masterplan-stage img {
    width: 100%;
    height: auto;
    display: block;
}
.masterplan-stage svg {
    position: absolute;
    top: 0; left: 0;
    width: 100%;
    height: 100%;
    overflow: visible;
}

/* Polígonos */
.zone-polygon {
    fill-opacity: 0.55;
    stroke-width: 0.25;
    transition: fill-opacity 0.2s, stroke-width 0.2s;
    cursor: pointer;
    pointer-events: all;
}
.zone-polygon.is-green   { fill: #6EAA8C; stroke: #87C29D; }
.zone-polygon.is-yellow  { fill: #D4915A; stroke: #E0A874; }
.zone-polygon.is-red     { fill: #C75D5D; stroke: #D87474; }
.zone-polygon.is-empty   { fill: #8FA5AD; stroke: #B0C0C7; fill-opacity: 0.30; }
.zone-polygon.is-info    { fill: #475569; stroke: #94A3B8; fill-opacity: 0.45; cursor: default; }

.zone-polygon:hover {
    fill-opacity: 0.78;
    stroke-width: 0.5;
}
.zone-polygon.is-info:hover {
    fill-opacity: 0.55;
}

/* Texto sobre la zona */
.zone-label {
    fill: #FFFFFF;
    font-size: 1.2px;
    font-weight: 700;
    text-anchor: middle;
    pointer-events: none;
    text-shadow: 0 0.05px 0.2px rgba(0,0,0,0.8);
    font-family: 'Inter', sans-serif;
    letter-spacing: 0.05px;
}
.zone-label-pct {
    fill: #FFFFFF;
    font-size: 1.5px;
    font-weight: 800;
    text-anchor: middle;
    pointer-events: none;
}
.zone-label-info {
    fill: #E2E8F0;
    font-size: 1.0px;
    font-weight: 600;
    text-anchor: middle;
    pointer-events: none;
    letter-spacing: 0.1px;
    text-transform: uppercase;
}

/* Modo edición */
.zone-polygon.editing {
    fill-opacity: 0.30;
    stroke-width: 0.4;
    stroke-dasharray: 0.8;
}
.zone-handle {
    fill: #C9A961;
    stroke: #0E1A1F;
    stroke-width: 0.2;
    cursor: grab;
    pointer-events: all;
}
.zone-handle:hover { fill: #FFC857; r: 1.5; }
.zone-handle.dragging { cursor: grabbing; fill: #FFC857; }

/* Leyenda */
.legend-dot {
    display: inline-block;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    margin-left: 8px;
}
.legend-dot.is-green  { background: #6EAA8C; }
.legend-dot.is-yellow { background: #D4915A; }
.legend-dot.is-red    { background: #C75D5D; }
.legend-dot.is-empty  { background: #8FA5AD; opacity: 0.5; }
.legend-dot.is-info   { background: #475569; }
.legend-text {
    font-size: 11px;
    color: var(--text-muted);
    margin-right: 4px;
}

/* ============ DRAWER LATERAL DEL SECTOR ============ */
.sector-drawer {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 0;
    background: rgba(0,0,0,0.6);
    z-index: 200;
    display: none;
}
.sector-drawer.is-open {
    display: block;
    width: 100%;
}
.sector-drawer-card {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    max-width: 580px;
    background: var(--bg-card);
    box-shadow: -4px 0 32px rgba(0,0,0,0.4);
    overflow-y: auto;
    padding: 24px 28px 80px;
    border-left: 1px solid var(--border);
}
.sector-drawer-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 20px;
}
.sector-drawer-stats {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-bottom: 8px;
}
.sd-stat {
    background: var(--bg);
    padding: 12px 14px;
    border-radius: 8px;
    border: 1px solid var(--border);
}
.sd-stat-label {
    font-size: 10px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1.5px;
    margin-bottom: 4px;
}
.sd-stat-value {
    font-size: 22px;
    font-weight: 700;
    color: var(--accent);
    font-family: 'Cormorant Garamond', Georgia, serif;
}
.sd-unit-row {
    display: grid;
    grid-template-columns: 50px 1fr auto;
    gap: 10px;
    padding: 10px 12px;
    background: var(--bg);
    border-radius: 6px;
    margin-bottom: 6px;
    border: 1px solid var(--border);
    align-items: center;
    font-size: 13px;
}
.sd-unit-num {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-size: 18px;
    font-weight: 700;
    color: var(--accent);
}
.sd-unit-info { line-height: 1.4; }
.sd-unit-info b { color: var(--text); }
.sd-unit-info .small { color: var(--text-muted); font-size: 11px; }
.sd-unit-status {
    text-align: right;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
}
.sd-unit-status.is-libre    { color: #6EAA8C; }
.sd-unit-status.is-asignada { color: #D4915A; }
.sd-unit-status.is-vendida  { color: #C75D5D; }
.sd-unit-status.is-no-disp  { color: var(--text-muted); }

/* Mobile drawer */
@media (max-width: 700px) {
    .sector-drawer-card { max-width: 100%; }
    .sector-drawer-stats { grid-template-columns: 1fr 1fr; }
}
