/* =========================================================
   VARIABLES & RESET
   ========================================================= */
:root{
  /* Paleta base (tema clásico) */
  --bg: #f6f8fb;
  --card: #ffffff;
  --text: #1a2433;
  --muted: #5a6b86;
  --border: #dfe6ef;
  --brand: #2563eb;
  --brand-2: #10b981;
  --danger: #d64141;
  --ok: #0f9d58;

  --field-bg: #ffffff;
  --field-bd: #cbd5e1;
  --field-fx: #2563eb;

  --shadow: 0 8px 22px rgba(16,24,40,.08);

  /* UI generics */
  --radius: 14px;

  /* PDF (vista previa en pantalla ~ A4 a 96dpi) */
  --pdf-width: 794px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body{
  margin: 0;
  color: var(--text);
  font: 16px/1.4 system-ui, -apple-system, Segoe UI, Roboto, Inter, "Helvetica Neue", Arial, "Noto Sans", "Liberation Sans", sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
a { color: inherit; text-decoration: none; }
img { max-width: 100%; height: auto; display: block; }

/* Tema arena (opcional) */
body[data-theme="arena"]{
  --bg: #fbf8f3;
  --card: #ffffff;
  --text: #3a3328;
  --muted: #7d6f58;
  --border: #eadfce;
  --brand: #c36a1f;
  --brand-2: #3f8f7b;
  --danger: #c04a4a;
  --ok: #2e8a57;
  --field-bg: #ffffff;
  --field-bd: #e6dccd;
  --field-fx: #c36a1f;
  --shadow: 0 8px 22px rgba(145,115,78,.12);
}

@media (prefers-reduced-motion: reduce){
  *{ animation: none !important; transition: none !important; }
}

/* =========================================================
   LAYOUT GENERAL
   ========================================================= */
body.bg{
  background: var(--bg);
  min-height: 100svh;
}

/* HEADER */
.bar{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(255,255,255,.85);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap; /* permite romper línea cuando no entra */
}
.brand{
  display: flex;
  gap: 10px;
  align-items: center;
  min-width: 0;
}
.brand h1{
  font-size: 1.35rem;
  line-height: 1.2;
  margin: 0;
}
.logo{ height: 40px; }

/* nav del header */
.nav{
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.wrap{
  width: 100%;
  max-width: 960px;
  margin-inline: auto;
  padding: 16px 14px 24px;
}

.card{
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
}

/* Layout del dashboard (Panel) */
.grid2{
  min-height: calc(100svh - 70px); /* para que no quede pegado arriba */
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
  padding: 16px;
}

/* Tarjetas-botón del dashboard */
.card.action{
  max-width: 260px;
  width: 100%;
  text-align: center;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px 16px;
}



.subtitle{ margin: 0 0 10px; font-size: 1.05rem; color: var(--muted); }

.stack{ display: flex; flex-direction: column; gap: 10px; }
.hidden{ display: none !important; }
.ok{ color: var(--ok); font-weight: 600; }
.error{ color: var(--danger); font-weight: 600; }

/* Grillas responsive (mobile-first) */
.row{
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}
.col{ min-width: 0; }
.grid-2{ display: grid; grid-template-columns: 1fr; gap: 10px; }
.grid-3{ display: grid; grid-template-columns: 1fr; gap: 10px; }

/* =========================================================
   FORM CONTROLS
   ========================================================= */
label{ font-weight: 600; font-size: .95rem; color: var(--text); }

.input, .select, input, select, textarea{
  appearance: none;
  width: 100%;
  background: var(--field-bg);
  color: var(--text);
  border: 2px solid var(--field-bd);
  border-radius: var(--radius);
  padding: 14px 14px;
  font-size: 16px; /* evita zoom en iOS */
  line-height: 1.15;
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
.input:focus, .select:focus,
input:focus, select:focus, textarea:focus{
  border-color: var(--field-fx);
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--field-fx) 25%, transparent);
  background: #fff;
}
::placeholder{ color: color-mix(in oklab, var(--text) 55%, #999); opacity: 1; }

/* Select con flecha */
select, .select{
  background-image:
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23555' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 14px;
  padding-right: 40px;
}

/* Números sin spinners */
input[type=number]::-webkit-outer-spin-button,
input[type=number]::-webkit-inner-spin-button{ -webkit-appearance: none; margin: 0; }
input[type=number]{ -moz-appearance: textfield; }

/* Checkbox & Radio (no heredan estilos gigantes) */
input[type="checkbox"], input[type="radio"]{
  appearance: auto;
  width: 1.15rem; height: 1.15rem;
  margin: 0 8px 0 0;
  accent-color: var(--brand);
  vertical-align: middle;
}

/* Grupo de chips */
.chips{
  display: flex; flex-wrap: wrap; gap: 8px 12px; padding: 8px;
  background: #fff; border: 1px dashed var(--border); border-radius: 12px;
}
.chips label{
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--border); border-radius: 12px;
  padding: 8px 10px; background: #fff; cursor: pointer;
}
.chips input[type="checkbox"]{ margin-right: 4px; }

/* Bloques/secciones */
.section{
  padding: 12px;
  border: 1.5px solid var(--border);
  border-radius: 14px;
  background: #fff;
}

/* Hora 12h */
.time-12{
  display: grid; grid-template-columns: 1fr auto 1fr 100px;
  align-items: center; gap: 8px;
}
.time-12 span{ color: var(--muted); }

/* =========================================================
   BOTONES
   ========================================================= */
.btn{
  display: inline-flex; align-items: center; justify-content: center;
  gap: 8px; padding: 14px 16px; border-radius: 14px;
  border: 1px solid var(--border); color: #fff;
  background: linear-gradient(180deg, color-mix(in oklab, var(--brand) 92%, #ffffff 0%), var(--brand));
  font-weight: 700; cursor: pointer; text-decoration: none;
  transition: transform .04s ease, filter .15s ease, box-shadow .15s ease;
  width: 100%;
  box-shadow: 0 3px 0 color-mix(in oklab, var(--brand) 60%, #000 40%);
  text-align: center;
}
.btn:hover{ filter: brightness(1.05); }
.btn:active{ transform: translateY(1px); box-shadow: 0 2px 0 color-mix(in oklab, var(--brand) 60%, #000 40%); }
.btn.success{
  background: linear-gradient(180deg, color-mix(in oklab, var(--brand-2) 92%, #ffffff 0%), var(--brand-2));
  box-shadow: 0 3px 0 color-mix(in oklab, var(--brand-2) 60%, #000 40%);
}
.btn.danger{
  background: linear-gradient(180deg, #e57373, #d64141);
  box-shadow: 0 3px 0 #a33131;
}
.nav .btn{
  width: auto;
  white-space: nowrap;
}

/* =========================================================
   PDF / CONTRATO (vista previa HTML opcional)
   ========================================================= */
.pdf-a4{ width: var(--pdf-width); background:#fff; color:#000; margin-inline:auto; }
.pdf-inner{ padding: 28px 40px; }
.pdf-logo{ height: 52px; margin-bottom: 10px; }
.pdf-title{ text-align: center; margin: 8px 0 12px; }
.pdf-p{ margin: 8px 0; }
.pdf-ul{ margin: 6px 0 10px 18px; }

.firmas{ display: flex; justify-content: space-between; gap: 18px; margin-top: 36px; }
.firma{ width: 23%; text-align: center; font-size: .9rem; line-height: 1.3; }
.firma img{ height: 60px; object-fit: contain; }
.firma .linea{ height: 2px; background:#000; margin: 40px 0 6px; }

/* Página con fondo A4 para html2pdf */
.contract-page{
  width: 210mm; height: 297mm;
  background-image: url("./img/fondo-contrato.png");
  background-size: cover; background-repeat: no-repeat; background-position: center;
  padding: 40mm 25mm 30mm 25mm;
  box-sizing: border-box; position: relative;
  font-family: 'Times New Roman', serif;
}

/* =========================================================
   RESPONSIVE
   ========================================================= */

/* Mobile primero; ajustes extras para pantallas muy pequeñas */
@media (max-width: 600px){
  .bar{
    flex-direction: column;
    align-items: flex-start;
    padding: 10px 12px;
    gap: 8px;
  }

  .brand{
    width: 100%;
  }
  .brand h1{
    font-size: 1.15rem;
  }

  .nav{
    width: 100%;
    display: flex;
    justify-content: center;
    gap: 8px;
    flex-wrap: wrap;
  }

  /* Botones normales del header */
  .nav .btn{
    flex: 0 0 auto;
    padding: 10px 14px;
    font-size: .9rem;
  }

  /* Cerrar sesión: más pequeño y a la derecha */
  .nav .btn.danger{
    padding: 8px 12px;
    font-size: .85rem;
    box-shadow: 0 2px 0 #a33131;
    align-self: flex-end;
  }

  .wrap{
    padding-inline: 12px;
  }

  .card{
    padding: 14px;
  }

  .btn{
    font-size: .95rem;
    padding: 12px 14px;
  }
}


@media (min-width: 560px){
  .wrap{ padding: 22px; }
  .card{ padding: 18px; }
  .row{ grid-template-columns: repeat(2, 1fr); }
  .grid-2{ grid-template-columns: repeat(2, 1fr); }
  .grid-3{ grid-template-columns: repeat(3, 1fr); }
  .btn{ width: auto; }
}
@media (min-width: 900px){
  .row{ grid-template-columns: repeat(3, 1fr); }
  .time-12{ grid-template-columns: 90px auto 90px 120px; }
}

/* =========================================================
   IMPRESIÓN (si imprimes la UI desde el navegador)
   ========================================================= */
@media print{
  body.bg{ background: #fff; }
  .bar{ display: none !important; }
  .wrap{ max-width: none; padding: 0; }
}

/* Fondo */
.popup-overlay {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(0,0,0,0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999999;
}

/* Oculto */
.hidden { 
  display: none; 
}

/* Caja */
.popup-box {
  background: white;
  padding: 20px 25px;
  width: 85%;
  max-width: 380px;
  border-radius: 10px;
  box-shadow: 0px 0px 15px rgba(0,0,0,0.3);
  text-align: center;
  animation: fadeIn 0.2s ease-out;
  box-sizing: border-box;
}

/* Texto dentro del popup */
.popup-box h3 {
  margin-top: 0;
  margin-bottom: 8px;
  font-size: 1.1rem;
}

.popup-box p {
  margin: 0;
  font-size: 0.95rem;
}

/* Botones */
.popup-buttons {
  margin-top: 15px;
  display: flex;
  justify-content: space-around;
  gap: 10px;
}

.btn-confirm,
.btn-cancel {
  flex: 1;
  min-height: 40px;
  font-size: 0.95rem;
  border-radius: 6px;
  border: none;
  padding: 8px 12px;
  cursor: pointer;
}

/* Colores de botones */
.btn-confirm {
  background: #e63946;
  color: white;
}

.btn-cancel {
  background: #ddd;
  color: black;
}

@keyframes fadeIn {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

/* 🔽 Ajustes especiales para pantallas pequeñas (celular) */
@media (max-width: 480px) {
  .popup-box {
    width: 92%;
    max-width: 340px;
    padding: 16px 18px;
  }

  .popup-box h3 {
    font-size: 1rem;
  }

  .popup-box p {
    font-size: 0.9rem;
  }

  .popup-buttons {
    flex-direction: column;
    align-items: stretch;
  }

  .btn-confirm,
  .btn-cancel {
    width: 100%;
    font-size: 0.95rem;
  }
}

/* Popup de carga: un poco más compacto */
.popup-loading {
  padding: 20px 24px;
}

/* Spinner circular */
.popup-loading .spinner {
  width: 40px;
  height: 40px;
  margin: 0 auto 14px auto;
  border-radius: 50%;
  border: 4px solid rgba(0, 0, 0, 0.08);
  border-top-color: #e63946; /* tu rojo de "danger" */
  animation: spinLoading 0.8s linear infinite;
}

/* Animación de giro */
@keyframes spinLoading {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

/* Opcional: que el popup aparezca con un pequeño fade/zoom */
@keyframes popupZoomIn {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.popup-loading {
  animation: popupZoomIn 0.18s ease-out;
}

/* nieve eliminar despues de naviada*/
#snowCanvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none; /* no bloquea clicks */
  z-index: 9999;
}

/* nieve eliminar despues de naviada*/