@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&display=swap");

/* =========================================================
   DESIGN SYSTEM  -  tokens, base, componentes e movimento
   Carregado em TODAS as páginas: mude aqui = muda em todo lugar.
   ========================================================= */

:root {
  color-scheme: light;

  /* superfícies / texto */
  --bg: #e9edfb;
  --surface: #ffffff;
  --surface-2: #f2f5fc;
  --surface-3: #e7ecf8;
  --border: #e1e6f3;
  --text: #151a2d;
  --text-muted: #69718f;

  /* marca */
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --primary-soft: rgba(99, 102, 241, 0.12);
  --on-primary: #ffffff;
  --violet: #a855f7;
  --accent: #06b6d4;
  --brand: linear-gradient(135deg, #6366f1 0%, #8b5cf6 52%, #a855f7 100%);
  --brand-soft: linear-gradient(135deg, rgba(99, 102, 241, 0.14), rgba(168, 85, 247, 0.12));

  /* estados */
  --danger: #ef4444;
  --danger-hover: #dc2626;
  --success: #16a34a;
  --warning: #d97706;
  --ring: rgba(99, 102, 241, 0.40);

  /* elevação */
  --shadow-sm: 0 1px 2px rgba(16, 24, 64, 0.06), 0 2px 8px rgba(16, 24, 64, 0.06);
  --shadow: 0 8px 24px rgba(16, 24, 64, 0.10), 0 2px 6px rgba(16, 24, 64, 0.05);
  --shadow-lg: 0 26px 60px rgba(16, 24, 64, 0.20), 0 10px 24px rgba(16, 24, 64, 0.10);
  --shadow-primary: 0 10px 28px rgba(99, 102, 241, 0.35);

  /* raios */
  --radius-sm: 12px;
  --radius: 18px;
  --radius-lg: 26px;

  /* movimento */
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --dur-1: 0.15s;
  --dur-2: 0.28s;
  --dur-3: 0.5s;
}

body.dark {
  color-scheme: dark;

  --bg: #090d18;
  --surface: #141b2e;
  --surface-2: #1c2540;
  --surface-3: #232e4d;
  --border: #2a3556;
  --text: #e9edf8;
  --text-muted: #97a1c0;

  --primary: #818cf8;
  --primary-hover: #a5b4fc;
  --primary-soft: rgba(129, 140, 248, 0.16);
  --on-primary: #0a0e1a;
  --violet: #c084fc;
  --accent: #22d3ee;
  --brand: linear-gradient(135deg, #818cf8 0%, #a78bfa 52%, #c084fc 100%);
  --brand-soft: linear-gradient(135deg, rgba(129, 140, 248, 0.18), rgba(192, 132, 252, 0.16));

  --danger: #f87171;
  --danger-hover: #ef4444;
  --warning: #fbbf24;
  --ring: rgba(129, 140, 248, 0.45);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow: 0 12px 30px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 28px 60px rgba(0, 0, 0, 0.65);
  --shadow-primary: 0 10px 30px rgba(99, 102, 241, 0.5);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

img,
svg,
canvas,
video {
  max-width: 100%;
}

body {
  font-family: "Inter", "Segoe UI", system-ui, sans-serif;
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  background-color: var(--bg);
  transition: background-color 0.4s var(--ease), color 0.3s var(--ease);
}

/* ---- Scrollbar discreta ---- */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

::-webkit-scrollbar {
  width: 11px;
  height: 11px;
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 999px;
  border: 3px solid transparent;
  background-clip: padding-box;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

::selection {
  background: var(--primary);
  color: var(--on-primary);
}

/* =========================================================
   FUNDO "aurora" animado (camada fixa, injetada por tema.js)
   ========================================================= */
.bg-aurora {
  position: fixed;
  /* maior que a viewport: o parallax do mouse (~24px) nunca expoe as bordas */
  inset: -90px;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
  background-color: var(--bg);
  background-image:
    radial-gradient(1100px 640px at 100% -10%, var(--primary-soft), transparent 60%),
    radial-gradient(900px 560px at -10% 110%, rgba(168, 85, 247, 0.10), transparent 55%);
}

.bg-aurora::before,
.bg-aurora::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.55;
  will-change: transform;
}

.bg-aurora::before {
  width: 46vw;
  height: 46vw;
  top: -12vw;
  left: -8vw;
  background: radial-gradient(circle at 30% 30%, rgba(99, 102, 241, 0.55), transparent 70%);
  animation: auroraA 26s ease-in-out infinite alternate;
}

.bg-aurora::after {
  width: 52vw;
  height: 52vw;
  bottom: -16vw;
  right: -12vw;
  background: radial-gradient(circle at 70% 70%, rgba(168, 85, 247, 0.45), transparent 70%);
  animation: auroraB 32s ease-in-out infinite alternate;
}

.bg-aurora__blob {
  position: absolute;
  width: 40vw;
  height: 40vw;
  top: 30%;
  left: 35%;
  border-radius: 50%;
  filter: blur(100px);
  opacity: 0.4;
  background: radial-gradient(circle at 50% 50%, rgba(56, 189, 248, 0.4), transparent 70%);
  animation: auroraC 38s ease-in-out infinite alternate;
  will-change: transform;
}

body.dark .bg-aurora::before { opacity: 0.42; }
body.dark .bg-aurora::after { opacity: 0.4; }
body.dark .bg-aurora__blob { opacity: 0.3; }

@keyframes auroraA {
  0%   { transform: translate(0, 0) scale(1); }
  100% { transform: translate(14vw, 10vh) scale(1.18); }
}

@keyframes auroraB {
  0%   { transform: translate(0, 0) scale(1.05); }
  100% { transform: translate(-12vw, -8vh) scale(0.9); }
}

@keyframes auroraC {
  0%   { transform: translate(-6vw, 4vh) scale(0.95); }
  50%  { transform: translate(8vw, -6vh) scale(1.2); }
  100% { transform: translate(-4vw, 8vh) scale(1); }
}

/* =========================================================
   TIPOGRAFIA
   ========================================================= */
h1, h2, h3, h4 {
  line-height: 1.2;
  font-weight: 800;
  letter-spacing: -0.02em;
}

a {
  color: var(--primary);
  text-decoration: none;
  transition: color var(--dur-1) var(--ease), opacity var(--dur-1) var(--ease);
}

a:hover {
  opacity: 0.85;
}

/* Texto com gradiente da marca (utilitário opcional) */
.text-gradient {
  background: var(--brand);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}

/* =========================================================
   BOTÕES  (padrão = primário com leve brilho ao passar o mouse)
   ========================================================= */
button {
  font: inherit;
  font-weight: 600;
  color: var(--on-primary);
  background-color: var(--primary);
  background-image:
    linear-gradient(110deg, transparent 28%, rgba(255, 255, 255, 0.22) 50%, transparent 72%),
    var(--brand);
  background-size: 220% 100%, 100% 100%;
  background-position: 130% 0, 0 0;
  background-repeat: no-repeat;
  border: none;
  border-radius: var(--radius-sm);
  padding: 11px 20px;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition:
    transform var(--dur-1) var(--ease-out),
    box-shadow var(--dur-2) var(--ease),
    filter var(--dur-2) var(--ease),
    opacity var(--dur-2) var(--ease),
    background-color var(--dur-2) var(--ease),
    background-position var(--dur-3) var(--ease);
}

button:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow), var(--shadow-primary);
  filter: brightness(1.04);
  background-position: -40% 0, 0 0;
}

button:active {
  transform: translateY(0) scale(0.97);
  box-shadow: var(--shadow-sm);
  filter: brightness(0.98);
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
  filter: none;
}

:focus-visible {
  outline: 3px solid var(--ring);
  outline-offset: 2px;
}

/* =========================================================
   CAMPOS DE FORMULÁRIO
   ========================================================= */
input,
select,
textarea {
  font: inherit;
  width: 100%;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  outline: none;
  transition: border-color var(--dur-2) var(--ease), box-shadow var(--dur-2) var(--ease),
    background-color var(--dur-2) var(--ease), transform var(--dur-1) var(--ease);
}

input::placeholder,
textarea::placeholder {
  color: var(--text-muted);
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  background: var(--surface);
  box-shadow: 0 0 0 4px var(--ring);
}

/* =========================================================
   BOTÃO DE TEMA (flutuante, em todas as páginas)
   ========================================================= */
#toggle-theme {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 1000;
  width: 46px;
  height: 46px;
  padding: 0;
  font-size: 1.2rem;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 50%;
  box-shadow: var(--shadow);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

#toggle-theme:hover {
  background: var(--surface);
  color: var(--primary);
  border-color: var(--primary);
  transform: translateY(-2px) rotate(-12deg);
}

#toggle-theme:active {
  transform: translateY(0) rotate(0) scale(0.92);
}

#toggle-theme i,
#toggle-theme svg {
  transition: transform var(--dur-3) var(--spring);
}

/* =========================================================
   TOASTS
   ========================================================= */
#toast-wrap {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 9999;
  pointer-events: none;
  max-width: 92vw;
}

.toast {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
  padding: 13px 20px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  font-size: 0.93rem;
  font-weight: 600;
  text-align: left;
  opacity: 0;
  transform: translateY(-16px) scale(0.96);
  transition: opacity var(--dur-2) var(--ease), transform var(--dur-3) var(--spring);
}

.toast.show {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.toast-sucesso { border-left-color: var(--success); }
.toast-erro { border-left-color: var(--danger); }
.toast-info { border-left-color: var(--primary); }

/* =========================================================
   ANIMAÇÕES UTILITÁRIAS
   ========================================================= */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(18px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes popIn {
  from { opacity: 0; transform: scale(0.85); }
  to { opacity: 1; transform: scale(1); }
}

@keyframes riseIn {
  from { opacity: 0; transform: translateY(26px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes slideInRight {
  from { opacity: 0; transform: translateX(24px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes floatY {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

@keyframes glowPulse {
  0%, 100% { box-shadow: 0 0 0 0 var(--ring); }
  50% { box-shadow: 0 0 0 8px transparent; }
}

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

@keyframes shine {
  to { background-position: -160% 0; }
}

/* Aparição em sequência: aplique .reveal e --d (atraso) onde quiser */
.reveal {
  animation: riseIn 0.6s var(--ease-out) both;
  animation-delay: var(--d, 0s);
}

/* =========================================================
   MODAL DE CONFIRMAÇÃO (js/confirmar.js)
   ========================================================= */
.confirm-overlay {
  position: fixed;
  inset: 0;
  z-index: 9998;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(10, 14, 28, 0.55);
  backdrop-filter: blur(5px);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur-2) var(--ease);
}

.confirm-overlay.show {
  opacity: 1;
  pointer-events: auto;
}

.confirm-box {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 24px;
  transform: translateY(8px) scale(0.9);
  transition: transform var(--dur-3) var(--spring);
}

.confirm-overlay.show .confirm-box {
  transform: translateY(0) scale(1);
}

.confirm-box h3 {
  font-size: 1.15rem;
  margin-bottom: 8px;
  color: var(--text);
}

.confirm-box p {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-bottom: 22px;
}

.confirm-acoes {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.confirm-cancelar {
  background: var(--surface-2);
  background-image: none;
  color: var(--text);
  border: 1px solid var(--border);
  box-shadow: none;
}

.confirm-cancelar:hover {
  background: var(--border);
  box-shadow: var(--shadow-sm);
}

.confirm-ok.perigo {
  background-color: var(--danger);
  background-image: linear-gradient(135deg, var(--danger), var(--danger-hover));
}

.confirm-ok.perigo:hover {
  background-color: var(--danger-hover);
}

/* =========================================================
   ÍCONES INLINE (js/icones.js)
   ========================================================= */
.ic {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  vertical-align: middle;
}

.ic svg {
  display: block;
}

/* SVG inserido direto (sem wrapper .ic) dentro de medalhas/insignias:
   sem display:block o svg fica como inline e sobe no circulo (descentralizado). */
.perfil-insignia-icone > svg,
.insignia-medalha > svg,
.conq-medalha > svg,
.rank-medalha > svg,
.mandan-avatar > svg {
  display: block;
}

/* =========================================================
   NOTIFICAÇÕES PERSISTENTES (js/notificacao.js)
   ========================================================= */
#notif-wrap {
  position: fixed;
  top: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  z-index: 9999;
  max-width: 92vw;
}

.notif {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  width: 340px;
  max-width: 92vw;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  padding: 14px 16px;
  opacity: 0;
  transform: translateX(24px) scale(0.97);
  transition: opacity var(--dur-2) var(--ease), transform var(--dur-3) var(--spring);
}

.notif.show {
  opacity: 1;
  transform: translateX(0) scale(1);
}

.notif-ic {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--brand);
  color: #fff;
  box-shadow: var(--shadow-primary);
}

.notif-corpo {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-top: 2px;
}

.notif-corpo strong {
  color: var(--text);
  font-size: 0.95rem;
}

.notif-corpo span {
  color: var(--text-muted);
  font-size: 0.86rem;
}

.notif-fechar {
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  padding: 0;
  background: transparent;
  background-image: none;
  color: var(--text-muted);
  border: none;
  box-shadow: none;
  display: flex;
  align-items: center;
  justify-content: center;
}

.notif-fechar:hover {
  background: var(--surface-2);
  color: var(--text);
  transform: none;
  box-shadow: none;
}

/* =========================================================
   BASE MOBILE  (contenção global contra overflow)
   ========================================================= */
@media (max-width: 768px) {
  html,
  body {
    width: 100%;
    overflow-x: hidden;
  }

  body {
    min-width: 0;
  }

  button,
  input,
  select,
  textarea {
    max-width: 100%;
  }

  input,
  select,
  textarea {
    font-size: 16px;
  }

  #notif-wrap {
    left: 12px;
    right: 12px;
    top: 12px;
    max-width: none;
  }

  .notif {
    width: 100%;
    max-width: none;
  }

  .confirm-overlay {
    padding: 12px;
    align-items: flex-end;
  }

  .confirm-box {
    width: 100%;
    max-width: 420px;
    max-height: calc(100dvh - 24px);
    overflow-y: auto;
    padding: 20px;
    border-radius: var(--radius);
  }

  .confirm-acoes {
    flex-direction: column-reverse;
  }

  .confirm-acoes button {
    width: 100%;
  }
}

@media (max-width: 420px) {
  :root {
    --radius-sm: 10px;
    --radius: 14px;
    --radius-lg: 20px;
  }

  button {
    padding: 10px 14px;
  }

  input,
  select,
  textarea {
    padding: 11px 12px;
  }
}

/* =========================================================
   MOVIMENTO REDUZIDO  (acessibilidade)
   ========================================================= */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
