/* =========================================================
   ✅ OFFLINE FONT: Baloo Thambi 2
   - Archivos reales detectados en tu carpeta:
     baloo-thambi-2-latin-XXX-normal.woff2/woff
     baloo-thambi-2-latin-ext-XXX-normal.woff2/woff
   - Se incluye latin + latin-ext (400–800)
   - font-display: swap para mejor UX offline
   ========================================================= */

@font-face {
  font-family: "Baloo Thambi 2";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src:
    url("./resources/fonts/baloo-thambi-2/baloo-thambi-2-latin-400-normal.woff2") format("woff2"),
    url("./resources/fonts/baloo-thambi-2/baloo-thambi-2-latin-400-normal.woff") format("woff");
}

@font-face {
  font-family: "Baloo Thambi 2";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src:
    url("./resources/fonts/baloo-thambi-2/baloo-thambi-2-latin-500-normal.woff2") format("woff2"),
    url("./resources/fonts/baloo-thambi-2/baloo-thambi-2-latin-500-normal.woff") format("woff");
}

@font-face {
  font-family: "Baloo Thambi 2";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src:
    url("./resources/fonts/baloo-thambi-2/baloo-thambi-2-latin-600-normal.woff2") format("woff2"),
    url("./resources/fonts/baloo-thambi-2/baloo-thambi-2-latin-600-normal.woff") format("woff");
}

@font-face {
  font-family: "Baloo Thambi 2";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src:
    url("./resources/fonts/baloo-thambi-2/baloo-thambi-2-latin-700-normal.woff2") format("woff2"),
    url("./resources/fonts/baloo-thambi-2/baloo-thambi-2-latin-700-normal.woff") format("woff");
}

@font-face {
  font-family: "Baloo Thambi 2";
  font-style: normal;
  font-weight: 800;
  font-display: swap;
  src:
    url("./resources/fonts/baloo-thambi-2/baloo-thambi-2-latin-800-normal.woff2") format("woff2"),
    url("./resources/fonts/baloo-thambi-2/baloo-thambi-2-latin-800-normal.woff") format("woff");
}

/* Latin-Ext (acentos/extendido) */
@font-face {
  font-family: "Baloo Thambi 2";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src:
    url("./resources/fonts/baloo-thambi-2/baloo-thambi-2-latin-ext-400-normal.woff2") format("woff2"),
    url("./resources/fonts/baloo-thambi-2/baloo-thambi-2-latin-ext-400-normal.woff") format("woff");
}

@font-face {
  font-family: "Baloo Thambi 2";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src:
    url("./resources/fonts/baloo-thambi-2/baloo-thambi-2-latin-ext-500-normal.woff2") format("woff2"),
    url("./resources/fonts/baloo-thambi-2/baloo-thambi-2-latin-ext-500-normal.woff") format("woff");
}

@font-face {
  font-family: "Baloo Thambi 2";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src:
    url("./resources/fonts/baloo-thambi-2/baloo-thambi-2-latin-ext-600-normal.woff2") format("woff2"),
    url("./resources/fonts/baloo-thambi-2/baloo-thambi-2-latin-ext-600-normal.woff") format("woff");
}

@font-face {
  font-family: "Baloo Thambi 2";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src:
    url("./resources/fonts/baloo-thambi-2/baloo-thambi-2-latin-ext-700-normal.woff2") format("woff2"),
    url("./resources/fonts/baloo-thambi-2/baloo-thambi-2-latin-ext-700-normal.woff") format("woff");
}

@font-face {
  font-family: "Baloo Thambi 2";
  font-style: normal;
  font-weight: 800;
  font-display: swap;
  src:
    url("./resources/fonts/baloo-thambi-2/baloo-thambi-2-latin-ext-800-normal.woff2") format("woff2"),
    url("./resources/fonts/baloo-thambi-2/baloo-thambi-2-latin-ext-800-normal.woff") format("woff");
}

/* =========================================================
   ✅ BASE
   ========================================================= */

html,
body {
  height: 100%;
}

body {
  font-family: "Baloo Thambi 2", sans-serif;
  -webkit-tap-highlight-color: transparent;
}

.scrollbar-hide::-webkit-scrollbar {
  display: none;
}

.scrollbar-hide {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

/* Tailwind-compatible hidden utility */
.hidden {
  display: none !important;
}

/* =========================================================
   ✅ STAGE CHIPS (Blazor setea variables, CSS aplica)
   - Nombres largos: ellipsis por CSS (no recortar en backend)
   - Variables esperadas por chip:
       --chip-bg, --chip-text
       --chip-bg-active, --chip-text-active
   - Estado activo: data-active="true"
   ========================================================= */

.stage-chip {
  background: var(--chip-bg, #f3f4f6);
  color: var(--chip-text, #6b7280);
}

.stage-chip[data-active="true"] {
  background: var(--chip-bg-active, #263765);
  color: var(--chip-text-active, #ffffff);
}

.stage-chip__label {
  /* ✅ límite visual (no rompe diseño) */
  max-width: 110px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: inline-block;
}

/* ✅ Sombreado rápido y suave, SIN recortar sombras */
.press-dim {
  position: relative;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.press-dim::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: rgba(0, 0, 0, 0.06);
  opacity: 0;
  pointer-events: none;
  transition: opacity 70ms ease-out;
}

.press-dim:active::after {
  opacity: 1;
}

/* ✅ FAB fade (rápido pero suave) */
.fab-fade-target {
  transition:
    opacity 140ms ease-out,
    transform 140ms ease-out !important;
  will-change: opacity, transform;
}

body.fabs-hidden .fab-fade-target {
  opacity: 0 !important;
  transform: translateY(8px) !important;
  pointer-events: none;
}

/* Swipe visuals */
.swipe-card-container {
  position: relative;
  overflow: hidden;
  touch-action: pan-y;
}

.swipe-edge {
  position: absolute;
  top: 0;
  height: 100%;
  width: 4px;
  pointer-events: none;
  z-index: 0;
  opacity: 0.3;
}

.swipe-edge.left {
  left: 0;
  background-color: #4d82bc;
}

.swipe-edge.right {
  right: 0;
  background-color: #2c611c;
}

.swipe-actions-bg {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}

.swipe-bg-left,
.swipe-bg-right {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  transition: opacity 200ms;
  opacity: 0;
}

.swipe-bg-left {
  left: 0;
  justify-content: flex-start;
  padding-left: 2rem;
  background-color: #4d82bc;
}

.swipe-bg-right {
  right: 0;
  justify-content: flex-end;
  padding-right: 2rem;
  background-color: #2c611c;
}

.swipe-bg-left .swipe-icon-wrap,
.swipe-bg-right .swipe-icon-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  opacity: 0;
  transition: opacity 100ms;
}

.swipe-bg-label {
  font-size: 0.875rem;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.95);
  white-space: nowrap;
}

.swipe-content {
  position: relative;
  z-index: 10;
  will-change: transform;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  background: white;
  touch-action: pan-y;
}

.animate-fade-in {
  animation: fadeIn 160ms ease-out;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

/* =========================================================
   ✅ viewport real + bottom nav + safe-area + FAB vars
   ========================================================= */

:root {
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --bottom-nav-h: 0px;
  --app-h: 100dvh;

  /* ✅ FAB defaults (se recalculan en ui-core.js) */
  --fab-ai-bottom: 96px;
  --fab-plus-bottom: 180px;
}

/* ✅ Alto real visible */
.fullscreen-dvh {
  height: var(--app-h, 100dvh);
  min-height: var(--app-h, 100dvh);
  min-height: -webkit-fill-available;
}

/* Bottom nav fijo + safe-area */
.bottom-nav-fixed {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 60;
  padding-bottom: calc(var(--safe-bottom) + 8px);
}

/* ✅ El contenido no debe quedar tapado por el bottom nav */
.content-with-bottomnav {
  padding-bottom: var(--bottom-nav-h);
}

/* =========================================================
   ✅ Download UI (Bitácora)
   ========================================================= */

@keyframes dlSpin {
  to {
    transform: rotate(360deg);
  }
}

.download-banner {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  z-index: 80;
  width: 100%;
  max-width: 420px;
  padding: 0 16px;
  pointer-events: none;
}

.download-banner-card {
  background: #389537;
  color: #fff;
  border-radius: 18px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.16);
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.banner-pop {
  animation: bannerFade 140ms ease-out;
}

@keyframes bannerFade {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

.banner-spinner {
  width: 16px;
  height: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.banner-spinner::before {
  content: "";
  width: 16px;
  height: 16px;
  border-radius: 999px;
  border: 2px solid rgba(255, 255, 255, 0.45);
  border-top-color: #fff;
  animation: dlSpin 850ms linear infinite;
}

.inline-spinner {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 14px;
  height: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.inline-spinner::before {
  content: "";
  width: 14px;
  height: 14px;
  border-radius: 999px;
  border: 2px solid rgba(38, 55, 101, 0.18);
  border-top-color: #264cb6;
  animation: dlSpin 850ms linear infinite;
}

.is-downloading {
  opacity: 0.92;
}

/* =========================================================
   ✅ SAFE AREAS: PWA Standalone + Capacitor Native
   - Respeta notch, Dynamic Island, barra de gestos
   - Aplica en PWA (display-mode: standalone) y Capacitor
   ========================================================= */

/* ── Siempre aplicar safe area al header (viewport-fit=cover) ── */
header:first-of-type {
  padding-top: env(safe-area-inset-top, 0px);
}

/* ── Bottom nav: siempre respetar home indicator ── */
nav:last-of-type {
  padding-bottom: env(safe-area-inset-bottom, 0px) !important;
}

/* =========================================================
   ✅ SAFE AREAS: PWA Standalone + Capacitor Native
   - Respeta notch, Dynamic Island, barra de gestos
   - Aplica en PWA (display-mode: standalone) y Capacitor
   ========================================================= */

/* ── Variables de Safe Area (Apple/Android) ── */
:root {
  --sa-top: env(safe-area-inset-top, 0px);
  --sa-bottom: env(safe-area-inset-bottom, 0px);
  --sa-left: env(safe-area-inset-left, 0px);
  --sa-right: env(safe-area-inset-right, 0px);
}

/* ── PWA Standalone mode (iPhone "Add to Home Screen") o Capacitor ── */
@media (display-mode: standalone) {
  /* Evitar doble padding, aseguramos que el header superior reciba el espacio del notch */
  header:first-of-type,
  .ui-modal-header

  /* Modales que ocupan pantalla completa */
    {
    padding-top: calc(var(--sa-top) + 0.5rem) !important;
  }

  /* El menú inferior recibe el espacio del home indicator */
  nav:last-of-type,
  .bottom-nav-fixed {
    padding-bottom: calc(var(--sa-bottom) + 0.5rem) !important;
  }

  /* El body solo maneja el safe area horizontal (landscape) */
  body {
    padding-left: var(--sa-left);
    padding-right: var(--sa-right);
  }

  /* Ajuste de los FABs para no chocar con el nav expandido */
  .fab-fade-target {
    margin-bottom: var(--sa-bottom) !important;
  }
}

/* ── Mismas reglas para Capacitor Native ── */
body.capacitor-native header:first-of-type,
body.capacitor-native .ui-modal-header {
  padding-top: calc(var(--sa-top) + 0.5rem) !important;
}

body.capacitor-native nav:last-of-type,
body.capacitor-native .bottom-nav-fixed {
  padding-bottom: calc(var(--sa-bottom) + 0.5rem) !important;
}

body.capacitor-native {
  padding-left: var(--sa-left);
  padding-right: var(--sa-right);
}

body.capacitor-native .fab-fade-target {
  margin-bottom: var(--sa-bottom) !important;
}