/* ── Variables ───────────────────────────────────────────── */
:root {
  --sidebar-bg: #1a2332;
  --sidebar-hover: rgba(255,255,255,.08);
  --sidebar-active: #0d6efd;
  --sidebar-width: 240px;
  --content-bg: #f4f6fb;
  --card-shadow: 0 2px 12px rgba(0,0,0,.07);
}

/* ── Body ────────────────────────────────────────────────── */
body { background: var(--content-bg); font-family: 'Segoe UI', system-ui, sans-serif; }

/* ── Login ───────────────────────────────────────────────── */
.login-bg {
  background: linear-gradient(135deg, #1a2332 0%, #0d6efd 100%);
}
.login-card { width: 100%; max-width: 400px; border-radius: 1rem; }

/* ── Sidebar ─────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  background: var(--sidebar-bg);
  min-height: 100vh;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-brand { letter-spacing: .5px; }

.sidebar-divider {
  border-color: rgba(255,255,255,.1);
  margin: .5rem 0;
}

.sidebar-link {
  color: rgba(255,255,255,.7) !important;
  border-radius: .5rem;
  font-size: .875rem;
  padding: .5rem .75rem;
  transition: background .15s, color .15s;
}
.sidebar-link:hover {
  background: var(--sidebar-hover) !important;
  color: #fff !important;
}
.sidebar-link.active {
  background: var(--sidebar-active) !important;
  color: #fff !important;
}

/* ── Content area ────────────────────────────────────────── */
.content-area { background: var(--content-bg); }

/* ── Page header ─────────────────────────────────────────── */
.page-header {
  border-bottom: 1px solid #e2e8f0;
  padding-bottom: 1rem;
  margin-bottom: 1.5rem;
}

/* ── Cards ───────────────────────────────────────────────── */
.card { border: none; border-radius: .75rem; box-shadow: var(--card-shadow); }
.card-header { border-radius: .75rem .75rem 0 0 !important; }

/* Stat cards */
.stat-card { border-radius: .75rem; transition: transform .15s; cursor: default; }
.stat-card:hover { transform: translateY(-2px); }
.stat-icon { width: 52px; height: 52px; border-radius: .6rem; display:flex; align-items:center; justify-content:center; font-size:1.4rem; }

/* ── Tables ──────────────────────────────────────────────── */
.table { font-size: .875rem; }
.table thead th { font-weight: 600; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: #64748b; background: #f8fafc; border-bottom: 2px solid #e2e8f0; }
.table tbody tr:hover { background: #f0f4ff; }

/* ── Badges ──────────────────────────────────────────────── */
.badge { font-size: .72rem; font-weight: 600; letter-spacing: .03em; }

/* ── Forms ───────────────────────────────────────────────── */
.form-label { font-weight: 600; font-size: .83rem; color: #374151; }
.form-control, .form-select { font-size: .875rem; border-color: #d1d5db; }
.form-control:focus, .form-select:focus { border-color: #0d6efd; box-shadow: 0 0 0 .2rem rgba(13,110,253,.15); }

/* ── Modals ──────────────────────────────────────────────── */
.modal-header { background: #f8fafc; border-bottom: 1px solid #e2e8f0; }
.modal-title { font-weight: 700; font-size: 1rem; }

/* ── Workflow tabs (Calidad) ─────────────────────────────── */
.workflow-step { border-left: 3px solid #e2e8f0; padding-left: 1rem; margin-bottom: 1.5rem; }
.workflow-step.active-step { border-left-color: #0d6efd; }
.step-badge { width: 28px; height: 28px; border-radius: 50%; display:inline-flex; align-items:center; justify-content:center; font-size:.75rem; font-weight:700; }

/* ── Protocol print view ─────────────────────────────────── */
@media print {
  .sidebar, .modal-footer, #toast-container { display: none !important; }
  .modal-dialog { max-width: 100%; margin: 0; }
  .modal-content { border: none; box-shadow: none; }
}

/* ── Spinner overlay ─────────────────────────────────────── */
.spinner-overlay {
  position: absolute; inset: 0; background: rgba(255,255,255,.6);
  display: flex; align-items: center; justify-content: center;
  border-radius: inherit; z-index: 10;
}

/* ── Empty state ─────────────────────────────────────────── */
.empty-state { padding: 3rem 1rem; text-align: center; color: #94a3b8; }
.empty-state i { font-size: 3rem; display: block; margin-bottom: .75rem; }

/* ── Trazabilidad timeline ───────────────────────────────── */
.trace-step { display: flex; gap: .75rem; align-items: flex-start; margin-bottom: 1rem; }
.trace-dot { width: 12px; height: 12px; border-radius: 50%; background: #0d6efd; flex-shrink: 0; margin-top: 4px; }
.trace-line { width: 2px; background: #e2e8f0; flex-shrink: 0; }

/* ── Tom Select ─────────────────────────────────────────── */
/* Wrapper dentro de celdas de tabla */
.table td .ts-wrapper { min-width: 160px; }
.table-sm td .ts-wrapper .ts-control { padding: 2px 6px; font-size: .875rem; }
/* Dropdown anclado al body: debe estar sobre modales (z-index 1055) */
body > .ts-dropdown { z-index: 1070 !important; }

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar { width: 60px; min-width: 60px; }
  .sidebar span, .sidebar-brand span, #sidebar-user, #sidebar-role { display: none; }
  .sidebar-link { padding: .5rem; justify-content: center; }
  .sidebar-link i { margin: 0 !important; }
}
