/* ============================================================
   PALLIQ WMS — Design System
   Paleta: azul industrial + fondo oscuro profundo
   Font: DM Sans (display) + JetBrains Mono (códigos)
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@300;400;500;600&family=JetBrains+Mono:wght@400;500&display=swap');

/* ── Variables ─────────────────────────────────────────────── */
:root {
  /* Paleta principal */
  --blue-950: #0a1628;
  --blue-900: #0f2240;
  --blue-800: #163358;
  --blue-700: #1e4a80;
  --blue-600: #2563b0;
  --blue-500: #3b82f6;
  --blue-400: #60a5fa;
  --blue-300: #93c5fd;
  --blue-100: #dbeafe;
  --blue-50:  #eff6ff;

  /* Superficies (modo oscuro por defecto en el depósito) */
  --surface-0:  #080f1e;   /* fondo más profundo */
  --surface-1:  #0d1a30;   /* fondo página */
  --surface-2:  #111f3a;   /* sidebar */
  --surface-3:  #162844;   /* cards */
  --surface-4:  #1c3050;   /* hover / elevated */
  --surface-5:  #243658;   /* inputs */

  --border-dim:    rgba(255,255,255,.07);
  --border-normal: rgba(255,255,255,.12);
  --border-accent: rgba(59,130,246,.4);

  /* Texto */
  --text-primary:   #f0f6ff;
  --text-secondary: #8ba4c4;
  --text-muted:     #4e6a88;
  --text-accent:    #60a5fa;

  /* Semánticos */
  --success:    #22c55e;
  --success-bg: rgba(34,197,94,.12);
  --warning:    #f59e0b;
  --warning-bg: rgba(245,158,11,.12);
  --danger:     #ef4444;
  --danger-bg:  rgba(239,68,68,.12);
  --info:       #3b82f6;
  --info-bg:    rgba(59,130,246,.12);

  /* Layout */
  --sidebar-w:  240px;
  --topbar-h:   56px;
  --radius-sm:  6px;
  --radius-md:  10px;
  --radius-lg:  14px;
  --radius-xl:  20px;

  /* Tipografía */
  --font-sans: 'DM Sans', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  /* Transiciones */
  --transition: .18s cubic-bezier(.4,0,.2,1);
}

/* ── Reset ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-sans);
  background: var(--surface-1);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100vh;
}
a { color: var(--text-accent); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; }

/* ── Scrollbar ─────────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--surface-5); border-radius: 99px; }

/* ── App Layout ─────────────────────────────────────────────── */
.app { display: flex; height: 100vh; overflow: hidden; }

/* ── Sidebar ─────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--surface-2);
  border-right: 1px solid var(--border-dim);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: width var(--transition);
  overflow: hidden;
  z-index: 100;
}
.sidebar.collapsed { width: 60px; }

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 16px;
  border-bottom: 1px solid var(--border-dim);
  min-height: var(--topbar-h);
}
.logo-icon {
  width: 32px; height: 32px;
  background: var(--blue-600);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 15px; color: #fff;
  flex-shrink: 0;
  letter-spacing: -.5px;
}
.logo-text { font-size: 17px; font-weight: 600; color: var(--text-primary); white-space: nowrap; }
.logo-tenant { font-size: 11px; color: var(--text-muted); white-space: nowrap; margin-top: 1px; }

.sidebar-nav { flex: 1; padding: 10px 8px; overflow-y: auto; }
.nav-section {
  font-size: 10px; font-weight: 600; letter-spacing: .1em;
  color: var(--text-muted); padding: 10px 10px 4px;
  text-transform: uppercase; white-space: nowrap;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: 14px; font-weight: 400;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
  margin-bottom: 1px;
  white-space: nowrap;
  position: relative;
}
.nav-item:hover { background: var(--surface-4); color: var(--text-primary); }
.nav-item.active {
  background: var(--info-bg);
  color: var(--blue-400);
  font-weight: 500;
}
.nav-item.active::before {
  content: '';
  position: absolute; left: 0; top: 25%; bottom: 25%;
  width: 3px; background: var(--blue-500);
  border-radius: 0 3px 3px 0;
}
.nav-item i { font-size: 18px; flex-shrink: 0; }
.nav-badge {
  margin-left: auto;
  background: var(--warning-bg); color: var(--warning);
  font-size: 11px; padding: 2px 7px;
  border-radius: 99px; font-weight: 600;
}
.nav-badge.danger { background: var(--danger-bg); color: var(--danger); }

.sidebar-footer {
  padding: 12px 8px;
  border-top: 1px solid var(--border-dim);
}
.user-card {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: var(--radius-md);
  cursor: pointer; transition: background var(--transition);
}
.user-card:hover { background: var(--surface-4); }
.user-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--blue-800); border: 1px solid var(--blue-600);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 600; color: var(--blue-300);
  flex-shrink: 0;
}
.user-name { font-size: 13px; font-weight: 500; color: var(--text-primary); white-space: nowrap; }
.user-role { font-size: 11px; color: var(--text-muted); white-space: nowrap; }

/* ── Main Area ─────────────────────────────────────────────── */
.main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

/* ── Topbar ─────────────────────────────────────────────────── */
.topbar {
  height: var(--topbar-h);
  background: var(--surface-2);
  border-bottom: 1px solid var(--border-dim);
  display: flex; align-items: center; gap: 12px;
  padding: 0 24px;
  flex-shrink: 0;
}
.topbar-title { font-size: 15px; font-weight: 500; color: var(--text-primary); flex: 1; }
.topbar-breadcrumb {
  font-size: 13px; color: var(--text-muted);
  display: flex; align-items: center; gap: 6px;
}
.topbar-breadcrumb span { color: var(--text-secondary); }

/* ── Search Input ─────────────────────────────────────────── */
.search-wrap {
  position: relative;
  display: flex; align-items: center;
}
.search-wrap i {
  position: absolute; left: 10px;
  font-size: 16px; color: var(--text-muted);
  pointer-events: none;
}
.search-input {
  background: var(--surface-5);
  border: 1px solid var(--border-dim);
  border-radius: var(--radius-md);
  padding: 7px 12px 7px 34px;
  font-size: 13px; color: var(--text-primary);
  width: 240px;
  transition: border-color var(--transition), width var(--transition);
  outline: none;
}
.search-input::placeholder { color: var(--text-muted); }
.search-input:focus { border-color: var(--border-accent); width: 320px; }

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 16px; border-radius: var(--radius-md);
  font-size: 13px; font-weight: 500;
  border: 1px solid var(--border-normal);
  background: var(--surface-4); color: var(--text-primary);
  transition: background var(--transition), border-color var(--transition), transform var(--transition);
  outline: none;
}
.btn:hover { background: var(--surface-5); border-color: var(--border-normal); }
.btn:active { transform: scale(.98); }
.btn i { font-size: 16px; }
.btn-primary {
  background: var(--blue-600); border-color: var(--blue-500);
  color: #fff;
}
.btn-primary:hover { background: var(--blue-700); }
.btn-danger { background: var(--danger-bg); border-color: var(--danger); color: var(--danger); }
.btn-sm { padding: 5px 11px; font-size: 12px; }
.btn-icon {
  padding: 8px; width: 36px; height: 36px;
  justify-content: center;
}
.btn-icon i { font-size: 17px; }

/* ── Page Content ─────────────────────────────────────────── */
.page { flex: 1; overflow-y: auto; padding: 24px; }
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 24px;
}
.page-heading { font-size: 20px; font-weight: 600; color: var(--text-primary); }
.page-sub { font-size: 13px; color: var(--text-muted); margin-top: 3px; }

/* ── KPI Cards ─────────────────────────────────────────────── */
.kpi-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 14px; margin-bottom: 24px; }
.kpi {
  background: var(--surface-3);
  border: 1px solid var(--border-dim);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  position: relative; overflow: hidden;
}
.kpi::before {
  content: ''; position: absolute;
  top: 0; left: 0; right: 0; height: 2px;
  background: var(--kpi-accent, var(--blue-600));
}
.kpi-icon {
  width: 36px; height: 36px;
  background: var(--surface-4);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; color: var(--kpi-accent, var(--blue-400));
  margin-bottom: 12px;
}
.kpi-label { font-size: 12px; color: var(--text-muted); margin-bottom: 4px; }
.kpi-value { font-size: 28px; font-weight: 600; color: var(--text-primary); line-height: 1; }
.kpi-sub { font-size: 11px; color: var(--text-muted); margin-top: 5px; }

/* ── Cards ─────────────────────────────────────────────────── */
.card {
  background: var(--surface-3);
  border: 1px solid var(--border-dim);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px;
}
.card-title { font-size: 14px; font-weight: 500; color: var(--text-primary); }
.card-title-icon { font-size: 17px; color: var(--text-muted); }

/* ── Tables ─────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  font-size: 11px; font-weight: 600; letter-spacing: .06em;
  color: var(--text-muted); text-transform: uppercase;
  padding: 0 16px 10px;
  text-align: left; border-bottom: 1px solid var(--border-dim);
}
tbody tr {
  border-bottom: 1px solid var(--border-dim);
  transition: background var(--transition);
  cursor: pointer;
}
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--surface-4); }
tbody td { padding: 12px 16px; color: var(--text-secondary); vertical-align: middle; }
tbody td:first-child { color: var(--text-primary); font-weight: 500; }

/* ── Badges ─────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; font-weight: 500; padding: 3px 9px;
  border-radius: 99px;
}
.badge-active  { background: var(--success-bg); color: var(--success); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-danger  { background: var(--danger-bg);  color: var(--danger); }
.badge-info    { background: var(--info-bg);    color: var(--blue-400); }
.badge-muted   { background: var(--surface-5);  color: var(--text-muted); }
.badge i { font-size: 12px; }

/* ── Pallet Number ─────────────────────────────────────────── */
.pallet-num {
  font-family: var(--font-mono);
  font-size: 13px; font-weight: 500;
  color: var(--blue-400);
  background: var(--info-bg);
  padding: 3px 8px; border-radius: var(--radius-sm);
  display: inline-block;
}

/* ── Location Tag ─────────────────────────────────────────── */
.location-tag {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12px; color: var(--text-secondary);
  background: var(--surface-4);
  padding: 3px 8px; border-radius: var(--radius-sm);
}
.location-tag i { font-size: 13px; color: var(--text-muted); }

/* ── Forms ─────────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-label {
  display: block; font-size: 12px; font-weight: 500;
  color: var(--text-secondary); margin-bottom: 6px;
}
.form-label .req { color: var(--danger); margin-left: 2px; }
.form-control {
  width: 100%;
  background: var(--surface-5);
  border: 1px solid var(--border-normal);
  border-radius: var(--radius-md);
  padding: 9px 12px;
  font-size: 14px; color: var(--text-primary);
  outline: none;
  transition: border-color var(--transition);
}
.form-control::placeholder { color: var(--text-muted); }
.form-control:focus { border-color: var(--blue-500); }
.form-control.error { border-color: var(--danger); }
.form-error { font-size: 11px; color: var(--danger); margin-top: 4px; }
.form-hint  { font-size: 11px; color: var(--text-muted); margin-top: 4px; }
select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 80px; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }

/* ── Modal ─────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.6);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000; padding: 20px;
  opacity: 0; pointer-events: none;
  transition: opacity var(--transition);
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal {
  background: var(--surface-3);
  border: 1px solid var(--border-normal);
  border-radius: var(--radius-xl);
  width: 100%; max-width: 680px;
  max-height: 90vh; display: flex; flex-direction: column;
  transform: translateY(20px);
  transition: transform var(--transition);
}
.modal-overlay.open .modal { transform: translateY(0); }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 24px; border-bottom: 1px solid var(--border-dim);
  flex-shrink: 0;
}
.modal-title { font-size: 16px; font-weight: 600; color: var(--text-primary); }
.modal-body { padding: 24px; overflow-y: auto; flex: 1; }
.modal-footer {
  padding: 16px 24px; border-top: 1px solid var(--border-dim);
  display: flex; justify-content: flex-end; gap: 10px;
  flex-shrink: 0;
}

/* ── Toast Notifications ─────────────────────────────────── */
.toast-container {
  position: fixed; top: 20px; right: 20px;
  z-index: 2000; display: flex; flex-direction: column; gap: 8px;
}
.toast {
  display: flex; align-items: center; gap: 12px;
  background: var(--surface-3);
  border: 1px solid var(--border-normal);
  border-radius: var(--radius-lg);
  padding: 12px 16px;
  min-width: 280px; max-width: 380px;
  box-shadow: 0 8px 32px rgba(0,0,0,.4);
  animation: toastIn .25s ease forwards;
  font-size: 13px;
}
.toast.leaving { animation: toastOut .2s ease forwards; }
.toast-icon { font-size: 20px; flex-shrink: 0; }
.toast-msg { flex: 1; color: var(--text-primary); }
.toast-close { font-size: 16px; color: var(--text-muted); cursor: pointer; flex-shrink: 0; }
.toast-success { border-left: 3px solid var(--success); }
.toast-error   { border-left: 3px solid var(--danger); }
.toast-warning { border-left: 3px solid var(--warning); }
.toast-info    { border-left: 3px solid var(--info); }

@keyframes toastIn  { from { opacity:0; transform:translateX(20px); } to { opacity:1; transform:translateX(0); } }
@keyframes toastOut { from { opacity:1; transform:translateX(0); } to { opacity:0; transform:translateX(20px); } }

/* ── Loader ─────────────────────────────────────────────────── */
.loader {
  width: 20px; height: 20px;
  border: 2px solid var(--border-normal);
  border-top-color: var(--blue-500);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.page-loader {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 12px; padding: 60px; color: var(--text-muted); font-size: 14px;
}

/* ── Warehouse Map ─────────────────────────────────────────── */
.map-grid { display: grid; grid-template-columns: repeat(2,1fr); gap: 12px; }
.aisle-block {
  background: var(--surface-4);
  border: 1px solid var(--border-dim);
  border-radius: var(--radius-md);
  padding: 12px;
}
.aisle-name { font-size: 12px; font-weight: 600; color: var(--text-primary); margin-bottom: 8px; }
.shelves-grid { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 8px; }
.shelf-dot {
  width: 24px; height: 24px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 9px; font-weight: 600; cursor: pointer;
  transition: transform var(--transition);
  border: 1px solid transparent;
}
.shelf-dot:hover { transform: scale(1.2); z-index: 1; }
.shelf-free     { background: var(--success-bg); color: var(--success); border-color: rgba(34,197,94,.2); }
.shelf-occupied { background: var(--info-bg);    color: var(--blue-400); border-color: rgba(59,130,246,.2); }
.shelf-partial  { background: var(--warning-bg); color: var(--warning); border-color: rgba(245,158,11,.2); }
.occ-bar { height: 4px; background: var(--surface-5); border-radius: 99px; overflow: hidden; }
.occ-fill { height: 100%; background: var(--blue-600); border-radius: 99px; }
.occ-label { font-size: 10px; color: var(--text-muted); margin-top: 4px; }

/* ── QR Scanner ─────────────────────────────────────────────── */
.scanner-container {
  display: flex; flex-direction: column;
  align-items: center; gap: 20px;
  padding: 24px;
}
.scanner-viewport {
  width: 100%; max-width: 360px;
  aspect-ratio: 1;
  background: var(--surface-0);
  border-radius: var(--radius-lg);
  border: 2px solid var(--border-accent);
  position: relative; overflow: hidden;
}
.scanner-viewport video { width: 100%; height: 100%; object-fit: cover; }
.scanner-overlay {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
}
.scanner-frame {
  width: 200px; height: 200px;
  border: 2px solid var(--blue-400);
  border-radius: var(--radius-md);
  position: relative;
}
.scanner-frame::before, .scanner-frame::after,
.scanner-frame .c::before, .scanner-frame .c::after {
  content: ''; position: absolute;
  width: 20px; height: 20px;
  border-color: var(--blue-400); border-style: solid;
}
.scanner-line {
  position: absolute; left: 10px; right: 10px;
  height: 2px; background: var(--blue-400);
  opacity: .7;
  animation: scanLine 2s ease-in-out infinite;
}
@keyframes scanLine {
  0%  { top: 10px; }
  50% { top: calc(100% - 12px); }
  100%{ top: 10px; }
}

/* ── Product List in Pallet ─────────────────────────────────── */
.product-row {
  display: grid;
  grid-template-columns: 1fr auto auto auto 36px;
  gap: 10px; align-items: center;
  padding: 10px 12px;
  background: var(--surface-4);
  border: 1px solid var(--border-dim);
  border-radius: var(--radius-md);
  margin-bottom: 8px;
}
.product-row input { background: var(--surface-5); }

/* ── QR Print Label ─────────────────────────────────────────── */
@media print {
  .sidebar, .topbar, .modal-overlay, .no-print { display: none !important; }
  .print-label { display: block !important; }
  body { background: #fff; color: #000; }
}
.print-label { display: none; }

/* ── Empty State ─────────────────────────────────────────────── */
.empty-state {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 12px; padding: 60px 24px;
  color: var(--text-muted); text-align: center;
}
.empty-state i { font-size: 48px; opacity: .4; }
.empty-state h3 { font-size: 16px; font-weight: 500; color: var(--text-secondary); }
.empty-state p  { font-size: 13px; }

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 1024px) {
  .kpi-grid { grid-template-columns: repeat(2,1fr); }
}
@media (max-width: 768px) {
  :root { --sidebar-w: 0px; }
  .sidebar { position: fixed; width: 240px; height: 100%; left: -240px; transition: left var(--transition); }
  .sidebar.mobile-open { left: 0; }
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
  .page { padding: 16px; }
  .topbar { padding: 0 16px; }
  .search-input { width: 140px; }
  .search-input:focus { width: 200px; }

  /* Mobile scanner — pantalla completa */
  .scanner-viewport { max-width: 100%; }
  .shelf-dot { width: 28px; height: 28px; font-size: 10px; }
}
