/* ============================================================
   Buscarlo Gestión — Estilos globales
   ============================================================ */

* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* === Paleta DVL (Distribuidora Villa Luro) === */
  --bg-primary: #0c2630;     /* verde-petróleo profundo DVL */
  --bg-secondary: #143a47;   /* teal DVL (header/sidebar/cards base) */
  --bg-card: rgba(20, 58, 71, 0.72);
  --border: rgba(120, 184, 172, 0.16);
  --text-primary: #e8f1ef;
  --text-secondary: #c3d6d2;
  --text-muted: #8aa9a4;
  --accent-blue: #3fb5a6;    /* teal-verde DVL (acento principal) */
  --accent-purple: #5e9e94;  /* verde apagado DVL (par del degradé) */
  --accent-green: #4fc2a6;   /* verde DVL brillante */
  --accent-teal: #3fb5a6;
  --accent-red: #ef8278;
  --accent-amber: #efb13c;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow-lg: 0 10px 40px rgba(0, 0, 0, 0.45);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background:
    radial-gradient(1100px 560px at 80% -12%, rgba(63,181,166,0.10), transparent 55%),
    radial-gradient(900px 520px at 12% 112%, rgba(63,181,166,0.06), transparent 55%),
    linear-gradient(160deg, #09212a 0%, #123745 100%);
  background-attachment: fixed;
  color: var(--text-primary);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ============== AUTH PAGES ============== */
.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

.auth-card {
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2.5rem;
  max-width: 420px;
  width: 100%;
  box-shadow: var(--shadow-lg);
}

.auth-header { text-align: center; margin-bottom: 2rem; }
.auth-header .logo { font-size: 3rem; margin-bottom: 0.5rem; }
.auth-header h1 {
  font-size: 1.875rem;
  font-weight: 700;
  background: linear-gradient(90deg, var(--accent-blue), var(--accent-purple));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  margin-bottom: 0.5rem;
}
.auth-header .subtitle { color: var(--text-muted); font-size: 0.9rem; }

.auth-form .form-group { margin-bottom: 1.25rem; }
.auth-form label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
}
.auth-form input {
  width: 100%;
  padding: 0.75rem 1rem;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 1rem;
  transition: border-color 0.15s;
}
.auth-form input:focus {
  outline: none;
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px rgba(63, 181, 166, 0.15);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-primary {
  width: 100%;
  background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
  color: white;
  margin-top: 0.5rem;
}
.btn-primary:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(63, 181, 166, 0.4);
}
.btn-primary:disabled { opacity: 0.6; cursor: wait; }

.btn-secondary {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: rgba(255, 255, 255, 0.15); }

.error-msg {
  background: rgba(248, 113, 113, 0.1);
  border: 1px solid var(--accent-red);
  color: var(--accent-red);
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  margin-bottom: 1rem;
}

.auth-footer { text-align: center; margin-top: 1.5rem; }
.link-muted {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.875rem;
}
.link-muted:hover { color: var(--text-secondary); text-decoration: underline; }

/* ============== APP LAYOUT ============== */
.app-layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  grid-template-rows: 60px 1fr;
  min-height: 100vh;
}

.app-header {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
}
.app-header .brand {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--text-primary);
  letter-spacing: 0.01em;
}
.app-header .brand::before {
  content: '';
  width: 30px;
  height: 30px;
  flex: 0 0 auto;
  background: url(/assets/img/dvl-logo.svg) no-repeat center / contain;
}
.app-header .user-info {
  display: flex;
  align-items: center;
  gap: 1rem;
  color: var(--text-secondary);
  font-size: 0.875rem;
}
.app-header .logout-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 0.4rem 0.8rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.875rem;
}
.app-header .logout-btn:hover { color: var(--accent-red); border-color: var(--accent-red); }

.app-sidebar {
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  padding: 1.5rem 0.75rem;
}
.app-sidebar nav { display: flex; flex-direction: column; gap: 0.25rem; }
.app-sidebar a {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.625rem 0.875rem;
  color: var(--text-secondary);
  text-decoration: none;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  transition: background 0.15s;
}
.app-sidebar a:hover { background: rgba(255, 255, 255, 0.05); color: var(--text-primary); }
.app-sidebar a.active {
  background: rgba(63, 181, 166, 0.16);
  color: var(--accent-blue);
  box-shadow: inset 3px 0 0 var(--accent-blue);
}
.app-sidebar a .icon { font-size: 1.125rem; }

.app-main { padding: 2rem; }
.app-main h2 { font-size: 1.5rem; font-weight: 600; margin-bottom: 1.5rem; }

/* ============== KPI CARDS ============== */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}
.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
}
.kpi-card .label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.5rem;
}
.kpi-card .value {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text-primary);
}
.kpi-card .change {
  font-size: 0.8rem;
  margin-top: 0.5rem;
  color: var(--text-muted);
}
.kpi-card .change.up { color: var(--accent-green); }
.kpi-card .change.down { color: var(--accent-red); }

/* ============== TABLE ============== */
.data-table {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  border-collapse: separate;
  border-spacing: 0;
}
.data-table th {
  text-align: left;
  padding: 0.75rem 1rem;
  background: rgba(0, 0, 0, 0.2);
  color: var(--text-secondary);
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border);
}
.data-table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}
.data-table tr:last-child td { border-bottom: none; }
/* ===== Convención GLOBAL: zebra + columnas ordenables (modelo stock/movimientos) =====
   Aplica AUTOMÁTICAMENTE a toda <table class="data-table">. El orden A-Z/Z-A se activa
   poniendo data-sort="campo" en el <th> + el handler JS de la página. */
.data-table tbody tr:nth-child(even) td { background: rgba(63, 181, 166, 0.045); }
.data-table tbody tr:hover td { background: rgba(63, 181, 166, 0.10); }
.data-table th[data-sort] { cursor: pointer; user-select: none; position: relative; padding-right: 1.3rem; }
.data-table th[data-sort]:hover { background: rgba(63, 181, 166, 0.10); color: #7fe0cf; }
.data-table th[data-sort]::after { content: '⇅'; position: absolute; right: 0.45rem; opacity: 0.35; font-size: 0.72rem; }
.data-table th[data-sort].sort-asc::after { content: '▲'; opacity: 1; color: #3fb5a6; }
.data-table th[data-sort].sort-desc::after { content: '▼'; opacity: 1; color: #3fb5a6; }

/* ===== Header sticky + UNIFICADO — TODA tabla de TODO tablero (presente y futuro) =====
   El thead de CUALQUIER <table> dentro de .app-main queda FIJO al scrollear (sticky relativo al
   documento: se quitaron los contenedores de scroll intermedios) y comparte el MISMO fondo, color
   y tipografía → diseño unificado en todo el proyecto sin tocar cada HTML. Gana especificidad
   (.app-layout .app-main, 2 clases) a los estilos por-página (table.prov/.dep/.pr/.u/.t/.bld/.grid-grupos…).
   No fija text-align/padding/font-size para respetar la densidad de cada tabla. */
.tbl-scroll { overflow: visible; max-height: none; }   /* wrapper passthrough (no crea scroll interno) */
.app-layout .app-main table thead th {
  position: sticky; top: 0; z-index: 5;
  background: #0f2f3a;
  color: var(--text-secondary);
  font-weight: 600;
  text-transform: none;
  letter-spacing: 0;
  box-shadow: inset 0 -1px 0 var(--border);
}
/* sub-tablas dentro de celdas (accordions / detalles): NO fijar ni pisar su fondo */
.app-layout .app-main td table thead th,
.app-layout .app-main th table thead th {
  position: static; z-index: auto; box-shadow: none; background: transparent; color: inherit;
}
/* ===== Caja de tabla reutilizable: el header queda FIJO y baja solo la lista (filtros quedan arriba).
   Envolver la <table> en <div class="tbl-box">. Es el formato de Proveedores. Ver docs/PLANTILLA-TABLA-DVL.md ===== */
.tbl-box { max-height: 68vh; overflow: auto; border-radius: var(--radius); }

.tag {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
}
.tag-green { background: rgba(79, 194, 166, 0.15); color: var(--accent-green); }
.tag-amber { background: rgba(251, 191, 36, 0.15); color: var(--accent-amber); }
.tag-red { background: rgba(248, 113, 113, 0.15); color: var(--accent-red); }
.tag-blue { background: rgba(63, 181, 166, 0.15); color: var(--accent-blue); }

.loader {
  text-align: center;
  padding: 3rem;
  color: var(--text-muted);
}

@media (max-width: 768px) {
  .app-layout { grid-template-columns: 1fr; grid-template-rows: 60px auto 1fr; }
  .app-sidebar { border-right: none; border-bottom: 1px solid var(--border); padding: 0.75rem; }
  .app-sidebar nav { flex-direction: row; overflow-x: auto; }
  .app-sidebar a { padding: 0.5rem 0.75rem; white-space: nowrap; }
  .app-main { padding: 1rem; }
  .auth-card { padding: 1.5rem; }
}
