/* ═══════════════════════════════════════════════════
   MADERA LABRADA — Estilos compartidos
   Paleta: madera oscura + dorado ámbar + crema
   ═══════════════════════════════════════════════════ */
:root {
  --bg:         #1c1208;
  --surface:    #2a1f0f;
  --card:       #3a2810;
  --border:     #5c3d1e;
  --accent:     #c8a45a;
  --accent-l:   #e8d090;
  --text:       #f5ead8;
  --muted:      #9a7850;
  --ok:         #5a9e6f;
  --ok-bg:      rgba(90,158,111,0.15);
  --err:        #c05050;
  --err-bg:     rgba(192,80,80,0.15);
  --warn-bg:    rgba(200,164,90,0.15);
  --radius:     10px;
  --radius-sm:  6px;
  --shadow:     0 2px 16px rgba(0,0,0,0.5);
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  min-height: 100vh;
}

/* ── Alerta global ─────────────────────────────────── */
.global-alert {
  position: fixed;
  top: 14px; left: 50%;
  transform: translateX(-50%);
  padding: 10px 22px;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 14px;
  z-index: 9999;
  max-width: 90vw;
  text-align: center;
  box-shadow: var(--shadow);
  animation: fadeIn .2s ease;
}
.alert-ok  { background: var(--ok);  color: #fff; }
.alert-err { background: var(--err); color: #fff; }
.alert-warn { background: var(--accent); color: #1c1208; }

@keyframes fadeIn { from { opacity: 0; transform: translateX(-50%) translateY(-6px) } to { opacity: 1; transform: translateX(-50%) translateY(0) } }

/* ── Página de auth (login) ────────────────────────── */
.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
}
.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px 36px;
  width: 100%;
  max-width: 380px;
  box-shadow: var(--shadow);
}
.brand { text-align: center; margin-bottom: 32px; }
.brand-icon { font-size: 42px; margin-bottom: 8px; }
.brand-name { font-size: 22px; font-weight: 700; color: var(--accent); letter-spacing: .5px; }
.brand-sub  { font-size: 13px; color: var(--muted); margin-top: 4px; }

/* ── Campos de formulario ──────────────────────────── */
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 5px; text-transform: uppercase; letter-spacing: .5px; }
.field input, .field select, .field textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  font-size: 15px;
  outline: none;
  transition: border-color .15s;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--accent); }
.field textarea { resize: vertical; min-height: 70px; }
.field select option { background: var(--surface); }

/* ── Botones ───────────────────────────────────────── */
button { cursor: pointer; font-family: inherit; border: none; outline: none; transition: opacity .15s, background .15s; }
button:disabled { opacity: .45; cursor: not-allowed; }

.btn-primary {
  background: var(--accent);
  color: #1c1208;
  font-weight: 700;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: 15px;
}
.btn-primary:hover:not(:disabled) { opacity: .88; }
.btn-full { width: 100%; }

.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 16px;
  border-radius: var(--radius-sm);
}
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }

.btn-ghost-sm {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 5px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
}
.btn-ghost-sm:hover { color: var(--text); border-color: var(--accent); }

.btn-danger {
  background: transparent;
  border: 1px solid var(--err);
  color: var(--err);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
}
.btn-danger:hover { background: var(--err-bg); }

.btn-warn {
  background: transparent;
  border: 1px solid var(--accent);
  color: var(--accent);
  padding: 8px 16px;
  border-radius: var(--radius-sm);
}
.btn-warn:hover { background: var(--warn-bg); }

.btn-ok {
  background: var(--ok);
  color: #fff;
  font-weight: 600;
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
}
.btn-ok:hover:not(:disabled) { opacity: .85; }

.btn-sm {
  padding: 5px 11px;
  font-size: 13px;
  border-radius: var(--radius-sm);
}

/* ── Cards ─────────────────────────────────────────── */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
}
.card-title {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--accent);
  margin-bottom: 14px;
}

/* ── Mensajes ──────────────────────────────────────── */
.err-msg  { color: var(--err);  font-size: 13px; margin-top: 8px; }
.ok-msg   { color: var(--ok);   font-size: 13px; margin-top: 8px; }
.muted    { color: var(--muted); font-size: 13px; }

/* ── Header (empleado) ─────────────────────────────── */
.header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
}
.header-brand { font-size: 15px; font-weight: 700; color: var(--accent); }
.header-user  { display: flex; align-items: center; gap: 12px; font-size: 14px; color: var(--muted); }

/* ── Portal empleado ───────────────────────────────── */
.emp-main { padding: 20px 16px; max-width: 520px; margin: 0 auto; }
.emp-meta { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }

.badge {
  background: var(--warn-bg);
  border: 1px solid var(--accent);
  color: var(--accent);
  border-radius: 20px;
  padding: 3px 12px;
  font-size: 12px;
  font-weight: 600;
}

/* Estado del día */
.estado-card { text-align: center; padding: 28px 20px; }
.estado-icon { font-size: 40px; margin-bottom: 10px; }
.estado-txt  { font-size: 18px; font-weight: 700; margin-bottom: 6px; }
.estado-fecha { color: var(--muted); font-size: 14px; }
.estado-meta  { display: flex; justify-content: center; gap: 16px; margin-top: 10px; font-size: 14px; color: var(--muted); flex-wrap: wrap; }
.estado-trabajando { margin-top: 8px; font-size: 13px; color: var(--accent); }
.estado-horas { margin-top: 8px; font-size: 15px; font-weight: 700; color: var(--ok); }
.badge-facial { font-size: 12px; background: var(--surface); border-radius: 12px; padding: 2px 10px; }

/* Botón marcar (grande) */
.btn-wrap { margin-bottom: 16px; }
.btn-marcar {
  width: 100%;
  padding: 18px;
  border-radius: var(--radius);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: .3px;
  box-shadow: var(--shadow);
}
.btn-entrada { background: var(--ok);    color: #fff; }
.btn-salida  { background: var(--accent); color: #1c1208; }
.btn-marcar:hover { opacity: .88; }

/* Historial */
.hist-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  gap: 8px;
}
.hist-row:last-child { border-bottom: none; }
.tag-tipo {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
  margin-right: 8px;
}
.tag-tipo.entrada { background: var(--ok-bg);   color: var(--ok); }
.tag-tipo.salida  { background: var(--warn-bg);  color: var(--accent); }
.tag-metodo { font-size: 16px; margin-left: 6px; }

/* ── Modal ─────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 16px;
}
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  width: 100%;
  max-width: 440px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow);
}
.modal-title { font-size: 16px; font-weight: 700; color: var(--accent); margin-bottom: 18px; }
.modal-footer { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.modal-footer-between { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 20px; }

/* Cámara */
.cam-wrap {
  position: relative;
  background: #000;
  border-radius: var(--radius-sm);
  overflow: hidden;
  margin-bottom: 12px;
  aspect-ratio: 4/3;
}
.cam-wrap video  { width: 100%; display: block; }
.cam-wrap canvas { position: absolute; top: 0; left: 0; width: 100%; height: 100%; }
.cam-status {
  text-align: center;
  font-size: 13px;
  color: var(--accent);
  min-height: 20px;
  margin-bottom: 4px;
}
.cam-no-feed {
  width: 100%;
  aspect-ratio: 4/3;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #111;
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 12px;
}

/* Foto preview */
.foto-wrap { text-align: center; margin-bottom: 12px; }
.foto-wrap img { width: 120px; height: 120px; border-radius: 50%; object-fit: cover; border: 3px solid var(--accent); }
.foto-placeholder { width: 120px; height: 120px; border-radius: 50%; background: var(--card); border: 2px dashed var(--border); display: inline-flex; align-items: center; justify-content: center; color: var(--muted); font-size: 40px; }

/* ── Admin header ──────────────────────────────────── */
.admin-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.admin-header-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--accent);
  flex: 1;
  text-align: center;
}

/* ── Bottom nav ────────────────────────────────────── */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  z-index: 100;
  height: 60px;
}
.bnav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  background: transparent;
  color: var(--muted);
  font-size: 10px;
  font-weight: 500;
  padding: 6px 2px;
  border-radius: 0;
  transition: color .15s, background .15s;
  min-width: 0;
}
.bnav-item:hover, .bnav-item.active {
  color: var(--accent);
  background: var(--card);
}
.bnav-icon { font-size: 20px; line-height: 1; }

/* ── Main content ──────────────────────────────────── */
.main-content {
  padding: 16px 14px 76px;
  max-width: 100%;
  overflow-x: hidden;
}

/* Secciones */
.section { display: none; }
.section.active { display: block; }
.section-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Stats cards */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}
.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 16px;
  text-align: center;
}
.stat-num   { font-size: 32px; font-weight: 700; color: var(--accent); }
.stat-label { font-size: 12px; color: var(--muted); margin-top: 4px; text-transform: uppercase; letter-spacing: .5px; }

/* Tablas */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th {
  background: var(--surface);
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  padding: 9px 12px;
  text-align: left;
  white-space: nowrap;
}
td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(255,255,255,.025); }

/* Tags de estado */
.tag {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
}
.tag-ok   { background: var(--ok-bg);   color: var(--ok); }
.tag-warn { background: var(--warn-bg); color: var(--accent); }
.tag-err  { background: var(--err-bg);  color: var(--err); }
.tag-muted { background: rgba(255,255,255,.07); color: var(--muted); }

/* Mini foto en tabla */
.mini-foto {
  width: 34px; height: 34px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--border);
  vertical-align: middle;
}
.mini-foto-placeholder {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--card);
  border: 2px dashed var(--border);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 14px;
  vertical-align: middle;
}

/* Filtros */
.filtros {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
  margin-bottom: 20px;
}
.filtros .field { margin-bottom: 0; min-width: 140px; }
.filtros .field input, .filtros .field select { font-size: 14px; padding: 7px 10px; }

/* Topbar de sección */
.section-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.search-input {
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: 14px;
  outline: none;
  width: 220px;
}
.search-input:focus { border-color: var(--accent); }

/* Acciones en tabla */
.actions { display: flex; gap: 6px; align-items: center; }

/* Fecha group header */
.date-group-header {
  background: var(--surface);
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 700;
  color: var(--accent);
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* Validar horas — fila */
.val-row {
  display: grid;
  grid-template-columns: 1fr auto auto auto;
  gap: 10px;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.val-row:last-child { border-bottom: none; }

/* ── Mobile ────────────────────────────────────────── */
@media (max-width: 600px) {
  .auth-card { padding: 28px 18px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat-num { font-size: 26px; }
  .section-title { font-size: 16px; margin-bottom: 12px; }
  .section-topbar { flex-direction: column; align-items: stretch; }
  .search-input { width: 100%; }
  .filtros { flex-direction: column; gap: 8px; }
  .filtros .field { min-width: 0; width: 100%; }
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  table { font-size: 13px; }
  th, td { padding: 8px 6px; }
  .actions { gap: 4px; }
  .btn-sm { padding: 6px 8px; font-size: 12px; }
  .modal-overlay { padding: 0; align-items: flex-end; }
  .modal {
    max-width: 100%;
    width: 100%;
    border-radius: var(--radius) var(--radius) 0 0;
    max-height: 92vh;
    padding: 20px 16px;
  }
  .card { padding: 14px 12px; }
  .btn-primary, .btn-ghost, .btn-warn, .btn-ok { min-height: 44px; }
  .btn-marcar { padding: 20px; font-size: 17px; }
  .emp-main { padding: 14px 12px 76px; }
}
