/* ============================================================
   Tema ObraViva (panel interno, post-login)
   Origen: kondominios-demo.html - sidebar azul (var(--brand-deep)).
   El tema de Kondominios usa la misma paleta pero sidebar blanco/crema
   (#FAFAF7) - ver kondominios-demo (1).html; NO mezclar.
   ============================================================ */
:root {
  --bg: #F5F3EE;
  --bg-card: #FFFFFF;
  --ink: #0F2440;
  --ink-soft: #3D5572;
  --ink-muted: #8E9BAD;
  --line: #DDE1E8;
  --line-soft: #EAEDF1;

  --brand-deep: #0F2440;
  --brand-mid: #1B3A5C;
  --brand-light: #3478B8;
  --brand-accent: #E85D1A;
  --brand-accent-soft: #FCE7DA;

  --green: #2F7D52;   --green-soft: #DCEFE2;
  --amber: #B8800B;   --amber-soft: #F8EBC9;
  --red: #B73A2D;     --red-soft: #F6DCD7;
  --blue: #2B5C8C;    --blue-soft: #DCE8F4;

  --shadow-sm: 0 1px 2px rgba(15,36,64,0.04);
  --shadow-md: 0 4px 14px rgba(15,36,64,0.07);
  --shadow-lg: 0 16px 40px rgba(15,36,64,0.12);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body {
  background: var(--bg);
  color: var(--ink);
  font-family: 'Manrope', -apple-system, Segoe UI, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100%;
}
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, select, textarea { font-family: inherit; font-size: 13.5px; }
a { color: inherit; text-decoration: none; }
.serif { font-family: 'Fraunces', serif; }

/* ========== LAYOUT ========== */
.app { display: grid; grid-template-columns: 244px 1fr; min-height: 100vh; }

/* ========== SIDEBAR (azul, unico punto real de diferencia con tema-kondominios.css) ========== */
.sidebar {
  background: var(--brand-deep);
  color: rgba(220,227,237,0.78);
  display: flex; flex-direction: column;
  padding: 24px 0;
  border-right: 1px solid var(--brand-deep);
}
.brand { padding: 0 24px 22px; border-bottom: 1px solid rgba(255,255,255,0.08); margin-bottom: 20px; }
.brand-logo { display: flex; align-items: center; gap: 12px; }
.brand-mark { width: 38px; height: 38px; flex-shrink: 0; }
/* El logo (logo.png) tiene fondo blanco solido, no transparente - en el sidebar azul necesita un
   chip claro detras para no verse como un recuadro roto. */
.brand-img-chip { background: #fff; border-radius: 6px; padding: 6px 10px; display: inline-flex; }
.brand-img { height: 26px; width: auto; display: block; }
.brand-name { font-size: 19px; font-weight: 600; letter-spacing: -0.02em; color: #F5F3EE; line-height: 1; }

/* ========== MENU MOVIL (hamburguesa) ========== */
.btn-menu-movil { display: none; width: 34px; height: 34px; align-items: center; justify-content: center; border-radius: 6px; color: var(--brand-deep); margin-right: 10px; }
.btn-menu-movil svg { width: 20px; height: 20px; }
.btn-menu-movil:hover { background: var(--line-soft); }
.sidebar-fondo { display: none; }
.brand-tag { font-size: 9.5px; letter-spacing: 0.22em; text-transform: uppercase; color: var(--brand-accent); margin-top: 5px; font-weight: 600; }

.nav-section { padding: 0 16px; margin-bottom: 22px; }
.nav-label {
  font-size: 10px; letter-spacing: 0.16em; text-transform: uppercase; color: rgba(220,227,237,0.4);
  padding: 0 8px 8px; font-weight: 700;
  display: flex; align-items: center; justify-content: space-between; cursor: pointer; user-select: none;
}
.nav-label .chevron { width: 12px; height: 12px; flex-shrink: 0; stroke-width: 2.4; transition: transform .15s ease; }
.nav-section.colapsado .nav-label .chevron { transform: rotate(-90deg); }
.nav-section.colapsado .nav-item { display: none; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 12px; border-radius: 5px;
  font-size: 13.5px; color: rgba(220,227,237,0.78);
  transition: all .15s ease; margin-bottom: 1px; width: 100%; text-align: left;
}
.nav-item:hover { background: rgba(255,255,255,0.05); color: #F5F3EE; }
.nav-item.active { background: rgba(232,93,26,0.14); color: var(--brand-accent); position: relative; }
.nav-item.active::before { content: ''; width: 3px; height: 16px; background: var(--brand-accent); margin-left: -12px; margin-right: 9px; border-radius: 2px; }
.nav-item svg { width: 16px; height: 16px; flex-shrink: 0; stroke-width: 1.7; }
.nav-badge { margin-left: auto; background: var(--brand-accent); color: white; font-size: 10px; padding: 1px 6px; border-radius: 8px; font-weight: 700; }

.sidebar-footer { margin-top: auto; padding: 16px 24px; border-top: 1px solid rgba(255,255,255,0.08); }
.user-chip { display: flex; align-items: center; gap: 10px; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: linear-gradient(135deg, var(--brand-accent), #F4A261); display: grid; place-items: center; font-weight: 700; font-size: 12px; color: white; }
.user-info { flex: 1; min-width: 0; }
.user-name { font-size: 13px; color: #F5F3EE; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 11px; color: rgba(220,227,237,0.5); }
.logout-link { font-size: 11px; color: rgba(220,227,237,0.5); margin-top: 4px; display: inline-block; }
.logout-link:hover { color: var(--brand-accent); }

.main { overflow-y: auto; position: relative; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 36px; background: var(--bg); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10;
}
.topbar-left h1 { font-size: 22px; font-weight: 700; letter-spacing: -0.02em; color: var(--brand-deep); }
.topbar-left .subtitle { font-size: 12.5px; color: var(--ink-muted); margin-top: 3px; }
.topbar-right { display: flex; align-items: center; gap: 12px; }

.content { padding: 32px 36px 60px; }

/* ========== BUTTONS ========== */
.btn-primary, .btn-accent, .btn-secondary {
  padding: 9px 16px; border-radius: 6px; font-size: 13px; font-weight: 600;
  display: inline-flex; align-items: center; gap: 6px; transition: all .15s;
}
.btn-primary { background: var(--brand-deep); color: #fff; }
.btn-primary:hover { background: var(--brand-mid); }
.btn-accent { background: var(--brand-accent); color: #fff; }
.btn-accent:hover { background: #C44A0F; }
.btn-secondary { background: var(--bg-card); color: var(--ink); border: 1px solid var(--line); }
.btn-secondary:hover { border-color: var(--ink-muted); }
button:disabled, .btn-primary:disabled, .btn-accent:disabled { opacity: .5; cursor: not-allowed; }

/* ========== CARDS / SECTIONS ========== */
.card { background: var(--bg-card); border: 1px solid var(--line); border-radius: 10px; padding: 22px; }
.section-title { font-size: 17px; font-weight: 700; letter-spacing: -0.015em; margin-bottom: 16px; color: var(--brand-deep); }

/* ========== TOOLBAR / FILTERS ========== */
.toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 20px; flex-wrap: wrap; }
.filtro-chip {
  padding: 7px 14px; border-radius: 20px; font-size: 12.5px; font-weight: 600;
  background: var(--bg-card); border: 1px solid var(--line); color: var(--ink-soft);
}
.filtro-chip.active { background: var(--brand-deep); color: #fff; border-color: var(--brand-deep); }
.search { display: flex; align-items: center; gap: 8px; background: var(--bg-card); border: 1px solid var(--line); padding: 8px 14px; border-radius: 6px; width: 280px; font-size: 13px; color: var(--ink-muted); }
.search input { background: none; border: none; outline: none; flex: 1; font-size: 13px; color: var(--ink); }

/* ========== TABLA (grillas de datos) ========== */
.tabla-datos { background: var(--bg-card); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.tabla-datos table { width: 100%; border-collapse: collapse; }
.tabla-datos thead th {
  text-align: left; padding: 12px 18px; background: #FAFAFA; border-bottom: 1px solid var(--line);
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-muted); font-weight: 700;
}
.tabla-datos tbody td { padding: 14px 18px; border-bottom: 1px solid var(--line-soft); font-size: 13.5px; }
.tabla-datos tbody tr:last-child td { border-bottom: none; }
.tabla-datos tbody tr:hover { background: #FAFAFA; cursor: pointer; }
.tabla-datos .fila-acciones { display: flex; gap: 8px; }
.tabla-datos .fila-acciones a { color: var(--brand-light); font-weight: 600; font-size: 12.5px; }
.tabla-datos .fila-acciones a.borrar { color: var(--red); }
.tabla-vacia { padding: 40px; text-align: center; color: var(--ink-muted); }

/* ========== KPI CARDS ========== */
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 28px; }
.kpi-card { background: var(--bg-card); border: 1px solid var(--line); border-radius: 10px; padding: 18px 20px; }
.kpi-label { font-size: 11.5px; color: var(--ink-muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 8px; }
.kpi-value { font-size: 26px; font-weight: 700; color: var(--brand-deep); letter-spacing: -0.02em; }
.kpi-sub { font-size: 12px; color: var(--ink-muted); margin-top: 4px; }

/* ========== STATUS / PRIORIDAD PILLS ========== */
.status-pill { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 700; padding: 4px 9px; border-radius: 4px; letter-spacing: 0.02em; white-space: nowrap; text-transform: uppercase; }
.s-activo, .s-new { background: var(--blue-soft); color: var(--blue); }
.s-inactivo { background: var(--line-soft); color: var(--ink-soft); }
.s-pendiente, .s-progress { background: var(--amber-soft); color: var(--amber); }
.s-alerta, .s-vencida { background: var(--red-soft); color: var(--red); }
.s-scheduled { background: var(--blue-soft); color: var(--blue); }
.s-resolved, .s-vigente { background: var(--green-soft); color: var(--green); }
.s-closed { background: var(--line-soft); color: var(--ink-soft); }
.p-high { background: var(--red-soft); color: var(--red); }
.p-med { background: var(--amber-soft); color: var(--amber); }
.p-low { background: var(--green-soft); color: var(--green); }

/* ========== FORMULARIOS ========== */
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.form-grid.una-columna { grid-template-columns: 1fr; }
.dashboard-resumen-grid { display: grid; grid-template-columns: 1.4fr 1fr; align-items: start; gap: 20px; }
.reportes-periodo-grid { display: grid; grid-template-columns: auto auto auto; align-items: end; gap: 16px; }
.reportes-resumen-grid { display: grid; grid-template-columns: 1fr 1fr; align-items: start; gap: 20px; }
.campo { display: flex; flex-direction: column; gap: 6px; margin-bottom: 4px; }
.campo label { font-size: 12.5px; font-weight: 600; color: var(--ink-soft); }
.campo input, .campo select, .campo textarea {
  padding: 9px 12px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg-card); color: var(--ink);
}
.campo input:focus, .campo select:focus, .campo textarea:focus { outline: none; border-color: var(--brand-light); box-shadow: 0 0 0 3px var(--blue-soft); }
.campo .validacion { color: var(--red); font-size: 12px; }
.campo-checkbox { display: flex; align-items: center; gap: 8px; }
.form-acciones { display: flex; gap: 10px; margin-top: 20px; }

/* ========== ALERTAS / MENSAJES ========== */
.alerta { padding: 12px 16px; border-radius: 8px; font-size: 13.5px; margin-bottom: 16px; }
.alerta-exito { background: var(--green-soft); color: var(--green); }
.alerta-error { background: var(--red-soft); color: var(--red); }
.alerta-info { background: var(--blue-soft); color: var(--blue); }

/* ========== DRAWER (detalle de ticket) ========== */
.drawer-fondo { display: none; position: fixed; inset: 0; background: rgba(15,36,64,0.45); z-index: 900; }
.drawer-fondo.visible { display: block; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: 460px; max-width: 92vw; background: var(--bg-card); box-shadow: var(--shadow-lg); overflow-y: auto; padding: 28px; z-index: 901; }
.drawer-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 18px; }
.drawer-cerrar { font-size: 20px; color: var(--ink-muted); }
.timeline { margin-top: 8px; }
.timeline-item { display: flex; gap: 12px; padding-bottom: 16px; position: relative; }
.timeline-item:not(:last-child)::before { content: ''; position: absolute; left: 5px; top: 16px; bottom: 0; width: 1px; background: var(--line); }
.timeline-dot { width: 11px; height: 11px; border-radius: 50%; background: var(--line); flex-shrink: 0; margin-top: 3px; }
.timeline-dot.done { background: var(--green); }
.timeline-dot.active { background: var(--brand-accent); }
.warranty-strip { background: var(--green-soft); color: var(--green); padding: 10px 14px; border-radius: 8px; font-size: 12.5px; margin-bottom: 16px; }
.warranty-strip.vencida { background: var(--red-soft); color: var(--red); }
.fotos-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 8px; }
.inmuebles-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.foto-item { aspect-ratio: 1; background: var(--line-soft); border-radius: 6px; display: grid; place-items: center; font-size: 11px; color: var(--ink-muted); text-align: center; padding: 4px; }

/* ========== MODAL ========== */
.modal-fondo {
  display: none; position: fixed; inset: 0; background: rgba(15,36,64,0.45);
  align-items: center; justify-content: center; z-index: 1000;
}
.modal-fondo.visible { display: flex; }
.modal-caja { background: var(--bg-card); border-radius: 10px; box-shadow: var(--shadow-lg); max-width: 480px; width: 92%; padding: 28px; text-align: center; }
.modal-caja h3 { color: var(--brand-deep); font-size: 17px; margin-bottom: 10px; }
.modal-caja p { color: var(--ink-soft); font-size: 14px; margin-bottom: 20px; }

/* ========== LOGIN (pagina publica, sin sidebar) ========== */
.login-pantalla { min-height: 100vh; display: grid; place-items: center; background: var(--brand-deep); }
.login-caja { background: var(--bg-card); border-radius: 12px; box-shadow: var(--shadow-lg); width: 92%; max-width: 380px; padding: 34px 30px; }
.login-caja .brand-name { color: var(--brand-deep); text-align: center; margin-bottom: 2px; }
.login-caja .brand-tag { display: block; text-align: center; margin-bottom: 26px; }

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .btn-menu-movil { display: flex; }
  .sidebar {
    position: fixed; top: 0; bottom: 0; left: -280px; width: 260px; z-index: 1001;
    transition: left .2s ease; box-shadow: var(--shadow-lg);
  }
  .sidebar.abierto { left: 0; }
  .sidebar-fondo.visible { display: block; position: fixed; inset: 0; background: rgba(15,36,64,0.45); z-index: 1000; }
  .form-grid { grid-template-columns: 1fr; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .inmuebles-grid { grid-template-columns: repeat(2, 1fr); }
  .dashboard-resumen-grid { grid-template-columns: 1fr; }
  .reportes-periodo-grid { grid-template-columns: 1fr; }
  .reportes-resumen-grid { grid-template-columns: 1fr; }
  .drawer { width: 100vw; }
}

@media (max-width: 600px) {
  .inmuebles-grid { grid-template-columns: 1fr; }
}
