/* ============================================================================
   Portal Autogestión — patrón de diseño «Industrial Systems» (mismo estándar
   que Muestras). Se carga DESPUÉS de style.css y lo sobreescribe: tokens,
   barra superior y componentes. Fuente de verdad del estándar:
   stitch_human_ui_redesign/tecnoboga_industrial_systems/DESIGN.md
   ============================================================================ */

:root {
  /* Marca */
  --primary: #1b365d;            /* Prussian Steel Blue */
  --primary-hover: #002046;
  --primary-light: rgba(27, 54, 93, 0.08);
  --header-bg: #002046;
  --header-link: #87a0cd;
  --secondary: #334155;
  --tertiary: #15803d;

  /* Superficies */
  --bg-main: #faf8ff;
  --bg-sidebar: #ffffff;
  --bg-card: #ffffff;
  --bg-card-hover: #f2f3ff;
  --bg-input: #ffffff;
  --bg-trough: #f8fafc;

  /* Texto */
  --text-primary: #131b2e;
  --text-secondary: #44474e;
  --text-muted: #64748b;

  /* Estados funcionales */
  --success: #15803d;
  --success-light: #f0fdf4;
  --warning: #b45309;
  --warning-light: #fffbeb;
  --danger: #b91c1c;
  --danger-light: #fef2f2;

  --border-color: #e2e8f0;
  --border-strong: #cbd5e1;

  /* Forma: "Soft Industrial Geometry" -- nada de pastillas ni curvas globo */
  --radius-sm: 2px;
  --radius-md: 4px;
  --radius-lg: 8px;

  --shadow-md: 0 1px 2px 0 rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 10px 15px -3px rgba(15, 23, 42, 0.12), 0 4px 6px -4px rgba(15, 23, 42, 0.08);

  --font-body: 'Geist', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, 'SFMono-Regular', Consolas, monospace;
  --header-h: 56px;
}

html, body {
  font-family: var(--font-body);
  font-size: 13px;
  line-height: 18px;
  color: var(--text-primary);
  background: var(--bg-main);
  -webkit-font-smoothing: antialiased;
}

body { display: block; }
#app-layout { display: flex; height: 100vh; width: 100%; }
.content-column { height: 100vh; }

/* Cifras tabulares siempre */
td, th, .stat-value, .badge, .kpi, input, select { font-variant-numeric: tabular-nums; }

/* Foco: anillo nitido de doble borde, sin brillos difusos */
:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: none; }

/* ── Barra superior ───────────────────────────────────────────────────── */
.app-header {
  position: relative;
  flex-shrink: 0;
  z-index: 60;
  background: var(--header-bg);
  box-shadow: 0 1px 8px rgba(0, 0, 0, 0.04);
}
.app-header-bar {
  height: var(--header-h);
  padding: 0 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}
.app-header-left, .app-header-right { display: flex; align-items: center; gap: 0.75rem; min-width: 0; }
.app-header-left { gap: 1rem; }
.app-brand { display: flex; align-items: center; gap: 0.5rem; text-decoration: none; flex-shrink: 0; }
.app-brand-icon { border-radius: 4px; }
.app-brand-name { font-size: 18px; font-weight: 600; letter-spacing: -0.015em; color: #fff; line-height: 1; }
.app-header-sep { width: 1px; height: 24px; background: rgba(255, 255, 255, 0.15); flex-shrink: 0; }

.app-nav { display: flex; align-items: center; gap: 0.25rem; }
.app-nav .nav-item {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.25rem 0.75rem;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 400;
  color: var(--header-link);
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
  transition: color 0.15s ease, background-color 0.15s ease;
}
.app-nav .nav-item:hover { color: #fff; background: transparent; }
.app-nav .nav-item.active { background: var(--primary); color: #fff; }
.app-nav .nav-item:focus-visible { outline-color: #aec7f7; }

/* Selector de fuente: pastilla clara (los logos de cliente son oscuros) */
.app-fuente { min-width: 0; }
.app-fuente .animated-select { position: relative; }
.app-fuente .animated-select-trigger,
.app-fuente .fuente-badge-plain {
  height: 32px;
  min-width: 11rem;
  max-width: 17rem;
  padding: 0 0.6rem;
  background: #fff;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 13px;
  box-shadow: none;
}
.app-fuente .animated-select-trigger:hover { background: #eef2f9; }
.app-fuente .animated-select-dropdown {
  left: auto;
  right: 0;
  min-width: 17rem;
  background: #fff;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: 0 4px 6px -1px rgba(15, 23, 42, 0.08), 0 2px 4px -2px rgba(15, 23, 42, 0.06);
}
#topbar-fuente-logo-grande { display: none !important; }

/* Buscador (translucido sobre la barra) */
.app-search.topbar-search-box { width: 14rem; flex: 0 1 auto; }
.app-search.topbar-search-box input {
  height: 32px;
  width: 100%;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  color: #fff;
  font-size: 12px;
  padding: 0 0.5rem 0 2rem;
}
.app-search.topbar-search-box input::placeholder { color: var(--header-link); }
.app-search.topbar-search-box input:focus { border-color: #aec7f7; background: rgba(255, 255, 255, 0.14); box-shadow: none; }
.app-search .search-icon { color: var(--header-link); }

/* Usuario */
.app-user { position: relative; }
.app-user-btn { display: flex; align-items: center; gap: 0.5rem; background: none; border: 0; cursor: pointer; padding: 0 0 0 0.25rem; }
.app-user-text { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.15; }
.app-user .user-name { color: #fff; font-size: 12px; font-weight: 600; max-width: 12rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.app-user-role { font-family: var(--font-mono); font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--header-link); }
.app-user .user-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--primary); color: #fff; font-size: 13px; font-weight: 600;
}
.app-user-menu {
  display: none;
  position: absolute; right: 0; top: 40px; width: 16rem; z-index: 80;
  background: #fff; border: 1px solid var(--border-strong); border-radius: var(--radius-lg);
  box-shadow: 0 4px 6px -1px rgba(15, 23, 42, 0.08), 0 2px 4px -2px rgba(15, 23, 42, 0.06);
  padding: 0.5rem;
}
.app-user-menu.open { display: block; }
.app-user-menu-head { padding: 0.25rem 0.5rem 0.5rem; border-bottom: 1px solid var(--border-color); margin-bottom: 0.25rem; }
.app-user-menu-name { font-weight: 600; color: var(--text-primary); }
.app-user-menu-email { font-size: 12px; color: var(--text-muted); word-break: break-all; }
.app-user-menu-item {
  width: 100%; height: 32px; display: flex; align-items: center; gap: 0.5rem; padding: 0 0.5rem;
  background: none; border: 0; border-radius: var(--radius-md); cursor: pointer;
  color: var(--danger); font-size: 13px;
}
.app-user-menu-item:hover { background: var(--danger-light); }

/* Hamburguesa y menu movil */
.btn-hamburger { display: none; background: none; border: 0; color: #fff; padding: 0.375rem; border-radius: var(--radius-md); cursor: pointer; }
.btn-hamburger:hover { background: rgba(255, 255, 255, 0.1); }

@media (max-width: 1279px) {
  .app-header-bar { padding: 0 1.5rem; }
  .btn-hamburger { display: inline-flex; }
  .app-header-sep:not(.app-header-sep-user) { display: none; }
  .app-nav {
    display: none;
    position: absolute; left: 0; right: 0; top: var(--header-h);
    flex-direction: column; align-items: stretch; gap: 0.25rem;
    background: var(--header-bg);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding: 0.5rem 0.75rem 0.75rem;
  }
  .app-header.menu-abierto .app-nav { display: flex; }
  .app-nav .nav-item { padding: 0.5rem 0.75rem; }
}
@media (max-width: 767px) {
  .app-header-bar { padding: 0 0.75rem; }
  .app-search.topbar-search-box { display: none; }
  .app-user-text { display: none; }
  .app-fuente .animated-select-trigger, .app-fuente .fuente-badge-plain { min-width: 0; max-width: 11rem; }
  .app-header-sep-user { display: none; }
}

/* ── Contenido ────────────────────────────────────────────────────────── */
.main-content { background: var(--bg-main); }
/* Margenes laterales: 2rem en escritorio (igual que la barra), contenido centrado y acotado en pantallas muy anchas */
.page-container { padding: 1.5rem 2rem 2rem; gap: 1rem; max-width: 1680px; width: 100%; margin: 0 auto; }
@media (max-width: 1279px) { .page-container { padding: 1.25rem 1.5rem 1.5rem; } }
@media (max-width: 767px) { .page-container { padding: 0.75rem; } }

/* Pestanas de estado (antes sub-items del sidebar) y sub-menu de Administracion */
.estado-tabs, .admin-subnav {
  display: flex; gap: 0.25rem; flex-wrap: wrap;
  border-bottom: 1px solid var(--border-color);
}
.estado-tab, .admin-subnav-item {
  background: none; border: 0; border-bottom: 2px solid transparent; margin-bottom: -1px;
  padding: 0.5rem 0.9rem; font-family: var(--font-body); font-size: 13px; font-weight: 500;
  color: var(--text-muted); cursor: pointer; transition: color 0.15s ease, border-color 0.15s ease;
}
.estado-tab:hover, .admin-subnav-item:hover { color: var(--text-primary); }
.estado-tab.active, .admin-subnav-item.active { color: var(--primary); border-bottom-color: var(--primary); }

/* Tarjetas / KPI */
.table-card, .stat-card, .order-section {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}
.stat-card { padding: 1rem; }
.stat-title { font-family: var(--font-mono); font-size: 11px; font-weight: 600; letter-spacing: 0.06em; color: var(--text-muted); }
.stat-value { font-size: 28px; line-height: 34px; font-weight: 700; letter-spacing: -0.03em; color: var(--text-primary); }
.stat-card-clickable:hover { border-color: var(--border-strong); background: var(--bg-trough); }

/* ── Botones ──────────────────────────────────────────────────────────── */
.btn {
  height: 32px; padding: 0 0.9rem; gap: 0.4rem;
  border-radius: var(--radius-md);
  font-family: var(--font-body); font-size: 13px; font-weight: 500;
  box-shadow: none;
}
.btn-sm { height: 28px; padding: 0 0.65rem; font-size: 12px; }
.btn-primary { background: var(--primary); color: #fff; border: 1px solid var(--primary); }
.btn-primary:hover { background: #1e293b; border-color: #1e293b; }
.btn-primary:active { background: #0f172a; border-color: #0f172a; }
.btn-secondary { background: #fff; color: var(--text-primary); border: 1px solid var(--border-strong); }
.btn-secondary:hover { background: var(--bg-trough); border-color: #94a3b8; }
.btn-danger { background: #fff; color: var(--danger); border: 1px solid #fecaca; }
.btn-danger:hover { background: #fef2f2; border-color: var(--danger); }
.btn-success { background: var(--tertiary); color: #fff; border: 1px solid var(--tertiary); }
.btn-success:hover { background: #166534; border-color: #166534; }
.btn:disabled, .btn[disabled] { opacity: 0.5; cursor: not-allowed; }
/* Cabecera del modal: botones rectos, no pildoras */
.modal-header-actions .btn { border-radius: var(--radius-md); font-weight: 500; font-size: 12px; padding: 0 0.75rem; box-shadow: none; }
.modal-header-actions .btn-secondary:hover { background: var(--bg-trough); border-color: #94a3b8; color: var(--text-primary); }
.modal-header-actions .btn-success { box-shadow: none; }

/* Acciones de fila */
.btn-icon-row { height: 28px; padding: 0 0.55rem; border-radius: var(--radius-md); font-size: 12px; background: #fff; border: 1px solid var(--border-strong); color: var(--text-primary); box-shadow: none; }
.btn-icon-row:hover { background: var(--bg-trough); border-color: #94a3b8; transform: none; box-shadow: none; color: var(--text-primary); }
.btn-icon-row-accent { background: var(--primary-light); border-color: rgba(27, 54, 93, 0.25); color: var(--primary); }
.btn-icon-row-accent:hover { background: var(--primary); border-color: var(--primary); color: #fff; box-shadow: none; }

/* ── Inputs ───────────────────────────────────────────────────────────── */
.form-input, select.form-input {
  height: 32px; padding: 0 0.75rem;
  background: #fff; border: 1px solid var(--border-strong); border-radius: var(--radius-md);
  color: var(--text-primary); font-family: var(--font-body); font-size: 13px;
}
textarea.form-input { height: auto; padding: 0.5rem 0.75rem; }
.form-input:focus { border-color: var(--primary); box-shadow: 0 0 0 1px #fff, 0 0 0 3px var(--primary); }
.form-label { font-family: var(--font-mono); font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-muted); }
.form-input-inline { height: 28px; }

/* ── Tablas de alta densidad ──────────────────────────────────────────── */
.data-table { font-size: 13px; }
.data-table th {
  height: 32px; padding: 0 0.75rem;
  background: var(--bg-trough); color: var(--text-muted);
  font-family: var(--font-mono); font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase;
  border-bottom: 1px solid var(--border-strong);
}
.data-table td { padding: 0.45rem 0.75rem; border-bottom: 1px solid #f1f5f9; background: #fff; }
.data-table tbody tr:hover td { background: var(--bg-trough); }
th[data-sort]:hover { background: #eef2f9; color: var(--primary); }
.data-table-container { border-radius: var(--radius-lg); }

/* ── Chips de estado: rectangulares, mono, mayusculas ─────────────────── */
.badge {
  display: inline-flex; align-items: center;
  height: 20px; padding: 0 0.4rem;
  border-radius: var(--radius-sm); border: 1px solid transparent;
  font-family: var(--font-mono); font-size: 11px; font-weight: 700; letter-spacing: 0.02em; text-transform: uppercase;
}
.badge-success { background: #f0fdf4; color: #15803d; border-color: #bbf7d0; }
.badge-warning { background: #fffbeb; color: #b45309; border-color: #fde68a; }
.badge-danger  { background: #fef2f2; color: #b91c1c; border-color: #fecaca; }
.badge-info    { background: #eef2f9; color: #1b365d; border-color: #d6e3ff; }
.badge-muted   { background: #f1f5f9; color: #475569; border-color: #e2e8f0; }
.fuente-tag { font-family: var(--font-mono); border-radius: var(--radius-sm); }

/* ── Modales y capas flotantes ────────────────────────────────────────── */
.modal-overlay { background-color: rgba(15, 23, 42, 0.4); backdrop-filter: none; -webkit-backdrop-filter: none; }
.modal-overlay.active { backdrop-filter: none; -webkit-backdrop-filter: none; }
.modal-box { border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); border: 1px solid var(--border-color); }
.modal-title { font-size: 18px; font-weight: 600; letter-spacing: -0.015em; }
.excel-filter-popup { border-radius: var(--radius-lg); border-color: var(--border-strong); box-shadow: 0 4px 6px -1px rgba(15, 23, 42, 0.08), 0 2px 4px -2px rgba(15, 23, 42, 0.06); }
.toast { border-radius: var(--radius-lg); }

/* El perfil activo (boton deshabilitado) no debe verse "apagado" */
.btn-primary:disabled, .btn-primary[disabled] { opacity: 1; cursor: default; }
