/* ══════════════════════════════════════════════════════════════════
   GELATOMAPS — UI States v1.0
   Loading · Empty · Error · Success

   Depende de: design-tokens.css (debe cargarse antes)
   Owner: Dpto 06 UX & Diseño
   Fecha: 30 Mar 2026

   Uso: showLoading() / showEmpty() / showError() / showSuccess()
   en web/js/components.js
   ══════════════════════════════════════════════════════════════════ */

/* ──────────────────────────────────────────────────────────────
   Animaciones base
   ────────────────────────────────────────────────────────────── */

@keyframes gm-fade-in {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes gm-spin {
  to { transform: rotate(360deg); }
}

@keyframes gm-pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: .40; }
}

@keyframes gm-toast-out {
  to { opacity: 0; transform: translateX(-50%) translateY(12px); }
}

/* ──────────────────────────────────────────────────────────────
   Contenedor base compartido
   ────────────────────────────────────────────────────────────── */

.gm-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--sp-3xl, 40px) var(--sp-base, 16px);
  text-align: center;
  animation: gm-fade-in 0.25s ease forwards;
  font-family: var(--font-body, 'DM Sans', system-ui, sans-serif);
}

.gm-state-icon {
  font-size: 36px;
  line-height: 1;
  margin-bottom: var(--sp-sm, 8px);
}

.gm-state-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--color-text, #0B1F38);
  margin-bottom: var(--sp-2xs, 4px);
}

.gm-state-text {
  font-size: 12px;
  color: var(--color-text-3, #6B7280);
  line-height: 1.5;
  max-width: 260px;
}

/* ──────────────────────────────────────────────────────────────
   Loading state — spinner + pulso en el texto
   ────────────────────────────────────────────────────────────── */

.gm-state-loading .gm-spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--color-neutral-border, #E5E7EB);
  border-top-color: var(--color-accent, #0D9488);
  border-radius: 50%;
  animation: gm-spin 0.6s linear infinite;
  margin-bottom: var(--sp-sm, 8px);
  flex-shrink: 0;
}

.gm-state-loading .gm-state-text {
  animation: gm-pulse 1.5s ease-in-out infinite;
}

/* ──────────────────────────────────────────────────────────────
   Error state — rojo semántico
   ────────────────────────────────────────────────────────────── */

.gm-state-error .gm-state-title {
  color: var(--color-error, #DC2626);
}

/* ──────────────────────────────────────────────────────────────
   Success state — verde semántico
   ────────────────────────────────────────────────────────────── */

.gm-state-success .gm-state-icon {
  font-size: 32px;
  color: var(--color-success, #16A34A);
}

.gm-state-success .gm-state-title {
  color: var(--color-success, #16A34A);
}

/* ──────────────────────────────────────────────────────────────
   Toast global — notificación flotante auto-dismiss
   ────────────────────────────────────────────────────────────── */

.gm-toast {
  position: fixed;
  bottom: calc(var(--sp-2xl, 32px) + env(safe-area-inset-bottom, 0px));
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: var(--sp-sm, 8px);
  padding: var(--sp-md, 12px) var(--sp-lg, 20px);
  background: var(--color-text, #0B1F38);
  color: var(--color-text-on-dark, #FFFFFF);
  border-radius: var(--radius-pill, 999px);
  font-size: 13px;
  font-weight: 500;
  font-family: var(--font-body, 'DM Sans', system-ui, sans-serif);
  box-shadow: 0 8px 32px rgba(11, 31, 56, .18);
  z-index: 9999;
  white-space: nowrap;
  max-width: calc(100vw - 32px);
  overflow: hidden;
  text-overflow: ellipsis;
  animation: gm-fade-in 0.2s ease forwards;
  pointer-events: none;
}

.gm-toast.gm-toast-exit {
  animation: gm-toast-out 0.25s ease forwards;
}

/* Variantes de color del toast */
.gm-toast-success { background: var(--color-success, #16A34A); }
.gm-toast-error   { background: var(--color-error, #DC2626); }

/* Touch targets mobile — los estados deben tener mínimo 44px de alto si son interactivos */
@media (max-width: 768px) {
  .gm-state {
    padding: var(--sp-2xl, 32px) var(--sp-base, 16px);
  }
}
