/* ============================================================
   SRMPN Captura Diaria – styles.css
   Dark mode institucional / Salud Pública México
   ============================================================ */

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

/* ── Variables ──────────────────────────────────────────────── */
:root {
  --bg:           #0d1117;
  --bg-card:      #161b22;
  --bg-card2:     #1c2129;
  --border:       #30363d;
  --border-focus: #388bfd;
  --accent:       #1f6feb;
  --accent-hover: #388bfd;
  --success:      #2ea043;
  --danger:       #da3633;
  --warning:      #d29922;
  --text:         #e6edf3;
  --text-muted:   #8b949e;
  --text-dim:     #6e7681;
  --tab-active:   #f0883e;
  --radius:       8px;
  --radius-lg:    12px;
  --shadow:       0 4px 24px rgba(0,0,0,.5);
  --font:         'Inter', system-ui, sans-serif;
}

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

html, body {
  height: 100%;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

/* ── Layout ─────────────────────────────────────────────────── */
.app-header {
  background: linear-gradient(135deg, #0d1b2a 0%, #1a2942 50%, #0f2035 100%);
  border-bottom: 1px solid var(--border);
  padding: 16px 24px;
  display: flex;
  align-items: center;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow);
}

.app-header .logo {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, var(--accent), var(--tab-active));
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

.app-header h1 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
}

.app-header .subtitle {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.app-header .header-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
}

.badge-fecha {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 4px 14px;
  font-size: 0.75rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.container {
  max-width: 1600px;
  margin: 0 auto;
  padding: 0 16px 40px;
}

/* ── Tabs ────────────────────────────────────────────────────── */
.tabs-nav {
  display: flex;
  gap: 2px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 4px;
  margin: 20px 0 24px;
  width: fit-content;
}

.tab-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-family: var(--font);
  font-size: 0.85rem;
  font-weight: 500;
  padding: 8px 20px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.tab-btn:hover:not(.active) {
  background: var(--bg-card2);
  color: var(--text);
}

.tab-btn.active {
  background: linear-gradient(135deg, var(--accent) 0%, var(--tab-active) 100%);
  color: #fff;
  box-shadow: 0 2px 8px rgba(31,111,235,.4);
}

.tab-btn .tab-icon { font-size: 1rem; }

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

/* ── Cards ───────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.card-header h2 {
  font-size: 1rem;
  font-weight: 600;
}

.card-header .card-meta {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-left: auto;
}

.card-body { padding: 20px; }

/* ── Toolbar ─────────────────────────────────────────────────── */
.toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.search-input, .filter-select {
  background: var(--bg-card2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font);
  font-size: 0.85rem;
  padding: 8px 12px;
  outline: none;
  transition: border-color 0.2s;
}

.search-input:focus, .filter-select:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(56,139,253,.15);
}

.search-input { min-width: 220px; }
.filter-select { cursor: pointer; }
.filter-select option { background: var(--bg-card2); }

.toolbar-right { margin-left: auto; display: flex; gap: 8px; }

/* ── Buttons ─────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: all 0.2s;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover { background: var(--accent-hover); transform: translateY(-1px); }

.btn-success {
  background: var(--success);
  color: #fff;
}
.btn-success:hover { filter: brightness(1.15); transform: translateY(-1px); }

.btn-sm { padding: 5px 10px; font-size: 0.78rem; }

.btn:active { transform: translateY(0); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

/* ── Table ───────────────────────────────────────────────────── */
.table-wrap {
  overflow: auto;
  max-height: 62vh;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

thead {
  position: sticky;
  top: 0;
  z-index: 10;
}

thead th {
  background: #1e2b3a;
  padding: 10px 12px;
  text-align: left;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background 0.15s;
}

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

tbody td {
  padding: 8px 12px;
  color: var(--text);
  vertical-align: middle;
}

td.clues {
  font-family: 'Courier New', monospace;
  font-size: 0.75rem;
  color: var(--text-muted);
}

td.nombre { font-weight: 500; max-width: 200px; }

/* ── Activo Column ───────────────────────────────────────────── */
.activo-select {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-family: var(--font);
  font-size: 0.8rem;
  padding: 4px 8px;
  cursor: pointer;
  outline: none;
  width: 70px;
  transition: border-color 0.2s;
}

.activo-select:focus { border-color: var(--border-focus); }
.activo-select.si { border-color: var(--success); color: #2ea043; }
.activo-select.no { border-color: var(--border); color: var(--text-muted); }

/* Celda de pegado rápido en tab 1 */
.paste-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  background: var(--bg-card2);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 10px 16px;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.paste-area {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

/* ── Stats bar Tab 1 ─────────────────────────────────────────── */
.stats-bar {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.stat-chip {
  background: var(--bg-card2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 5px 14px;
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  gap: 6px;
}

.stat-chip .dot {
  width: 8px; height: 8px;
  border-radius: 50%;
}
.dot-green { background: var(--success); }
.dot-gray  { background: var(--text-dim); }
.dot-blue  { background: var(--accent); }

/* ── Existencias Tab ─────────────────────────────────────────── */
.existencias-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.bio-section {
  background: var(--bg-card2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
}

.bio-section h3 {
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.bio-badge {
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 600;
}
.bio-badge.sr  { background: rgba(210,153,34,.2);  color: var(--warning); border: 1px solid rgba(210,153,34,.4); }
.bio-badge.srp { background: rgba(31,111,235,.2);  color: var(--accent);  border: 1px solid rgba(31,111,235,.4); }

.field-group {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.field-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.field-row label {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 500;
}

.num-input {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font);
  font-size: 1rem;
  font-weight: 600;
  padding: 10px 14px;
  outline: none;
  transition: border-color 0.2s;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.num-input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(56,139,253,.15);
}

.existencias-actions {
  margin-top: 20px;
  display: flex;
  align-items: center;
  gap: 12px;
}

/* ── Aplicación diaria Tab ────────────────────────────────────── */
.aplicacion-layout {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 20px;
}

.form-card {
  background: var(--bg-card2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
}

.form-card h3 {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 20px;
}

.form-fields {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.date-input {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font);
  font-size: 0.9rem;
  padding: 9px 12px;
  outline: none;
  width: 100%;
  colorscheme: dark;
  transition: border-color 0.2s;
}

.date-input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(56,139,253,.15);
}

/* ── Historial table ──────────────────────────────────────────── */
.historial-empty {
  text-align: center;
  color: var(--text-dim);
  padding: 40px;
  font-size: 0.85rem;
}

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

.toast {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 18px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.85rem;
  box-shadow: var(--shadow);
  animation: slideIn 0.3s ease;
  max-width: 320px;
}

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

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

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 900px) {
  .existencias-grid { grid-template-columns: 1fr; }
  .aplicacion-layout { grid-template-columns: 1fr; }
  .tabs-nav { width: 100%; overflow-x: auto; }
}

@media (max-width: 600px) {
  .app-header { padding: 12px 16px; }
  .app-header h1 { font-size: 0.95rem; }
  .container { padding: 0 10px 30px; }
}

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