/* ============================================================
   DAEM Monitor — Hoja de estilos del dashboard
   Sin dependencias externas (la red corporativa bloquea CDNs).
   Servida desde /static/dashboard.css
   ============================================================ */

/* ---------- Variables de color (identidad DAEM) ---------- */
:root {
  --daem-red:        #b91c1c;  /* acciones / acentos */
  --daem-red-hover:  #991b1b;  /* hover de acciones */
  --bg:              #f9fafb;  /* fondo general */
  --card-bg:         #ffffff;  /* tarjetas */
  --border:          #e5e7eb;  /* bordes */
  --border-soft:     #f3f4f6;  /* separadores suaves */
  --text:            #111827;  /* texto principal */
  --text-muted:      #6b7280;  /* texto secundario */
  --text-faint:      #9ca3af;  /* texto terciario */
  --green:           #16a34a;  /* productivo */
  --orange:          #f97316;  /* no productivo */
  --neutral:         #d1d5db;  /* neutro */
  --radius:          12px;
  --radius-sm:       8px;
  --shadow-sm:       0 1px 2px rgba(0,0,0,0.05);
  --shadow-md:       0 10px 25px rgba(0,0,0,0.15);
}

/* ---------- Reset básico ---------- */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1 { font-size: 24px; font-weight: 700; margin: 0; color: var(--text); }

a { color: inherit; }

/* ---------- Layout ---------- */
.container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 24px;
}

.hidden { display: none !important; }

/* ---------- Header ---------- */
.header {
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 0;
  z-index: 50;
}
.header-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-title { font-weight: 700; color: var(--text); }
.brand-sub { font-size: 12px; color: var(--text-muted); }

/* Logo: cuadrado rojo con la D blanca */
.logo {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: var(--daem-red);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  flex-shrink: 0;
}
.logo-lg {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-sm);
  font-size: 20px;
}

/* Navegación por pestañas */
.nav { display: flex; gap: 4px; }
.tab {
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  padding: 8px 16px;
  font-size: 14px;
  color: var(--text-muted);
  cursor: pointer;
  font-family: inherit;
}
.tab:hover { color: var(--text); }
.tab-active {
  border-bottom-color: var(--daem-red);
  color: var(--daem-red);
  font-weight: 600;
}

/* Bloque de usuario en el header */
.user-block { display: flex; align-items: center; gap: 12px; }
.user-meta { text-align: right; }
.user-name { font-size: 12px; font-weight: 500; color: var(--text); }
.user-role { font-size: 12px; color: var(--text-faint); }
.user-initials {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #fee2e2;
  color: var(--daem-red);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  flex-shrink: 0;
}

/* ---------- Botones ---------- */
.btn {
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  padding: 8px 16px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  line-height: 1.2;
}
.btn:disabled { opacity: 0.6; cursor: default; }

.btn-primary { background: var(--daem-red); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--daem-red-hover); }

.btn-secondary {
  background: #fff;
  color: var(--text);
  border-color: var(--border);
}
.btn-secondary:hover:not(:disabled) { background: var(--bg); }

.btn-block { width: 100%; justify-content: center; padding: 10px 16px; }

/* Enlace de texto (Salir, volver, etc.) */
.btn-link {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
  padding: 0;
}
.btn-link:hover { color: var(--daem-red); }

/* ---------- Tarjetas ---------- */
.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.card-flush { padding: 0; overflow: hidden; }
.card-title { font-weight: 600; color: var(--text); margin-bottom: 12px; }
.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

/* ---------- KPIs ---------- */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}
.kpi {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.kpi-label {
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.kpi-value {
  font-size: 30px;
  font-weight: 700;
  color: var(--text);
  margin-top: 4px;
  line-height: 1.1;
}
.kpi-value-sm { font-size: 24px; }
.kpi-unit { font-size: 18px; color: var(--text-faint); font-weight: 700; }
.kpi-note { font-size: 12px; color: var(--text-faint); margin-top: 4px; }
.kpi-value.is-orange { color: var(--orange); }
.kpi-value.is-green  { color: var(--green); }
.kpi-value.is-muted  { color: var(--text-muted); }

/* ---------- Grids de dos / seis columnas ---------- */
.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}
.section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 24px;
}
.section-sub { font-size: 14px; color: var(--text-muted); margin-top: 4px; }

/* ---------- Barras de progreso ---------- */
.bar-row { margin-bottom: 10px; }
.bar-row-head {
  display: flex;
  justify-content: space-between;
  font-size: 14px;
  margin-bottom: 4px;
}
.bar-row-head .label { color: var(--text); }
.bar-row-head .meta  { color: var(--text-muted); }
.bar-track {
  background: #f3f4f6;
  border-radius: 9999px;
  height: 8px;
  overflow: hidden;
}
.bar-fill { height: 100%; border-radius: 9999px; }
.bar-fill.is-orange { background: var(--orange); }
.bar-fill.is-green  { background: var(--green); }
.bar-fill.is-red    { background: var(--daem-red); }
.bar-fill.is-yellow { background: #eab308; }

/* Barra fina (tabla de empleados) */
.bar-track-thin { height: 6px; width: 96px; background: #e5e7eb; }

/* Lista clave/valor (apps productivas, distractores) */
.kv-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
  font-size: 14px;
}
.kv-row .name { color: var(--text); }
.kv-row .val  { text-align: right; }
.kv-row .val .dur { color: var(--text); font-weight: 500; }
.kv-row .val .sub { font-size: 12px; color: var(--text-faint); }
.kv-row.is-distractor .name,
.kv-row.is-distractor .val { color: #c2410c; }

.muted { color: var(--text-faint); font-size: 14px; }
.spacer-list > * + * { margin-top: 8px; }

/* ---------- Tabla ---------- */
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table thead {
  background: var(--bg);
  color: var(--text-muted);
  font-size: 12px;
  text-transform: uppercase;
}
.table th {
  text-align: left;
  padding: 12px 20px;
  font-weight: 600;
}
.table th.right { text-align: right; }
.table td {
  padding: 12px 20px;
  border-top: 1px solid var(--border-soft);
}
.table tbody tr.clickable { cursor: pointer; }
.table tbody tr.clickable:hover { background: var(--bg); }
.table .empty-cell {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-faint);
}
.cell-emp { display: flex; align-items: center; gap: 12px; }
.cell-emp .name { font-weight: 500; color: var(--text); }
.cell-muted { color: var(--text-muted); }
.cell-faint { color: var(--text-faint); font-size: 12px; }
.prod-cell { display: flex; align-items: center; gap: 8px; }
.prod-pct { font-size: 14px; font-weight: 500; }
.prod-pct.is-green  { color: var(--green); }
.prod-pct.is-yellow { color: #ca8a04; }
.prod-pct.is-red    { color: var(--daem-red); }
.nowrap { white-space: nowrap; }
.text-right { text-align: right; }

/* ---------- Buscador ---------- */
.input {
  font-family: inherit;
  font-size: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  outline: none;
  color: var(--text);
  width: 100%;
  background: #fff;
}
.input:focus {
  border-color: var(--daem-red);
  box-shadow: 0 0 0 2px rgba(185, 28, 28, 0.2);
}
.input-search { width: 256px; padding: 6px 12px; }
.field { margin-bottom: 16px; }
.field-label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 4px;
}
select.input { appearance: auto; background: #fff; }

/* ---------- Badges / estados ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
}
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--neutral);
  flex-shrink: 0;
}
.status-dot.is-online { background: var(--green); }

/* Leyenda del timeline */
.legend { display: flex; align-items: center; gap: 16px; font-size: 12px; }
.legend-item { display: flex; align-items: center; gap: 6px; }
.legend-swatch { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.legend-swatch.is-green   { background: var(--green); }
.legend-swatch.is-orange  { background: var(--orange); }
.legend-swatch.is-neutral { background: var(--neutral); }
.legend-swatch.is-idle    { background: #93c5fd; }

/* ---------- Avatares (set FIJO de 8 clases reales) ---------- */
.avatar {
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  flex-shrink: 0;
}
.avatar-sm { width: 32px; height: 32px; font-size: 12px; }
.avatar-lg { width: 64px; height: 64px; font-size: 20px; }
.av-0 { background: #dbeafe; color: #1d4ed8; } /* azul */
.av-1 { background: #ede9fe; color: #6d28d9; } /* morado */
.av-2 { background: #dcfce7; color: #15803d; } /* verde */
.av-3 { background: #fef9c3; color: #a16207; } /* amarillo */
.av-4 { background: #fce7f3; color: #be185d; } /* rosa */
.av-5 { background: #e0e7ff; color: #4338ca; } /* índigo */
.av-6 { background: #ccfbf1; color: #0f766e; } /* teal */
.av-7 { background: #ffedd5; color: #c2410c; } /* naranja */

/* ---------- Timeline ---------- */
.timeline > * + * { margin-top: 4px; }
.timeline-row { display: flex; align-items: center; gap: 12px; }
.timeline-hour { font-size: 12px; color: var(--text-faint); width: 48px; flex-shrink: 0; }
.timeline-bar {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--border-soft);
  border-radius: 4px;
  height: 28px;
  position: relative;
  overflow: hidden;
}
.timeline-fill { height: 100%; }
.timeline-fill.is-productive   { background: var(--green); }
.timeline-fill.is-unproductive { background: var(--orange); }
.timeline-fill.is-neutral      { background: var(--neutral); }
.timeline-fill.is-idle         { background: #93c5fd; }
.timeline-fill.is-empty        { background: #f3f4f6; }
.timeline-label {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  padding: 0 12px;
  font-size: 12px;
  color: var(--text);
  font-weight: 500;
  pointer-events: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------- Header del empleado ---------- */
.emp-header { display: flex; align-items: center; gap: 16px; }
.emp-header .emp-info { flex: 1; }
.emp-header .emp-sub { font-size: 14px; color: var(--text-muted); margin-top: 2px; }
.emp-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Capturas ---------- */
.screens-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 12px;
}
.screenshot-tile { cursor: pointer; transition: transform 0.15s; }
.screenshot-tile:hover { transform: scale(1.03); }
.screenshot-thumb {
  aspect-ratio: 16 / 9;
  background: #f3f4f6;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border);
}
.screenshot-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.screenshot-time { font-size: 12px; color: var(--text-muted); margin-top: 4px; text-align: center; }
.grid-span-full { grid-column: 1 / -1; text-align: center; padding: 32px 0; }

/* ---------- Banner de error ---------- */
.error-banner {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #b91c1c;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.error-banner::before { content: "⚠"; font-size: 16px; }

/* ---------- Modales ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px;
}
.modal {
  background: #fff;
  border-radius: var(--radius);
  width: 100%;
  max-width: 560px;
  overflow: hidden;
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  max-height: 90vh;
}
.modal-wide { max-width: 1024px; }
.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.modal-header .modal-title { font-weight: 600; font-size: 15px; }
.modal-close {
  background: none;
  border: none;
  color: var(--text-faint);
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  padding: 0 4px;
}
.modal-close:hover { color: var(--text); }
.modal-body { padding: 20px; overflow: auto; }
.modal-body-flush { padding: 8px; background: #f3f4f6; }
.modal-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}
.modal-img { width: 100%; height: auto; max-height: 80vh; object-fit: contain; background: #fff; border-radius: 4px; display: block; }

/* Tabla compacta dentro de modales (consentimientos) */
.table-sm { width: 100%; border-collapse: collapse; font-size: 13px; }
.table-sm th {
  text-align: left;
  padding: 8px 10px;
  background: var(--bg);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  white-space: nowrap;
}
.table-sm td {
  padding: 8px 10px;
  border-top: 1px solid var(--border-soft);
  vertical-align: top;
}
.mono { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: 12px; }

/* ---------- Login ---------- */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: linear-gradient(to bottom right, #f9fafb, #f3f4f6);
}
.login-card {
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
  padding: 32px;
  width: 100%;
  max-width: 420px;
}
.login-head { display: flex; align-items: center; gap: 12px; margin-bottom: 24px; }
.login-head .title { font-weight: 700; font-size: 18px; }
.login-head .sub { font-size: 12px; color: var(--text-muted); }
.login-foot {
  font-size: 12px;
  color: var(--text-faint);
  text-align: center;
  margin-top: 24px;
  line-height: 1.6;
}

/* ---------- Responsive ---------- */
@media (max-width: 1024px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .screens-grid { grid-template-columns: repeat(4, 1fr); }
}
@media (max-width: 720px) {
  .container { padding: 16px; }
  .header-inner { padding: 12px 16px; flex-wrap: wrap; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
  .screens-grid { grid-template-columns: repeat(2, 1fr); }
  .user-meta { display: none; }
  .input-search { width: 100%; }
  .card-header { flex-direction: column; align-items: stretch; }
  /* Tabla con scroll horizontal en pantallas pequeñas */
  .table-scroll { overflow-x: auto; }
  .table { min-width: 760px; }
}
