/* ============================================================
   Sistema de Arriendos — Tema moderno
   ============================================================ */
:root {
  --primario: #4f46e5;
  --primario-oscuro: #4338ca;
  --primario-suave: #eef2ff;
  --acento: #7c3aed;
  --fondo: #f1f5f9;
  --tinta: #0f172a;
  --tinta-suave: #64748b;
  --borde: #e2e8f0;
  --sidebar-ancho: 250px;
  --radio: 14px;
}

* { font-family: 'Inter', 'Segoe UI', sans-serif; }

body {
  background: var(--fondo);
  color: var(--tinta);
  min-height: 100vh;
}

.app-wrapper { display: flex; min-height: 100vh; }

/* ---------------- SIDEBAR ---------------- */
.sidebar {
  width: var(--sidebar-ancho);
  min-height: 100vh;
  background: linear-gradient(180deg, #0f172a 0%, #1e1b4b 100%);
  color: #cbd5e1;
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 1040;
  transition: transform .25s ease;
}

.sidebar-brand {
  display: flex; align-items: center; gap: 12px;
  padding: 22px 20px;
  border-bottom: 1px solid rgba(255,255,255,.07);
}
.brand-icon {
  width: 42px; height: 42px; border-radius: 12px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--primario), var(--acento));
  color: #fff; font-size: 20px;
  box-shadow: 0 6px 16px rgba(79,70,229,.4);
}
.brand-text strong { display: block; color: #fff; font-size: 16px; letter-spacing: .3px; }
.brand-text small { color: #94a3b8; font-size: 11px; }

.sidebar-nav { padding: 14px 12px; overflow-y: auto; }
.nav-item-link {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 14px; margin-bottom: 4px;
  color: #cbd5e1; text-decoration: none;
  border-radius: 10px; font-size: 14px; font-weight: 500;
  transition: background .15s, color .15s;
}
.nav-item-link i { font-size: 17px; width: 20px; text-align: center; }
.nav-item-link:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-item-link.active {
  background: linear-gradient(135deg, var(--primario), var(--acento));
  color: #fff;
  box-shadow: 0 6px 14px rgba(79,70,229,.35);
}
.badge-menu {
  margin-left: auto;
  background: #f43f5e; color: #fff;
  font-size: 11px; font-weight: 700;
  min-width: 20px; height: 20px; padding: 0 6px;
  border-radius: 10px; display: grid; place-items: center;
}

.sidebar-footer { padding: 12px; border-top: 1px solid rgba(255,255,255,.07); }
.sidebar-footer .nav-item-link { color: #fda4af; }
.sidebar-footer .nav-item-link:hover { background: rgba(244,63,94,.15); color: #fecdd3; }

.sidebar-backdrop {
  display: none; position: fixed; inset: 0;
  background: rgba(15,23,42,.5); z-index: 1035;
}

/* ---------------- MAIN ---------------- */
.main-area {
  flex: 1;
  /* Sin min-width:0 un flex item nunca se encoge por debajo del ancho de su
     contenido: las tablas anchas estirarían la página en vez de dejar que
     .table-responsive haga su propio scroll horizontal. */
  min-width: 0;
  margin-left: var(--sidebar-ancho);
  display: flex; flex-direction: column; min-height: 100vh;
}

.content-area, .topbar { min-width: 0; }

.topbar {
  display: flex; align-items: center; gap: 14px;
  background: #fff;
  padding: 14px 26px;
  border-bottom: 1px solid var(--borde);
  position: sticky; top: 0; z-index: 1020;
}
.topbar-title { font-size: 19px; font-weight: 700; margin: 0; }
.btn-toggle-sidebar {
  border: 1px solid var(--borde); background: #fff;
  border-radius: 10px; font-size: 20px; line-height: 1;
  padding: 6px 10px; display: none;
}

.user-chip { display: flex; align-items: center; gap: 10px; }
.user-avatar {
  width: 38px; height: 38px; border-radius: 50%;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--primario), var(--acento));
  color: #fff; font-weight: 700; font-size: 15px;
}
.user-name { font-size: 13px; font-weight: 600; line-height: 1.2; }
.user-role { font-size: 11px; color: var(--tinta-suave); }

.content-area { padding: 26px; flex: 1; overflow-x: hidden; }
.app-footer {
  padding: 14px 26px; font-size: 12px; color: var(--tinta-suave);
  border-top: 1px solid var(--borde);
}

/* ---------------- TARJETAS ---------------- */
.card { border: none; border-radius: var(--radio); box-shadow: 0 1px 4px rgba(15,23,42,.06); }
.card-header {
  background: #fff; border-bottom: 1px solid var(--borde);
  border-radius: var(--radio) var(--radio) 0 0 !important;
  font-weight: 600; padding: 16px 20px;
}

.stat-card {
  border-radius: var(--radio);
  padding: 20px 22px;
  background: #fff;
  display: flex; align-items: center; gap: 16px;
  box-shadow: 0 1px 4px rgba(15,23,42,.06);
  cursor: pointer;
  transition: transform .15s, box-shadow .15s;
  border: 2px solid transparent;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(15,23,42,.1); }
.stat-card.activa { border-color: var(--primario); }
.stat-icon {
  width: 50px; height: 50px; border-radius: 13px;
  display: grid; place-items: center; font-size: 22px; color: #fff;
}
.stat-icon.bg-info-grad     { background: linear-gradient(135deg,#0ea5e9,#2563eb); }
.stat-icon.bg-success-grad  { background: linear-gradient(135deg,#22c55e,#059669); }
.stat-icon.bg-warning-grad  { background: linear-gradient(135deg,#f59e0b,#ea580c); }
.stat-icon.bg-secondary-grad{ background: linear-gradient(135deg,#94a3b8,#64748b); }
.stat-icon.bg-danger-grad   { background: linear-gradient(135deg,#f43f5e,#e11d48); }
.stat-icon.bg-purple-grad   { background: linear-gradient(135deg,#8b5cf6,#6d28d9); }
.stat-info h3 { margin: 0; font-size: 26px; font-weight: 800; }
.stat-info span { font-size: 13px; color: var(--tinta-suave); font-weight: 500; }

/* ---------------- TABLAS ---------------- */
.table { font-size: 14px; }
.table thead th {
  background: #f8fafc; color: #475569;
  font-size: 12px; text-transform: uppercase; letter-spacing: .5px;
  border-bottom: 1px solid var(--borde) !important;
  font-weight: 700; white-space: nowrap;
}
.table tbody td { vertical-align: middle; }
.estado-badge { font-size: 12px; font-weight: 600; padding: 6px 12px; border-radius: 20px; }

.thumb-arrendatario {
  width: 46px; height: 46px; object-fit: cover;
  border-radius: 10px; border: 1px solid var(--borde);
}

/* ---------------- FORMULARIOS ---------------- */
.form-label { font-weight: 600; font-size: 13px; color: #334155; }
.form-control, .form-select {
  border-radius: 10px; border-color: var(--borde);
  padding: 9px 13px; font-size: 14px;
}
.form-control:focus, .form-select:focus {
  border-color: var(--primario);
  box-shadow: 0 0 0 3px rgba(79,70,229,.15);
}

.btn { border-radius: 10px; font-weight: 600; font-size: 14px; }
.btn-primary {
  background: linear-gradient(135deg, var(--primario), var(--acento));
  border: none;
}
.btn-primary:hover { background: linear-gradient(135deg, var(--primario-oscuro), #6d28d9); }

/* ---------------- LOGIN ---------------- */
.login-body {
  min-height: 100vh;
  display: grid; place-items: center;
  background: linear-gradient(135deg, #0f172a 0%, #312e81 55%, #4f46e5 100%);
  padding: 20px;
}
.login-card {
  width: 100%; max-width: 420px;
  background: #fff; border-radius: 20px;
  padding: 40px 36px;
  box-shadow: 0 25px 60px rgba(0,0,0,.35);
}
.login-logo {
  width: 64px; height: 64px; border-radius: 18px; margin: 0 auto 16px;
  display: grid; place-items: center; font-size: 30px; color: #fff;
  background: linear-gradient(135deg, var(--primario), var(--acento));
  box-shadow: 0 10px 25px rgba(79,70,229,.45);
}

/* ---------------- RESPONSIVE ---------------- */
@media (max-width: 991.98px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.abierta { transform: translateX(0); }
  .sidebar-backdrop.visible { display: block; }
  .main-area { margin-left: 0; }
  .btn-toggle-sidebar { display: inline-block; }
  .content-area { padding: 16px; }
}

/* RUT en lista negra */
.aviso-lista-negra {
  border-radius: 10px;
  animation: pulso 1.2s ease-in-out infinite alternate;
}
@keyframes pulso { from { box-shadow: 0 0 0 0 rgba(220,38,38,.35); } to { box-shadow: 0 0 0 8px rgba(220,38,38,0); } }

/* FullCalendar */
.fc { background: #fff; border-radius: var(--radio); padding: 10px; }
.fc .fc-button-primary { background: var(--primario); border-color: var(--primario); }
.fc .fc-button-primary:not(:disabled):hover { background: var(--primario-oscuro); }
