/* =====================================================
   APP ALERT – SIMPLES + LOADING ESTÁVEL (FINAL)
===================================================== */

:root {
  --roxo: #854d8b;
  --roxo-active: #6d2f85; /* roxo mais escuro p/ spinner */
  --verde: #28a745;
  --vermelho: #dc3545;
  --laranja: #f0ad4e;
  --texto: #111827;
}

/* =========================
   OVERLAY
========================= */
.app-alert-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: none;
  z-index: 9999;

  align-items: center;
  justify-content: center;
}

/* =========================
   ALERT NORMAL (CAIXA)
========================= */
.app-alert {
  background: #ffffff;
  border-radius: 12px;
  padding: 20px;

  width: calc(100% - 40px);
  max-width: 360px;

  text-align: center;
  font-family: Arial, Helvetica, sans-serif;

  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
  box-sizing: border-box;
}

/* =========================
   TÍTULO / TEXTO
========================= */
.app-alert-title {
  font-size: 1.25rem;
  font-weight: bold;
  color: var(--roxo);
  margin-bottom: 10px;
}

.app-alert-message {
  font-size: 1rem;
  color: var(--texto);
  margin-bottom: 18px;
  line-height: 1.4;
}

/* =========================
   TIPOS
========================= */
.app-alert.info {
  border: 2px solid var(--roxo);
}

.app-alert.success {
  border: 2px solid var(--verde);
}

.app-alert.warning {
  border: 2px solid var(--laranja);
}

.app-alert.error {
  border: 2px solid var(--vermelho);
}

/* =========================
   AÇÕES / BOTÕES
========================= */
.app-alert-actions {
  display: flex;
  justify-content: center;
  gap: 10px;
}

.app-alert-btn {
  background: transparent;
  border-radius: 6px;
  padding: 6px 14px;
  font-size: 0.85rem;
  font-weight: bold;
  cursor: pointer;
  min-width: 90px;
  border: 2px solid transparent;
}

/* BOTÕES */
.app-alert-btn.ok {
  border-color: var(--roxo);
  color: var(--roxo);
}

.app-alert-btn.success {
  border-color: var(--verde);
  color: var(--verde);
}

.app-alert-btn.warning {
  border-color: var(--laranja);
  color: var(--laranja);
}

.app-alert-btn.danger {
  border-color: var(--vermelho);
  color: var(--vermelho);
}

/* =====================================================
   LOADING FULLSCREEN – SEM CAIXA (SPINNER DUPLO)
===================================================== */

.app-alert-overlay.loading-only {
  background: rgba(0, 0, 0, 0.25);
}

/* remove completamente o alert box */
.app-alert-overlay.loading-only .app-alert {
  display: none;
}

/* container do loading */
.app-alert-loading-only {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

/* =========================
   SPINNER DUPLO (VISÍVEL)
========================= */
.app-alert-spinner {
  position: relative;
  width: 60px;
  height: 60px;
}

/* anel externo */
.app-alert-spinner::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 4px solid rgba(133, 77, 139, 0.35);
}

/* anel interno girando */
.app-alert-spinner::before {
  content: "";
  position: absolute;
  inset: 6px;
  border-radius: 50%;
  border: 4px solid transparent;
  border-top-color: var(--roxo-active);
  border-right-color: var(--roxo-active);
  animation: appAlertSpin 0.85s linear infinite;
}

@keyframes appAlertSpin {
  to {
    transform: rotate(360deg);
  }
}

/* texto do loading */
.app-alert-loading-text {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--roxo-active);
}

/* =========================
   MOBILE
========================= */
@media (max-width: 600px) {
  .app-alert {
    width: calc(100% - 24px);
    max-width: 320px;
  }
  .app-alert-overlay {
    padding: 12px; /* evita grudar nas bordas no iPhone */
  }

  .app-alert-body {
    overscroll-behavior: contain;
    touch-action: pan-y;
  }
  .checkbox-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .app-alert-overlay {
    position: fixed;
    inset: 0;

    display: flex;
    align-items: center;
    justify-content: center;

    overflow: hidden; /* IMPORTANTE */
  }

  .app-alert {
    max-height: 90vh;
    display: flex;
    flex-direction: column;
  }

  .app-alert-body {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    max-height: 60vh;
  }
  .app-alert-body {
    touch-action: pan-y;
  }
}

/* =====================================================
   MOBILE MUITO PEQUENO – ALTURA CONTROLADA (iPhone SE)
===================================================== */

@media (max-width: 390px) {
  .app-alert {
    max-height: 90vh; /* 🔥 limita altura */
    display: flex;
    flex-direction: column;
  }
  .checkbox-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .app-alert-overlay {
    position: fixed;
    inset: 0;

    display: flex;
    align-items: center;
    justify-content: center;

    overflow: hidden; /* IMPORTANTE */
  }

  .app-alert {
    max-height: 90vh;
    display: flex;
    flex-direction: column;
  }

  .app-alert-body {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    max-height: 60vh;
  }

  /* corpo do formulário rola */
  .app-alert-body {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    max-height: calc(90vh - 140px);
    /* 140px ≈ título + ações */
  }

  /* ações sempre visíveis, mas NÃO fixas */
  .app-alert-actions {
    margin-top: 12px;
  }
  .app-alert-overlay {
    padding: 12px; /* evita grudar nas bordas no iPhone */
  }

  .app-alert-body {
    overscroll-behavior: contain;
    touch-action: pan-y;
  }

  .app-alert-body {
    touch-action: pan-y;
  }
}
