/* ============================================================
   STYLE.CSS — Template base Monarca Computer S.A.S
   Uplift moderno 2026-07 (conjuntosResidenciales).
   Las variables de color/tipografía vienen de cargarTema() (BD)
   por conjunto; aquí solo el diseño de los componentes.
   NO fijar valores de marca en :root — se sobrescriben en runtime.
   ============================================================ */

/* ── Variables por defecto (fallback si la API no responde) ── */
:root {
  --primary:       #1a3a5c;
  --primary-hover: #2563eb;
  --accent:        #f59e0b;
  --bg:            #f4f6fb;
  --surface:       #ffffff;
  --border:        #e6eaf1;
  --text:          #1e293b;
  --text-muted:    #64748b;
  --success:       #16a34a;
  --danger:        #dc2626;
  --warning:       #d97706;
  --radius:        12px;
  --radius-sm:     8px;
  --sidebar-w:     236px;
  --font-body:     'Segoe UI', system-ui, -apple-system, sans-serif;
  --font-heading:  'Segoe UI', system-ui, -apple-system, sans-serif;
  --font-size:     14px;
  /* Sombras suaves y escalonadas */
  --shadow-sm:  0 1px 2px rgba(16,30,54,0.06), 0 1px 3px rgba(16,30,54,0.05);
  --shadow-md:  0 4px 12px rgba(16,30,54,0.08), 0 2px 4px rgba(16,30,54,0.04);
  --shadow-lg:  0 12px 32px rgba(16,30,54,0.14);
  --ring:       0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent);
}

/* ── Modo oscuro ─────────────────────────────────────────── */
html[data-dark] {
  --bg:         #0b1220;
  --surface:    #151e30;
  --border:     #263145;
  --text:       #e6edf6;
  --text-muted: #93a3b8;
  --shadow-sm:  0 1px 2px rgba(0,0,0,0.4);
  --shadow-md:  0 4px 14px rgba(0,0,0,0.45);
  --shadow-lg:  0 16px 40px rgba(0,0,0,0.6);
}

html[data-dark] .alert-success { background: rgba(22,163,74,0.15);  color: #86efac; }
html[data-dark] .alert-danger  { background: rgba(220,38,38,0.15);  color: #fca5a5; }
html[data-dark] .alert-warning { background: rgba(217,119,6,0.15);  color: #fcd34d; }
html[data-dark] .alert-info    { background: rgba(37,99,235,0.15);  color: #93c5fd; }

html[data-dark] .badge-success { background: rgba(22,163,74,0.2);  }
html[data-dark] .badge-danger  { background: rgba(220,38,38,0.2);  }
html[data-dark] .badge-warning { background: rgba(217,119,6,0.2);  }
html[data-dark] .badge-primary { background: rgba(37,99,235,0.2);  }
html[data-dark] .badge-muted   { background: rgba(255,255,255,0.1); }

html[data-dark] ::-webkit-scrollbar-track { background: #151e30; }
html[data-dark] ::-webkit-scrollbar-thumb { background: #37455f; }

/* ── Scrollbars finas ──────────────────────────────────────── */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(100,116,139,0.35); border-radius: 20px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: rgba(100,116,139,0.55); background-clip: content-box; }

/* Botón modo oscuro en topbar */
.dark-toggle {
  background:    var(--bg);
  border:        1px solid var(--border);
  border-radius: 999px;
  padding:       5px 13px;
  cursor:        pointer;
  font-size:     0.76rem;
  font-weight:   600;
  color:         var(--text-muted);
  display:       flex;
  align-items:   center;
  gap:           5px;
  transition:    background 0.15s, color 0.15s, border-color 0.15s;
  white-space:   nowrap;
}
.dark-toggle:hover { background: var(--surface); color: var(--text); border-color: var(--primary); }

/* Animaciones */
@keyframes toastIn { from { opacity:0; transform:translateY(10px); } to { opacity:1; transform:translateY(0); } }
@keyframes modalIn { from { opacity:0; transform:translateY(8px) scale(0.98); } to { opacity:1; transform:translateY(0) scale(1); } }
@keyframes fadeIn  { from { opacity:0; } to { opacity:1; } }

/* ── Reset y base ─────────────────────────────────────────── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family:      var(--font-body);
  font-size:        var(--font-size);
  background:       var(--bg);
  color:            var(--text);
  min-height:       100vh;
  line-height:      1.55;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  line-height: 1.2;
  color:       var(--text);
  letter-spacing: -0.01em;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-hover); }

/* ── Layout principal ─────────────────────────────────────── */
.app-layout { display: flex; min-height: 100vh; }

/* ── Sidebar ──────────────────────────────────────────────── */
.sidebar {
  width:      var(--sidebar-w);
  background: linear-gradient(180deg,
                color-mix(in srgb, var(--primary) 92%, #000 8%) 0%,
                var(--primary) 55%,
                color-mix(in srgb, var(--primary) 88%, #000 12%) 100%);
  color:      #fff;
  display:    flex;
  flex-direction: column;
  position:   fixed;
  top: 0; left: 0;
  height:     100vh;
  z-index:    200;
  transition: transform 0.25s ease;
  overflow-y: auto;
  flex-shrink: 0;
  box-shadow: 4px 0 24px rgba(16,30,54,0.08);
}

.sidebar-brand {
  padding:     20px 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.10);
  display:     flex;
  align-items: center;
  gap:         11px;
}
.sidebar-brand img {
  width:  38px; height: 38px;
  object-fit: contain;
  border-radius: 9px;
  background: rgba(255,255,255,0.12);
  padding: 4px;
}
.brand-text { font-size: 0.92rem; font-weight: 800; color: #fff; line-height: 1.15; }
.brand-accent { color: var(--accent); }

/* Banner de contexto (staff administrando un conjunto) */
.sidebar-context {
  margin: 12px 12px 4px;
  padding: 11px 13px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: var(--radius-sm);
}
.sidebar-context-label {
  font-size: 0.58rem; font-weight: 800; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--accent);
}
.sidebar-context-name {
  font-size: 0.86rem; font-weight: 700; color: #fff;
  margin: 2px 0 8px; line-height: 1.2;
}
.sidebar-back {
  display: inline-block; font-size: 0.74rem; font-weight: 600;
  color: rgba(255,255,255,0.85);
  padding: 5px 10px; border-radius: 999px;
  background: rgba(255,255,255,0.10); transition: background 0.15s, color 0.15s;
}
.sidebar-back:hover { background: rgba(255,255,255,0.2); color: #fff; }

.sidebar-nav { padding: 12px 12px 16px; flex: 1; }

.nav-section-label {
  font-size:      0.6rem;
  font-weight:    800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color:          rgba(255,255,255,0.4);
  padding:        16px 12px 7px;
}

.nav-link {
  display:     flex;
  align-items: center;
  gap:         11px;
  padding:     10px 12px;
  margin-bottom: 2px;
  border-radius: var(--radius-sm);
  color:       rgba(255,255,255,0.78);
  font-size:   0.83rem;
  font-weight: 600;
  position:    relative;
  transition:  background 0.15s, color 0.15s, transform 0.05s;
  cursor:      pointer;
  text-decoration: none;
}
.nav-link:hover { background: rgba(255,255,255,0.09); color: #fff; }
.nav-link.active {
  background: rgba(255,255,255,0.14);
  color: #fff;
}
/* Barra de acento a la izquierda del ítem activo */
.nav-link.active::before {
  content: ''; position: absolute; left: -12px; top: 50%; transform: translateY(-50%);
  width: 4px; height: 60%; border-radius: 0 4px 4px 0; background: var(--accent);
}
.nav-link .nav-icon { font-size: 1.02rem; flex-shrink: 0; opacity: 0.9; width: 20px; text-align: center; }
.nav-link.active .nav-icon { opacity: 1; }

.sidebar-footer {
  padding:    16px 20px;
  border-top: 1px solid rgba(255,255,255,0.10);
  font-size:  0.72rem;
  color:      rgba(255,255,255,0.42);
}

/* ── Overlay móvil ────────────────────────────────────────── */
.sidebar-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(8,15,30,0.5); z-index: 150; backdrop-filter: blur(2px);
}
.sidebar-overlay.show { display: block; animation: fadeIn 0.2s ease; }

/* ── Contenido principal ──────────────────────────────────── */
.main-content {
  flex: 1; margin-left: var(--sidebar-w);
  display: flex; flex-direction: column; min-height: 100vh;
}

/* ── Topbar ───────────────────────────────────────────────── */
.topbar {
  background:    color-mix(in srgb, var(--surface) 85%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  padding:       0 26px;
  height:        58px;
  display:       flex;
  align-items:   center;
  justify-content: space-between;
  position:      sticky;
  top:           0;
  z-index:       100;
}
.topbar-left { display: flex; align-items: center; gap: 12px; }
.topbar-title { font-size: 0.95rem; font-weight: 800; color: var(--text); letter-spacing: -0.01em; }

.hamburger-btn {
  display: none; background: none; border: none; cursor: pointer;
  font-size: 1.35rem; color: var(--text); padding: 4px; line-height: 1;
}

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

.user-chip {
  display: flex; align-items: center; gap: 8px;
  font-size: 0.78rem; color: var(--text-muted);
  background: var(--bg); border: 1px solid var(--border);
  padding: 6px 13px; border-radius: 999px;
}
.user-chip strong { color: var(--text); }

/* ── Page content ─────────────────────────────────────────── */
.page-content { padding: 26px; flex: 1; max-width: 1400px; width: 100%; }

.page-header { margin-bottom: 22px; }
.page-header h1 { font-size: 1.35rem; font-weight: 800; }
.page-header p  { font-size: 0.85rem; color: var(--text-muted); margin-top: 4px; }

/* ── Cards ────────────────────────────────────────────────── */
.card {
  background:    var(--surface);
  border:        1px solid var(--border);
  border-radius: var(--radius);
  padding:       22px 24px;
  box-shadow:    var(--shadow-sm);
  transition:    box-shadow 0.2s, transform 0.2s;
}
.card + .card { margin-top: 18px; }
.card-hover:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }

/* Fila de KPIs en grilla: las tarjetas se separan con gap y quedan a la misma
   altura. Anula el margin-top de `.card + .card` (pensado para cards apiladas),
   que dentro de una grilla desalinea las tarjetas a partir de la segunda. */
.kpi-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; align-items: stretch; }
.kpi-row > .card { margin-top: 0; }

.card-title {
  font-size:      0.72rem;
  font-weight:    800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color:          var(--text-muted);
  margin-bottom:  16px;
  padding-bottom: 12px;
  border-bottom:  1px solid var(--border);
}

/* ── Stat tiles / KPIs ────────────────────────────────────── */
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 16px; }
.stat-tile {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px 20px;
  box-shadow: var(--shadow-sm); transition: box-shadow 0.2s, transform 0.2s;
  display: flex; flex-direction: column; gap: 6px;
}
.stat-tile:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.stat-tile .stat-label { font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); }
.stat-tile .stat-value { font-size: 1.7rem; font-weight: 800; color: var(--text); line-height: 1.1; letter-spacing: -0.02em; }
.stat-tile .stat-foot  { font-size: 0.74rem; color: var(--text-muted); }
.stat-tile .stat-icon  {
  width: 40px; height: 40px; border-radius: 11px; display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem; background: color-mix(in srgb, var(--primary) 12%, transparent); margin-bottom: 2px;
}

/* ── Botones ──────────────────────────────────────────────── */
.btn, .btn-primary, .btn-secondary, .btn-success, .btn-danger, .btn-warning {
  display:         inline-flex;
  align-items:     center;
  gap:             7px;
  padding:         9px 17px;
  border-radius:   var(--radius-sm);
  font-size:       0.8rem;
  font-weight:     700;
  border:          1px solid transparent;
  cursor:          pointer;
  transition:      background 0.15s, box-shadow 0.15s, transform 0.05s, border-color 0.15s;
  text-decoration: none;
  white-space:     nowrap;
  line-height:     1.2;
}
.btn:active, .btn-primary:active, .btn-secondary:active { transform: translateY(1px); }
.btn:disabled, .btn-primary:disabled, .btn-secondary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn:focus-visible, .btn-primary:focus-visible, .btn-secondary:focus-visible { outline: none; box-shadow: var(--ring); }

.btn-primary { background: var(--primary); color: #fff; box-shadow: var(--shadow-sm); }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); box-shadow: var(--shadow-md); }

.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-secondary:hover:not(:disabled) { background: var(--bg); border-color: var(--text-muted); }

.btn-success { background: var(--success); color: #fff; }
.btn-danger  { background: var(--danger);  color: #fff; }
.btn-warning { background: var(--warning); color: #fff; }

.btn-sm  { padding: 5px 11px; font-size: 0.72rem; border-radius: 7px; }
.btn-lg  { padding: 11px 24px; font-size: 0.9rem; }
.btn-full { width: 100%; justify-content: center; }

.btn-group { display: flex; gap: 6px; align-items: center; flex-wrap: nowrap; }

/* ── Formularios ──────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 0.76rem; font-weight: 700; color: var(--text); margin-bottom: 6px; }
.form-label .required { color: var(--danger); margin-left: 2px; }

.form-control {
  width: 100%; padding: 9px 13px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: 0.84rem; color: var(--text); background: var(--surface);
  transition: border-color 0.15s, box-shadow 0.15s; font-family: var(--font-body);
}
.form-control:focus { outline: none; border-color: var(--primary); box-shadow: var(--ring); }
.form-control::placeholder { color: var(--text-muted); }
select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 80px; }
.form-hint { font-size: 0.7rem; color: var(--text-muted); margin-top: 4px; }

/* ── Tablas ───────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); }
.card .table-wrap { border: none; border-radius: 0; }

table { width: 100%; border-collapse: collapse; font-size: 0.82rem; }

thead tr { background: color-mix(in srgb, var(--primary) 8%, var(--surface)); }
thead th {
  color: var(--text-muted); font-weight: 800; font-size: 0.68rem;
  text-transform: uppercase; letter-spacing: 0.05em;
  text-align: left; padding: 12px 15px; white-space: nowrap;
  border-bottom: 1px solid var(--border);
}
tbody tr { border-bottom: 1px solid var(--border); transition: background 0.12s; }
tbody tr:hover { background: color-mix(in srgb, var(--primary) 4%, transparent); }
tbody tr:last-child { border-bottom: none; }
td { padding: 11px 15px; vertical-align: middle; color: var(--text); }

/* ── Badges ───────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border-radius: 999px;
  font-size: 0.66rem; font-weight: 800; white-space: nowrap;
  text-transform: uppercase; letter-spacing: 0.03em;
}
.badge-success { background: rgba(22,163,74,0.12);  color: var(--success); }
.badge-danger  { background: rgba(220,38,38,0.12);  color: var(--danger);  }
.badge-warning { background: rgba(217,119,6,0.12);  color: var(--warning); }
.badge-primary { background: rgba(26,58,92,0.12);   color: var(--primary); }
.badge-muted   { background: rgba(0,0,0,0.06);      color: var(--text-muted); }

/* ── Alertas ──────────────────────────────────────────────── */
.alert {
  display: flex; gap: 9px; align-items: flex-start;
  padding: 12px 15px; border-radius: var(--radius-sm);
  font-size: 0.8rem; line-height: 1.6; margin-bottom: 14px;
}
.alert-success { background: rgba(22,163,74,0.08);  border: 1px solid rgba(22,163,74,0.3);  color: #14532d; }
.alert-danger  { background: rgba(220,38,38,0.08);  border: 1px solid rgba(220,38,38,0.3);  color: #7f1d1d; }
.alert-warning { background: rgba(217,119,6,0.08);  border: 1px solid rgba(217,119,6,0.3);  color: #78350f; }
.alert-info    { background: rgba(26,58,92,0.06);   border: 1px solid rgba(26,58,92,0.2);   color: var(--primary); }

/* ── Modal ────────────────────────────────────────────────── */
.modal-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(8,15,30,0.5); backdrop-filter: blur(3px);
  z-index: 300; align-items: center; justify-content: center; padding: 16px;
}
.modal-overlay.show { display: flex; animation: fadeIn 0.15s ease; }
.modal {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); width: 100%; max-width: 480px;
  box-shadow: var(--shadow-lg); animation: modalIn 0.2s ease;
}
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--border); }
.modal-title { font-size: 0.98rem; font-weight: 800; }
.modal-close { background: none; border: none; font-size: 1.2rem; cursor: pointer; color: var(--text-muted); line-height: 1; }
.modal-close:hover { color: var(--text); }
.modal-body   { padding: 22px; }
.modal-footer { padding: 16px 22px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }

/* ── Utilidades ───────────────────────────────────────────── */
.text-muted { color: var(--text-muted); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-primary { color: var(--primary); }
.fw-bold { font-weight: 700; }
.mt-1 { margin-top: 8px; } .mt-2 { margin-top: 16px; }
.mb-1 { margin-bottom: 8px; } .mb-2 { margin-bottom: 16px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 18px; }

/* ── LOGIN ────────────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  background: linear-gradient(135deg, var(--primary) 0%, color-mix(in srgb, var(--primary) 60%, var(--primary-hover)) 100%);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.login-card {
  background: var(--surface); border-radius: var(--radius);
  width: 100%; max-width: 380px; box-shadow: var(--shadow-lg);
  padding: 40px 34px 30px;
}
.login-logo-wrap { text-align: center; margin-bottom: 22px; }
.login-logo-wrap img { max-height: 62px; max-width: 190px; object-fit: contain; }
.login-title { font-size: 1.12rem; font-weight: 800; color: var(--text); text-align: center; margin-bottom: 4px; }
.login-sub { font-size: 0.76rem; color: var(--text-muted); text-align: center; margin-bottom: 24px; }
.btn-login { background: var(--primary); color: #fff; border-radius: var(--radius-sm); box-shadow: var(--shadow-sm); }
.btn-login:hover { background: var(--primary-hover); box-shadow: var(--shadow-md); }
.login-footer { text-align: center; margin-top: 20px; font-size: 0.72rem; color: var(--text-muted); }

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); box-shadow: var(--shadow-lg); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .hamburger-btn { display: block; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .page-content { padding: 18px; }
  .topbar { padding: 0 16px; }
  .page-header h1 { font-size: 1.2rem; }
}
