.wrapper {
  position: sticky;
  top: 0;
  z-index: 1000;
  width: 100%;
  background: var(--nav-bg);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border-500);
  box-shadow: var(--nav-shadow);
  animation: nav-enter 0.5s ease;
}

@keyframes nav-enter {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.wrapper nav {
  max-width: 1240px;
  min-height: 74px;
  margin: 0 auto;
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.wrapper input[type="checkbox"] {
  display: none;
}

nav .menu-icon {
  display: none;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: 1px solid var(--border-500);
  background: var(--bg-800);
  color: var(--text-100);
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: border-color 0.3s ease, background-color 0.3s ease, color 0.3s ease, box-shadow 0.3s ease !important;
}

nav .menu-icon:hover {
  border-color: var(--accent-500);
  background: var(--bg-700);
  box-shadow: var(--nav-menu-shadow);
}

nav .content {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.content .brand {
  display: inline-flex;
  align-items: center;
  outline: none;
  gap: 10px;
  font-family: "Outfit", "Sora", sans-serif;
  font-weight: 800;
  letter-spacing: 0.02em;
  color: var(--text-100);
  font-size: 1.1rem;
  line-height: 1.2;
  white-space: nowrap;
  transition: color 0.3s ease !important;
}

.content .brand span {
  display: inline-block;
  max-width: min(46vw, 420px);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.content .brand img {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  border: 1px solid var(--nav-brand-ring);
  transition: transform 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease !important;
}

.content .brand:hover {
  color: var(--accent-300);
}

.content .brand:hover img {
  transform: rotate(-6deg) scale(1.05);
  border-color: var(--nav-brand-ring-hover);
  box-shadow: var(--nav-brand-shadow);
}

nav .content .links {
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: 7px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.content .links li {
  list-style: none;
}

.content .links li a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 40px;
  padding: 0 13px;
  border-radius: 12px;
  color: var(--text-300);
  font-size: 0.88rem;
  line-height: 1.2;
  font-weight: 600;
  letter-spacing: 0.01em;
  transition: color 0.3s ease, background-color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease, transform 0.3s ease !important;
  border: 1px solid transparent;
  position: relative;
  overflow: hidden;
  isolation: isolate;
}

/* Estilos modernos para navbar com ícones */
.modern-nav .nav-link {
  gap: 8px;
}

.modern-nav .nav-link i {
  font-size: 1rem;
  opacity: 0.85;
  transition: opacity 0.3s ease, transform 0.3s ease !important;
}

.modern-nav .nav-link:hover i {
  opacity: 1;
  transform: scale(1.1);
}

.modern-nav .nav-link.active-link i {
  opacity: 1;
}

.modern-nav .nav-link-icon {
  width: 40px;
  min-width: 40px;
  padding: 0;
  font-size: 1.1rem;
}

.modern-nav .nav-link-icon span {
  display: none;
}

.content .links li a::before {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--nav-link-overlay);
  opacity: 0;
  transition: opacity 0.3s ease !important;
  z-index: -1;
}

.content .links li a:hover,
.content .links li a:focus-visible {
  color: var(--text-100);
  border-color: var(--nav-link-hover-border);
  background: var(--nav-link-hover-bg);
  transform: translateY(-1px);
}

.content .links li a:hover::before,
.content .links li a:focus-visible::before {
  opacity: 1;
}

.content .links li a.active-link {
  color: var(--text-100);
  background: var(--nav-link-active-bg);
  border-color: var(--accent-500);
  box-shadow: var(--nav-link-active-shadow);
}

.content .links li a.icon-link {
  width: 40px;
  min-width: 40px;
  padding: 0;
  font-size: 1rem;
}

.nav-auth {
  margin-left: 8px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.user-avatar-container {
  display: inline-flex;
  align-items: center;
}

.user-avatar {
  width: 55px;
  height: 55px;
  border-radius: 50%;
  border: 1px solid var(--nav-brand-ring);
  transition: transform 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease !important;
}

.user-avatar:hover {
  transform: translateY(-2px);
  box-shadow: var(--nav-btn-shadow);
  border-color: var(--accent);
}

.mobile-only {
  display: none;
}

/* Modal de Logout */
.logout-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 9999;
  display: none;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.3s ease;
}

.logout-modal.show {
  display: flex;
}

.logout-modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
}

.logout-modal-content {
  position: relative;
  background: var(--nav-bg);
  border-radius: 16px;
  box-shadow: var(--shadow-xl);
  max-width: 400px;
  width: 90%;
  max-height: 90vh;
  overflow: hidden;
  animation: slideUp 0.3s ease;
  border: 1px solid var(--border-500);
}

.logout-modal-header {
  display: flex;
  align-items: center;
  padding: 20px;
  border-bottom: 1px solid var(--border-500);
  background: var(--bg-secondary);
}

.logout-modal-avatar {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  margin-right: 16px;
  border: 3px solid var(--accent);
}

.logout-modal-icon {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  margin-right: 16px;
  background: var(--warning, #ffc107);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
}

.logout-modal-user-info h3 {
  margin: 0;
  color: var(--text-primary);
  font-size: 1.1rem;
  font-weight: 600;
}

.logout-modal-user-info p {
  margin: 4px 0 0;
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-family: "JetBrains Mono", monospace;
}

.logout-modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 8px;
  border-radius: 8px;
  transition: all 0.2s ease !important;
}

.logout-modal-close:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.logout-modal-body {
  padding: 20px;
  text-align: center;
}

.logout-modal-body p {
  margin: 0;
  color: var(--text-primary);
  font-size: 1rem;
}

.logout-modal-footer {
  display: flex;
  gap: 12px;
  padding: 20px;
  border-top: 1px solid var(--border-500);
  background: var(--bg-secondary);
}

.logout-modal-footer .btn {
  flex: 1;
  height: 42px;
  border: none;
  border-radius: 10px;
  font-family: "Outfit", "Sora", sans-serif;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s ease !important;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn-secondary {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border-500);
}

.btn-secondary:hover {
  background: var(--bg-quaternary);
  transform: translateY(-1px);
}

.btn-danger {
  background: var(--danger, #dc3545);
  color: white;
}

.btn-danger:hover {
  background: var(--danger-hover, #c82333);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(220, 53, 69, 0.3);
}

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

@keyframes slideUp {
  from { 
    opacity: 0;
    transform: translateY(20px) scale(0.95);
  }
  to { 
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.nav-auth .auth-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 42px;
  min-width: 104px;
  padding: 0 14px;
  border: 0;
  border-radius: 12px;
  font-family: "Outfit", "Sora", sans-serif;
  font-size: 0.85rem;
  line-height: 1.1;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: var(--nav-btn-text);
  background: var(--nav-btn-bg);
  cursor: pointer;
  transition: transform 0.3s ease, box-shadow 0.3s ease, background 0.3s ease, filter 0.3s ease !important;
}

.nav-auth .auth-btn:hover {
  transform: translateY(-2px);
  box-shadow: var(--nav-btn-shadow);
  filter: brightness(1.04);
}

.nav-auth .auth-btn:active {
  transform: translateY(0) scale(0.98);
}

.nav-auth .auth-btn.auth-btn-danger {
  color: var(--nav-btn-text);
  background: var(--nav-btn-bg);
}

.nav-auth .auth-btn img {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: middle;
}

.nav-theme {
  display: inline-flex;
  align-items: center;
  position: relative;
}

.theme-switch-input {
  position: absolute;
  top: 0;
  left: 0;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  border: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

.theme-switch-control {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 28px;
  border-radius: 999px;
  border: 1px solid var(--border-500);
  background: var(--toggle-bg);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
  flex: 0 0 auto;
  cursor: pointer;
  user-select: none;
  touch-action: manipulation;
  transition: background 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease, transform 0.2s ease !important;
}

.theme-switch-control:hover {
  border-color: var(--accent-500);
  background: var(--toggle-bg-hover);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06), var(--toggle-shadow);
}

.theme-switch-control:active {
  transform: scale(0.98);
}

.theme-switch-input:focus-visible + .theme-switch-control {
  outline: 2px solid var(--accent-500);
  outline-offset: 2px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06), var(--toggle-shadow);
}

.theme-switch-thumb {
  position: absolute;
  top: 50%;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  background: var(--bg-800);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.28);
  transform: translate(0, -50%);
  transition: transform 0.25s ease, background 0.25s ease, box-shadow 0.25s ease !important;
}

.theme-switch-input:checked + .theme-switch-control {
  border-color: var(--accent-500);
  background: linear-gradient(145deg, var(--accent-500), var(--accent-700));
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06), var(--toggle-shadow);
}

.theme-switch-input:checked + .theme-switch-control .theme-switch-thumb {
  transform: translate(28px, -50%);
}

.theme-icon {
  font-size: 0.9rem;
  line-height: 1;
}

.theme-switch-thumb .theme-icon {
  position: absolute;
  inset: 0;
  margin: auto;
  width: 100%;
  height: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  opacity: 0;
  transform: scale(0.82) rotate(-14deg);
  transition: opacity 0.22s ease, transform 0.28s ease, color 0.22s ease !important;
}

body.theme-discord .theme-switch-thumb .theme-icon-moon {
  opacity: 1;
  transform: scale(1) rotate(0deg);
  color: var(--accent-300);
}

body.theme-king .theme-switch-thumb .theme-icon-bolt {
  opacity: 1;
  transform: scale(1) rotate(0deg);
  color: var(--badge-500);
}

body.theme-king .theme-switch-thumb .theme-icon-moon {
  opacity: 0;
  transform: scale(0.82) rotate(-18deg);
}

body.theme-discord .theme-switch-thumb .theme-icon-bolt {
  opacity: 0;
  transform: scale(0.82) rotate(18deg);
}

@media (max-width: 1080px) {
  nav .content .links {
    gap: 3px;
  }

  .content .links li a {
    height: 36px;
    padding: 0 10px;
    font-size: 0.8rem;
  }

  .content .links li a.icon-link {
    width: 36px;
    min-width: 36px;
  }

  .nav-auth .auth-btn {
    min-width: 92px;
    height: 38px;
    font-size: 0.78rem;
  }
}

@media (max-width: 900px) {
  nav .menu-icon {
    display: inline-flex;
  }

  body.nav-open {
    overflow: hidden;
  }

  nav .content {
    justify-content: flex-end;
    display: flex;
    align-items: center;
  }

  nav .content .brand {
    margin-right: auto;
  }

  /* Avatar visível na barra principal */
  .nav-auth {
    position: static;
    margin-left: auto;
    margin-right: 8px;
    order: 3;
  }

  nav .content .links {
    position: fixed;
    top: 74px;
    left: -100%;
    width: min(88vw, 340px);
    height: calc(100dvh - 74px);
    overflow-y: auto;
    padding: 20px 14px calc(90px + env(safe-area-inset-bottom, 0px));
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
    background: var(--nav-bg-mobile);
    border-right: 1px solid var(--border-500);
    box-shadow: var(--shadow-lg);
    opacity: 0;
    visibility: hidden;
    transform: translateX(-16px);
    pointer-events: none;
    overscroll-behavior: contain;
    transition: left 0.3s ease, opacity 0.3s ease, transform 0.3s ease !important;
  }

  nav #show-menu:checked ~ .content .links {
    left: 0;
    opacity: 1;
    visibility: visible;
    transform: translateX(0);
    pointer-events: auto;
  }

  .content .links li {
    width: 100%;
  }

  .content .links li a {
    width: 100%;
    justify-content: flex-start;
    height: 42px;
    border-radius: 10px;
    padding: 0 12px;
    font-size: 0.9rem;
    line-height: 1.28;
  }

  .content .links li a:hover {
    transform: translateX(1px);
  }

  .content .links li a.icon-link {
    justify-content: center;
    font-size: 1.1rem;
  }

  /* Mobile: mostrar ícones e texto */
  .modern-nav .nav-link {
    gap: 10px;
  }

  .modern-nav .nav-link i {
    font-size: 1.1rem;
    min-width: 20px;
  }

  .modern-nav .nav-link-icon {
    width: 100%;
    justify-content: flex-start;
    padding: 0 12px;
  }

  .modern-nav .nav-link-icon span {
    display: inline;
  }

  .modern-nav .nav-link-icon i {
    margin-right: 10px;
  }

  .nav-theme {
    width: 100%;
    height: 42px;
    padding: 0 12px;
    display: flex;
    align-items: center;
    justify-content: flex-start;
  }

  .nav-auth .auth-btn {
    width: 100%;
    justify-content: center;
  }

  .mobile-only {
    display: none;
  }

  .user-avatar-container {
    display: inline-flex;
  }

  .user-avatar {
    width: 60px;
    height: 60px;
  }

  nav .content .links .nav-auth {
    display: none;
  }
}

@media (max-width: 560px) {
  .wrapper nav {
    min-height: 66px;
  }

  nav .content .brand {
    font-size: 0.96rem;
  }

  .content .brand span {
    max-width: min(50vw, 210px);
    font-size: 0.92rem;
  }

  .content .brand img {
    width: 50px;
    height: 50px;
  }

  nav .content .links {
    top: 66px;
    height: calc(100dvh - 66px);
  }

  .content .links li a {
    height: 40px;
    font-size: 0.84rem;
  }

  .nav-theme {
    height: 40px;
  }

  .user-avatar {
    width: 50px;
    height: 50px;
  }

  .nav-auth .auth-btn {
    height: 36px;
    min-width: 86px;
    font-size: 0.75rem;
    letter-spacing: 0.02em;
  }
}

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