/* =========================================================
   BE WATER — Sistema de diseño (v2, estilo panel tipo Stripe)
   ========================================================= */

:root {
  /* Marca */
  --azul-profundo: #0B4F6C;
  --azul-claro: #3FA9D8;
  --blanco: #FFFFFF;
  --gris-oscuro: #1F1F1F;
  --gris-industrial: #6E6E6E;

  /* Tokens de tema (modo claro) */
  --bg: #F5F7FA;
  --surface: #FFFFFF;
  --surface-2: #F1F5F8;
  --border: #E3E8ED;
  --text: #16212B;
  --text-muted: #64748B;
  --accent: #0B4F6C;
  --accent-hover: #093c53;
  --accent-soft: #E6F1F6;
  --accent-contrast: #FFFFFF;

  --success-text: #15803D;
  --success-bg: #DCFCE7;
  --warn-text: #A15C07;
  --warn-bg: #FEF3C7;
  --danger-text: #B91C1C;
  --danger-bg: #FEE2E2;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.05);
  --shadow-md: 0 4px 16px rgba(16, 24, 40, 0.07);
  --sidebar-bg: #0B1F2E;
  --sidebar-text: #A9BBC9;
  --sidebar-text-active: #FFFFFF;
  --sidebar-border: rgba(255, 255, 255, 0.08);
}

[data-theme="dark"] {
  --bg: #0E1622;
  --surface: #161F2E;
  --surface-2: #1D2838;
  --border: #2A3648;
  --text: #E7EDF3;
  --text-muted: #8FA0B3;
  --accent: #4FB8E8;
  --accent-hover: #6BC5EC;
  --accent-soft: rgba(79, 184, 232, 0.14);
  --accent-contrast: #0B1F2E;

  --success-text: #4ADE80;
  --success-bg: rgba(74, 222, 128, 0.12);
  --warn-text: #FBBF24;
  --warn-bg: rgba(251, 191, 36, 0.12);
  --danger-text: #F87171;
  --danger-bg: rgba(248, 113, 113, 0.12);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.35);
  --sidebar-bg: #0A1520;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---- Login ---- */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: var(--bg);
}
.auth-card {
  width: 100%;
  max-width: 360px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2.5rem 2rem;
  box-shadow: var(--shadow-md);
}
.auth-card .logo { display: block; margin: 0 auto 1.5rem; max-width: 220px; width: 100%; height: auto; }
.auth-card h1 { text-align: center; font-size: 18px; font-weight: 600; color: var(--accent); margin: 0 0 1.5rem; }

label { display: block; font-size: 13px; margin-bottom: 4px; color: var(--text); font-weight: 500; }

input[type="text"], input[type="email"], input[type="password"], input[type="date"],
input[type="number"], select, textarea {
  width: 100%;
  padding: 9px 12px;
  margin-bottom: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  background: var(--surface);
  color: var(--text);
  transition: border-color 0.15s ease;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }
input::placeholder, textarea::placeholder { color: var(--text-muted); }

.checkbox-row { display: flex; align-items: center; gap: 8px; font-size: 13px; margin-bottom: 20px; }
.checkbox-row input { margin: 0; width: auto; }

button {
  width: 100%;
  padding: 10px 16px;
  background: var(--accent);
  color: var(--accent-contrast);
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s ease, opacity 0.15s ease;
}
button:hover { background: var(--accent-hover); }
button:disabled { opacity: 0.6; cursor: default; }

.error-msg { color: var(--danger-text); font-size: 13px; margin-top: 10px; text-align: center; }

/* ---- App shell (barra lateral + contenido) ---- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 224px;
  flex-shrink: 0;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar-brand { padding: 20px 18px 12px; display: flex; align-items: center; }
.sidebar-logo { height: 30px; filter: brightness(0) invert(1); opacity: 0.95; }

.sidebar-nav { flex: 1; padding: 10px 10px; display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 500;
  color: var(--sidebar-text);
  text-decoration: none;
  white-space: nowrap;
}
.nav-item svg { width: 17px; height: 17px; flex-shrink: 0; }
.nav-item:hover { background: rgba(255, 255, 255, 0.06); color: var(--sidebar-text-active); }
.nav-item.active { background: var(--azul-claro); color: #08202E; font-weight: 600; }

.sidebar-footer { padding: 12px 10px 16px; border-top: 1px solid var(--sidebar-border); }
.theme-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  background: none;
  color: var(--sidebar-text);
  font-size: 13px;
  font-weight: 500;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  margin-bottom: 6px;
}
.theme-toggle:hover { background: rgba(255, 255, 255, 0.06); }
.theme-toggle svg { width: 16px; height: 16px; }
.theme-toggle .icon-moon { display: none; }
[data-theme="dark"] .theme-toggle .icon-sun { display: none; }
[data-theme="dark"] .theme-toggle .icon-moon { display: inline-block; }

.sidebar-user { padding: 8px 12px 4px; }
.sidebar-user-email { font-size: 12px; color: var(--sidebar-text-active); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-footer .role-badge { margin-top: 4px; display: inline-block; }
.sidebar-logout {
  width: 100%;
  margin-top: 10px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--sidebar-text-active);
  font-size: 12.5px;
  padding: 8px 12px;
}
.sidebar-logout:hover { background: rgba(255, 255, 255, 0.16); }

.main-area { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar-slim {
  padding: 18px 32px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.page-title { font-size: 20px; font-weight: 700; color: var(--text); margin: 0; }

.mobile-menu-btn { display: none; background: none; width: auto; padding: 6px; color: var(--text); }

.content { max-width: 1100px; margin: 0 auto; padding: 28px 32px 60px; width: 100%; }
.content h1 { color: var(--text); font-size: 22px; }

/* ---- Botones secundarios ---- */
.btn-secondary { background: var(--surface); color: var(--accent); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--surface-2); }
.btn-danger { background: var(--surface); color: var(--danger-text); border: 1px solid var(--border); }
.btn-danger:hover { background: var(--danger-bg); }
.btn-inline { width: auto; padding: 8px 14px; font-size: 13px; }

/* ---- Barra de herramientas ---- */
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.search-input { flex: 1; min-width: 200px; margin-bottom: 0 !important; }
.filter-select { padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 13px; background: var(--surface); color: var(--text); }

/* ---- Tabla ---- */
.table-wrap { background: var(--surface); border-radius: var(--radius-md); border: 1px solid var(--border); overflow-x: auto; box-shadow: var(--shadow-sm); }
table.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data-table th {
  text-align: left; padding: 11px 16px; background: var(--surface-2); color: var(--text-muted);
  font-weight: 600; white-space: nowrap; border-bottom: 1px solid var(--border);
}
table.data-table td { padding: 11px 16px; border-bottom: 1px solid var(--border); white-space: nowrap; color: var(--text); }
table.data-table tbody tr { cursor: pointer; transition: background 0.1s ease; }
table.data-table tbody tr:hover { background: var(--surface-2); }
table.data-table tbody tr:last-child td { border-bottom: none; }
.row-actions { display: flex; gap: 6px; }
.empty-state { padding: 40px; text-align: center; color: var(--text-muted); font-size: 13px; }

.pill { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 500; }
.pill-ok { background: var(--success-bg); color: var(--success-text); }
.pill-warn { background: var(--warn-bg); color: var(--warn-text); }
.pill-bad { background: var(--danger-bg); color: var(--danger-text); }
.pill-neutral { background: var(--surface-2); color: var(--text-muted); }

.pagination { display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 16px; font-size: 13px; color: var(--text-muted); }

/* ---- Modal ---- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(10, 20, 28, 0.55);
  display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 50;
}
.modal-box {
  background: var(--surface); border-radius: var(--radius-lg); width: 100%; max-width: 640px;
  max-height: 90vh; overflow-y: auto; padding: 1.75rem; box-shadow: var(--shadow-md);
}
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.25rem; }
.modal-header h2 { font-size: 17px; color: var(--text); margin: 0; font-weight: 700; }
.modal-close { background: none; border: none; font-size: 20px; color: var(--text-muted); cursor: pointer; width: auto; padding: 0; }

.form-section-title { font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); font-weight: 600; margin: 18px 0 8px; }
.form-section-title:first-child { margin-top: 0; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.form-grid .full { grid-column: 1 / -1; }
.form-grid input:disabled, .form-grid select:disabled, .form-grid textarea:disabled { background: var(--surface-2); color: var(--text-muted); }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }
.modal-actions button { width: auto; padding: 9px 18px; }
.hidden { display: none !important; }

/* ---- Detalle de equipo ---- */
.back-link { font-size: 13px; color: var(--accent); text-decoration: none; display: inline-flex; align-items: center; gap: 4px; margin-bottom: 16px; }
.back-link:hover { text-decoration: underline; }

.info-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 20px 24px; margin-bottom: 20px; box-shadow: var(--shadow-sm); }
.info-header { display: flex; justify-content: space-between; align-items: flex-start; flex-wrap: wrap; gap: 12px; margin-bottom: 18px; }
.info-title { font-size: 22px; color: var(--text); font-weight: 700; margin: 0; }
.info-subtitle { font-size: 13px; color: var(--text-muted); margin-top: 4px; }
.info-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px 20px; }
.info-item label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted); display: block; margin-bottom: 2px; font-weight: 600; }
.info-item .value { font-size: 14px; color: var(--text); }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 18px; overflow-x: auto; }
.tab-btn { padding: 10px 16px; border: none; background: none; font-size: 14px; color: var(--text-muted); cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap; font-family: inherit; width: auto; }
.tab-btn:hover { color: var(--text); background: none; }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ---- Dashboard / KPIs ---- */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 16px; margin-bottom: 24px; }
.kpi-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 18px 20px; box-shadow: var(--shadow-sm); }
.kpi-value { font-size: 28px; font-weight: 700; color: var(--text); line-height: 1; }
.kpi-label { font-size: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; margin-top: 8px; }
.kpi-card.alert .kpi-value { color: var(--warn-text); }
.kpi-card.danger .kpi-value { color: var(--danger-text); }
.section-title { font-size: 16px; color: var(--text); margin: 28px 0 12px; font-weight: 700; }

/* ---- Etiquetas / QR ---- */
.label-picker { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.picker-col { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 16px; max-height: 420px; overflow-y: auto; }
.picker-col h3 { margin: 0 0 10px; font-size: 14px; color: var(--text); }
.picker-item { display: flex; align-items: center; gap: 8px; padding: 6px 0; font-size: 13px; border-bottom: 1px solid var(--border); color: var(--text); }
.picker-item:last-child { border-bottom: none; }
.picker-item input { margin: 0; width: auto; }
.label { border: 1px dashed #999; border-radius: 4px; padding: 10px; text-align: center; page-break-inside: avoid; }
.label-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 20px; }
.label canvas { margin: 0 auto; display: block; }
.label .label-code { font-weight: 700; font-size: 13px; margin-top: 4px; }
.label .label-sub { font-size: 11px; color: var(--gris-industrial); }
.print-area { display: none; }
@media print {
  body * { visibility: hidden; }
  .print-area, .print-area * { visibility: visible; }
  .print-area { position: absolute; top: 0; left: 0; width: 100%; display: block !important; padding: 20px; }
}

/* ---- Responsive ---- */
@media (max-width: 640px) {
  .form-grid { grid-template-columns: 1fr; }
  .auth-card { padding: 2rem 1.25rem; }
  .label-picker { grid-template-columns: 1fr; }
}

@media (max-width: 880px) {
  .sidebar {
    position: fixed; left: 0; top: 0; z-index: 40;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    width: 240px;
  }
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-md); }
  .mobile-menu-btn { display: inline-flex; align-items: center; justify-content: center; }
  .topbar-slim { padding: 14px 18px; }
  .content { padding: 20px 18px 50px; }
}
