/* ==========================================================================
   VARIÁVEIS DE TEMA: NOITE (LANTERNA DESLIGADA) vs DIA (LANTERNA LIGADA)
   ========================================================================== */
:root,
html[data-theme="night"] {
  --bg-sky-top: #040711;
  --bg-sky-mid: #0a1128;
  --bg-sky-bottom: #111a3a;

  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  --card-bg: rgba(15, 23, 42, 0.78);
  --card-border: rgba(148, 163, 184, 0.16);
  --card-shadow: 0 24px 60px -15px rgba(0, 0, 0, 0.75);

  --tab-bg: rgba(30, 41, 59, 0.65);
  --tab-bg-hover: rgba(51, 65, 85, 0.8);
  --tab-border: rgba(148, 163, 184, 0.18);
  --tab-active-bg: linear-gradient(135deg, rgba(245, 158, 11, 0.22), rgba(234, 88, 12, 0.14));
  --tab-active-border: #f59e0b;
  --tab-active-text: #fde047;

  --input-bg: rgba(15, 23, 42, 0.9);
  --input-border: rgba(148, 163, 184, 0.3);
  --input-focus: #f59e0b;

  --badge-bg: rgba(15, 23, 42, 0.75);
  --badge-border: rgba(148, 163, 184, 0.22);
  --badge-dot: #64748b;

  --pay-btn-bg: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  --pay-btn-text: #0f172a;
  --pay-btn-shadow: 0 10px 25px -5px rgba(245, 158, 11, 0.4);

  --beam-opacity: 0;
  --stars-opacity: 0.9;
  --sun-opacity: 0;
  --clouds-opacity: 0;
}

html[data-theme="day"] {
  --bg-sky-top: #38bdf8;
  --bg-sky-mid: #bae6fd;
  --bg-sky-bottom: #fef9c3;

  --text-primary: #0f172a;
  --text-secondary: #334155;
  --text-muted: #475569;

  --card-bg: rgba(255, 255, 255, 0.86);
  --card-border: rgba(251, 191, 36, 0.45);
  --card-shadow: 0 24px 60px -15px rgba(217, 119, 6, 0.22), 0 0 40px rgba(254, 240, 138, 0.5);

  --tab-bg: rgba(248, 250, 252, 0.9);
  --tab-bg-hover: #ffffff;
  --tab-border: rgba(203, 213, 225, 0.9);
  --tab-active-bg: linear-gradient(135deg, #fef3c7, #fde68a);
  --tab-active-border: #d97706;
  --tab-active-text: #92400e;

  --input-bg: #ffffff;
  --input-border: #cbd5e1;
  --input-focus: #d97706;

  --badge-bg: rgba(255, 255, 255, 0.85);
  --badge-border: rgba(245, 158, 11, 0.45);
  --badge-dot: #f59e0b;

  --pay-btn-bg: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
  --pay-btn-text: #fef08a;
  --pay-btn-shadow: 0 12px 28px -6px rgba(15, 23, 42, 0.35);

  --beam-opacity: 1;
  --stars-opacity: 0;
  --sun-opacity: 1;
  --clouds-opacity: 0.85;
}

/* ==========================================================================
   RESET E BASE
   ========================================================================== */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  min-height: 100%;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  color: var(--text-primary);
  background-color: var(--bg-sky-top);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  transition: color 0.55s cubic-bezier(0.22, 1, 0.36, 1),
              background-color 0.55s cubic-bezier(0.22, 1, 0.36, 1);
}

body {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100dvh;
  padding: 1.25rem 1rem 2rem;
}

/* ==========================================================================
   FUNDO ATMOSFÉRICO (CÉU, ESTRELAS, SOL, NUVENS)
   ========================================================================== */
.sky-backdrop {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background: linear-gradient(
    180deg,
    var(--bg-sky-top) 0%,
    var(--bg-sky-mid) 52%,
    var(--bg-sky-bottom) 100%
  );
  transition: background 0.65s ease;
  overflow: hidden;
}

/* Camada de estrelas para a noite */
.stars-layer {
  position: absolute;
  inset: 0;
  opacity: var(--stars-opacity);
  transition: opacity 0.6s ease;
  background-image:
    radial-gradient(1.5px 1.5px at 12% 18%, #ffffff, transparent),
    radial-gradient(2px 2px at 28% 9%, #e2e8f0, transparent),
    radial-gradient(1.5px 1.5px at 46% 24%, #ffffff, transparent),
    radial-gradient(2px 2px at 67% 14%, #fde047, transparent),
    radial-gradient(1.2px 1.2px at 84% 22%, #ffffff, transparent),
    radial-gradient(1.8px 1.8px at 19% 42%, #cbd5e1, transparent),
    radial-gradient(1.5px 1.5px at 76% 38%, #ffffff, transparent),
    radial-gradient(2px 2px at 91% 11%, #e2e8f0, transparent),
    radial-gradient(1.5px 1.5px at 8% 62%, #ffffff, transparent),
    radial-gradient(1.5px 1.5px at 58% 48%, #cbd5e1, transparent);
  background-size: 100% 100%;
  animation: twinkle 5s ease-in-out infinite alternate;
}

@keyframes twinkle {
  0% { opacity: calc(var(--stars-opacity) * 0.7); }
  100% { opacity: var(--stars-opacity); }
}

/* Clarão solar para o dia */
.sun-glow {
  position: absolute;
  top: -15%;
  left: 50%;
  transform: translateX(-50%);
  width: min(850px, 130vw);
  height: min(850px, 130vw);
  border-radius: 50%;
  background: radial-gradient(
    circle,
    rgba(254, 240, 138, 0.85) 0%,
    rgba(253, 224, 71, 0.45) 35%,
    rgba(56, 189, 248, 0) 70%
  );
  opacity: var(--sun-opacity);
  transition: opacity 0.65s ease;
}

/* Nuvens suaves no modo dia */
.ambient-clouds {
  position: absolute;
  inset: 0;
  opacity: var(--clouds-opacity);
  transition: opacity 0.65s ease;
}

.cloud {
  position: absolute;
  background: rgba(255, 255, 255, 0.55);
  filter: blur(22px);
  border-radius: 999px;
}

.cloud-1 {
  width: 260px;
  height: 70px;
  top: 12%;
  left: 8%;
}

.cloud-2 {
  width: 320px;
  height: 85px;
  top: 18%;
  right: 6%;
}

.cloud-3 {
  width: 220px;
  height: 60px;
  top: 36%;
  left: 16%;
}

/* ==========================================================================
   CONTAINER PRINCIPAL
   ========================================================================== */
.app-container {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 560px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

/* ==========================================================================
   CABEÇALHO DE STATUS (DIA / NOITE)
   ========================================================================== */
.status-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.45rem;
  text-align: center;
}

.mode-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.42rem 0.95rem;
  border-radius: 999px;
  background: var(--badge-bg);
  border: 1px solid var(--badge-border);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  transition: all 0.45s ease;
}

.mode-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background-color: var(--badge-dot);
  box-shadow: 0 0 0 0 rgba(245, 158, 11, 0);
  transition: all 0.4s ease;
}

html[data-theme="day"] .mode-dot {
  box-shadow: 0 0 10px 3px rgba(245, 158, 11, 0.75);
}

.hint-text {
  font-size: 0.88rem;
  color: var(--text-secondary);
  font-weight: 500;
  transition: color 0.45s ease;
}

/* ==========================================================================
   PALCO CENTRAL DA LANTERNA E FEIXE DE LUZ
   ========================================================================== */
.flashlight-stage {
  position: relative;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1.5rem 0 0.5rem;
}

/* Feixe de luz que sai do topo da lanterna */
.light-beam-wrapper {
  position: absolute;
  bottom: 62%;
  left: 50%;
  transform: translateX(-50%);
  width: min(460px, 95vw);
  height: 300px;
  pointer-events: none;
  opacity: var(--beam-opacity);
  transition: opacity 0.45s cubic-bezier(0.16, 1, 0.3, 1),
              transform 0.45s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 0;
}

html[data-theme="night"] .light-beam-wrapper {
  transform: translateX(-50%) scaleY(0.75);
}

html[data-theme="day"] .light-beam-wrapper {
  transform: translateX(-50%) scaleY(1);
}

.light-beam-cone {
  position: absolute;
  inset: 0;
  clip-path: polygon(0% 0%, 100% 0%, 66% 100%, 34% 100%);
  background: linear-gradient(
    0deg,
    rgba(254, 240, 138, 0.92) 0%,
    rgba(253, 224, 71, 0.52) 40%,
    rgba(254, 249, 195, 0) 100%
  );
  filter: blur(10px);
}

.light-beam-core {
  position: absolute;
  inset: 10% 18% 0 18%;
  clip-path: polygon(10% 0%, 90% 0%, 64% 100%, 36% 100%);
  background: linear-gradient(
    0deg,
    rgba(255, 255, 255, 0.95) 0%,
    rgba(254, 240, 138, 0.55) 55%,
    rgba(255, 255, 255, 0) 100%
  );
  filter: blur(6px);
}

/* Partículas flutuantes na luz */
.light-particles span {
  position: absolute;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #fffbeb;
  box-shadow: 0 0 8px #fde047;
  animation: floatParticle 3.2s infinite ease-in-out;
}

.light-particles span:nth-child(1) { left: 42%; bottom: 18%; animation-delay: 0s; }
.light-particles span:nth-child(2) { left: 56%; bottom: 34%; animation-delay: 0.6s; }
.light-particles span:nth-child(3) { left: 36%; bottom: 52%; animation-delay: 1.2s; }
.light-particles span:nth-child(4) { left: 62%; bottom: 64%; animation-delay: 1.8s; }
.light-particles span:nth-child(5) { left: 49%; bottom: 45%; animation-delay: 0.9s; }
.light-particles span:nth-child(6) { left: 46%; bottom: 76%; animation-delay: 1.5s; }

@keyframes floatParticle {
  0%, 100% { transform: translateY(0) scale(0.8); opacity: 0.4; }
  50% { transform: translateY(-16px) scale(1.2); opacity: 1; }
}

/* Botão da Lanterna */
.flashlight-btn {
  position: relative;
  z-index: 2;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0.5rem;
  border-radius: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.22s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.flashlight-btn:hover {
  transform: translateY(-3px) scale(1.02);
}

.flashlight-btn:active {
  transform: translateY(2px) scale(0.97);
}

.flashlight-btn:focus-visible {
  outline: 3px solid #f59e0b;
  outline-offset: 6px;
}

.flashlight-btn.locked-shake {
  animation: lockedShake 0.42s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}

@keyframes lockedShake {
  10%, 90% { transform: translateX(-3px); }
  20%, 80% { transform: translateX(5px); }
  30%, 50%, 70% { transform: translateX(-6px); }
  40%, 60% { transform: translateX(6px); }
}

.payment-card.highlight-pulse {
  border-color: rgba(245, 158, 11, 0.75);
  box-shadow: 0 0 0 4px rgba(245, 158, 11, 0.2), var(--card-shadow);
}

/* Botão explícito de Desligar/Ligar Lanterna (visível após o pagamento) */
.flashlight-control-btn {
  margin-top: 0.55rem;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.5rem 1.1rem;
  border-radius: 999px;
  border: 1.5px solid var(--badge-border);
  background: var(--badge-bg);
  color: var(--text-primary);
  font-family: 'Inter', sans-serif;
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.15);
  transition: transform 0.2s ease, background 0.25s ease, border-color 0.25s ease;
  -webkit-tap-highlight-color: transparent;
}

.flashlight-control-btn[hidden] {
  display: none;
}

.flashlight-control-btn:hover {
  transform: translateY(-2px);
  border-color: #f59e0b;
}

.flashlight-control-btn:active {
  transform: translateY(0);
}

.control-btn-icon {
  font-size: 0.95rem;
  color: #f59e0b;
}

.flashlight-aura {
  position: absolute;
  width: 170px;
  height: 170px;
  top: -10px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(253, 224, 71, 0.55) 0%, rgba(245, 158, 11, 0) 70%);
  opacity: var(--beam-opacity);
  transition: opacity 0.45s ease;
  pointer-events: none;
}

.flashlight-svg {
  width: clamp(128px, 30vw, 165px);
  height: auto;
  filter: drop-shadow(0 18px 28px rgba(0, 0, 0, 0.45));
  transition: filter 0.45s ease;
}

html[data-theme="day"] .flashlight-svg {
  filter: drop-shadow(0 20px 32px rgba(180, 83, 9, 0.32));
}

/* Estados Internos do SVG da Lanterna */
.svg-lens-surface {
  fill: url(#lensGlowOff);
  transition: fill 0.35s ease;
}

html[data-theme="day"] .svg-lens-surface {
  fill: url(#lensGlowOn);
}

.svg-bulb-core {
  fill: #475569;
  transition: fill 0.35s ease, filter 0.35s ease;
}

html[data-theme="day"] .svg-bulb-core {
  fill: #ffffff;
  filter: url(#bulbBloom);
}

.svg-lens-halo {
  fill: rgba(253, 224, 71, 0);
  transition: fill 0.35s ease;
}

html[data-theme="day"] .svg-lens-halo {
  fill: rgba(253, 224, 71, 0.45);
  filter: blur(6px);
}

.svg-power-switch {
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

html[data-theme="day"] .svg-power-switch {
  transform: translateY(-4px);
}

html[data-theme="day"] .svg-switch-cap {
  fill: #f59e0b;
}

html[data-theme="day"] .svg-power-icon {
  stroke: #0f172a;
}

/* ==========================================================================
   CARD DE PAGAMENTO E 4 ABAS DE VALOR
   ========================================================================== */
.payment-card {
  width: 100%;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  box-shadow: var(--card-shadow);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-radius: 24px;
  padding: 1.5rem;
  transition: background 0.5s ease, border-color 0.5s ease, box-shadow 0.5s ease;
}

.payment-header {
  text-align: center;
  margin-bottom: 1.15rem;
}

.payment-title {
  font-family: 'Space Grotesk', sans-serif;
  font-size: clamp(1.25rem, 3.5vw, 1.5rem);
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.25rem;
}

.payment-subtitle {
  font-size: 0.86rem;
  color: var(--text-secondary);
}

/* Grid das 4 Abas ($1, $100, $1000, Personalizado) */
.tabs-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.6rem;
  margin-bottom: 1.2rem;
}

.amount-tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.22rem;
  padding: 0.85rem 0.4rem;
  border-radius: 16px;
  background: var(--tab-bg);
  border: 1.5px solid var(--tab-border);
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.22s ease;
  -webkit-tap-highlight-color: transparent;
}

.amount-tab:hover {
  background: var(--tab-bg-hover);
  transform: translateY(-2px);
}

.amount-tab:focus-visible {
  outline: 2px solid #f59e0b;
  outline-offset: 2px;
}

.amount-tab.active {
  background: var(--tab-active-bg);
  border-color: var(--tab-active-border);
  box-shadow: 0 8px 20px -6px rgba(245, 158, 11, 0.35);
  transform: translateY(-2px);
}

.tab-currency {
  font-family: 'Space Grotesk', sans-serif;
  font-size: clamp(1.05rem, 2.8vw, 1.25rem);
  font-weight: 700;
  color: var(--text-primary);
  transition: color 0.2s ease;
}

.amount-tab.active .tab-currency {
  color: var(--tab-active-text);
}

.tab-label {
  font-size: 0.73rem;
  font-weight: 600;
  color: var(--text-secondary);
  white-space: nowrap;
}

.amount-tab.active .tab-label {
  color: var(--text-primary);
}

/* Campo de Valor Personalizado */
.custom-input-wrapper {
  margin-bottom: 1.15rem;
  animation: slideFadeIn 0.25s ease-out;
}

@keyframes slideFadeIn {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.custom-input-label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 0.45rem;
}

.currency-input-box {
  position: relative;
  display: flex;
  align-items: center;
  background: var(--input-bg);
  border: 1.5px solid var(--input-border);
  border-radius: 14px;
  padding: 0 1rem;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.currency-input-box:focus-within {
  border-color: var(--input-focus);
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.22);
}

.currency-prefix {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--text-secondary);
  margin-right: 0.5rem;
  user-select: none;
}

.custom-amount-input {
  width: 100%;
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.15rem;
  font-weight: 700;
  padding: 0.8rem 0;
  outline: none;
}

.custom-amount-input::placeholder {
  color: var(--text-muted);
  font-weight: 500;
}

/* Remove setas padrão do input number */
.custom-amount-input::-webkit-outer-spin-button,
.custom-amount-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.custom-amount-input[type="number"] {
  -moz-appearance: textfield;
}

.custom-error-msg {
  margin-top: 0.4rem;
  font-size: 0.78rem;
  font-weight: 500;
  color: #ef4444;
}

/* Barra Inferior de Resumo e Botão Pagar */
.checkout-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding-top: 0.9rem;
  border-top: 1px solid var(--card-border);
}

.selected-summary {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.summary-caption {
  font-size: 0.76rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.summary-value {
  font-family: 'Space Grotesk', sans-serif;
  font-size: clamp(1.2rem, 3.5vw, 1.45rem);
  font-weight: 700;
  color: var(--text-primary);
}

.pay-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  padding: 0.9rem 1.45rem;
  border-radius: 14px;
  border: none;
  background: var(--pay-btn-bg);
  color: var(--pay-btn-text);
  font-family: 'Inter', sans-serif;
  font-size: 0.96rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: var(--pay-btn-shadow);
  transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}

.pay-button:hover:not(:disabled) {
  transform: translateY(-2px);
}

.pay-button:active:not(:disabled) {
  transform: translateY(0);
}

.pay-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.pay-arrow {
  transition: transform 0.2s ease;
}

.pay-button:hover:not(:disabled) .pay-arrow {
  transform: translateX(3px);
}

.checkout-feedback {
  margin-top: 0.85rem;
  padding: 0.65rem 0.9rem;
  border-radius: 12px;
  font-size: 0.82rem;
  font-weight: 500;
  text-align: center;
  background: rgba(245, 158, 11, 0.14);
  border: 1px solid rgba(245, 158, 11, 0.35);
  color: var(--text-primary);
}

/* ==========================================================================
   RESPONSIVIDADE (MOBILE & TELAS PEQUENAS)
   ========================================================================== */
@media (max-width: 520px) {
  body {
    padding: 1rem 0.85rem 1.5rem;
  }

  .payment-card {
    padding: 1.2rem;
    border-radius: 20px;
  }

  /* Em telas mobile estreitas, 2x2 para as 4 abas ficarem amplas e fáceis de tocar */
  .tabs-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.55rem;
  }

  .amount-tab {
    padding: 0.8rem 0.5rem;
  }

  .checkout-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 0.8rem;
  }

  .selected-summary {
    flex-direction: row;
    align-items: baseline;
    justify-content: space-between;
  }

  .pay-button {
    width: 100%;
    padding: 0.95rem;
  }
}
