/* ==========================================================================
   IdleManager · Sistema · estilos base
   As cores, a fonte e os componentes foram COPIADOS do site (idlemanager-site)
   para este projeto funcionar sozinho: ele não usa nenhum arquivo de lá.
   Se mudar uma cor no site, mude aqui também (as cores estão logo abaixo).
   ========================================================================== */

:root {
  color-scheme: dark;

  /* Fundos, bordas e textos (iguais aos do site) */
  --bg: #0A0C10;
  --bg-alt: #0D1015;
  --surface: #12151C;
  --surface-2: #171B23;
  --surface-3: #1E232D;
  --border: #20252F;
  --border-strong: #2C3240;

  --text: #E9EBF0;
  --text-strong: #F5F6F8;
  --text-2: #A2A9B6;
  --text-3: #7C8494;

  /* Destaque azul (igual ao do site) */
  --accent: #2563EB;
  --accent-hover: #1D4ED8;
  --accent-text: #6EA8FE;
  --accent-soft: rgba(59, 130, 246, 0.12);
  --accent-border: rgba(59, 130, 246, 0.35);

  /* Status (iguais aos do site) */
  --ok: #22C55E;
  --ok-text: #4ADE80;
  --ok-soft: rgba(34, 197, 94, 0.12);
  --warn-text: #FBBF24;
  --warn-soft: rgba(245, 158, 11, 0.13);
  --twitch: #A970FF;
  --kick: #53FC18;

  /* Novas no sistema: perigo (excluir, tirar acesso). O vermelho é o mesmo dos erros do site. */
  --danger: #DC2626;
  --danger-hover: #B91C1C;
  --danger-text: #F87171;
  --danger-soft: rgba(248, 113, 113, 0.12);
  --danger-border: rgba(248, 113, 113, 0.35);

  /* Gráficos e barras de progresso: uma cor só (o azul da marca), com a trilha num tom mais fraco do mesmo azul */
  --viz-fill: #3B82F6;
  --viz-track: rgba(59, 130, 246, 0.16);

  /* Cores que dá para escolher para cada grupo */
  --g-violeta: #A78BFA;
  --g-azul: #6EA8FE;
  --g-rosa: #F472B6;
  --g-ciano: #22D3EE;
  --g-laranja: #FB923C;
  --g-cinza: #A2A9B6;

  --radius: 12px;
  --radius-lg: 16px;
  --shadow-lg: 0 30px 80px -24px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(255, 255, 255, 0.02);
  --header-h: 64px;
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

/* ---------- Base ---------- */

*,
*::before,
*::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  background: var(--bg);
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4 {
  margin: 0;
  color: var(--text-strong);
  line-height: 1.2;
  letter-spacing: -0.02em;
}
h1 { font-size: clamp(1.6rem, 1.3rem + 1vw, 2rem); font-weight: 700; letter-spacing: -0.025em; }
h2 { font-size: 1.0625rem; font-weight: 600; letter-spacing: -0.01em; }
h3 { font-size: 1rem; font-weight: 600; letter-spacing: -0.01em; }
h1, h2, h3 { text-wrap: balance; }

p { margin: 0; text-wrap: pretty; }
a { color: inherit; }
img { max-width: 100%; }
ul { margin: 0; padding: 0; list-style: none; }
fieldset { min-width: 0; margin: 0; padding: 0; border: 0; }

/* "hidden" sempre esconde, mesmo em peças que têm display definido */
[hidden] { display: none !important; }

:focus-visible {
  outline: 2px solid var(--accent-text);
  outline-offset: 3px;
  border-radius: 6px;
}

::selection { background: rgba(37, 99, 235, 0.45); color: #fff; }

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.icon {
  width: 20px;
  height: 20px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.skip-link {
  position: absolute;
  left: 16px;
  top: -64px;
  z-index: 100;
  padding: 10px 14px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  text-decoration: none;
}
.skip-link:focus { top: 12px; }

.muted { color: var(--text-2); font-size: 0.9375rem; }
.strong { color: var(--text-strong); font-weight: 600; }

/* ---------- Botões ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 44px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: 10px;
  font-family: inherit;
  font-size: 0.9375rem;
  font-weight: 600;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.15s ease;
}
.btn:active { transform: translateY(1px); }
.btn .icon { width: 18px; height: 18px; }
.btn:disabled,
.btn[aria-disabled="true"] { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 10px 28px -12px rgba(37, 99, 235, 0.8);
}
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }

.btn-secondary {
  background: rgba(255, 255, 255, 0.02);
  border-color: var(--border-strong);
  color: var(--text-strong);
}
.btn-secondary:hover:not(:disabled) { background: var(--surface-2); border-color: #3A4252; }

.btn-ghost { background: transparent; border-color: transparent; color: var(--text-strong); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: var(--danger-hover); }

.btn-danger-text { color: var(--danger-text); }
.btn-danger-text:hover:not(:disabled):not([aria-disabled="true"]) { background: var(--danger-soft); }

.btn-social { background: var(--surface-2); border-color: var(--border-strong); color: var(--text-strong); }
.btn-social:hover { background: var(--surface-3); border-color: #3A4252; }

.btn-lg { height: 50px; padding: 0 24px; font-size: 1rem; }
.btn-sm { height: 38px; padding: 0 14px; font-size: 0.875rem; }
.btn-block { width: 100%; }
.btn-icon { width: 38px; padding: 0; }

.btn.is-loading { pointer-events: none; opacity: 0.85; }
.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.link-btn {
  appearance: none;
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent-text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.link-btn:hover { text-decoration: underline; }

.text-link { color: var(--accent-text); font-weight: 600; text-decoration: none; }
.text-link:hover { text-decoration: underline; }

.icon-brand { flex: none; width: 18px; height: 18px; }
.icon-discord { color: #5865F2; }

/* ---------- Campos de formulário ---------- */

.field { display: grid; gap: 7px; }
.field + .field { margin-top: 16px; }
.field label,
.field .label { color: var(--text-strong); font-size: 0.875rem; font-weight: 500; }
.field .optional { color: var(--text-3); font-weight: 400; }
.field-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.field-row .link-btn { font-size: 0.8125rem; }

.input {
  width: 100%;
  height: 44px;
  padding: 0 14px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: #0E1117;
  color: var(--text-strong);
  font: 400 0.9375rem/1.2 var(--font);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.input::placeholder { color: var(--text-3); }
.input:hover:not(:disabled) { border-color: #3A4252; }
.input:focus { outline: none; border-color: var(--accent-text); box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.25); }
.input:disabled { opacity: 0.6; cursor: not-allowed; }
.input[aria-invalid="true"] { border-color: var(--danger-text); }
.input[aria-invalid="true"]:focus { box-shadow: 0 0 0 3px rgba(248, 113, 113, 0.2); }
.input:-webkit-autofill {
  -webkit-box-shadow: 0 0 0 1000px #0E1117 inset;
  -webkit-text-fill-color: var(--text-strong);
  caret-color: var(--text-strong);
}

select.input {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 40px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%237C8494' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-position: right 12px center;
  background-repeat: no-repeat;
  background-size: 18px;
  cursor: pointer;
}
select.input option { background: var(--surface); color: var(--text-strong); }

.field-hint { color: var(--text-3); font-size: 0.8125rem; }
.field:has(.input[aria-invalid="true"]) .field-hint { display: none; }
.field-error { color: #FCA5A5; font-size: 0.8125rem; }

.form-error {
  margin-top: 14px;
  padding: 10px 12px;
  border: 1px solid var(--danger-border);
  border-radius: 10px;
  background: var(--danger-soft);
  color: #FCA5A5;
  font-size: 0.875rem;
}

.pw-wrap { position: relative; }
.pw-wrap .input { padding-right: 48px; }
.pw-toggle {
  position: absolute;
  top: 50%;
  right: 4px;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text-3);
  cursor: pointer;
  transform: translateY(-50%);
}
.pw-toggle:hover { background: var(--surface-2); color: var(--text-strong); }
.pw-toggle .icon { width: 18px; height: 18px; }
.pw-toggle .icon-hide,
.pw-toggle[aria-pressed="true"] .icon-show { display: none; }
.pw-toggle[aria-pressed="true"] .icon-hide { display: block; }

/* Botão liga/desliga (permissões) */
.switch {
  appearance: none;
  -webkit-appearance: none;
  position: relative;
  flex: none;
  width: 42px;
  height: 24px;
  margin: 0;
  border-radius: 999px;
  background: #2A3140;
  cursor: pointer;
  transition: background-color 0.15s ease;
}
.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #7C8494;
  transition: transform 0.15s ease, background-color 0.15s ease;
}
.switch:checked { background: var(--accent); }
.switch:checked::after { background: #fff; transform: translateX(18px); }
.switch:disabled { cursor: not-allowed; opacity: 0.5; }
.switch:focus-visible { outline: 2px solid var(--accent-text); outline-offset: 3px; border-radius: 999px; }

/* ---------- Cartões, selos e etiquetas ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.icon-box {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid rgba(59, 130, 246, 0.22);
  border-radius: 11px;
  background: var(--accent-soft);
  color: var(--accent-text);
}

.badge-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}
.badge-status::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-status.ok { background: var(--ok-soft); color: var(--ok-text); }
.badge-status.warn { background: var(--warn-soft); color: var(--warn-text); }
.badge-status.off { background: var(--surface-3); color: var(--text-3); }
.badge-status.danger { background: var(--danger-soft); color: var(--danger-text); }

/* Cor de cada grupo: a classe c-<cor> define --c, usada pelo selo, avatar e bolinha */
.c-violeta { --c: var(--g-violeta); }
.c-azul { --c: var(--g-azul); }
.c-rosa { --c: var(--g-rosa); }
.c-ciano { --c: var(--g-ciano); }
.c-laranja { --c: var(--g-laranja); }
.c-cinza { --c: var(--g-cinza); }

.group-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  padding: 3px 10px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--c, var(--g-cinza)) 15%, transparent);
  color: var(--c, var(--g-cinza));
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.4;
  white-space: nowrap;
}
.group-badge::before { content: ""; flex: none; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.dot {
  display: inline-block;
  flex: none;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--c, var(--text-3));
}

.avatar {
  display: grid;
  place-items: center;
  flex: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 0.875rem;
  font-weight: 700;
}
.avatar-soft {
  background: color-mix(in srgb, var(--c, var(--g-cinza)) 18%, transparent);
  color: var(--c, var(--g-cinza));
}

/* Faixa amarela de "prévia" */
.demo-banner {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  border: 1px solid rgba(245, 158, 11, 0.3);
  border-radius: 12px;
  background: rgba(245, 158, 11, 0.07);
  color: #FCD34D;
  font-size: 0.9rem;
}
.demo-banner .icon { margin-top: 1px; }
.demo-banner .link-btn { color: #FDE68A; text-decoration: underline; text-underline-offset: 2px; }

/* Avisos dentro das telas */
.notice {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 0.875rem;
}
.notice .icon { width: 16px; height: 16px; margin-top: 2px; color: var(--text-3); }
.notice-warn { border-color: rgba(245, 158, 11, 0.3); background: rgba(245, 158, 11, 0.07); color: #FCD34D; }
.notice-warn .icon { color: var(--warn-text); }
.notice-ok { border-color: rgba(34, 197, 94, 0.3); background: rgba(34, 197, 94, 0.07); color: #86EFAC; }
.notice-ok .icon { color: var(--ok-text); }

/* ---------- Aviso rápido (toast) ---------- */

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  z-index: 80;
  display: flex;
  align-items: center;
  gap: 10px;
  width: max-content;
  max-width: calc(100vw - 32px);
  padding: 12px 18px;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  background: var(--surface-3);
  box-shadow: 0 20px 40px -12px rgba(0, 0, 0, 0.7);
  color: var(--text-strong);
  font-size: 0.9375rem;
  font-weight: 500;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 16px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.toast::before { content: ""; flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--ok); }
.toast.is-error::before { background: var(--danger-text); }
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Janelas (modal) ---------- */

html.modal-open { overflow: hidden; }

.modal {
  width: min(500px, calc(100vw - 32px));
  max-height: calc(100dvh - 32px);
  padding: 0;
  overflow: auto;
  border: 1px solid var(--border-strong);
  border-radius: 20px;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 40px 100px -20px rgba(0, 0, 0, 0.85);
}
.modal-sm { width: min(420px, calc(100vw - 32px)); }
.modal::backdrop { background: rgba(5, 6, 9, 0.8); }
.modal[open] { animation: modalIn 0.22s ease; }
@keyframes modalIn { from { opacity: 0; transform: translateY(10px) scale(0.98); } to { opacity: 1; transform: none; } }

.modal-card { position: relative; padding: 24px; }
.modal-card > h2 { padding-right: 44px; font-size: 1.25rem; letter-spacing: -0.02em; }
.modal-card > h2 + .muted { margin-top: 6px; }
.modal-card .field + .field { margin-top: 14px; }
.modal-card form > .field:first-child,
.modal-card > .field:first-of-type { margin-top: 18px; }

.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
}
.modal-close:hover { background: var(--surface-2); color: var(--text-strong); }

.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 24px; }

@media (max-width: 480px) {
  .modal-card { padding: 22px 18px 18px; }
  .modal-actions { flex-direction: column-reverse; }
  .modal-actions .btn { width: 100%; }
}

/* ---------- Movimento reduzido ---------- */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
