@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@800&display=swap');

:root {
  --app-loader-backdrop: rgba(15, 23, 42, 0.55);
}

body.app-loader-visible {
  overflow: hidden;
}

.app-loader {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  pointer-events: none;
  z-index: 999999;
}

.app-loader__backdrop {
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity 200ms ease;
  background: transparent;
}

.app-loader--blocking .app-loader__backdrop {
  opacity: 1;
  background: var(--app-loader-backdrop);
  backdrop-filter: blur(8px) saturate(125%);
}

.app-loader__inner {
  position: relative;
  display: grid;
  place-content: center;
  pointer-events: auto;
}

.loader {
  display: flex;
  font-family: 'Montserrat', sans-serif;
  font-weight: 800;
  font-size: 5rem;
  text-transform: uppercase;
  color: #333;
  gap: 0.2em;
}

.letter {
  color: transparent;
  -webkit-text-fill-color: transparent;
  -webkit-text-stroke: 2px #444;
  /* text-stroke: 2px #444;  Grosor y color del borde de la letra */
  background-repeat: no-repeat;
  background-size: 100% 0;
  background-position: 0 100%;
  -webkit-background-clip: text;
  background-clip: text;
  animation: fill-effect 3s infinite;
}

.letter:nth-child(1),
.letter:nth-child(2),
.letter:nth-child(3) {
  background-image: linear-gradient(#ffcd00, #ffcd00);
  animation-delay: 0.2s;
}

.letter:nth-child(2) {
  animation-delay: 0.4s;
}

.letter:nth-child(3) {
  animation-delay: 0.6s;
}

.letter:nth-child(4) {
  background-image: linear-gradient(#003893, #003893);
  animation-delay: 0.8s;
}

.letter:nth-child(5) {
  background-image: linear-gradient(#ce1126, #ce1126);
  animation-delay: 1s;
}

@keyframes fill-effect {
  0%,
  100% {
    background-size: 100% 0%;
    -webkit-text-stroke: 2px #444;
    /* text-stroke: 2px #444; */
  }

  40%,
  80% {
    background-size: 100% 100%;
    -webkit-text-stroke: 2px transparent;
    /* text-stroke: 2px transparent; */
  }
}

.app-loader--toast {
  justify-content: flex-end;
  align-items: flex-start;
  padding: 1.5rem;
}

.app-loader--toast .app-loader__backdrop {
  display: none;
}

.app-loader--inline {
  position: absolute;
  inset: auto;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  padding: 0;
}

.app-loader--inline .app-loader__backdrop {
  display: none;
}

.app-loader--inline .loader {
  font-size: 3rem;
}

@media (max-width: 640px) {
  .app-loader {
    padding: 1.5rem;
  }

  .loader {
    font-size: 3.5rem;
    gap: 0.15em;
  }
}

@media (prefers-reduced-motion: reduce) {
  .letter {
    animation-duration: 6s;
  }
}

/* ============================================================
   SKELETON LOADER — placeholders de contenido durante la carga
   ============================================================ */

@keyframes sk-shimmer {
  0%   { background-position: -600px 0; }
  100% { background-position:  600px 0; }
}

.sk-box {
  border-radius: 8px;
  background: linear-gradient(
    90deg,
    #e2e8f0 25%,
    #f1f5f9 50%,
    #e2e8f0 75%
  );
  background-size: 1200px 100%;
  animation: sk-shimmer 1.6s ease-in-out infinite;
}

@media (prefers-reduced-motion: reduce) {
  .sk-box { animation: none; background: #e2e8f0; }
}

/* ---- Skeleton del dashboard ---- */
.dashboard-skeleton {
  position: absolute;
  inset: 0;
  padding: 24px;
  pointer-events: none;
  overflow: hidden;
  z-index: 5;
  opacity: 0;
  visibility: hidden;
  transition: opacity 200ms ease, visibility 200ms ease;
}

body.app-loader-visible .dashboard-skeleton {
  opacity: 1;
  visibility: visible;
}

.dashboard-skeleton__inner {
  display: grid;
  grid-template-columns: 1fr;
  grid-template-areas:
    "filters"
    "map"
    "content"
    "table";
  gap: 20px;
  height: 100%;
}

@media (min-width: 1200px) {
  .dashboard-skeleton__inner {
    grid-template-columns: minmax(350px, 400px) 1fr;
    grid-template-areas:
      "filters filters"
      "map     content"
      "table   table";
  }
}

/* Filtros */
.dashboard-skeleton__filters {
  grid-area: filters;
  display: flex;
  gap: 14px;
  align-items: center;
  background: #fff;
  border-radius: 12px;
  padding: 16px 20px;
  box-shadow: 0 4px 6px -1px rgba(0,0,0,.08);
}

.sk-box--filter {
  flex: 1;
  height: 44px;
  border-radius: 10px;
}

.sk-box--btn {
  width: 120px;
  height: 44px;
  border-radius: 10px;
  flex-shrink: 0;
}

/* Mapa */
.dashboard-skeleton__map {
  grid-area: map;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: #fff;
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 4px 6px -1px rgba(0,0,0,.08);
}

.sk-box--map-header {
  height: 24px;
  width: 60%;
  border-radius: 6px;
}

.sk-box--map-body {
  flex: 1;
  min-height: 280px;
  border-radius: 10px;
}

/* Contenido (métricas + narrativa) */
.dashboard-skeleton__content {
  grid-area: content;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.dashboard-skeleton__metrics {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}

@media (min-width: 900px) {
  .dashboard-skeleton__metrics {
    grid-template-columns: repeat(4, 1fr);
  }
}

.sk-box--metric {
  height: 110px;
  border-radius: 12px;
}

.sk-box--narrative {
  flex: 1;
  min-height: 160px;
  border-radius: 12px;
}

/* Tabla de indicadores */
.dashboard-skeleton__table {
  grid-area: table;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #fff;
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 4px 6px -1px rgba(0,0,0,.08);
}

.sk-box--table-header {
  height: 36px;
  width: 40%;
  border-radius: 6px;
}

.sk-box--table-row {
  height: 48px;
  border-radius: 8px;
}

/* ---- Skeleton de la página de Mapa ---- */
.mapa-skeleton {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 5;
  opacity: 0;
  visibility: hidden;
  transition: opacity 200ms ease, visibility 200ms ease;
}

body.app-loader-visible .mapa-skeleton {
  opacity: 1;
  visibility: visible;
}

.mapa-skeleton__inner {
  display: grid;
  grid-template-columns: 1fr 420px;
  width: 100%;
  height: 100%;
  gap: 0;
}

.mapa-skeleton__stage {
  padding: 16px;
  display: flex;
  flex-direction: column;
}

.mapa-skeleton__map-body {
  flex: 1;
  border-radius: 10px;
  min-height: 200px;
}

.mapa-skeleton__side {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 18px;
  border-left: 1px solid #e5e7eb;
  background: #f8fafc;
}

.mapa-skeleton__side-header {
  height: 40px;
  border-radius: 10px;
  width: 70%;
}

.mapa-skeleton__metrics {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.mapa-skeleton__metric {
  height: 110px;
  border-radius: 12px;
}

.mapa-skeleton__narrative {
  flex: 1;
  min-height: 120px;
  border-radius: 12px;
}

@media (max-width: 900px) {
  .mapa-skeleton__inner {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr auto;
  }
  .mapa-skeleton__side {
    border-left: none;
    border-top: 1px solid #e5e7eb;
    max-height: 260px;
  }
}
