/* ==========================================================================
   4FUN — Design System (Glassmorphism)
   Tokens, reset, layout base e componentes compartilhados entre páginas.
   ========================================================================== */

:root {
  --bg-deep: #070d1a;
  --bg-mid: #0f1f3d;
  --bg-light: #16305e;

  --glass-bg: rgba(255, 255, 255, 0.06);
  --glass-bg-hover: rgba(255, 255, 255, 0.10);
  --glass-bg-active: rgba(255, 255, 255, 0.14);
  --glass-border: rgba(255, 255, 255, 0.14);
  --glass-highlight: rgba(255, 255, 255, 0.22);
  --glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  --glass-blur: blur(22px) saturate(180%);

  --text: #f5f7fb;
  --text-dim: rgba(245, 247, 251, 0.68);
  --text-faint: rgba(245, 247, 251, 0.42);

  --accent: #5eb2ff;
  --accent-strong: #3b8fe6;
  --accent-glow: rgba(94, 178, 255, 0.38);
  --amber: #ff8a4d;
  --teal: #5fe8c6;
  --danger: #ff6b6b;
  --purple: #b18cfa;

  --radius-lg: 22px;
  --radius-md: 16px;
  --radius-sm: 12px;
  --radius-pill: 999px;

  --mono: 'JetBrains Mono', ui-monospace, Consolas, monospace;
  --sans: 'Inter', -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;

  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --sidebar-w: 250px;
  --sidebar-w-collapsed: 72px;
}

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

html {
  color-scheme: dark;
}

body {
  background: radial-gradient(circle at 15% 0%, rgba(94, 178, 255, 0.10), transparent 45%),
    radial-gradient(circle at 85% 100%, rgba(255, 138, 77, 0.08), transparent 45%),
    linear-gradient(160deg, var(--bg-deep) 0%, var(--bg-mid) 55%, var(--bg-light) 100%);
  background-attachment: fixed;
  color: var(--text);
  font-family: var(--sans);
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

body::before {
  content: '';
  position: fixed;
  inset: -20%;
  background: radial-gradient(circle at 25% 20%, rgba(94, 178, 255, 0.10) 0%, transparent 42%),
    radial-gradient(circle at 78% 78%, rgba(255, 138, 77, 0.07) 0%, transparent 42%);
  pointer-events: none;
  z-index: 0;
  animation: ambientFloat 28s ease-in-out infinite;
}

@keyframes ambientFloat {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(-1.5%, 1.5%) scale(1.03); }
}

a { color: var(--accent); text-decoration: none; }
img, video { display: block; max-width: 100%; }
button { font-family: inherit; }

::selection { background: var(--accent-glow); }

*:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

/* ===== LAYOUT SHELL ===== */

.app-layout {
  display: flex;
  min-height: 100vh;
  position: relative;
  z-index: 1;
}

.sidebar {
  width: var(--sidebar-w);
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border-right: 1px solid var(--glass-border);
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
  gap: 28px;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  box-shadow: var(--glass-shadow);
}

.sidebar__logo {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-family: var(--mono);
  font-weight: 800;
  font-size: 18px;
  padding: 0 6px;
}

.sidebar__logo svg { color: var(--accent); filter: drop-shadow(0 0 8px var(--accent-glow)); }

.sidebar__nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sidebar__link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 13px;
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  font-size: 14px;
  font-weight: 500;
  transition: background 0.2s var(--ease), color 0.2s var(--ease), transform 0.2s var(--ease);
  border: 1px solid transparent;
}

.sidebar__link:hover {
  background: var(--glass-bg-hover);
  border-color: var(--glass-border);
  color: var(--text);
}

.sidebar__link.active {
  background: var(--glass-bg-active);
  border-color: var(--glass-highlight);
  color: var(--text);
  box-shadow: 0 0 18px var(--accent-glow), inset 0 1px 0 var(--glass-highlight);
}

.sidebar__link svg { width: 18px; height: 18px; flex-shrink: 0; }

.sidebar__footer {
  margin-top: auto;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-faint);
  padding: 0 6px;
}

.main-content {
  flex: 1;
  margin-left: var(--sidebar-w);
  position: relative;
  z-index: 1;
  min-width: 0;
}

@media (max-width: 860px) {
  .sidebar {
    width: var(--sidebar-w-collapsed);
    padding: 18px 8px;
  }
  .sidebar__logo span,
  .sidebar__link span,
  .sidebar__footer { display: none; }
  .sidebar__link { justify-content: center; padding: 12px; }
  .main-content { margin-left: var(--sidebar-w-collapsed); }
}

/* ===== GLASS PRIMITIVES ===== */

.glass-panel {
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--glass-shadow);
}

.glass-panel--hover {
  transition: background 0.25s var(--ease), border-color 0.25s var(--ease), transform 0.25s var(--ease), box-shadow 0.25s var(--ease);
}

.glass-panel--hover:hover {
  background: var(--glass-bg-hover);
  border-color: var(--glass-highlight);
  transform: translateY(-3px);
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.4), inset 0 1px 0 var(--glass-highlight);
}

/* ===== BUTTONS ===== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--glass-border);
  background: var(--glass-bg);
  backdrop-filter: blur(16px);
  color: var(--text);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  transition: background 0.2s var(--ease), transform 0.15s var(--ease), border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
  white-space: nowrap;
}

.btn:hover { background: var(--glass-bg-hover); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn--ghost.active {
  border-color: var(--accent);
  color: var(--accent);
  box-shadow: 0 0 16px var(--accent-glow);
}

.btn--primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  border-color: var(--accent-strong);
  color: #06131f;
  box-shadow: 0 8px 24px var(--accent-glow);
}

.btn--primary:hover {
  filter: brightness(1.08);
  box-shadow: 0 10px 30px var(--accent-glow);
}

.btn--danger {
  background: rgba(255, 107, 107, 0.12);
  border-color: rgba(255, 107, 107, 0.4);
  color: var(--danger);
}

.btn--danger:hover { background: rgba(255, 107, 107, 0.22); }

.btn--icon { padding: 10px; border-radius: 50%; }

.btn--sm { padding: 7px 12px; font-size: 12px; }

/* ===== FORMS ===== */

.field { display: flex; flex-direction: column; gap: 6px; }

.field__label {
  font-size: 11px;
  color: var(--text-dim);
  font-weight: 600;
  letter-spacing: 0.02em;
}

.input, .select, .textarea {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--glass-border);
  color: var(--text);
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: var(--sans);
  width: 100%;
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease), background 0.2s var(--ease);
}

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

.select {
  color-scheme: dark;
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

.select option { background: #0f1f3d; color: #fff; padding: 8px; }

.textarea { resize: vertical; min-height: 70px; font-family: var(--sans); }

.input:focus, .select:focus, .textarea:focus {
  border-color: var(--accent);
  outline: none;
  background: rgba(255, 255, 255, 0.08);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.input--mono { font-family: var(--mono); }

/* ===== MODAL ===== */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(4, 8, 16, 0.72);
  backdrop-filter: blur(6px);
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.18s var(--ease);
}

.modal-overlay.is-open { display: flex; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: linear-gradient(160deg, rgba(20, 32, 58, 0.96), rgba(10, 18, 34, 0.98));
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5), inset 0 1px 0 var(--glass-highlight);
  padding: 28px;
  max-width: 480px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  animation: modalPop 0.22s var(--ease);
}

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

.modal--wide { max-width: 1080px; padding: 0; overflow: hidden; }

.modal__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
}

.modal__title { font-size: 19px; font-weight: 800; color: var(--text); }

.modal__close {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  color: var(--text-dim);
  font-size: 18px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s, background 0.2s;
  flex-shrink: 0;
}

.modal__close:hover { color: var(--text); background: var(--glass-bg-hover); }

/* ===== TOAST ===== */

#toastRoot {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: min(360px, calc(100vw - 32px));
}

.toast {
  padding: 13px 18px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 13px;
  color: var(--text);
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
  animation: toastIn 0.25s var(--ease);
  display: flex;
  align-items: center;
  gap: 10px;
}

.toast--success { border-color: rgba(95, 232, 198, 0.4); }
.toast--success .toast__dot { background: var(--teal); }
.toast--error { border-color: rgba(255, 107, 107, 0.4); }
.toast--error .toast__dot { background: var(--danger); }
.toast--info .toast__dot { background: var(--accent); }

.toast__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 8px currentColor;
}

.toast.is-leaving { animation: toastOut 0.2s var(--ease) forwards; }

@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes toastOut { to { opacity: 0; transform: translateY(6px); } }

/* ===== SPINNER ===== */

.spinner {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.25);
  border-top-color: var(--text);
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}

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

/* ===== SKELETON ===== */

.skeleton {
  background: linear-gradient(100deg, rgba(255, 255, 255, 0.04) 30%, rgba(255, 255, 255, 0.10) 50%, rgba(255, 255, 255, 0.04) 70%);
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ===== SCROLLBAR ===== */

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.14);
  border-radius: var(--radius-pill);
  border: 2px solid transparent;
}
::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.22); }

/* ===== SECTION TITLES ===== */

.section-title {
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--text-dim);
  margin-bottom: 18px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--glass-border);
}
