/* Registro de Jornada — Cyberxia
   Tema oscuro, minimalista y con movimiento sutil. El verde es el acento.
   Todo el CSS vive aquí (CSP estricta: sin estilos en línea). */

:root {
  --bg: #050606;
  --bg-soft: #0a0c0d;
  --surface: #0c0f10;
  --surface-2: #13171a;
  --surface-3: #171d20;
  --border: #1d2326;
  --border-strong: #2a3236;
  --text: #e9ebec;
  --muted: #868d91;
  --accent: #3fb24a;
  --accent-strong: #57c863;
  --accent-dim: rgba(63, 178, 74, 0.14);
  --accent-glow: rgba(63, 178, 74, 0.38);
  --danger: #e5484d;
  --danger-strong: #f15b60;
  --warn: #f0b429;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 12px 34px rgba(0, 0, 0, 0.55);
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
  --font: "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }

/* Transiciones de página (cross-document, navegadores Chromium recientes). */
@view-transition { navigation: auto; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  overflow-x: hidden;
}

/* Glow de fondo, fijo y a la deriva muy lentamente. */
body::before {
  content: "";
  position: fixed;
  inset: -25%;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(46% 38% at 50% -2%, rgba(63, 178, 74, 0.10), transparent 72%),
    radial-gradient(38% 30% at 88% 8%, rgba(63, 178, 74, 0.05), transparent 70%),
    radial-gradient(50% 50% at 50% 120%, rgba(63, 178, 74, 0.04), transparent 70%);
  animation: drift 22s ease-in-out infinite alternate;
}

/* ---------------- Keyframes ---------------- */
@keyframes drift {
  0%   { transform: translate3d(0, 0, 0) scale(1); opacity: 0.9; }
  100% { transform: translate3d(0, 1.5%, 0) scale(1.06); opacity: 1; }
}
@keyframes reveal {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes slideIn {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes pulseDot {
  0%, 100% { box-shadow: 0 0 0 0 var(--accent-dim); }
  50%      { box-shadow: 0 0 0 7px rgba(63, 178, 74, 0); }
}
@keyframes ripple {
  to { transform: translate(-50%, -50%) scale(1); opacity: 0; }
}
@keyframes vtOut { to   { opacity: 0; transform: translateY(-8px); } }
@keyframes vtIn  { from { opacity: 0; transform: translateY(10px); } }

::view-transition-old(root) { animation: vtOut 0.22s var(--ease) both; }
::view-transition-new(root) { animation: vtIn 0.30s var(--ease) both; }

/* ---------------- Topbar ---------------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  background: rgba(5, 6, 6, 0.72);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 10;
  view-transition-name: topbar;
}
.brand {
  font-weight: 800;
  letter-spacing: 1px;
  font-size: 20px;
  text-decoration: none;
}
.brand-cyber { color: var(--text); }
.brand-xia { color: var(--accent); text-shadow: 0 0 16px var(--accent-glow); }

.nav { display: flex; align-items: center; gap: 14px; }
.nav-link {
  position: relative;
  color: var(--muted);
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  transition: color 0.2s var(--ease);
}
.nav-link:hover { color: var(--text); }
.nav-link::after {
  content: "";
  position: absolute;
  left: 10px; right: 10px; bottom: 1px;
  height: 2px;
  border-radius: 2px;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.28s var(--ease);
}
.nav-link:hover::after { transform: scaleX(1); }
.who { color: var(--muted); font-size: 14px; }
.inline { display: inline; margin: 0; }

/* ---------------- Layout ---------------- */
.container {
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: 32px 20px;
  flex: 1;
}
.footer {
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  padding: 20px;
  border-top: 1px solid var(--border);
}

/* ---------------- Cards (entrada escalonada) ---------------- */
.card {
  position: relative;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.015), transparent 40%), var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  margin-bottom: 22px;
  box-shadow: var(--shadow);
  animation: reveal 0.55s var(--ease) both;
}
.card:nth-of-type(2) { animation-delay: 0.07s; }
.card:nth-of-type(3) { animation-delay: 0.14s; }
.card:nth-of-type(4) { animation-delay: 0.21s; }

.auth-card { max-width: 420px; margin: 8vh auto 0; text-align: center; }

.title { font-size: 24px; font-weight: 700; margin: 0 0 6px; }
.subtitle { color: var(--muted); margin: 0 0 22px; }
.section-title { font-size: 13px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin: 0 0 16px; font-weight: 700; }
.hint { color: var(--muted); font-size: 13px; margin-top: 18px; }
.muted { color: var(--muted); }

/* ---------------- Dashboard ---------------- */
.dash { text-align: center; }
.greeting { font-size: 17px; margin: 0 0 14px; color: var(--muted); }
.greeting strong { color: var(--text); }

.clock {
  font-size: 58px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: 2px;
  line-height: 1.1;
  text-shadow: 0 0 30px rgba(63, 178, 74, 0.14);
}
.clock-date { color: var(--muted); margin-top: 4px; text-transform: capitalize; }

.status {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin: 22px 0;
  padding: 9px 16px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 14px;
  border: 1px solid var(--border);
  background: var(--surface-2);
}
.status .dot { width: 9px; height: 9px; border-radius: 50%; }
.status-on { color: var(--accent-strong); border-color: rgba(63, 178, 74, 0.3); }
.status-on .dot { background: var(--accent); animation: pulseDot 2.2s ease-in-out infinite; }
.status-off { color: var(--muted); }
.status-off .dot { background: var(--muted); }

.actions { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; margin-top: 8px; }
.actions form { margin: 0; }

/* ---------------- Buttons ---------------- */
.btn {
  position: relative;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 11px 18px;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.16s var(--ease), box-shadow 0.28s var(--ease),
              background 0.2s var(--ease), border-color 0.2s var(--ease);
}
/* Barrido de brillo al pasar el cursor. */
.btn::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(120deg, transparent 28%, rgba(255, 255, 255, 0.10) 50%, transparent 72%);
  transform: translateX(-130%);
  transition: transform 0.6s var(--ease);
  pointer-events: none;
}
.btn:hover { transform: translateY(-2px); background: var(--surface-3); }
.btn:hover::before { transform: translateX(130%); }
.btn:active { transform: translateY(0) scale(0.975); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.btn[disabled] {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
}
.btn[disabled]::before { display: none; }

.btn-sm { padding: 7px 12px; font-size: 13px; }
.btn-lg { padding: 14px 26px; font-size: 16px; min-width: 184px; }
.btn-block { width: 100%; }

.btn-primary { background: var(--accent); border-color: var(--accent); color: #06210b; }
.btn-primary:hover { background: var(--accent-strong); box-shadow: 0 8px 26px -6px var(--accent-glow); }

.btn-danger { background: transparent; border-color: var(--danger); color: var(--danger-strong); }
.btn-danger:hover { background: rgba(229, 72, 77, 0.12); box-shadow: 0 8px 26px -8px rgba(229, 72, 77, 0.45); }

.btn-ghost { background: transparent; border-color: var(--border-strong); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-active { border-color: var(--accent); color: var(--accent-strong); }

/* Ripple (creado por ui.js vía CSSOM, permitido por la CSP). */
.ripple {
  position: absolute;
  left: var(--rx);
  top: var(--ry);
  width: var(--rsize);
  height: var(--rsize);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.18);
  transform: translate(-50%, -50%) scale(0);
  pointer-events: none;
  animation: ripple 0.6s var(--ease);
}
.btn-primary .ripple { background: rgba(0, 0, 0, 0.18); }

.ms-mark {
  width: 16px; height: 16px;
  background:
    linear-gradient(#06210b, #06210b) 0 0 / 7px 7px no-repeat,
    linear-gradient(#06210b, #06210b) 9px 0 / 7px 7px no-repeat,
    linear-gradient(#06210b, #06210b) 0 9px / 7px 7px no-repeat,
    linear-gradient(#06210b, #06210b) 9px 9px / 7px 7px no-repeat;
}

/* ---------------- Tables ---------------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th {
  text-align: left;
  color: var(--muted);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}
.table td { padding: 11px 12px; border-bottom: 1px solid var(--border); }
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr { transition: background 0.15s var(--ease); }
.table tbody tr:hover { background: var(--surface-2); }
.row-open td:first-child { box-shadow: inset 3px 0 0 var(--accent); }
.row-important td:first-child { box-shadow: inset 3px 0 0 var(--warn); }
.empty { text-align: center; color: var(--muted); padding: 22px; }

/* ---------------- Admin ---------------- */
.admin-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}
.admin-head .title { margin-bottom: 2px; }
.admin-head form { margin: 0; }

.filters { display: flex; gap: 14px; flex-wrap: wrap; align-items: flex-end; margin: 0; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.field-actions { flex-direction: row; gap: 8px; }
.filters select,
.filters input[type="date"] {
  font-family: inherit;
  font-size: 14px;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 9px 11px;
  min-width: 150px;
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}
.filters select:focus,
.filters input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

/* ---------------- Badges / logs ---------------- */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid var(--border);
  white-space: nowrap;
}
.badge-info { color: var(--muted); background: var(--surface-2); }
.badge-warning { color: var(--warn); background: rgba(240, 180, 41, 0.12); border-color: rgba(240, 180, 41, 0.4); }
.badge-critical { color: var(--danger-strong); background: rgba(229, 72, 77, 0.12); border-color: rgba(229, 72, 77, 0.4); }

/* ---------------- Flashes ---------------- */
.flashes { margin-bottom: 18px; display: flex; flex-direction: column; gap: 10px; }
.flash {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  border: 1px solid var(--border);
  animation: slideIn 0.4s var(--ease) both;
}
.flash-success { background: var(--accent-dim); border-color: rgba(63, 178, 74, 0.4); color: var(--accent-strong); }
.flash-error { background: rgba(229, 72, 77, 0.12); border-color: rgba(229, 72, 77, 0.4); color: var(--danger-strong); }

/* ---------------- Error page ---------------- */
.error-code {
  font-size: 64px;
  font-weight: 800;
  color: var(--accent);
  line-height: 1;
  margin-bottom: 8px;
  text-shadow: 0 0 30px var(--accent-glow);
}

/* ---------------- Responsive ---------------- */
@media (max-width: 560px) {
  .clock { font-size: 46px; }
  .actions { flex-direction: column; }
  .actions .btn-lg { width: 100%; }
  .auth-card { margin-top: 4vh; }
  .filters { flex-direction: column; align-items: stretch; }
  .filters select, .filters input[type="date"] { min-width: 0; width: 100%; }
}

/* ---------------- Accesibilidad: sin movimiento ---------------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
  body::before { animation: none; }
  ::view-transition-group(*),
  ::view-transition-old(*),
  ::view-transition-new(*) { animation: none !important; }
}
