/* ============================================================
   MONITOR DE SURTIDO — tema claro fijo para TV de almacén
   ============================================================ */

/* ── 1. Base reset ── */
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.5;
}
body {
  background: #f0f2f5;
  color: #1a1a1a;
  min-height: 100vh;
}

/* ── 1b. Connection banner ── */
.conn-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  background: #dc2626;
  animation: conn-pulse 2s ease-in-out infinite;
}
.conn-banner.reconectado {
  background: #16a34a;
  animation: none;
}
@keyframes conn-pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: .7; }
}

/* ── 2. Header ── */
.monitor-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #1e293b;
  color: #fff;
  padding: 0 20px;
  height: 60px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 4px rgba(0,0,0,.25);
}
.monitor-header h1 {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: .3px;
  white-space: nowrap;
}
.suc-name {
  font-size: 20px;
  font-weight: 600;
  color: #e2e8f0;
  margin-left: 12px;
  letter-spacing: .2px;
}
.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}
.clock {
  font-size: 22px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: 1px;
  color: #e2e8f0;
}
.btn-config {
  background: transparent;
  border: 1px solid #475569;
  color: #cbd5e1;
  border-radius: 6px;
  padding: 5px 10px;
  font-size: 13px;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.btn-config:hover {
  background: #334155;
  color: #fff;
}

/* ── 3. Filter bar ── */
.filter-bar {
  background: #fff;
  border-bottom: 1px solid #e2e8f0;
  padding: 10px 20px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}
.filter-group {
  display: flex;
  align-items: center;
  gap: 6px;
}
.filter-group label {
  font-size: 12px;
  font-weight: 600;
  color: #64748b;
  white-space: nowrap;
}
.filter-group input[type="date"],
.filter-group select {
  border: 1px solid #d1d5db;
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 13px;
  color: #1a1a1a;
  background: #f8fafc;
  height: 32px;
}
.filter-group input[type="date"]:focus,
.filter-group select:focus {
  outline: 2px solid #3b82f6;
  outline-offset: -1px;
}
.filter-sep {
  width: 1px;
  height: 24px;
  background: #e2e8f0;
  margin: 0 4px;
}
.auto-refresh-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: #64748b;
  margin-left: auto;
}
.dot-pulse {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #22c55e;
  animation: pulse 2s infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: .45; transform: scale(.8); }
}

/* ── 4. KPIs ── */
.kpis-row {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 14px;
  padding: 16px 20px 8px;
}
.kpi {
  background: #fff;
  border-radius: 10px;
  padding: 14px 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,.08);
  border-left: 4px solid #94a3b8;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.kpi-total    { border-left-color: #3b82f6; }
.kpi-completo { border-left-color: #22c55e; }
.kpi-curso    { border-left-color: #f59e0b; }
.kpi-pendiente{ border-left-color: #ef4444; }
.kpi-noenc    { border-left-color: #8b5cf6; }
.kpi-value {
  font-size: 28px;
  font-weight: 800;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.kpi-total     .kpi-value { color: #1e40af; }
.kpi-completo  .kpi-value { color: #15803d; }
.kpi-curso     .kpi-value { color: #b45309; }
.kpi-pendiente .kpi-value { color: #dc2626; }
.kpi-noenc     .kpi-value { color: #7c3aed; }
.kpi-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: #64748b;
}

/* ── 5. Tabs ── */
.tabs-bar {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 0 20px;
  margin-top: 8px;
  border-bottom: 2px solid #e2e8f0;
  background: transparent;
}
.tab {
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  padding: 9px 16px;
  font-size: 13px;
  font-weight: 600;
  color: #64748b;
  cursor: pointer;
  border-radius: 6px 6px 0 0;
  transition: color .15s, background .15s;
  display: flex;
  align-items: center;
  gap: 6px;
}
.tab:hover {
  color: #1e40af;
  background: #eff6ff;
}
.tab.active {
  color: #1e40af;
  border-bottom-color: #3b82f6;
  background: #eff6ff;
}
.tab .badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  font-size: 11px;
  font-weight: 700;
  background: #e2e8f0;
  color: #475569;
}
.tab.active .badge {
  background: #bfdbfe;
  color: #1e40af;
}

/* ── 6. Tab panels ── */
.tab-panel {
  display: none;
  background: #fff;
  border-radius: 0 0 10px 10px;
  margin: 0 20px 20px;
  box-shadow: 0 1px 4px rgba(0,0,0,.08);
  overflow: hidden;
}
.tab-panel.active {
  display: block;
}

/* ── 7. Grid table ── */
.grid {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.grid thead tr {
  background: #f8fafc;
  border-bottom: 2px solid #e2e8f0;
}
.grid thead th {
  padding: 10px 12px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: #64748b;
  white-space: nowrap;
  user-select: none;
}
.grid thead th[data-col] {
  cursor: pointer;
}
.grid thead th[data-col]:hover {
  background: #f1f5f9;
  color: #334155;
}
.grid tbody tr {
  border-bottom: 1px solid #f1f5f9;
  transition: background .1s;
}
.grid tbody tr:last-child {
  border-bottom: none;
}
.grid tbody tr:hover {
  background: #f8fafc;
}
.grid tbody td {
  padding: 10px 12px;
  color: #1a1a1a;
  vertical-align: middle;
}
.grid tbody tr.completo {
  background: #f0fdf4;
}
.grid tbody tr.completo td {
  color: #6b7280;
}

/* ── 8. Numeric cells ── */
.num {
  text-align: center;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}

/* ── 9. Color utilities ── */
.c-green  { color: #15803d; }
.c-amber  { color: #b45309; }
.c-red    { color: #dc2626; }
.c-purple { color: #7c3aed; }
.c-blue   { color: #1e40af; }
.c-muted  { color: #94a3b8; }

/* ── 10. Progress bar ── */
.progress-bar {
  display: flex;
  align-items: center;
  gap: 6px;
}
.bar {
  flex: 1;
  height: 8px;
  background: #e5e7eb;
  border-radius: 4px;
  overflow: hidden;
}
.bar .fill {
  height: 100%;
  border-radius: 4px;
  transition: width .4s ease;
}
.pct {
  font-size: 12px;
  font-weight: 700;
  min-width: 35px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* ── 11. Time indicator ── */
.tiempo {
  font-size: 12px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.tiempo.verde {
  color: #15803d;
}
.tiempo.amarillo {
  color: #b45309;
  background: #fef3c7;
  border-radius: 4px;
  padding: 1px 6px;
}
.tiempo.rojo {
  color: #dc2626;
  background: #fef2f2;
  border-radius: 4px;
  padding: 1px 6px;
  animation: blink 1.5s infinite;
}
@keyframes blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: .6; }
}

/* ── 12. Estado badges ── */
.estado {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 999px;
  white-space: nowrap;
}
.estado.en-curso {
  background: #fef3c7;
  color: #b45309;
}
.estado.completo {
  background: #dcfce7;
  color: #15803d;
}
.estado.pendiente {
  background: #fee2e2;
  color: #dc2626;
}

/* ── 13. Sort icon ── */
.sort-icon {
  display: inline-block;
  font-size: 10px;
  color: #94a3b8;
  margin-left: 4px;
  opacity: .4;
}
.sort-icon.asc,
.sort-icon.desc {
  opacity: 1;
  color: #3b82f6;
}
.sort-icon.asc::after  { content: '▲'; }
.sort-icon.desc::after { content: '▼'; }

/* ── 14. Detail button ── */
.btn-detalle {
  background: transparent;
  border: 1px solid #3b82f6;
  color: #1e40af;
  border-radius: 5px;
  padding: 3px 9px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, color .15s;
  white-space: nowrap;
}
.btn-detalle:hover {
  background: #3b82f6;
  color: #fff;
}

/* ── 15. Modal ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
}
.modal-overlay.hidden {
  display: none;
}
.modal-box {
  background: #fff;
  border-radius: 10px;
  max-width: 1280px;
  width: calc(100% - 40px);
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 8px 32px rgba(0,0,0,.2);
  display: flex;
  flex-direction: column;
}
.modal-box.modal-config {
  max-width: 460px;
}
.modal-box.modal-detail {
  max-width: 1280px;
}
.modal-detail .modal-body {
  padding: 16px 20px;
}
.modal-detail table.grid {
  font-size: 13px;
  table-layout: auto;
}
.modal-detail table.grid thead th {
  font-size: 11px;
  padding: 8px 10px;
}
.modal-detail table.grid tbody td {
  padding: 7px 10px;
  vertical-align: middle;
}
.modal-detail .col-clave {
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  color: #1e293b;
  white-space: nowrap;
}
.modal-detail .col-descripcion {
  font-size: 12px;
  line-height: 1.35;
  color: #1e293b;
  min-width: 280px;
}
.modal-detail .col-zona {
  font-size: 11px;
  color: #475569;
  white-space: nowrap;
}
.modal-detail .col-alm {
  font-size: 12px;
  color: #475569;
  min-width: 160px;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid #e2e8f0;
  flex-shrink: 0;
}
.modal-header h3 {
  font-size: 15px;
  font-weight: 700;
  color: #1e293b;
}
.modal-close {
  background: transparent;
  border: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: #64748b;
  cursor: pointer;
  transition: background .15s, color .15s;
  line-height: 1;
}
.modal-close:hover {
  background: #f1f5f9;
  color: #1e293b;
}
.modal-body {
  padding: 16px 18px;
  flex: 1;
  overflow-y: auto;
}
.modal-footer {
  border-top: 1px solid #e2e8f0;
  padding: 12px 18px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-shrink: 0;
}

/* ── 16. Config form ── */
.config-section {
  margin-bottom: 18px;
}
.config-section h4 {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: #64748b;
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid #f1f5f9;
}
.config-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 8px 0;
}
.config-row label {
  font-size: 13px;
  color: #374151;
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
}
.config-input {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.config-input input {
  width: 64px;
  border: 1px solid #d1d5db;
  border-radius: 5px;
  padding: 4px 6px;
  font-size: 13px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.config-input input:focus {
  outline: 2px solid #3b82f6;
  outline-offset: -1px;
}
.config-input span {
  font-size: 12px;
  color: #64748b;
  white-space: nowrap;
}
.color-dot {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}
.color-dot.verde    { background: #22c55e; }
.color-dot.amarillo { background: #f59e0b; }
.color-dot.rojo     { background: #ef4444; }

/* ── 17. Empty state ── */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: #94a3b8;
  font-style: italic;
  font-size: 14px;
}

/* ── 18. Responsive ── */
@media (max-width: 768px) {
  .kpis-row {
    grid-template-columns: repeat(3, 1fr);
  }
  .kpi-value {
    font-size: 22px;
  }
  .grid {
    font-size: 12px;
  }
  .grid thead th,
  .grid tbody td {
    padding: 8px 8px;
  }
  .monitor-header h1 {
    font-size: 14px;
  }
  .clock {
    font-size: 17px;
  }
  .filter-bar {
    gap: 8px;
  }
}
@media (max-width: 480px) {
  .kpis-row {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ── 19. Print ── */
@media print {
  .monitor-header,
  .filter-bar,
  .tabs-bar,
  .btn-config,
  .btn-detalle,
  .modal-overlay {
    display: none !important;
  }
  .tab-panel {
    display: block !important;
    margin: 0;
    box-shadow: none;
    border-radius: 0;
  }
  .grid {
    width: 100%;
    font-size: 11px;
  }
  body {
    background: #fff;
  }
}
