/* ─── Beta Inventario — Global Styles ────────────────────────── */

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

/* Variables de color */
:root {
  --bg-base:      #0d0f14;
  --bg-surface:   #131720;
  --bg-elevated:  #1b2030;
  --bg-hover:     #222840;
  --border:       #2a3050;
  --border-light: #323a55;
  --accent:       #3b82f6;
  --accent-hover: #2563eb;
  --accent-dim:   rgba(59,130,246,.15);
  --text-primary: #e8eaf0;
  --text-muted:   #7b85a0;
  --text-dim:     #4b5568;
  --success:      #22c55e;
  --warning:      #f59e0b;
  --danger:       #ef4444;
  --info:         #06b6d4;
  --radius-sm:    6px;
  --radius:       10px;
  --radius-lg:    14px;
  --shadow:       0 2px 16px rgba(0,0,0,.4);
  --shadow-lg:    0 8px 40px rgba(0,0,0,.6);
  --sidebar-w:    240px;
  --header-h:     60px;
}

/* Reset / base */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 14px;
  background: var(--bg-base);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

/* ─── Layout ──────────────────────────────────────────────────── */
.app-wrapper {
  display: flex;
  min-height: 100vh;
}

/* ─── Sidebar ─────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: transform .25s ease;
}

.sidebar-brand {
  height: var(--header-h);
  padding: 0 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--border);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -.3px;
  color: var(--text-primary);
}

.sidebar-brand .brand-icon {
  width: 32px; height: 32px;
  background: var(--accent);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

.sidebar-brand .brand-icon svg { width: 18px; height: 18px; color: #fff; }

.sidebar-nav {
  flex: 1;
  padding: 12px 8px;
  overflow-y: auto;
}

.nav-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: var(--text-dim);
  padding: 6px 12px 4px;
  margin-top: 8px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-weight: 500;
  cursor: pointer;
  transition: background .15s, color .15s;
  text-decoration: none;
  font-size: 13.5px;
}

.nav-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.nav-item.active {
  background: var(--accent-dim);
  color: var(--accent);
}

.nav-item svg { width: 16px; height: 16px; flex-shrink: 0; }

.sidebar-footer {
  padding: 12px 8px;
  border-top: 1px solid var(--border);
}

/* ─── Main content ────────────────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* ─── Header ──────────────────────────────────────────────────── */
.app-header {
  height: var(--header-h);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 90;
}

.page-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}

.header-actions { display: flex; align-items: center; gap: 12px; }

.user-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 10px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 12.5px;
  color: var(--text-muted);
}

.user-badge .dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--success);
}

/* ─── Page content ────────────────────────────────────────────── */
.page-content {
  padding: 28px;
  flex: 1;
}

/* ─── Cards ───────────────────────────────────────────────────── */
.card-custom {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
}

.stat-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: border-color .2s;
}

.stat-card:hover { border-color: var(--border-light); }

.stat-card .stat-icon {
  width: 36px; height: 36px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 4px;
}

.stat-card .stat-value {
  font-size: 28px;
  font-weight: 700;
  line-height: 1;
  color: var(--text-primary);
}

.stat-card .stat-label {
  font-size: 12.5px;
  color: var(--text-muted);
  font-weight: 500;
}

/* ─── Table ───────────────────────────────────────────────────── */
.table-wrapper {
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  overflow: hidden;
}

.table-custom {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.table-custom thead th {
  background: var(--bg-elevated);
  padding: 11px 16px;
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  transition: color .15s;
}

.table-custom thead th:hover { color: var(--text-primary); }

.table-custom thead th .sort-icon { opacity: .4; margin-left: 4px; }
.table-custom thead th.sorted .sort-icon { opacity: 1; color: var(--accent); }

.table-custom tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background .12s;
  cursor: pointer;
}

.table-custom tbody tr:last-child { border-bottom: none; }
.table-custom tbody tr:hover { background: var(--bg-hover); }

.table-custom tbody td {
  padding: 12px 16px;
  color: var(--text-primary);
  vertical-align: middle;
}

.code-badge {
  font-family: 'Courier New', monospace;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-dim);
  padding: 2px 8px;
  border-radius: 4px;
}

/* ─── Badges de estado ────────────────────────────────────────── */
.badge-estado {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 600;
}

.badge-estado::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
}

.badge-activo   { background: rgba(34,197,94,.15);  color: var(--success); }
.badge-activo::before { background: var(--success); }
.badge-baja     { background: rgba(239,68,68,.15);  color: var(--danger); }
.badge-baja::before { background: var(--danger); }
.badge-mantenimiento { background: rgba(245,158,11,.15); color: var(--warning); }
.badge-mantenimiento::before { background: var(--warning); }
.badge-sin_usuario { background: rgba(107,114,128,.15); color: var(--text-muted); }
.badge-sin_usuario::before { background: var(--text-dim); }

/* ─── Inputs & Forms ──────────────────────────────────────────── */
.form-control-custom,
.form-select-custom {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 8px 12px;
  font-size: 13px;
  width: 100%;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  font-family: inherit;
}

.form-control-custom:focus,
.form-select-custom:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(59,130,246,.2);
}

.form-control-custom::placeholder { color: var(--text-dim); }

/* Search bar */
.search-bar-wrapper {
  position: relative;
}

.search-bar-wrapper svg {
  position: absolute;
  left: 10px; top: 50%;
  transform: translateY(-50%);
  color: var(--text-dim);
  width: 14px; height: 14px;
  pointer-events: none;
}

.search-bar-wrapper .form-control-custom {
  padding-left: 32px;
}

/* ─── Buttons ─────────────────────────────────────────────────── */
.btn-primary-custom {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-primary-custom:hover { background: var(--accent-hover); }

.btn-secondary-custom {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s, border-color .15s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-secondary-custom:hover {
  background: var(--bg-hover);
  border-color: var(--border-light);
  color: var(--text-primary);
}

.btn-danger-custom {
  background: rgba(239,68,68,.15);
  color: var(--danger);
  border: 1px solid rgba(239,68,68,.3);
  border-radius: var(--radius-sm);
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

/* ─── Modals ──────────────────────────────────────────────────── */
.modal-content {
  background: var(--bg-surface) !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--radius-lg) !important;
  color: var(--text-primary) !important;
}

.modal-header {
  border-bottom: 1px solid var(--border) !important;
  padding: 18px 22px !important;
}

.modal-footer {
  border-top: 1px solid var(--border) !important;
  padding: 14px 22px !important;
}

.modal-title { font-size: 16px; font-weight: 600; }

.btn-close {
  filter: invert(1) !important;
  opacity: .5 !important;
}

/* ─── Pagination ──────────────────────────────────────────────── */
.pagination-custom {
  display: flex;
  gap: 4px;
  align-items: center;
}

.page-btn {
  width: 32px; height: 32px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text-muted);
  font-size: 12.5px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all .12s;
}

.page-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.page-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.page-btn:disabled { opacity: .35; cursor: default; }

/* ─── Tabs ────────────────────────────────────────────────────── */
.tab-nav {
  display: flex;
  gap: 2px;
  background: var(--bg-elevated);
  border-radius: var(--radius-sm);
  padding: 3px;
  border: 1px solid var(--border);
  width: fit-content;
}

.tab-btn {
  padding: 6px 14px;
  border-radius: 5px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all .15s;
  font-family: inherit;
}

.tab-btn:hover { color: var(--text-primary); }
.tab-btn.active { background: var(--bg-surface); color: var(--text-primary); box-shadow: 0 1px 4px rgba(0,0,0,.25); }

.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* ─── Detail field ────────────────────────────────────────────── */
.field-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 16px;
}

.field-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--text-dim);
}

.field-value {
  font-size: 13.5px;
  color: var(--text-primary);
  padding: 8px 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  min-height: 36px;
}

.field-value.empty { color: var(--text-dim); font-style: italic; }

/* ─── QR modal ────────────────────────────────────────────────── */
#qrCanvas {
  border-radius: var(--radius-sm);
  display: block;
  margin: 0 auto;
  image-rendering: pixelated;
}

.qr-info-box {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  font-size: 13px;
  line-height: 2;
}

.qr-info-box span { color: var(--text-muted); }
.qr-info-box strong { color: var(--text-primary); float: right; }

/* ─── QR Scanner button flotante ─────────────────────────────── */
#btnScanQR {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 200;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 50px;
  padding: 12px 20px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(59,130,246,.4);
  display: flex;
  align-items: center;
  gap: 8px;
  transition: background .15s, transform .15s, box-shadow .15s;
  font-family: inherit;
}

#btnScanQR:hover {
  background: var(--accent-hover);
  transform: translateY(-2px);
  box-shadow: 0 6px 28px rgba(59,130,246,.55);
}

/* ─── Scanner viewport ────────────────────────────────────────── */
#qr-reader {
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
}

#qr-reader video { border-radius: var(--radius); }

/* ─── Login page ──────────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  background: var(--bg-base);
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 40px 36px;
  box-shadow: var(--shadow-lg);
}

.login-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 32px;
}

.login-logo .brand-icon {
  width: 40px; height: 40px;
  background: var(--accent);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
}

.login-logo .brand-icon svg { width: 22px; height: 22px; color: #fff; }
.login-logo span { font-size: 20px; font-weight: 700; }

.login-card h2 { font-size: 18px; font-weight: 600; margin-bottom: 6px; }
.login-card p  { font-size: 13px; color: var(--text-muted); margin-bottom: 28px; }

.form-group { margin-bottom: 16px; }

.form-group label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.login-btn {
  width: 100%;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 11px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 8px;
  transition: background .15s;
  font-family: inherit;
}

.login-btn:hover { background: var(--accent-hover); }
.login-btn:disabled { opacity: .6; cursor: wait; }

.alert-error {
  background: rgba(239,68,68,.12);
  border: 1px solid rgba(239,68,68,.3);
  border-radius: var(--radius-sm);
  color: #f87171;
  padding: 10px 14px;
  font-size: 13px;
  margin-bottom: 16px;
  display: none;
}

/* ─── Topbar (mobile) ─────────────────────────────────────────── */
.mobile-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
}

/* ─── Charts ──────────────────────────────────────────────────── */
.chart-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
}

.chart-card h6 {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .5px;
  margin-bottom: 16px;
}

/* ─── Historial ───────────────────────────────────────────────── */
.historial-item {
  display: flex;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.historial-item:last-child { border-bottom: none; }

.historial-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--accent);
  margin-top: 5px;
  flex-shrink: 0;
}

.historial-text { font-size: 13px; color: var(--text-primary); }
.historial-meta { font-size: 11.5px; color: var(--text-muted); margin-top: 2px; }

/* ─── Responsive ──────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: var(--shadow-lg);
  }

  .main-content { margin-left: 0; }

  .mobile-toggle { display: block; }

  .page-content { padding: 16px; }

  .app-header { padding: 0 16px; }

  #btnScanQR { bottom: 16px; right: 16px; }
}

/* ─── Scrollbar ───────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-base); }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }

/* ─── Loader ──────────────────────────────────────────────────── */
.spinner-custom {
  width: 32px; height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.loading-overlay {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 60px;
  color: var(--text-muted);
  font-size: 13px;
}

/* ─── Toasts ──────────────────────────────────────────────────── */
.toast-container {
  position: fixed;
  top: 16px; right: 16px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast-msg {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 13px;
  color: var(--text-primary);
  box-shadow: var(--shadow);
  animation: slideIn .2s ease;
}

.toast-msg.success { border-left: 3px solid var(--success); }
.toast-msg.error   { border-left: 3px solid var(--danger); }

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

/* ─── Empty state ─────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.empty-state svg { width: 48px; height: 48px; opacity: .3; margin-bottom: 12px; }
.empty-state p   { font-size: 14px; }
