/* ==========================================================================
   VALSEQ Licencias — Sistema de diseño
   Paleta corporativa extraída del logotipo. El grueso del layout viene de
   Tailwind CDN; aquí definimos los COMPONENTES reutilizables (.btn, .card,
   .tbl, .input, .badge, .modal…) que usan todas las vistas para mantener
   coherencia visual.
   ========================================================================== */
:root {
  --primary:      #0c8a74;  /* turquesa VALSEQ (acción) */
  --primary-700:  #0a6f5e;  /* hover */
  --petrol:       #123f4a;  /* petróleo (chrome oscuro) */
  --petrol-900:   #0d2e36;
  --turquesa:     #26c6a8;  /* turquesa brillante (acentos) */
  --success:      #16a34a;
  --warning:      #d97706;
  --danger:       #dc2626;
  --neutral:      #64748b;

  --ink:          #1e293b;  /* slate-800 */
  --ink-soft:     #475569;  /* slate-600 */
  --muted:        #94a3b8;  /* slate-400 */
  --line:         #e2e8f0;  /* slate-200 */
  --line-soft:    #f1f5f9;  /* slate-100 */

  --radius:       0.75rem;
  --shadow-sm:    0 1px 2px rgba(15, 23, 42, .06), 0 1px 3px rgba(15, 23, 42, .04);
  --shadow-md:    0 4px 12px -2px rgba(15, 23, 42, .10), 0 2px 6px -2px rgba(15, 23, 42, .06);
  --shadow-lg:    0 24px 50px -12px rgba(13, 46, 54, .30);

  --font-display: "Sora", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-body:    "Manrope", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

body {
  font-family: var(--font-body);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* Titulares con la fuente display de marca */
.page-title, .section-title, .modal-title, .stat-value, .brand-wordmark {
  font-family: var(--font-display);
  letter-spacing: -.02em;
}

[x-cloak] { display: none !important; }

/* --------------------------------------------------------------------------
   Navegación lateral
   -------------------------------------------------------------------------- */
.nav-valseq a {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.6rem 0.8rem;
  border-radius: 0.6rem;
  border-left: 3px solid transparent;
  font-size: 0.9rem;
  font-weight: 500;
  color: rgba(255, 255, 255, .72);
  transition: background-color .15s ease, border-color .15s ease, color .15s ease;
}
.nav-valseq a svg { width: 18px; height: 18px; flex: none; opacity: .8; transition: opacity .15s ease; }
.nav-valseq a:hover { background-color: rgba(255, 255, 255, .08); color: #fff; }
.nav-valseq a:hover svg { opacity: 1; }
.nav-activo {
  background-color: rgba(38, 198, 168, .16);
  border-left-color: var(--turquesa);
  color: #fff !important;
  font-weight: 600;
}
.nav-activo svg { opacity: 1; color: var(--turquesa); }

/* Encabezado de grupo dentro del menú */
.nav-group {
  font-size: .65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: rgba(255, 255, 255, .38);
  padding: .9rem .8rem .35rem;
}

/* Footer del sidebar: avatar de iniciales + rol + cerrar sesión */
.nav-avatar {
  width: 2.3rem; height: 2.3rem; flex: none;
  border-radius: 50%;
  display: grid; place-items: center;
  background: rgba(38, 198, 168, .18);
  border: 1px solid rgba(38, 198, 168, .4);
  color: var(--turquesa);
  font-family: var(--font-display);
  font-weight: 700; font-size: .82rem;
}
.nav-rol {
  font-size: .64rem; text-transform: uppercase; letter-spacing: .08em;
  color: var(--turquesa); margin-top: 1px;
}
.nav-logout {
  margin-top: .8rem;
  display: flex; align-items: center; gap: .55rem;
  width: 100%;
  padding: .5rem .65rem;
  border-radius: .55rem;
  color: rgba(255, 255, 255, .6);
  font-size: .85rem;
  transition: background-color .15s ease, color .15s ease;
}
.nav-logout:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.nav-logout svg { width: 16px; height: 16px; flex: none; }

/* La altura completa del sidebar en escritorio la da el contenedor flex */
@media (min-width: 768px) { .sidebar { min-height: 100vh; } }

/* --------------------------------------------------------------------------
   Encabezado de página
   -------------------------------------------------------------------------- */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.page-title  { font-size: 1.6rem; font-weight: 700; color: var(--ink); letter-spacing: -.01em; }
.page-sub    { font-size: .875rem; color: var(--ink-soft); margin-top: .15rem; }
.section-title { font-size: 1.05rem; font-weight: 700; color: var(--ink); }

/* --------------------------------------------------------------------------
   Tarjetas
   -------------------------------------------------------------------------- */
.card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 1.5rem;
}
.card-flush { padding: 0; overflow: hidden; }   /* para tablas a sangre */
.card-tight { padding: 1rem; }

/* KPI / estadística con barra de acento a la izquierda e icono */
.stat {
  position: relative;
  display: flex;
  align-items: center;
  gap: 1rem;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 1.25rem 1.4rem;
  overflow: hidden;
  transition: box-shadow .18s ease, transform .18s ease;
}
.stat:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.stat::before {
  content: "";
  position: absolute; left: 0; top: 0; bottom: 0; width: 4px;
  background: var(--accent, var(--primary));
}
.stat-ico {
  flex: none;
  width: 2.75rem; height: 2.75rem;
  display: grid; place-items: center;
  border-radius: .65rem;
  background: color-mix(in srgb, var(--accent, var(--primary)) 14%, white);
  color: var(--accent, var(--primary));
  font-size: 1.25rem;
}
.stat-label { font-size: .8rem; color: var(--ink-soft); }
.stat-value { font-size: 1.85rem; font-weight: 800; line-height: 1.1; color: var(--ink); letter-spacing: -.02em; }

/* Acentos para .stat / componentes (set via inline style o clase) */
.accent-teal   { --accent: var(--primary); }
.accent-green  { --accent: var(--success); }
.accent-amber  { --accent: var(--warning); }
.accent-red    { --accent: var(--danger); }
.accent-orange { --accent: #ea580c; }
.accent-violet { --accent: #7c3aed; }
.accent-petrol { --accent: var(--petrol); }

/* --------------------------------------------------------------------------
   Botones
   -------------------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .45rem;
  padding: .55rem 1rem;
  border-radius: .6rem;
  font-size: .875rem;
  font-weight: 600;
  line-height: 1;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background-color .15s ease, color .15s ease, border-color .15s ease, box-shadow .15s ease, transform .05s ease;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(12, 138, 116, .35); }
.btn:disabled { opacity: .55; cursor: not-allowed; }

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

.btn-secondary { background: #fff; color: var(--ink); border-color: var(--line); }
.btn-secondary:hover { background: var(--line-soft); border-color: #cbd5e1; }

.btn-ghost     { background: transparent; color: var(--ink-soft); }
.btn-ghost:hover { background: var(--line-soft); color: var(--ink); }

.btn-danger    { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; }

.btn-sm { padding: .35rem .7rem; font-size: .8rem; border-radius: .5rem; }

/* Enlace de acción discreto */
.link { color: var(--primary); font-weight: 500; cursor: pointer; }
.link:hover { color: var(--primary-700); text-decoration: underline; }

/* --------------------------------------------------------------------------
   Formularios
   -------------------------------------------------------------------------- */
.label {
  display: block;
  font-size: .7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--neutral);
  margin-bottom: .3rem;
}
.input, .select, .textarea {
  width: 100%;
  border: 1px solid #cbd5e1;
  border-radius: .6rem;
  padding: .55rem .7rem;
  font-size: .9rem;
  color: var(--ink);
  background: #fff;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.input::placeholder, .textarea::placeholder { color: var(--muted); }
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(12, 138, 116, .18);
}
.textarea { min-height: 4.5rem; resize: vertical; }
.field-group { display: flex; flex-direction: column; }

/* --------------------------------------------------------------------------
   Tablas
   -------------------------------------------------------------------------- */
.tbl { width: 100%; border-collapse: collapse; }
.tbl thead th {
  background: #f8fafc;
  text-align: left;
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--neutral);
  padding: .8rem 1rem;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.tbl tbody td {
  padding: .8rem 1rem;
  font-size: .875rem;
  color: var(--ink-soft);
  border-bottom: 1px solid var(--line-soft);
  vertical-align: middle;
}
.tbl tbody tr { transition: background-color .12s ease; }
.tbl tbody tr:hover { background: #f8fafc; }
.tbl tbody tr:last-child td { border-bottom: none; }
.tbl-empty { padding: 2.5rem 1rem; text-align: center; color: var(--muted); font-size: .9rem; }

/* --------------------------------------------------------------------------
   Badges / pills de estado
   -------------------------------------------------------------------------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  padding: .2rem .6rem;
  border-radius: 999px;
  font-size: .72rem;
  font-weight: 600;
  line-height: 1.4;
  text-transform: capitalize;
}
.badge::before {
  content: "";
  width: .45rem; height: .45rem; border-radius: 999px;
  background: currentColor; opacity: .9;
}
.badge-green  { background: #dcfce7; color: #15803d; }
.badge-amber  { background: #fef3c7; color: #b45309; }
.badge-red    { background: #fee2e2; color: #b91c1c; }
.badge-slate  { background: #e2e8f0; color: #475569; }
.badge-teal   { background: #cdf3ea; color: #0a6f5e; }
.badge-blue   { background: #cdf3ea; color: #0a6f5e; }    /* alias marca */
.badge-plain::before { display: none; }

/* Mapeo directo de estados de licencia (compatibilidad con .estado-*) */
.estado-activa               { color: var(--success); font-weight: 600; }
.estado-pendiente_activacion { color: var(--warning); font-weight: 600; }
.estado-suspendida           { color: var(--danger);  font-weight: 600; }
.estado-revocada             { color: var(--neutral);  font-weight: 600; }

/* --------------------------------------------------------------------------
   Modales
   -------------------------------------------------------------------------- */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, .55);
  backdrop-filter: blur(3px);
  display: grid; place-items: center;
  z-index: 50;
  padding: 1rem;
  animation: fadeIn .15s ease-out;
}
.modal {
  background: #fff;
  border-radius: 1rem;
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-height: 92vh;
  overflow-y: auto;
  animation: popIn .18s ease-out;
}
.modal-head { padding: 1.4rem 1.6rem 0; }
.modal-body { padding: 1.2rem 1.6rem; }
.modal-foot { padding: 0 1.6rem 1.4rem; display: flex; gap: .6rem; justify-content: flex-end; }
.modal-title { font-size: 1.2rem; font-weight: 700; color: var(--ink); }

/* --------------------------------------------------------------------------
   Misc
   -------------------------------------------------------------------------- */
.code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  background: var(--line-soft);
  border: 1px solid var(--line);
  border-radius: .4rem;
  padding: .15rem .45rem;
  font-size: .82rem;
  color: var(--ink);
}
.divider { height: 1px; background: var(--line); border: 0; margin: 1.25rem 0; }

/* Barra de progreso (bolsa de extracciones) */
.meter { height: .5rem; background: var(--line); border-radius: 999px; overflow: hidden; }
.meter > span { display: block; height: 100%; background: var(--primary); border-radius: 999px; transition: width .3s ease; }
.meter.warn > span { background: var(--warning); }
.meter.danger > span { background: var(--danger); }

/* Scrollbar discreta */
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 999px; border: 2px solid transparent; background-clip: content-box; }
*::-webkit-scrollbar-thumb:hover { background: #94a3b8; background-clip: content-box; }

/* --------------------------------------------------------------------------
   Toast
   -------------------------------------------------------------------------- */
.toast {
  position: fixed; bottom: 1.25rem; right: 1.25rem;
  display: flex; align-items: center; gap: .65rem;
  background: var(--petrol); color: #fff;
  padding: .8rem 1.1rem; border-radius: .65rem;
  border-left: 4px solid var(--turquesa);
  box-shadow: var(--shadow-lg);
  z-index: 60;
  font-size: .9rem;
  max-width: 24rem;
  animation: slideIn .2s ease-out;
}
.toast-ico { display: grid; place-items: center; flex: none; }
.toast-success { border-left-color: var(--success); }
.toast-success .toast-ico { color: #4ade80; }
.toast-error   { border-left-color: var(--danger); }
.toast-error .toast-ico { color: #f87171; }
.toast-info    { border-left-color: var(--turquesa); }
.toast-info .toast-ico { color: var(--turquesa); }
.toast-out { animation: slideOut .22s ease-in forwards; }

@keyframes slideIn  { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes slideOut { from { transform: translateY(0); opacity: 1; } to { transform: translateY(16px); opacity: 0; } }
@keyframes fadeIn  { from { opacity: 0; } to { opacity: 1; } }
@keyframes popIn   { from { transform: translateY(8px) scale(.98); opacity: 0; } to { transform: translateY(0) scale(1); opacity: 1; } }

/* ==========================================================================
   Motivo de marca VALSEQ — derivado del logotipo (la diana "Q" + línea de
   puntos). Se usa en el panel del login y otras superficies petróleo.
   ========================================================================== */
.brand-panel {
  position: relative;
  overflow: hidden;
  background: radial-gradient(135% 135% at 100% 0%, #1d6a78 0%, var(--petrol) 48%, var(--petrol-900) 100%);
  min-height: 30rem;
}
/* Diana concéntrica (el motivo del propio logo) sangrando por la esquina
   inferior derecha — sutil, sin invadir el texto. */
.brand-panel::before {
  content: "";
  position: absolute; right: -120px; bottom: -120px;
  width: 440px; height: 440px; border-radius: 50%;
  background: repeating-radial-gradient(circle at center,
      rgba(38, 198, 168, 0) 0 28px,
      rgba(38, 198, 168, .14) 28px 30px);
  -webkit-mask: radial-gradient(circle at center, #000 55%, transparent 72%);
          mask: radial-gradient(circle at center, #000 55%, transparent 72%);
  pointer-events: none;
}

/* Logotipo de marca grande y protagonista (versión blanca + acentos turquesa,
   fondo transparente) directamente sobre el panel petróleo. */
.brand-logo {
  width: 86%;
  max-width: 22rem;
  height: auto;
  filter: drop-shadow(0 6px 18px rgba(0, 0, 0, .28));
}
/* Marca dentro del hero del dashboard — más contenida, integrada con el saludo */
.dashboard-brand {
  height: 2.6rem;
  width: auto;
  display: block;
  filter: drop-shadow(0 5px 14px rgba(0, 0, 0, .28));
}
/* Halo turquesa difuso arriba-izquierda para dar profundidad */
.brand-panel::after {
  content: "";
  position: absolute; left: -90px; top: -90px;
  width: 260px; height: 260px; border-radius: 50%;
  background: radial-gradient(circle, rgba(38, 198, 168, .22), transparent 70%);
  pointer-events: none;
}
.brand-wordmark { color: #fff; }
/* Línea de puntos del logo (acento decorativo) */
.brand-dots {
  height: 2px; width: 9rem;
  background-image: radial-gradient(circle, var(--turquesa) 0 2.5px, transparent 3px);
  background-size: 16px 6px;
  background-repeat: repeat-x;
  background-position: left center;
}
.login-card { box-shadow: var(--shadow-lg); }

/* Revelado escalonado de las KPI del dashboard al entrar */
.grid-stats .stat { animation: rise .5s cubic-bezier(.2, .7, .2, 1) both; }
.grid-stats .stat:nth-child(1) { animation-delay: .03s; }
.grid-stats .stat:nth-child(2) { animation-delay: .09s; }
.grid-stats .stat:nth-child(3) { animation-delay: .15s; }
.grid-stats .stat:nth-child(4) { animation-delay: .21s; }
.grid-stats .stat:nth-child(5) { animation-delay: .27s; }
.grid-stats .stat:nth-child(6) { animation-delay: .33s; }
@keyframes rise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }

/* ==========================================================================
   Hero del dashboard + visualizaciones (anillo de salud, leyenda)
   ========================================================================== */
.hero {
  position: relative;
  overflow: hidden;
  background: radial-gradient(130% 130% at 100% 0%, #1d6a78 0%, var(--petrol) 50%, var(--petrol-900) 100%);
  border-radius: 1rem;
  color: #fff;
  padding: 1.9rem 2.1rem;
  box-shadow: var(--shadow-md);
  animation: rise .5s cubic-bezier(.2, .7, .2, 1) both;
}
.hero::before {  /* anillos concéntricos (diana del logo) */
  content: "";
  position: absolute; right: -70px; top: 50%; transform: translateY(-50%);
  width: 320px; height: 320px; border-radius: 50%;
  background: repeating-radial-gradient(circle at center,
      rgba(38, 198, 168, 0) 0 23px,
      rgba(38, 198, 168, .14) 23px 25px);
  -webkit-mask: radial-gradient(circle at center, #000 54%, transparent 72%);
          mask: radial-gradient(circle at center, #000 54%, transparent 72%);
  pointer-events: none;
}
.hero-eyebrow { font-size: .72rem; letter-spacing: .14em; text-transform: uppercase; color: rgba(255, 255, 255, .55); }
.hero-title   { font-family: var(--font-display); font-weight: 800; font-size: 1.95rem; letter-spacing: -.02em; line-height: 1.1; }

/* Anillo de progreso (CSS conic-gradient) */
.ring {
  position: relative;
  width: 126px; height: 126px; flex: none;
  border-radius: 50%;
  background: conic-gradient(var(--turquesa) calc(var(--pct, 0) * 1%), rgba(255, 255, 255, .16) 0);
}
.ring::after { content: ""; position: absolute; inset: 13px; border-radius: 50%; background: rgba(11, 47, 55, .92); }
.ring-center { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; z-index: 1; }
.ring-num { font-family: var(--font-display); font-weight: 800; font-size: 1.7rem; color: #fff; line-height: 1; }
.ring-cap { font-size: .68rem; text-transform: uppercase; letter-spacing: .08em; color: rgba(255, 255, 255, .6); margin-top: 3px; }

/* Leyenda con puntos de color */
.dot { display: inline-block; width: .6rem; height: .6rem; border-radius: 50%; flex: none; }
.legend { display: flex; flex-wrap: wrap; gap: .6rem 1.25rem; font-size: .85rem; }

/* Stat clicable (tarjeta KPI que enlaza) */
a.stat { text-decoration: none; color: inherit; cursor: pointer; }
a.stat:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }

/* --------------------------------------------------------------------------
   Skeletons de carga (shimmer)
   -------------------------------------------------------------------------- */
.sk {
  background: linear-gradient(90deg, #e9eef3 25%, #f4f7fa 50%, #e9eef3 75%);
  background-size: 200% 100%;
  animation: shimmer 1.25s ease-in-out infinite;
  border-radius: var(--radius);
}
.sk-title { height: 2.1rem; width: 15rem; margin-bottom: 1.6rem; }
.sk-stat  { height: 5.6rem; }
.sk-block { height: 20rem; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* Spinner inline para botones en estado "Procesando…" */
.anim-spin { animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Respeto a quien prefiere menos movimiento */
@media (prefers-reduced-motion: reduce) {
  .grid-stats .stat, .hero, .modal, .modal-backdrop, .toast, .sk { animation: none !important; }
}
