/* ==========================================================================
   Arlance · estilos base
   Son exactamente los del prototipo. Todo lo demás va en estilos en línea,
   igual que en el diseño original, para no desviarse ni un píxel.
   ========================================================================== */

html, body { margin: 0; padding: 0; background: #f7f5f3; }

body {
  /*
   * Century Gothic es de Monotype y llega con Office, así que en los equipos de
   * la oficina se ve la de verdad. Fuera de Windows no existe, y ahí entra
   * Mulish: es la geométrica libre que más se le parece y trae los cuatro pesos
   * que usa el portal (400/500/600/700), cosa que no hacen Questrial ni Didact
   * Gothic, que solo tienen la redonda y obligarían al navegador a falsear las
   * negritas.
   */
  font-family: 'Century Gothic', 'Mulish', system-ui, sans-serif;
  color: #221f1d;
  -webkit-font-smoothing: antialiased;
}

* { box-sizing: border-box; }

a { color: #d36061; text-decoration: none; }
a:hover { color: #ca3638; text-decoration: underline; }

input, button, select, textarea { font: inherit; color: inherit; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #dcd7d1; border-radius: 8px; border: 3px solid #f7f5f3; }

/* Añadidos mínimos que el prototipo no necesitaba por ser estático. */

:focus-visible { outline: 2px solid #cb3234; outline-offset: 2px; }

/* Marcador de carga mientras llegan los datos. */
.sk {
  background: linear-gradient(90deg, #f4f2ef 25%, #eeeae5 50%, #f4f2ef 75%);
  background-size: 200% 100%;
  animation: sk 1.2s infinite linear;
  border-radius: 12px;
}
@keyframes sk { to { background-position: -200% 0; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

/* Avisos: abajo en el centro y por encima de todo, se esté donde se esté de la página. */
.toast-host {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: 24px;
  z-index: 80;
  display: flex;
  justify-content: center;
  pointer-events: none;
}

/*
 * Barra superior: el menú no se encoge, así que cuando falta sitio se va
 * quitando lo prescindible, por este orden. Con todos los menús del
 * administrador, el menú ocupa unos 1000 px.
 */
@media (max-width: 1640px) {
  [data-topbar] [data-topbar-date] { display: none; }
}
@media (max-width: 1400px) {
  [data-topbar] [data-account-name] { display: none; }
}
@media (max-width: 1300px) {
  [data-topbar] [data-nav-icon],
  [data-topbar] [data-search-shortcut] { display: none; }
}

/* ==========================================================================
   Móvil
   app.js marca <html data-device="mobile"> por debajo de 860 px de ancho y
   pinta otro marco: barra superior, menú deslizante y barra inferior. Aquí se
   adaptan las pantallas. Como llevan los estilos en línea (igual que el
   prototipo), las reglas usan !important y buscan los patrones de rejilla que
   usan las propias pantallas.
   ========================================================================== */

/* Contenido: menos margen a los lados y hueco para la barra inferior. */
html[data-device="mobile"] [data-content] {
  /* El hueco para la barra inferior lo deja el pie legal, que va justo después. */
  padding: 16px 14px 24px !important;
}

html[data-device="mobile"] [data-tabs] {
  gap: 18px !important;
  padding: 12px 14px 0 !important;
  margin-top: 0 !important;
  background: #fff;
  scrollbar-width: none;
}

html[data-device="mobile"] .toast-host {
  bottom: calc(84px + env(safe-area-inset-bottom));
}

/* Pantallas de dos columnas (Inicio, Ausencias, Perfil, Espacios, acceso): una debajo de otra. */
html[data-device="mobile"] [style*="grid-template-columns:minmax(0,1fr) 330px"],
html[data-device="mobile"] [style*="grid-template-columns:minmax(0,1fr) 300px"],
html[data-device="mobile"] [style*="grid-template-columns:340px minmax(0,1fr)"],
html[data-device="mobile"] [style*="grid-template-columns:300px minmax(0,1fr)"],
html[data-device="mobile"] [style*="grid-template-columns:minmax(0,1fr) minmax(0,1fr)"] {
  grid-template-columns: minmax(0, 1fr) !important;
}

/*
 * Tablas (Organización, Tickets, Control horario, Horario, Roles, Firmas...):
 * todas empiezan por una primera columna minmax(2xxpx, ...). Mantienen su
 * ancho y la tabla se desliza de lado dentro de su tarjeta.
 */
html[data-device="mobile"] [data-content] [style*="grid-template-columns:minmax(2"] {
  min-width: 760px;
}
html[data-device="mobile"] [data-content] [style*="grid-template-columns:200px repeat(7"] {
  min-width: 1040px;
}
html[data-device="mobile"] [data-content] div:has(> [style*="grid-template-columns:minmax(2"]),
html[data-device="mobile"] [data-content] div:has(> [style*="grid-template-columns:200px repeat(7"]) {
  overflow-x: auto !important;
  -webkit-overflow-scrolling: touch;
}

/* Buscadores y filtros con ancho mínimo de escritorio: que encojan. */
html[data-device="mobile"] [data-content] [style*="min-width:220px"],
html[data-device="mobile"] [data-content] [style*="min-width:260px"] {
  min-width: 0 !important;
}

/* Ventanas: casi todo el ancho, y las filas de campos bajan de línea si no caben. */
html[data-device="mobile"] #modal-host > [style*="rgba(28,24,20,.42)"] {
  padding: 12px !important;
}
html[data-device="mobile"] #modal-host [role="dialog"] {
  max-width: 100% !important;
}
html[data-device="mobile"] #modal-host [role="dialog"] [style*="display:flex;gap:12px"] {
  flex-wrap: wrap;
}

/* Calendario: siete columnas en unos 340 px, así que todo más compacto. */
html[data-device="mobile"] [data-week] [data-day] {
  padding: 6px 3px !important;
}
html[data-device="mobile"] [data-week] [data-day] > div:first-child {
  overflow: hidden;
}
html[data-device="mobile"] [data-week] [data-day] > div:first-child > span:first-child {
  font-size: 12px !important;
}
html[data-device="mobile"] [data-week] [data-absence-bar],
html[data-device="mobile"] [data-week] [data-event-chip],
html[data-device="mobile"] [data-week] [data-birthday-chip] {
  font-size: 10.5px !important;
  padding-left: 3px !important;
  padding-right: 3px !important;
}

/* ==========================================================================
   Móvil · segunda pasada
   Login, cifras, listados como tarjetas, tablas con la primera columna fija,
   zonas táctiles y ventanas como hoja inferior.
   ========================================================================== */

html[data-device="mobile"] { -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; }
html[data-device="mobile"] body { overflow-x: hidden; }
html[data-device="mobile"] select, html[data-device="mobile"] input { max-width: 100%; }

/* Campos: 16 px evita que iOS haga zoom al enfocar; altura cómoda para el dedo. */
html[data-device="mobile"] input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]),
html[data-device="mobile"] select {
  font-size: 16px !important;
  min-height: 44px;
}
html[data-device="mobile"] textarea { font-size: 16px !important; }

/* Botones con forma (primarios, secundarios, iconos con borde): zona táctil de 40 px. */
html[data-device="mobile"] [data-content] button[style*="background:#cb3234"],
html[data-device="mobile"] [data-content] button[style*="border:1px solid"],
html[data-device="mobile"] #modal-host button[style*="background:#cb3234"],
html[data-device="mobile"] #modal-host button[style*="border:1px solid"] {
  min-height: 40px;
}

/* ---- Login ---------------------------------------------------------------- */
html[data-device="mobile"] [data-login] {
  display: flex !important;
  flex-direction: column;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-top: env(safe-area-inset-top);
}
html[data-device="mobile"] [data-login] [data-login-art] {
  flex: 0 0 auto;
  padding: 12px 12px 0 !important;
}
html[data-device="mobile"] [data-login] [data-login-art] > div {
  min-height: 132px;
  padding: 16px !important;
  border-radius: 18px !important;
  background-position: center 40% !important;
}
html[data-device="mobile"] [data-login] [data-login-art] span { font-size: 13.5px !important; }
html[data-device="mobile"] [data-login] [data-login-form] {
  flex: 1 0 auto;
  max-width: none !important;
  padding: 26px 22px calc(22px + env(safe-area-inset-bottom)) !important;
  justify-content: flex-start !important;
}
html[data-device="mobile"] [data-login] [data-login-logo] {
  width: 52px !important;
  height: 52px !important;
  margin-bottom: 20px !important;
}
html[data-device="mobile"] [data-login] h1 { font-size: 25px !important; }
html[data-device="mobile"] [data-login] label {
  margin-top: 20px !important;
  padding: 0 14px !important;
  min-height: 54px;
  border-radius: 12px !important;
}
html[data-device="mobile"] [data-login] label input { min-height: 52px; }
html[data-device="mobile"] [data-login] button[style*="background:#cb3234"] {
  min-height: 52px;
  font-size: 16px !important;
  border-radius: 12px !important;
}
html[data-device="mobile"] [data-login] button:disabled { opacity: .7; }

/* ---- Cifras: dos por fila ---------------------------------------------------- */
html[data-device="mobile"] [data-stats] {
  display: grid !important;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px !important;
}
html[data-device="mobile"] [data-stats] > div {
  flex: none !important;
  min-width: 0;
  padding: 14px 16px !important;
}
html[data-device="mobile"] [data-stats] > div > div:last-child,
html[data-device="mobile"] [data-stats] > div > div:nth-child(2) { font-size: 22px !important; overflow-wrap: anywhere; }
html[data-device="mobile"] [data-stats] > div:nth-child(odd):last-child { grid-column: 1 / -1; }

/* ---- Listado de proyectos: una tarjeta por proyecto ---------------------------- */
html[data-device="mobile"] [data-tizon-projects] > div:first-child { display: none !important; }
html[data-device="mobile"] [data-tizon-projects] [data-tizon-project] {
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas: "code status" "name name" "client budget" "country country";
  gap: 4px 12px;
  min-width: 0 !important;
  padding: 14px 16px;
  border-top: 1px solid #f1eeea;
}
html[data-device="mobile"] [data-tizon-projects] [data-tizon-project] > div {
  padding: 0 !important;
  border: 0 !important;
  white-space: normal !important;
  overflow: visible !important;
  text-overflow: clip !important;
  min-width: 0;
}
html[data-device="mobile"] [data-tizon-projects] [data-tizon-project] > div:nth-child(1) { display: none; }
html[data-device="mobile"] [data-tizon-projects] [data-tizon-project] > div:nth-child(2) { grid-area: code; font-size: 13.5px; }
html[data-device="mobile"] [data-tizon-projects] [data-tizon-project] > div:nth-child(5) { grid-area: status; justify-self: end; }
html[data-device="mobile"] [data-tizon-projects] [data-tizon-project] > div:nth-child(4) { grid-area: name; font-size: 15px; font-weight: 500; margin: 2px 0; }
html[data-device="mobile"] [data-tizon-projects] [data-tizon-project] > div:nth-child(3) { grid-area: client; font-size: 13.5px; color: #6f6862; }
html[data-device="mobile"] [data-tizon-projects] [data-tizon-project] > div:nth-child(7) { grid-area: budget; font-size: 14px; font-weight: 500; }
html[data-device="mobile"] [data-tizon-projects] [data-tizon-project] > div:nth-child(6) { grid-area: country; font-size: 12.5px; color: #8b847c; }

/* ---- Tablas que se deslizan: la primera columna se queda fija ------------------- */
html[data-device="mobile"] [data-content] [style*="grid-template-columns:minmax(2"] > :first-child,
html[data-device="mobile"] [data-tizon-clients] [style*="grid-template-columns:64px"] > :first-child {
  position: sticky;
  left: 0;
  z-index: 2;
  background: #fff;
  box-shadow: 1px 0 0 #f1eeea;
}
html[data-device="mobile"] [data-content] [style*="background:#faf8f6"] > :first-child,
html[data-device="mobile"] [data-content] [style*="background:#fbfaf9"] > :first-child { background: #faf8f6; }

/* ---- Roles y permisos: columnas de rol estrechas, el permiso fijo --------------- */
html[data-device="mobile"] [data-roles-matrix] [style*="grid-template-columns:minmax(260px,1fr)"] {
  grid-template-columns: 172px !important;
  grid-auto-flow: column;
  grid-auto-columns: 96px;
  min-width: 0 !important;
}
html[data-device="mobile"] [data-roles-matrix] [data-toggle] { width: 28px !important; height: 28px !important; border-radius: 8px !important; }

/* ---- Ventanas: hoja que sube desde abajo --------------------------------------- */
html[data-device="mobile"] #modal-host > div {
  align-items: flex-end !important;
  padding: 0 !important;
}
html[data-device="mobile"] #modal-host [role="dialog"] {
  margin: 0 !important;
  width: 100% !important;
  max-width: 100% !important;
  max-height: 92dvh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: 20px 20px 0 0 !important;
  padding-bottom: calc(24px + env(safe-area-inset-bottom)) !important;
}
html[data-device="mobile"] #modal-host [role="dialog"]::before {
  content: "";
  display: block;
  width: 40px;
  height: 4px;
  border-radius: 4px;
  background: #d8d2cb;
  margin: -8px auto 14px;
}

/* El código de acceso, bien legible y fácil de pulsar. */
html[data-device="mobile"] [data-login] [data-code] {
  font-size: 20px !important;
  letter-spacing: .14em !important;
  text-align: left;
}

/* Barra de acciones de una pantalla: los botones en dos columnas y el principal a todo el ancho. */
html[data-device="mobile"] [data-actions] {
  display: grid !important;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px !important;
}
html[data-device="mobile"] [data-actions] > :not(a):not(button) { grid-column: 1 / -1; min-width: 0 !important; }
html[data-device="mobile"] [data-actions] > a,
html[data-device="mobile"] [data-actions] > button {
  justify-content: center;
  min-height: 44px;
  text-align: center;
  font-size: 13.5px !important;
}
html[data-device="mobile"] [data-actions] > button:last-child { grid-column: 1 / -1; }

/* Botones de acción (Excel, etc.): una sola línea. */
html[data-device="mobile"] [data-actions] > a { white-space: nowrap; padding: 0 8px !important; gap: 6px !important; }

/* Asistentes por pasos (Nuevo proyecto, envíos en masa...). */
html[data-device="mobile"] #modal-host [role="dialog"]:has([data-mass-wizard])::before { display: none; }
html[data-device="mobile"] [data-mass-wizard] { min-height: 0 !important; }
html[data-device="mobile"] [data-mass-wizard] [style*="flex:0 0 330px"] {
  flex: 1 1 100% !important;
  padding: 26px 20px 0 !important;
}
html[data-device="mobile"] [data-mass-wizard] [style*="flex:0 0 330px"] [style*="font-size:28px"] { font-size: 23px !important; }
html[data-device="mobile"] [data-mass-wizard] [style*="margin-top:34px"] {
  flex-direction: row !important;
  margin-top: 14px !important;
  gap: 6px !important;
  overflow-x: auto;
}
html[data-device="mobile"] [data-mass-wizard] [style*="margin-top:34px"] > div { padding: 6px 10px 6px 6px !important; flex: 0 0 auto; }
html[data-device="mobile"] [data-mass-wizard] [style*="margin-top:34px"] span { font-size: 14px !important; white-space: nowrap; }
html[data-device="mobile"] [data-mass-wizard] [style*="padding:70px 40px 30px"] { padding: 18px 20px 24px !important; }
html[data-device="mobile"] [data-mass-wizard] [style*="padding:20px 32px;background:#f4f2ef"] {
  position: sticky;
  bottom: 0;
  z-index: 3;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom)) !important;
  border-radius: 0 !important;
  gap: 10px !important;
}
html[data-device="mobile"] [data-mass-wizard] [style*="padding:20px 32px;background:#f4f2ef"] button { flex: 1 1 auto; min-height: 46px; }
html[data-device="mobile"] #modal-host [role="dialog"]:has([data-mass-wizard]) { padding-bottom: 0 !important; }
html[data-device="mobile"] [data-mass-wizard] [style*="margin-top:34px"] { scrollbar-width: none; }
html[data-device="mobile"] [data-mass-wizard] [style*="margin-top:34px"]::-webkit-scrollbar { display: none; }

/* Buscadores: a todo el ancho, con los filtros debajo. */
html[data-device="mobile"] [data-content] label[style*="min-width:260px"],
html[data-device="mobile"] [data-content] label[style*="min-width:220px"] {
  flex: 1 1 100% !important;
  width: 100%;
}

/* ---------- Animación de carga de Arlance ---------- */
/* Las torres rojas se dibujan, cruza el puente gris, un pulso de energía recorre
   la línea y corre la barra. #arlance-loader es la pantalla completa del arranque
   (index.html y js/loader.js); .arlance-loader.is-compact, la de dentro de la app. */
.arlance-loader { --rojo:#C8202F; --rojo-osc:#8E1520; --rojo-luz:#FF6A6F; --gris:#A6A6AA; display:flex; align-items:center; justify-content:center; }
#arlance-loader { position:fixed; inset:0; z-index:9999; background:#fff; transition:opacity .2s ease, visibility .2s ease; }
#arlance-loader.is-hidden { opacity:0; visibility:hidden; pointer-events:none; }
.arlance-loader svg { width:min(60vw,340px); height:auto; overflow:visible; }
.arlance-loader.is-compact svg { width:130px; }
.arlance-loader .sr-only { position:absolute; width:1px; height:1px; overflow:hidden; clip:rect(0 0 0 0); white-space:nowrap; }

/* Trazo rojo: torres de la catedral + línea de energía */
.al-line { fill:none; stroke-width:15; stroke-linecap:round; stroke-linejoin:round; stroke-dasharray:1; stroke-dashoffset:1; }
.al-line-1 { animation:al-draw 1.5s cubic-bezier(.65,0,.35,1) .1s forwards; }
.al-line-2 { animation:al-draw .8s cubic-bezier(.65,0,.35,1) 1.35s forwards; }
.al-knob { fill:#B81C2A; transform-box:fill-box; transform-origin:center; transform:scale(0); animation:al-pop .45s cubic-bezier(.34,1.56,.64,1) forwards; }
.al-knob-1 { animation-delay:.75s; } .al-knob-2 { animation-delay:1.1s; }

/* Puente gris */
.al-bridge-mask { transform-box:fill-box; transform-origin:left center; transform:scaleX(0); animation:al-wipe 1s cubic-bezier(.65,0,.35,1) .85s forwards; }
.al-bridge { fill:var(--gris); }

/* Pulso de energía que recorre la línea en bucle */
.al-pulse { fill:none; stroke:var(--rojo-luz); stroke-width:17; stroke-linecap:round; stroke-dasharray:.05 .95; stroke-dashoffset:1; opacity:0; animation:al-pulse 2.4s linear 2.1s infinite; }

/* Barra de progreso fina */
.al-bar { fill:#EDEDEE; }
.al-bar-fill { fill:var(--rojo); transform-box:fill-box; transform-origin:left center; transform:scaleX(0); animation:al-load 2.8s cubic-bezier(.4,0,.2,1) 1.9s infinite; }

@keyframes al-draw { to { stroke-dashoffset:0; } }
@keyframes al-pop { to { transform:scale(1); } }
@keyframes al-wipe { to { transform:scaleX(1); } }
@keyframes al-pulse { 0% { stroke-dashoffset:1.05; opacity:1; } 95% { opacity:1; } 100% { stroke-dashoffset:0; opacity:0; } }
@keyframes al-load { 0% { transform:scaleX(0); opacity:1; } 70% { transform:scaleX(1); opacity:1; } 100% { transform:scaleX(1); opacity:0; } }

.loading-box { display:grid; place-items:center; min-height:300px; }
@media (prefers-reduced-motion: reduce) {
  .arlance-loader * { animation:none !important; stroke-dashoffset:0 !important; transform:none !important; opacity:1 !important; }
  .arlance-loader .al-pulse { display:none; }
}
/* ---------- Fin de la animación de carga ---------- */
