/* ============================================================
   Hola Congelados — Sistema de gestión
   Diseño moderno, mobile-first, sin frameworks externos.
   Paleta: azul profundo + acento cyan (alude a "congelados").
============================================================ */

:root {
  /* Color tokens */
  --color-primary:        #0066cc;
  --color-primary-dark:   #004ea3;
  --color-primary-light:  #e0f0ff;
  --color-accent:         #3fbbed;
  --color-accent-dark:    #1f9bd0;
  --color-brand-dark:     #23222c;

  --color-success:        #059669;
  --color-success-bg:     #ecfdf5;
  --color-success-border: #a7f3d0;
  --color-warning:        #d97706;
  --color-warning-bg:     #fffbeb;
  --color-warning-border: #fcd34d;
  --color-danger:         #dc2626;
  --color-danger-bg:      #fef2f2;
  --color-danger-border:  #fca5a5;
  --color-info:           #0284c7;
  --color-info-bg:        #f0f9ff;

  --color-bg:             #f1f5f9;
  --color-surface:        #ffffff;
  --color-surface-alt:    #f8fafc;

  --color-text:           #0f172a;
  --color-text-soft:      #334155;
  --color-text-muted:     #64748b;
  --color-text-faint:     #94a3b8;

  --color-border:         #e2e8f0;
  --color-border-strong:  #cbd5e1;

  /* Sidebar / topbar */
  --color-nav-bg:         #0c1f3f;
  --color-nav-bg-alt:     #14305f;
  --color-nav-text:       #cbd5e1;
  --color-nav-text-hover: #ffffff;
  --color-nav-active:     #0066cc;

  /* Elevation */
  --shadow-sm:  0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow:     0 1px 3px rgba(15, 23, 42, 0.08), 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md:  0 4px 6px -1px rgba(15, 23, 42, 0.08), 0 2px 4px -1px rgba(15, 23, 42, 0.04);
  --shadow-lg:  0 10px 15px -3px rgba(15, 23, 42, 0.08), 0 4px 6px -2px rgba(15, 23, 42, 0.04);

  /* Radius */
  --radius-sm:  6px;
  --radius:     10px;
  --radius-lg:  14px;
  --radius-xl:  20px;
  --radius-pill: 999px;

  /* Typography */
  --font-sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, "Cascadia Code", "SF Mono", Menlo, Consolas, monospace;

  /* Layout */
  --container-max: 1240px;
  --topbar-h: 76px;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: var(--font-sans);
  font-size: 14.5px;
  line-height: 1.5;
  color: var(--color-text);
  background: var(--color-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: var(--color-primary);
  text-decoration: none;
  transition: color 0.15s ease;
}
a:hover { color: var(--color-primary-dark); text-decoration: underline; }

h1, h2, h3, h4 { margin: 0 0 0.4em; font-weight: 600; letter-spacing: -0.01em; color: var(--color-text); }
h1 { font-size: 1.75rem; line-height: 1.2; margin-bottom: 0.6em; }
h2 { font-size: 1.2rem; margin-top: 1.6em; color: var(--color-text-soft); }
h3 { font-size: 1rem; }

.muted, em { color: var(--color-text-muted); font-style: normal; }
.muted { font-size: 0.875em; }

hr { border: 0; border-top: 1px solid var(--color-border); margin: 1.5em 0; }

/* ---------- Topbar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1em;
  padding: 0 1.4em;
  height: var(--topbar-h);
  background: linear-gradient(135deg, var(--color-nav-bg) 0%, var(--color-nav-bg-alt) 100%);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: var(--shadow-md);
}

.topbar .brand {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}
.topbar .brand a {
  display: flex;
  align-items: center;
  padding: 0.3em 0.5em;
  border-radius: var(--radius-sm);
  transition: background 0.15s ease;
}
.topbar .brand a:hover { background: rgba(255,255,255,0.06); text-decoration: none; }
.brand-logo {
  height: 56px;
  width: auto;
  display: block;
  /* Invertir colores oscuros del logo a blanco para fondo navy */
  filter: brightness(0) saturate(100%) invert(100%);
}

/* Topnav */
.topnav {
  display: flex;
  gap: 0.15em;
  flex: 1;
  margin: 0 1em;
  flex-wrap: wrap;
  overflow: hidden;
}
.topnav a {
  color: var(--color-nav-text);
  padding: 0.5em 0.85em;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 500;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 0.5em;
}
.topnav a:hover {
  background: rgba(255,255,255,0.1);
  color: #fff;
  text-decoration: none;
}
.topnav i, .topnav svg {
  width: 18px;
  height: 18px;
  stroke-width: 2;
}

/* User area */
.user-area {
  display: flex;
  align-items: center;
  gap: 0.7em;
  font-size: 0.88rem;
}
.user-area .muted { color: rgba(255,255,255,0.6); }
.user-area select {
  padding: 0.35em 0.6em;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255,255,255,0.15);
  background: rgba(255,255,255,0.08);
  color: #fff;
  font-size: 0.88em;
  cursor: pointer;
}
.user-area select:hover { background: rgba(255,255,255,0.15); }
.btn-link {
  color: var(--color-accent);
  font-size: 0.88em;
  padding: 0.4em 0.55em;
  border-radius: var(--radius-sm);
  transition: background 0.15s ease, color 0.15s ease;
  display: inline-flex;
  align-items: center;
  background: transparent;
  border: 0;
  cursor: pointer;
  font-family: inherit;
  outline: 0;
  -webkit-appearance: none;
  appearance: none;
}
.btn-link:hover {
  background: rgba(63, 187, 237, 0.18);
  color: var(--color-accent);
  text-decoration: none;
}
.btn-link:focus-visible {
  background: rgba(63, 187, 237, 0.18);
  color: var(--color-accent);
  box-shadow: 0 0 0 2px rgba(63, 187, 237, 0.4);
}
.btn-link:active { background: rgba(63, 187, 237, 0.28); }
.btn-link i, .btn-link svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  color: inherit;
}

/* Mobile menu toggle */
.menu-toggle {
  display: none;
  background: transparent;
  border: 0;
  color: #fff;
  cursor: pointer;
  padding: 0.5em;
  line-height: 0;
  border-radius: var(--radius-sm);
}
.menu-toggle:hover { background: rgba(255,255,255,0.1); }
.menu-toggle i, .menu-toggle svg { width: 22px; height: 22px; }

/* ---------- Container ---------- */
.container {
  max-width: var(--container-max);
  margin: 1.5em auto 4em;
  padding: 0 1.4em;
}

.messages {
  max-width: var(--container-max);
  margin: 1em auto 0;
  padding: 0 1.4em;
}
.msg {
  padding: 0.85em 1.1em;
  border-radius: var(--radius);
  margin-bottom: 0.5em;
  font-size: 0.92em;
  border: 1px solid transparent;
  display: flex;
  align-items: center;
  gap: 0.6em;
}
.msg::before { font-weight: 700; }
.msg-success { background: var(--color-success-bg); color: #065f46; border-color: var(--color-success-border); }
.msg-success::before { content: "✓"; color: var(--color-success); }
.msg-error    { background: var(--color-danger-bg); color: #991b1b; border-color: var(--color-danger-border); }
.msg-error::before { content: "✕"; color: var(--color-danger); }
.msg-warning, .msg-warn { background: var(--color-warning-bg); color: #92400e; border-color: var(--color-warning-border); }
.msg-warning::before { content: "⚠"; color: var(--color-warning); }
.msg-info     { background: var(--color-info-bg); color: #0369a1; border-color: #bae6fd; }
.msg-info::before { content: "ⓘ"; color: var(--color-info); }

/* ---------- Cards ---------- */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1em;
  margin-bottom: 1.5em;
}
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 1.1em 1.2em;
  box-shadow: var(--shadow-sm);
  transition: all 0.15s ease;
  position: relative;
  overflow: hidden;
}
.card:hover { transform: translateY(-1px); box-shadow: var(--shadow); border-color: var(--color-border-strong); }
.card h3 {
  font-size: 0.78rem;
  color: var(--color-text-muted);
  margin: 0 0 0.5em;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
}
.card .big {
  font-size: 2.2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--color-text);
  line-height: 1;
  margin-bottom: 0.3em;
}
.card a {
  font-size: 0.85em;
  font-weight: 500;
}

/* Panels */
.panel {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 1.4em 1.5em;
  margin-bottom: 1.4em;
  box-shadow: var(--shadow-sm);
}
.panel h2 { margin-top: 0; }

/* ---------- Tables ---------- */
table {
  width: 100%;
  border-collapse: collapse;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  font-size: 0.92em;
}
th, td {
  padding: 0.75em 1em;
  text-align: left;
  vertical-align: middle;
  border-bottom: 1px solid var(--color-border);
}
th {
  background: var(--color-surface-alt);
  font-weight: 600;
  font-size: 0.78rem;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}
tbody tr { transition: background 0.1s ease; }
tbody tr:hover { background: var(--color-surface-alt); }
tbody tr:last-child td { border-bottom: 0; }
tfoot td, tfoot th {
  background: var(--color-surface-alt);
  font-weight: 600;
  border-top: 2px solid var(--color-border-strong);
  border-bottom: 0;
}

table.compact th, table.compact td { padding: 0.5em 0.75em; font-size: 0.88em; }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25em 0.7em;
  border-radius: var(--radius-pill);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  background: #e2e8f0;
  color: var(--color-text-soft);
  white-space: nowrap;
}
.badge-borrador { background: #f1f5f9; color: #475569; }
.badge-cargado  { background: #dbeafe; color: #1e40af; }
.badge-enviado_a_proveedor, .badge-en_camino, .badge-pendiente { background: #fef3c7; color: #92400e; }
.badge-confirmado { background: #d1fae5; color: #065f46; }
.badge-recibido_parcial { background: #fed7aa; color: #9a3412; }
.badge-recibido_total, .badge-entregado, .badge-confirmado_inv, .badge-procesado { background: #d1fae5; color: #065f46; }
.badge-cancelado, .badge-error, .badge-fallo { background: #fee2e2; color: #991b1b; }
.badge-programado, .badge-en_curso { background: #ede9fe; color: #5b21b6; }
.badge-favorito { background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%); color: #78350f; }
.badge-enviado, .badge-interpretado { background: #cffafe; color: #155e75; }
.badge-recibido { background: #dbeafe; color: #1e40af; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4em;
  padding: 0.55em 1.1em;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border-strong);
  background: var(--color-surface);
  color: var(--color-text);
  cursor: pointer;
  font-size: 0.92rem;
  font-weight: 500;
  font-family: inherit;
  line-height: 1.3;
  transition: all 0.15s ease;
  text-decoration: none;
  white-space: nowrap;
}
.btn:hover {
  background: var(--color-surface-alt);
  border-color: var(--color-text-faint);
  color: var(--color-text);
  text-decoration: none;
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}
.btn:active { transform: translateY(0); }

.btn-primary {
  background: var(--color-primary);
  color: #fff;
  border-color: var(--color-primary);
  box-shadow: 0 1px 2px rgba(0, 102, 204, 0.2);
}
.btn-primary:hover { background: var(--color-primary-dark); border-color: var(--color-primary-dark); color: #fff; }

.btn-success { background: var(--color-success); color: #fff; border-color: var(--color-success); }
.btn-success:hover { background: #047857; border-color: #047857; color: #fff; }

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

.btn-sm { padding: 0.3em 0.7em; font-size: 0.8rem; }

/* ---------- Forms ---------- */
input[type=text], input[type=number], input[type=date], input[type=datetime-local],
input[type=time], input[type=password], input[type=email], input[type=url], input[type=search],
input[type=tel], input[type=file], select, textarea {
  padding: 0.55em 0.75em;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-sm);
  font-size: 0.92rem;
  font-family: inherit;
  background: var(--color-surface);
  color: var(--color-text);
  transition: all 0.15s ease;
  width: auto;
  max-width: 100%;
}
input:focus, select:focus, textarea:focus {
  outline: 0;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(0, 102, 204, 0.15);
}
input.qty   { width: 6em; text-align: right; font-variant-numeric: tabular-nums; }
input.stock { width: 5.5em; text-align: right; font-variant-numeric: tabular-nums; }

.field, .form-row { margin-bottom: 1em; }
.field label, .form-row label {
  display: block;
  font-size: 0.85em;
  color: var(--color-text-soft);
  margin-bottom: 0.35em;
  font-weight: 500;
}
.field label[for] { cursor: pointer; }

/* Toolbar */
.toolbar {
  display: flex;
  gap: 0.6em;
  margin-bottom: 1.2em;
  align-items: center;
  flex-wrap: wrap;
  background: var(--color-surface);
  padding: 0.8em 1em;
  border-radius: var(--radius);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-sm);
}
.toolbar input[type=text], .toolbar select { min-width: 180px; }
.spacer { flex: 1; }

.row { display: flex; gap: 1.2em; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 280px; }

.right { text-align: right; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }

/* ---------- Mensaje preformateado ---------- */
pre.message {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-left: 4px solid var(--color-primary);
  padding: 1.2em 1.4em;
  border-radius: var(--radius);
  white-space: pre-wrap;
  font-family: var(--font-mono);
  font-size: 0.88em;
  line-height: 1.6;
  color: var(--color-text);
  box-shadow: var(--shadow-sm);
}

/* ---------- Footer ---------- */
.footer {
  text-align: center;
  padding: 2em 1em 1.5em;
  color: var(--color-text-faint);
  font-size: 0.78em;
  border-top: 1px solid var(--color-border);
  margin-top: 3em;
}

/* ---------- Inline form helper ---------- */
.inline-form { display: inline-block; margin: 0; }

/* ---------- Login ---------- */
.login-box {
  max-width: 420px;
  margin: 4.5em auto 2em;
  background: var(--color-surface);
  border-radius: var(--radius-xl);
  padding: 2.6em 2.4em 2.4em;
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-lg);
}
.login-logo {
  display: block;
  margin: 0 auto 0.4em;
  width: 220px;
  height: auto;
  max-width: 100%;
}
.google-btn {
  background: #fff;
  border: 1px solid var(--color-border-strong);
  color: #3c4043;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6em;
}
.google-btn:hover { background: #f8fafc; border-color: var(--color-text-faint); color: #3c4043; }
.login-divider {
  text-align: center;
  margin: 1em 0;
  position: relative;
  color: var(--color-text-faint);
  font-size: 0.85em;
}
.login-divider::before, .login-divider::after {
  content: "";
  position: absolute;
  top: 50%;
  width: calc(50% - 8em);
  height: 1px;
  background: var(--color-border);
}
.login-divider::before { left: 0; }
.login-divider::after  { right: 0; }
.login-divider span { background: var(--color-surface); padding: 0 0.8em; position: relative; }
.login-box h1 {
  text-align: center;
  color: var(--color-text);
  margin-bottom: 0.2em;
  font-size: 1.6rem;
}

/* ---------- Alerts ---------- */
.alert-warn {
  background: var(--color-warning-bg);
  border-left: 4px solid var(--color-warning);
  padding: 0.8em 1em;
  border-radius: var(--radius-sm);
  margin-bottom: 1em;
  color: #713f12;
  font-size: 0.9em;
}

/* ---------- Stock warnings ---------- */
.bajo-stock { color: var(--color-danger); font-weight: 600; }
.crit { background: var(--color-danger-bg) !important; }
.crit:hover { background: #fee2e2 !important; }

/* ---------- Code inline ---------- */
code {
  background: #f1f5f9;
  border: 1px solid var(--color-border);
  padding: 0.1em 0.4em;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 0.88em;
  color: var(--color-text-soft);
}

/* ---------- Numeric tabular alignment ---------- */
table td, table th { font-variant-numeric: tabular-nums; }

/* ---------- Lucide icons globales ---------- */
.btn i, .btn svg { width: 16px; height: 16px; stroke-width: 2; }
.btn-sm i, .btn-sm svg { width: 14px; height: 14px; }

/* Card con icono opcional en esquina superior derecha */
.card-icon {
  position: absolute;
  top: 1em;
  right: 1em;
  width: 22px;
  height: 22px;
  color: var(--color-text-faint);
  opacity: 0.7;
}
.card-icon i, .card-icon svg { width: 22px; height: 22px; stroke-width: 1.7; }

/* Iconos al lado de textos sueltos (header brand etc) */
[data-lucide] { vertical-align: middle; }

/* ============================================================
   Responsive — mobile-first breakpoints
============================================================ */

/* Tablet — colapsar nav y user area en columna */
@media (max-width: 1100px) {
  .topbar { padding: 0 1em; }
  .topnav { display: none; }
  .menu-toggle { display: inline-flex; align-items: center; }
  .topbar.is-open {
    height: auto;
    flex-wrap: wrap;
    padding-bottom: 0.8em;
  }
  .topbar.is-open .topnav {
    display: flex;
    flex-direction: column;
    gap: 0.2em;
    width: 100%;
    margin: 0.6em 0 0;
    background: rgba(0,0,0,0.15);
    padding: 0.6em;
    border-radius: var(--radius);
  }
  .topbar.is-open .topnav a { padding: 0.7em 0.9em; }
  .user-area { font-size: 0.82rem; gap: 0.5em; }
  .user-area .user-name { display: none; }
  .container { padding: 0 1em; margin-top: 1em; }
  .messages { padding: 0 1em; }
  h1 { font-size: 1.4rem; }
}

/* Móvil chico — tablas con scroll horizontal y cards 1 por fila */
@media (max-width: 600px) {
  body { font-size: 14px; }
  .container { padding: 0 0.8em; }
  .panel { padding: 1em; }
  .cards { grid-template-columns: 1fr 1fr; gap: 0.7em; }
  .card { padding: 0.9em; }
  .card .big { font-size: 1.6rem; }

  /* Tablas scrolleables horizontalmente envueltas en .table-scroll cuando aplica */
  table { font-size: 0.84em; }
  th, td { padding: 0.55em 0.6em; }

  .toolbar { padding: 0.6em; gap: 0.4em; }
  .toolbar input[type=text], .toolbar select { min-width: 140px; flex: 1; }

  .row > * { min-width: 100%; }
  .login-box { margin: 2em 1em; padding: 1.8em 1.4em; }
}
