/* =====================================================================
   CAMADA VISUAL DO REDESIGN (protótipo v4) — ESTRUTURA
   Sidebar esquerda, área principal, painel de perfil, telas de acesso e
   responsivo. Usa os nomes de classe que o site já tem (o JS depende
   deles); os nomes do protótipo aparecem no comentário de cada bloco.
   Carregada depois de ui.css.
   ===================================================================== */

.app-shell {
  display: block;
  min-height: 100vh;
  background: var(--bg);
}

/* Sidebar esquerda (protótipo: .sidebar) ----------------------------- */
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  width: var(--sidebar-w);
  padding: 26px 14px 16px;
  background: var(--bg-side);
  border-right: 1px solid var(--border);
}

/* protótipo: .brand */
.sidebar-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 22px;
  padding: 16px 0 28px;
}

.sidebar-brand .medallion {
  --size: 78px;
}

.sidebar-brand-logo {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  box-shadow: 0 0 0 1px var(--accent-line), 0 12px 30px -12px rgba(0, 0, 0, 0.7);
}

.brand-name {
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.32em;
  margin-right: -0.32em;
  color: var(--text-2);
}

/* protótipo: .nav */
.sidebar-nav {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}

.nav-indicator {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 40px;
  border-radius: var(--r-sm);
  background: var(--accent-soft);
  box-shadow: inset 2px 0 0 var(--accent);
  transition: transform 260ms var(--ease-in-out);
  pointer-events: none;
}

.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  height: 40px;
  padding: 0 12px;
  border: 0;
  border-radius: var(--r-sm);
  background: none;
  color: var(--text-2);
  font-size: 13.5px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: color 200ms ease, background-color 200ms ease;
}

.nav-item > i {
  font-size: 18px;
  transition: transform 240ms var(--ease-out);
}

.nav-item.active {
  color: var(--accent);
}

.nav-rune {
  margin-left: auto;
  font-family: var(--font-rune);
  font-size: 14px;
  opacity: 0;
  transform: translateX(-6px);
  transition: opacity 220ms ease, transform 260ms var(--ease-out);
}

.nav-item.active .nav-rune {
  opacity: 0.9;
  transform: none;
}

@media (hover: hover) and (pointer: fine) {
  .nav-item:not(.active):hover {
    color: var(--text);
    background: var(--surface-hover);
  }
  .nav-item:not(.active):hover .nav-rune {
    opacity: 0.35;
    transform: none;
  }
  .nav-item:hover > i {
    transform: scale(1.08);
  }
}

.sidebar-footer {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-top: 14px;
  margin-top: 14px;
  border-top: 1px solid var(--border);
}

/* protótipo: .side-btn */
.side-btn,
.sound-toggle-btn,
.logout-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 36px;
  padding: 0 12px;
  border: 0;
  border-radius: var(--r-sm);
  background: none;
  color: var(--text-3);
  font-size: 13px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: color 200ms ease, background-color 200ms ease, transform 160ms var(--ease-out);
}

.side-btn i,
.sound-toggle-btn i,
.logout-btn i {
  font-size: 17px;
}

.side-btn:active,
.sound-toggle-btn:active,
.logout-btn:active {
  transform: scale(0.97);
}

.logout-btn:hover {
  color: var(--danger);
  background: var(--danger-soft);
}

.sound-toggle-btn:hover,
.side-btn:hover {
  color: var(--text);
  background: var(--surface-hover);
}

/* Entrar como master / Voltar: em destaque, pra ninguém esquecer em qual usuário está. */
.side-btn-master {
  color: var(--accent);
  background: var(--accent-soft);
}
.side-btn-master:hover {
  color: var(--accent);
  background: var(--accent-soft);
  filter: brightness(1.15);
}

/* O JS só liga/desliga a classe `muted` e troca o texto do rótulo: quem
   troca o ícone é o CSS (ver activity-alert.js#initActivitySoundToggle). */
.sound-toggle-btn .ph-speaker-slash {
  display: none;
}

.sound-toggle-btn.muted .ph-speaker-high {
  display: none;
}

.sound-toggle-btn.muted .ph-speaker-slash {
  display: inline;
}

.side-btn.rain[aria-checked="true"] > i {
  color: var(--accent);
}

/* Botão que oculta os dois painéis laterais de uma vez ---------------- */
.toggle-sidebars-btn {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 30;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--text-3);
  cursor: pointer;
  transition: color 200ms ease, border-color 200ms ease, background-color 200ms ease;
}

.toggle-sidebars-btn:hover {
  color: var(--accent);
  border-color: var(--accent-line);
  background: var(--accent-soft);
}

/* Conteúdo (protótipo: .main / .page) -------------------------------- */
.main-content {
  position: relative;
  z-index: 1;
  min-width: 0;
  margin-left: var(--sidebar-w);
  margin-right: var(--profile-w);
  padding: 36px 44px 120px;
}

.page-section {
  max-width: 1120px;
  margin: 0 auto;
}

/* =====================================================================
   SEM GUILDA
   Mesma regra do botão de ocultar painéis, só que sem volta: quem não
   está em guilda nenhuma não tem o que ver nos dois lados, então o
   próprio botão de mostrar sai junto (ver app.js#modoSemGuilda).
   ===================================================================== */
.app-shell.sem-guilda .sidebar,
.app-shell.sem-guilda .profile-sidebar,
.app-shell.sem-guilda .toggle-sidebars-btn {
  display: none;
}

.app-shell.sem-guilda .main-content {
  margin-left: 0;
  margin-right: 0;
}

/* A barra que substitui os painéis: logo, de quem é a conta, e o Sair
   — que morava no painel da esquerda. */
.sem-guilda-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 22px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}

.sem-guilda-marca {
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: var(--font-display);
  font-size: 15px;
  letter-spacing: 0.04em;
  color: var(--text-2);
}

.sem-guilda-marca img {
  width: 38px;
  height: 38px;
  border-radius: 50%;
}

/* O aviso de quem não tem nem o Timer: centralizado, sem mais nada na
   tela pra competir com ele. */
.sem-guilda-aviso {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  min-height: 55vh;
  text-align: center;
}

.sem-guilda-aviso .medallion {
  --size: 148px;
  width: 148px;
  height: 148px;
}

.sem-guilda-aviso .sidebar-brand-logo {
  width: 100%;
  height: 100%;
  border-radius: 50%;
}

.sem-guilda-aviso h2 {
  font-family: var(--font-display);
  font-size: 26px;
  letter-spacing: 0.04em;
}

.sem-guilda-aviso p {
  font-size: 14px;
  color: var(--text-3);
}

/* Fileira de ações da aba Admin — Sem guilda. */
.sem-guilda-acoes {
  display: flex;
  align-items: center;
  gap: 8px;
}

.app-shell.sidebars-hidden .sidebar,
.app-shell.sidebars-hidden .profile-sidebar {
  display: none;
}

.app-shell.sidebars-hidden .main-content {
  margin-left: 0;
  margin-right: 0;
}

.app-shell.sidebars-hidden .toggle-sidebars-btn svg {
  transform: rotate(180deg);
}

/* Cabeçalho de página (components/page-header.js) --------------------- */
.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.page-header h2 {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 600;
  letter-spacing: 0.02em;
  line-height: 1.15;
}

.page-header p {
  margin-top: 6px;
  font-size: 13.5px;
  color: var(--text-2);
}

/* Entrada de página: cada bloco sobe em sequência. */
.page-section.is-entering > * {
  animation: rise 360ms var(--ease-out) both;
  animation-delay: calc(var(--i, 0) * 45ms);
}

.page-section.is-entering .rune-rule::before,
.page-section.is-entering .rune-rule::after {
  animation: grow 700ms var(--ease-out) 80ms both;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(10px);
    filter: blur(3px);
  }
}

@keyframes grow {
  from {
    transform: scaleX(0);
  }
}

.stagger > * {
  animation: rise 320ms var(--ease-out) both;
  animation-delay: calc(var(--i, 0) * 40ms);
}

/* No Ranking (e ao trocar de mapa no Timer) a barra cresce do zero. */
.stagger .progress i {
  animation: bar-grow 900ms var(--ease-out) both;
  animation-delay: calc(var(--i, 0) * 40ms + 150ms);
}

@keyframes bar-grow {
  from {
    transform: scaleX(0);
  }
}

.countdown.urgent {
  color: var(--danger);
}

/* Painel de perfil (protótipo: .profile) ------------------------------ */
.profile-sidebar {
  position: fixed;
  inset: 0 0 0 auto;
  z-index: 20;
  width: var(--profile-w);
  padding: 30px 16px 20px;
  overflow-y: auto;
  background: var(--bg-side);
  border-left: 1px solid var(--border);
}

.sidebar-profile {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.sidebar-profile-avatar-wrap {
  position: relative;
  width: 78px;
  height: 78px;
  margin: 12px 0 18px;
  flex-shrink: 0;
}

.sidebar-profile-avatar {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  background: radial-gradient(circle at 35% 30%, var(--accent-soft), transparent 70%), var(--surface-2);
  border: 2px solid var(--accent-line);
}

.sidebar-profile-level {
  position: absolute;
  right: -4px;
  bottom: -2px;
  min-width: 26px;
  height: 22px;
  padding: 0 6px;
  border-radius: var(--r-pill);
  border: 2px solid var(--bg-side);
  background: var(--accent);
  color: var(--accent-ink);
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 11.5px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sidebar-profile-edit-btn {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text-2);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 160ms var(--ease-out), color 200ms ease, border-color 200ms ease;
}

.sidebar-profile-edit-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.sidebar-profile-edit-btn:active {
  transform: scale(0.92);
}

.sidebar-profile-nick {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.sidebar-profile-class {
  margin-top: 6px;
}

/* DKP e Poder numa linha só, direto embaixo da classe (sem quadro próprio). Se faltar largura,
   o Poder desce centralizado em vez de estourar. */
.sidebar-profile-stats {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 4px 14px;
  margin-top: 8px;
}

.sidebar-profile-dkp,
.sidebar-profile-power {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin: 0;
  font-size: 13.5px;
  font-weight: 600;
}

/* DKP e Poder na mesma cor de destaque (amarelo/dourado). */
.sidebar-profile-dkp,
.sidebar-profile-power {
  color: var(--accent);
}

.sidebar-profile-power-value {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.sidebar-profile-power-label {
  font-size: 11px;
  font-weight: 500;
  opacity: 0.75;
}

/* protótipo: .profile-guild */
.sidebar-guild-switcher {
  width: 100%;
  margin-top: 16px;
  text-align: left;
}

.sidebar-guild-switcher label {
  display: block;
  margin-bottom: 6px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-3);
}

.sidebar-guild-switcher .select {
  height: 36px;
  font-size: 13px;
}

/* =====================================================================
   TELAS DE ACESSO
   ===================================================================== */
.auth-page {
  position: relative;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 48px 20px 90px;
  background: var(--bg);
}

.auth-tools {
  position: absolute;
  top: 18px;
  right: 18px;
  display: flex;
  align-items: center;
  gap: 8px;
  z-index: 2;
}

.auth-tools .segmented {
  width: 180px;
}

.auth-card {
  position: relative;
  z-index: 1;
  width: min(420px, 100%);
}

.auth-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  margin-bottom: 30px;
  text-align: center;
}

.auth-brand .medallion,
.auth-brand .auth-mark {
  --size: 132px;
  position: relative;
  width: 132px;
  height: 132px;
  margin: 30px 0 22px;
}

.auth-brand .auth-mark img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  -webkit-mask-image: none;
  mask-image: none;
  background: #080810;
  box-shadow: 0 0 0 1px var(--accent-line), 0 12px 30px -12px rgba(0, 0, 0, 0.7);
}

.auth-brand h1 {
  font-family: var(--font-display);
  font-size: 30px;
  font-weight: 600;
  letter-spacing: 0.08em;
}

.auth-brand p {
  margin-top: -10px;
  font-size: 13.5px;
  color: var(--text-2);
}

.auth-footnote {
  margin-top: 18px;
  text-align: center;
  font-size: 12px;
  color: var(--text-3);
}

.auth-page .card-title {
  display: block;
  margin-bottom: 16px;
  font-family: var(--font-display);
  font-size: 16px;
  letter-spacing: 0.03em;
}

.picker,
.image-picker-button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 72px;
  height: 72px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--r-md);
  background: var(--input-bg);
  color: var(--text-3);
  font-size: 22px;
  cursor: pointer;
  overflow: hidden;
  transition: color 200ms ease, border-color 200ms ease, transform 160ms var(--ease-out);
}

.picker:hover,
.image-picker-button:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.picker:active,
.image-picker-button:active {
  transform: scale(0.96);
}

.hourglass {
  display: inline-flex;
  font-size: 34px;
  color: var(--accent);
  animation: hourglass 3.2s var(--ease-in-out) infinite;
}

@keyframes hourglass {
  0%,
  40% {
    transform: rotate(0);
  }
  50%,
  90% {
    transform: rotate(180deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

/* Transição de tema (View Transitions): o círculo cresce a partir do botão. */
::view-transition-old(root),
::view-transition-new(root) {
  animation: none;
  mix-blend-mode: normal;
}

/* =====================================================================
   RESPONSIVO  (1240 / 1000 / 860, como no protótipo)
   ===================================================================== */
@media (max-width: 1240px) {
  .main-content {
    margin-right: 0;
  }
  .profile-sidebar {
    position: static;
    width: auto;
    margin-left: var(--sidebar-w);
    border-left: 0;
    border-top: 1px solid var(--border);
    padding: 28px 44px 110px;
  }
  .sidebar-guild-switcher {
    max-width: 420px;
  }
  /* width: 100% pra acompanhar o card de Poder (até 420px) — sem isso os
     dois quadros encolhiam pro tamanho do conteúdo, estreitos no meio. */
  #spots-widget,
  #guild-participation-widget,
  #boss-timer-widget {
    width: 100%;
    max-width: 420px;
    margin-left: auto;
    margin-right: auto;
  }
}

@media (max-width: 860px) {
  .toggle-sidebars-btn {
    display: none;
  }
  .sidebar {
    position: sticky;
    top: 0;
    width: 100%;
    flex-direction: row;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-right: 0;
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
  }
  .sidebar-brand {
    flex-direction: row;
    padding: 0 8px 0 0;
    gap: 10px;
  }
  .sidebar-brand .medallion {
    --size: 36px;
    width: 36px;
    height: 36px;
  }
  .sidebar-brand .rune-ring,
  .brand-name {
    display: none;
  }
  .sidebar-nav {
    flex-direction: row;
    flex: none;
  }
  .nav-indicator {
    display: none;
  }
  .nav-item {
    flex-shrink: 0;
  }
  .nav-item.active {
    background: var(--accent-soft);
  }
  .nav-rune {
    display: none;
  }
  .sidebar-footer {
    flex-direction: row;
    align-items: center;
    border-top: 0;
    border-left: 1px solid var(--border);
    margin: 0;
    padding: 0 0 0 10px;
  }
  .sidebar-footer .segmented {
    width: 150px;
    flex-shrink: 0;
  }
  .side-btn span:not(.switch),
  .sound-toggle-btn .sound-toggle-label,
  .logout-btn span {
    display: none;
  }
  .main-content {
    margin-left: 0;
    padding: 24px 16px 110px;
  }
  .profile-sidebar {
    margin-left: 0;
    padding: 24px 16px 110px;
  }
  .field-row {
    grid-template-columns: 1fr;
  }
  .page-header h2 {
    font-size: 24px;
  }
  .auth-tools {
    position: static;
    justify-content: center;
    margin: 0 auto 10px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .page-section.is-entering > *,
  .stagger > * {
    animation-name: fade;
    animation-delay: 0ms;
  }
  .stagger .progress i {
    animation: none;
  }
  .page-section.is-entering .rune-rule::before,
  .page-section.is-entering .rune-rule::after {
    animation: none;
  }
  @keyframes fade {
    from {
      opacity: 0;
    }
  }
  .nav-indicator,
  .tabs-indicator,
  .segmented-thumb {
    transition: none;
  }
  .hourglass {
    animation: none;
  }
}
