/* ============================================================
   CleanFlow — Estilos personalizados
   Complementa Tailwind CDN
   ============================================================ */

/* ── Fuentes ─────────────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Plus+Jakarta+Sans:wght@700;800;900&display=swap');

/* ── Variables ───────────────────────────────────────────────── */
:root {
  --brand-50:  #f9fdf0;
  --brand-100: #f2f9dc;
  --brand-200: #e5f3bc;
  --brand-300: #d4e993;
  --brand-400: #bfda6c;
  --brand-500: #a5c73d;
  --brand-600: #687f20;
  --brand-700: #566a19;
  --brand-800: #445316;
  --brand-900: #364213;
  --brand-950: #20280a;

  --petrol-700: #0c4a6e;
  --petrol-800: #082f49;
  --petrol-900: #0c1a2e;
  --petrol-950: #080f1f;

  --shadow-card:       0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow-card-hover: 0 8px 25px rgba(0,0,0,.10), 0 3px 10px rgba(0,0,0,.06);
  --shadow-brand-glow: 0 0 20px rgba(165,199,61,.40);
}

/* ── Reset ───────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  font-family: 'Inter', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  color: #0f172a;
  background: #fff;
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 9999px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ── Tipografía display ──────────────────────────────────────── */
.font-display { font-family: 'Plus Jakarta Sans', system-ui, sans-serif; }

/* ── Gradientes de fondo ─────────────────────────────────────── */
.bg-gradient-hero {
  background: linear-gradient(135deg, var(--petrol-950) 0%, #0a1628 40%, var(--petrol-900) 100%);
}

/* ── Texto degradado ─────────────────────────────────────────── */
.text-gradient-green {
  background: linear-gradient(135deg, #a5c73d, #d4e993);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.text-gradient-blue {
  background: linear-gradient(135deg, #3b82f6, #60a5fa);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ── Noise overlay ───────────────────────────────────────────── */
.noise { position: relative; }
.noise::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.03'/%3E%3C/svg%3E");
  pointer-events: none;
  mix-blend-mode: overlay;
}

/* ── Sombras ─────────────────────────────────────────────────── */
.shadow-card       { box-shadow: var(--shadow-card); }
.shadow-card-hover { box-shadow: var(--shadow-card-hover); }
.shadow-brand-glow { box-shadow: var(--shadow-brand-glow); }

/* ── Animaciones ─────────────────────────────────────────────── */
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50%       { transform: translateY(-20px); }
}
@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
@keyframes pulse-slow {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.5; }
}
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(30px); }
  to   { opacity: 1; transform: translateY(0); }
}

.animate-float      { animation: float 6s ease-in-out infinite; }
.animate-pulse-slow { animation: pulse-slow 2s ease-in-out infinite; }
.animate-spin       { animation: spin 1s linear infinite; }
.animate-fade-up    { animation: fadeInUp 0.7s ease forwards; }

/* ── Logo animado ────────────────────────────────────────────
   Tres capas sobre el mismo PNG: un resplandor lima que respira
   detras, una flotacion suave del conjunto, y un destello diagonal
   que recorre el logo. El destello se recorta con mask-image usando
   el propio PNG, asi solo ilumina los pixeles del logo y nunca el
   rectangulo que lo contiene. */
.logo-anim {
  position: relative;
  display: inline-block;
  line-height: 0;
  animation: logo-float 7s ease-in-out infinite;
}
.logo-anim > img { position: relative; z-index: 1; }

.logo-anim::before {
  content: "";
  position: absolute;
  inset: -22% -12%;
  z-index: 0;
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(165,199,61,.30), rgba(165,199,61,0) 72%);
  filter: blur(14px);
  animation: logo-breathe 6s ease-in-out infinite;
  pointer-events: none;
}

/* El destello va sobre un hijo real, no sobre ::after del contenedor: asi la
   mascara queda fija sobre el logo y lo que se mueve es una barra con
   transform (interpolable y por compositor; background-position saltaba). */
.logo-anim .logo-sheen {
  position: absolute;
  inset: 0;
  z-index: 2;
  overflow: hidden;
  pointer-events: none;
  -webkit-mask-image: var(--logo-mask); mask-image: var(--logo-mask);
  -webkit-mask-size: 100% 100%;  mask-size: 100% 100%;
  -webkit-mask-repeat: no-repeat; mask-repeat: no-repeat;
}
.logo-anim .logo-sheen::after {
  content: "";
  position: absolute;
  top: -25%; bottom: -25%; left: 0;
  width: 42%;
  background: linear-gradient(90deg, rgba(255,255,255,0), rgba(255,255,255,.60), rgba(255,255,255,0));
  animation: logo-sheen 7s ease-in-out infinite;
}

@keyframes logo-float   { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-7px); } }
@keyframes logo-breathe { 0%,100% { opacity: .55; transform: scale(.94); } 50% { opacity: 1; transform: scale(1.06); } }
@keyframes logo-sheen   { 0%, 20% { transform: translateX(-160%) skewX(-18deg); }
                          60%, 100% { transform: translateX(340%) skewX(-18deg); } }

/* Quien pidio menos movimiento ve el logo quieto, solo con el resplandor. */
@media (prefers-reduced-motion: reduce) {
  .logo-anim, .logo-anim::before, .logo-anim .logo-sheen::after { animation: none; }
  .logo-anim .logo-sheen { display: none; }
}


/* ── Reveal on scroll ────────────────────────────────────────── */
.reveal {
  opacity: 0;
  transform: translateY(30px);
  transition: opacity 0.7s ease, transform 0.7s ease;
}
.reveal.visible { opacity: 1; transform: translateY(0); }

/* ── Botones ─────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-weight: 500;
  border-radius: 0.5rem;
  transition: all 0.2s;
  cursor: pointer;
  user-select: none;
  border: none;
  outline: none;
  text-decoration: none;
}
.btn:disabled { opacity: 0.5; pointer-events: none; }
.btn:focus-visible { outline: 2px solid var(--brand-500); outline-offset: 2px; }

.btn-sm  { padding: 0.375rem 0.75rem;  font-size: 0.875rem; }
.btn-md  { padding: 0.5rem  1rem;      font-size: 0.875rem; }
.btn-lg  { padding: 0.75rem 1.5rem;    font-size: 1rem;     }

/* El primario usa el lima exacto del logo (--brand-500) con tinta oscura:
   es el color de marca literal y da 7.9:1 de contraste, muy por encima de AA.
   Con texto blanco ese mismo lima daria 1.9:1, ilegible. */
.btn-primary {
  background: var(--brand-500); color: var(--brand-950);
  box-shadow: 0 1px 2px rgba(0,0,0,.08);
}
.btn-primary:hover  { background: var(--brand-400); box-shadow: var(--shadow-brand-glow); }

.btn-secondary { background: #f1f5f9; color: #334155; }
.btn-secondary:hover { background: #e2e8f0; }

.btn-danger { background: #dc2626; color: #fff; }
.btn-danger:hover { background: #b91c1c; }

.btn-ghost { background: transparent; color: #475569; }
.btn-ghost:hover { background: #f1f5f9; }

.btn-outline { background: #fff; color: #334155; border: 1px solid #cbd5e1; }
.btn-outline:hover { background: #f8fafc; }

/* ── Inputs ──────────────────────────────────────────────────── */
.input {
  width: 100%;
  border-radius: 0.5rem;
  border: 1px solid #cbd5e1;
  background: #fff;
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  color: #0f172a;
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: none;
  font-family: inherit;
}
.input::placeholder { color: #94a3b8; }
.input:focus {
  border-color: var(--brand-500);
  box-shadow: 0 0 0 3px rgba(165,199,61,.22);
}
.input:disabled { background: #f8fafc; color: #94a3b8; cursor: not-allowed; }
.input-error { border-color: #f87171; }
.input-error:focus { box-shadow: 0 0 0 3px rgba(248,113,113,.2); }

.label { display: block; font-size: 0.875rem; font-weight: 500; color: #374151; margin-bottom: 0.25rem; }
.field-error { margin-top: 0.25rem; font-size: 0.75rem; color: #ef4444; }

/* ── Cards ───────────────────────────────────────────────────── */
.card {
  background: #fff;
  border-radius: 0.75rem;
  border: 1px solid #e2e8f0;
  box-shadow: var(--shadow-card);
}
.card-header {
  padding: 1rem 1.5rem;
  border-bottom: 1px solid #f1f5f9;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.card-body { padding: 1.5rem; }

/* ── Badges ──────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.125rem 0.625rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 500;
}
.badge-green  { background: #dcfce7; color: #15803d; }
.badge-blue   { background: #dbeafe; color: #1d4ed8; }
.badge-yellow { background: #fef9c3; color: #a16207; }
.badge-red    { background: #fee2e2; color: #b91c1c; }
.badge-gray   { background: #f1f5f9; color: #475569; }
.badge-orange { background: #ffedd5; color: #c2410c; }
.badge-purple { background: #ede9fe; color: #6d28d9; }

/* ── Tablas ──────────────────────────────────────────────────── */
.table-wrapper { width: 100%; overflow-x: auto; border-radius: 0.75rem; border: 1px solid #e2e8f0; }
.table { width: 100%; font-size: 0.875rem; text-align: left; border-collapse: collapse; }
.table thead { background: #f8fafc; }
.table thead th {
  padding: 0.75rem 1rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
}
.table tbody td { padding: 0.75rem 1rem; color: #334155; }
.table tbody tr { border-top: 1px solid #f1f5f9; transition: background 0.15s; }
.table tbody tr:hover { background: rgba(248,250,252,.6); }

/* ── Skeleton ────────────────────────────────────────────────── */
.skeleton {
  background: linear-gradient(90deg, #e2e8f0 25%, #f1f5f9 50%, #e2e8f0 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 0.375rem;
}

/* ── Status dot ──────────────────────────────────────────────── */
.status-dot { width: 0.5rem; height: 0.5rem; border-radius: 9999px; flex-shrink: 0; }

/* ── Sidebar ─────────────────────────────────────────────────── */
#sidebar {
  width: 260px;
  min-width: 260px;
  background: #0f172a;
  border-right: 1px solid rgba(255,255,255,.05);
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: sticky;
  top: 0;
  transition: width 0.25s ease, min-width 0.25s ease;
  overflow: hidden;
  flex-shrink: 0;
}
#sidebar.collapsed { width: 0; min-width: 0; }

.sidebar-brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1rem;
  height: 4rem;
  border-bottom: 1px solid rgba(255,255,255,.05);
  flex-shrink: 0;
}

.sidebar-nav { flex: 1; padding: 1rem 0.75rem; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }

.nav-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.625rem 0.75rem;
  border-radius: 0.5rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: rgba(255,255,255,.6);
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}
.nav-link:hover { background: rgba(255,255,255,.05); color: #fff; }
.nav-link.active { background: var(--brand-600); color: #fff; }
.nav-link svg { width: 1rem; height: 1rem; flex-shrink: 0; }

.sidebar-user {
  padding: 0.75rem;
  border-top: 1px solid rgba(255,255,255,.05);
  flex-shrink: 0;
}
.sidebar-user-inner {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0.5rem;
}
.avatar {
  width: 2rem; height: 2rem;
  border-radius: 9999px;
  background: var(--brand-600);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.75rem; font-weight: 700; color: #fff;
  flex-shrink: 0;
}

/* ── App layout ──────────────────────────────────────────────── */
#app-wrapper { display: flex; height: 100vh; overflow: hidden; }
#app-main    { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
#app-header  {
  height: 4rem;
  border-bottom: 1px solid #e2e8f0;
  background: #fff;
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  gap: 1rem;
  flex-shrink: 0;
}
#app-content { flex: 1; overflow-y: auto; padding: 1.5rem; background: #f8fafc; }

/* ── Modal ───────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 50;
  display: flex; align-items: center; justify-content: center;
  padding: 1rem;
}
.modal-backdrop.hidden { display: none; }
.modal {
  background: #fff;
  border-radius: 0.75rem;
  width: 100%;
  max-width: 540px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid #f1f5f9;
}
.modal-body    { padding: 1.5rem; }
.modal-footer  {
  display: flex; justify-content: flex-end; gap: 0.75rem;
  padding: 1rem 1.5rem;
  border-top: 1px solid #f1f5f9;
}

/* ── Toast ───────────────────────────────────────────────────── */
#toast-container {
  position: fixed;
  top: 1rem; right: 1rem;
  z-index: 9999;
  display: flex; flex-direction: column; gap: 0.5rem;
}
.toast {
  display: flex; align-items: center; gap: 0.75rem;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 0.75rem;
  padding: 0.875rem 1rem;
  font-size: 0.875rem;
  color: #1e293b;
  box-shadow: 0 4px 20px rgba(0,0,0,.12);
  min-width: 280px;
  max-width: 380px;
  animation: fadeInUp 0.3s ease;
}
.toast.success { border-left: 4px solid var(--brand-500); }
.toast.error   { border-left: 4px solid #ef4444; }
.toast.warning { border-left: 4px solid #f59e0b; }
.toast.info    { border-left: 4px solid #3b82f6; }

/* ── Spinner ─────────────────────────────────────────────────── */
.spinner {
  width: 1rem; height: 1rem;
  border: 2px solid rgba(255,255,255,.3);
  border-top-color: #fff;
  border-radius: 9999px;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}
.spinner-dark {
  border-color: rgba(0,0,0,.15);
  border-top-color: #334155;
}

/* ── Section title (landing) ─────────────────────────────────── */
.section-title {
  font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
  font-size: clamp(2rem, 4vw, 3rem);
  font-weight: 900;
  letter-spacing: -0.02em;
  line-height: 1.1;
}
.section-subtitle {
  font-size: 1.125rem;
  color: #64748b;
  max-width: 42rem;
  margin-left: auto;
  margin-right: auto;
}

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 1024px) {
  #sidebar { position: fixed; top: 0; left: 0; height: 100vh; z-index: 30; }
  #sidebar.collapsed { width: 0; min-width: 0; }
  #overlay { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 20; }
  #overlay.hidden { display: none; }
}

/* ── Colores brand para Tailwind CDN ─────────────────────────── */
/* Estos se usan junto con Tailwind CDN; definimos las clases custom que Tailwind no tiene */
.bg-brand-50  { background-color: var(--brand-50); }
.bg-brand-100 { background-color: var(--brand-100); }
.bg-brand-500 { background-color: var(--brand-500); }
.bg-brand-600 { background-color: var(--brand-600); }
.bg-brand-700 { background-color: var(--brand-700); }
.bg-brand-900 { background-color: var(--brand-900); }
.text-brand-400 { color: var(--brand-400); }
.text-brand-500 { color: var(--brand-500); }
.text-brand-600 { color: var(--brand-600); }
.text-brand-700 { color: var(--brand-700); }
.border-brand-200 { border-color: var(--brand-200); }
.border-brand-500 { border-color: var(--brand-500); }
.hover\:bg-brand-500:hover { background-color: var(--brand-500); }
.hover\:bg-brand-700:hover { background-color: var(--brand-700); }
.hover\:shadow-brand-glow:hover { box-shadow: var(--shadow-brand-glow); }
.hover\:shadow-card-hover:hover { box-shadow: var(--shadow-card-hover); }

/* ── Utilidades extra ────────────────────────────────────────── */
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.line-clamp-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* ── Notificación bloqueante ──────────────────────────────────
   Modal de aviso que tapa la pantalla hasta que el usuario confirma.
   Vive fuera de .modal-backdrop porque no comparte comportamiento:
   éste no se cierra al clickear el fondo ni con Escape, y se apoya
   sobre todo lo demás (z-index por encima de sidebar y modales). */
.cf-notif-backdrop {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  background: rgba(15, 23, 42, .72);
  backdrop-filter: blur(3px);
  animation: cf-notif-fade .18s ease-out;
}

.cf-notif-card {
  width: 100%;
  max-width: 440px;
  background: #fff;
  border-radius: 1rem;
  overflow: hidden;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, .45);
  animation: cf-notif-pop .22s cubic-bezier(.16, 1, .3, 1);
}

.cf-notif-head {
  padding: 1.75rem 1.5rem 1.25rem;
  text-align: center;
  color: #f8fafc;
  background: linear-gradient(150deg, #1e293b 0%, #0f172a 100%);
  border-bottom: 3px solid var(--brand-500);
}

.cf-notif-icono {
  width: 56px; height: 56px;
  margin: 0 auto .875rem;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  color: #0f172a;
  background: var(--brand-500);
  animation: cf-notif-latido 1.8s ease-in-out 3;
}

.cf-notif-kicker {
  margin: 0;
  font-size: .6875rem;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--brand-400);
}
.cf-notif-numero  { margin: .25rem 0 .375rem; font-size: 1.5rem; font-weight: 800; letter-spacing: -.02em; }
.cf-notif-mensaje { margin: 0; font-size: .8125rem; color: #cbd5e1; }

.cf-notif-body  { padding: 1rem 1.5rem .5rem; }
.cf-notif-notas {
  margin: .75rem 0 0;
  padding: .625rem .75rem;
  border-radius: .5rem;
  font-size: .75rem;
  color: #92400e;
  background: #fffbeb;
  border: 1px solid #fde68a;
}

.cf-notif-pie { padding: 1rem 1.5rem 1.5rem; }
.cf-notif-btn {
  width: 100%;
  padding: .8125rem 1rem;
  border: none;
  border-radius: .625rem;
  font-family: inherit;
  font-size: .9375rem;
  font-weight: 700;
  color: #14210a;
  background: var(--brand-500);
  cursor: pointer;
  transition: background .15s, box-shadow .15s;
}
.cf-notif-btn:hover:not(:disabled) { background: var(--brand-400); box-shadow: var(--shadow-brand-glow); }
.cf-notif-btn:disabled { opacity: .6; cursor: default; }
.cf-notif-btn:focus-visible { outline: 3px solid var(--brand-400); outline-offset: 2px; }

@keyframes cf-notif-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes cf-notif-pop  { from { opacity: 0; transform: translateY(14px) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes cf-notif-latido {
  0%, 100% { transform: scale(1);    box-shadow: 0 0 0 0    rgba(165, 199, 61, .6); }
  50%      { transform: scale(1.06); box-shadow: 0 0 0 14px rgba(165, 199, 61, 0);  }
}
