/* ==========================================================================
   MINI HOST - AUTENTICACAO: TELA DE LOGIN E CAMADA COMPARTILHADA DE TRANSICAO
   Carregado por todas as paginas (HEAD_STYLES em server/core/static.js) e pelo login.html.

   Conteudo:
   - Login (.auth-standalone-page, .auth-card e filhos): uso exclusivo do login.html.
   - Camada transitoria de cabecalho (secoes 3 a 5 e modo claro): consumida por todos os modulos.
     Dívida: migrar para public/shared/css/header.css junto com as regras duplicadas dos
     style.css dos modulos (cards MDL-* e dono do header.css); ate la nao sair daqui sem
     conferir a cascata dos modulos.

   Sobre o uso de important: o badge do usuario (.auth-user-*) e as propriedades sem redeclaracao
   concorrente ja saem sem important. Todo important restante nas secoes 3 a 5 e no modo claro e intencional.
   Esta camada precisa vencer as regras de cabecalho que os style.css dos modulos (carregados
   depois do auth.css) ainda redeclaram (.app-header, .header-brand, .brand-icon,
   .header-actions, .status-badge, .header-btn:hover etc.) e o estilo
   inline/JS dos modulos. Remover um por um muda a cascata de quem depende dele.
   A tela de login (secoes sem cabecalho) nao usa important.
   ========================================================================== */

/* PADRÃO DARK MODE NATIVO PARA FORMULÁRIOS & SELECTS
   Mantido aqui de proposito: o login.html nao carrega o base.css; e, nos modulos, esta regra sem
   camada vence o color-scheme claro de shared/themes/light/tokens.css (que esta em @layer tokens). Mudar isso
   altera selects e barras de rolagem do modo claro em todos os modulos. */
:root {
  color-scheme: dark;
}

select {
  color-scheme: dark;
  background-color: #0d1527;
  color: #f1f5f9;
}

select option,
select optgroup {
  background-color: #0b0f19;
  color: #f1f5f9;
}

select option:checked,
select option:hover {
  background-color: #1e293b;
  color: #ffffff;
}

/* PÁGINA AUTÔNOMA DE LOGIN (SERVER-SIDE GATEKEEPER) */
.auth-standalone-page {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  background: radial-gradient(circle at 50% 20%, rgba(30, 41, 59, 0.95), rgba(7, 10, 19, 0.98));
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  color: #f8fafc;
  position: relative;
  overflow-x: hidden;
}

.auth-standalone-page::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image: url('/cat-bg.svg');
  background-size: 340px 340px;
  background-repeat: repeat;
  opacity: 0.75;
  animation: authCatDrift 110s linear infinite;
}

@keyframes authCatDrift {
  0% { background-position: 0 0; }
  100% { background-position: 320px 640px; }
}

.auth-page-container {
  width: 100%;
  max-width: 440px;
  padding: var(--space-16);
  position: relative;
  z-index: 1;
  display: flex;
  justify-content: center;
}

/* 1. OVERLAY DE LOGIN BLOQUEANTE (FULLSCREEN) */
#miniHostAuthOverlay {
  position: fixed;
  inset: 0;
  z-index: 999999;
  background: radial-gradient(circle at 50% 20%, rgba(30, 41, 59, 0.95), rgba(7, 10, 19, 0.98));
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-24);
  animation: authFadeIn 0.35s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes authFadeIn {
  from {
    opacity: 0;
    transform: scale(0.98);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* 2. CARD CENTRAL DE LOGIN */
.auth-card {
  position: relative;
  width: 100%;
  max-width: 420px;
  background: rgba(15, 23, 42, 0.75);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-xl, 28px);
  padding: 36px var(--space-24);
  text-align: center;
  box-shadow: 0 25px 60px -15px rgba(0, 0, 0, 0.8),
    0 0 50px -10px rgba(99, 102, 241, 0.2);
  overflow: hidden;
}

.auth-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 10%;
  right: 10%;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(99, 102, 241, 0.6), rgba(168, 85, 247, 0.6), transparent);
}

/* ÍCONE DO GATINHO COM GLOW */
.auth-brand-badge {
  position: relative;
  width: 80px;
  height: 80px;
  margin: 0 auto var(--space-16);
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.15), rgba(168, 85, 247, 0.15));
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-xl, 24px);
  box-shadow: 0 10px 25px rgba(99, 102, 241, 0.25);
}

.auth-cat-icon {
  width: 48px;
  height: 48px;
  object-fit: contain;
  filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.4));
  animation: authPulse 3s ease-in-out infinite;
}

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

.auth-title {
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  font-size: 1.6rem;
  font-weight: 800;
  color: #f8fafc;
  margin: 0 0 var(--space-6);
  letter-spacing: -0.02em;
}

.auth-tagline {
  display: inline-flex;
  align-items: center;
  gap: var(--space-6);
  padding: var(--space-4) var(--space-12);
  background: rgba(99, 102, 241, 0.12);
  border: 1px solid rgba(99, 102, 241, 0.25);
  border-radius: var(--radius-pill, 999px);
  font-size: 0.78rem;
  font-weight: 700;
  color: #a5b4fc;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: var(--space-16);
}

.auth-desc {
  font-size: 0.92rem;
  color: #94a3b8;
  line-height: 1.5;
  margin: 0 0 var(--space-24);
}

/* CONTAINER DO BOTÃO DO GOOGLE */
.auth-google-wrapper {
  display: flex;
  justify-content: center;
  min-height: 46px;
  margin-bottom: var(--space-16);
}

/* CAIXA DE ERRO / ALERTA */
.auth-error-box {
  display: none;
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: var(--radius-lg, 14px);
  padding: var(--space-12) var(--space-12);
  margin-bottom: var(--space-16);
  color: #fca5a5;
  font-size: 0.85rem;
  line-height: 1.4;
  text-align: left;
  animation: authFadeIn 0.2s ease-out forwards;
}

.auth-error-box.visible {
  display: flex;
  align-items: flex-start;
  gap: var(--space-8);
}

.auth-error-icon {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  color: #ef4444;
  margin-top: 1px;
}

.auth-footer-note {
  font-size: 0.74rem;
  color: #64748b;
  margin-top: var(--space-16);
}

/* 3. PADRONIZAÇÃO GLOBAL DE CABEÇALHOS (DISCRETO & MOBILE-FRIENDLY)
   important intencional (ver o cabecalho do arquivo): vence os style.css dos modulos.
   O cabeçalho não deve roubar a atenção do conteúdo principal; é sutil, compacto e ultra responsivo. */
.app-header,
.hub-header {
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  flex-wrap: nowrap !important;
  gap: var(--space-8) !important;
  padding: var(--space-6) 0 var(--space-12) !important;
  margin-bottom: var(--space-4) !important;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07) !important;
  min-height: 44px;
}

/* LADO ESQUERDO: MARCA / IDENTIDADE */
.header-left,
.header-brand {
  display: flex !important;
  align-items: center !important;
  gap: var(--space-8) !important;
  min-width: 0 !important;
  flex-shrink: 1;
}

.brand-icon,
.app-header-cat {
  width: 24px;
  height: 24px;
  border-radius: var(--radius-sm, 6px);
  box-shadow: none;
  flex-shrink: 0;
  object-fit: contain;
}

/* Logo do Hub (.brand-cat-img): width, height e border-radius ainda são redeclarados por header.css e style.css */
.brand-cat-img {
  width: 24px !important;
  height: 24px !important;
  border-radius: var(--radius-sm, 6px) !important;
  box-shadow: none;
  flex-shrink: 0;
  object-fit: contain;
}

.header-left h1,
.header-brand h1,
.app-header h1,
.hub-header h1 {
  font-size: 1.05rem !important;
  font-weight: 700 !important;
  color: #f8fafc !important;
  margin: 0 !important;
  letter-spacing: -0.01em !important;
  display: inline-flex !important;
  align-items: center !important;
  padding: 0;
  gap: var(--space-6);
  white-space: nowrap;
  line-height: 1.1;
  text-overflow: ellipsis;
  overflow: hidden;
}


/* LADO DIREITO: AÇÕES & USUÁRIO */
.header-right,
.header-actions {
  display: inline-flex !important;
  align-items: center !important;
  gap: var(--space-6) !important;
  justify-content: flex-end;
  flex-shrink: 0;
  flex-wrap: nowrap;
}

/* BOTÕES DE CABEÇALHO PADRONIZADOS (Elegantes e sem destaque excessivo) */
.header-btn,
.btn-action,
.btn-notify-hub {
  height: 32px !important;
  min-height: 32px;
  padding: 0 var(--space-12) !important;
  background: rgba(255, 255, 255, 0.05) !important;
  border: 1px solid rgba(255, 255, 255, 0.10) !important;
  border-radius: var(--radius-pill, 9999px) !important;
  color: #cbd5e1 !important;
  font-size: 0.78rem !important;
  font-weight: 600 !important;
  font-family: inherit !important;
  text-decoration: none !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center;
  gap: var(--space-4) !important;
  cursor: pointer !important;
  transition: all 0.15s ease !important;
  box-shadow: none !important;
  flex-shrink: 0 !important;
  white-space: nowrap;
}

/* .header-btn: cores por token de tema (.btn-action e .btn-notify-hub ficam com os valores acima). O valor de reserva de
   cada var() é o do Escuro: vale no login.html, que carrega só o auth.css (sem os tokens de tema do base.css). */
.header-btn {
  background: var(--header-btn-bg, rgba(255, 255, 255, 0.05)) !important;
  border: 1px solid var(--header-btn-border, rgba(255, 255, 255, 0.10)) !important;
  color: var(--header-btn-text, #cbd5e1) !important;
  box-shadow: var(--control-shadow, none) !important;
}

.header-btn:hover,
.btn-action:hover,
.btn-notify-hub:hover {
  background: rgba(255, 255, 255, 0.10) !important;
  color: #ffffff !important;
  border-color: rgba(255, 255, 255, 0.22) !important;
  transform: translateY(-1px) !important;
}

.header-btn:hover {
  background: var(--header-btn-bg-hover, rgba(255, 255, 255, 0.10)) !important;
  color: var(--header-btn-text-hover, #ffffff) !important;
  border-color: var(--header-btn-border-hover, rgba(255, 255, 255, 0.22)) !important;
  box-shadow: var(--control-shadow-hover, none) !important;
}

/* Rótulo do botão (.header-btn-text): currentcolor = herda a cor do botão (o Claro fixa o rótulo em --text-muted) */
.header-btn-text {
  color: var(--header-btn-label, currentcolor);
}

/* Ativo (.header-btn.active): :where() mantém a especificidade de .header-btn, para o tema que estiliza o botão com
   seletor próprio (cyberpunk) continuar vencendo. No escuro os tokens repetem o botão comum. */
.header-btn:where(.active) {
  background: var(--header-btn-active-bg, rgba(255, 255, 255, 0.05)) !important;
  border-color: var(--header-btn-active-border, rgba(255, 255, 255, 0.10)) !important;
  color: var(--header-btn-active-text, #cbd5e1) !important;
  box-shadow: var(--header-btn-active-shadow, none) !important;
}

.header-btn:where(.active):hover {
  background: var(--header-btn-active-bg-hover, rgba(255, 255, 255, 0.10)) !important;
  border-color: var(--header-btn-active-border-hover, rgba(255, 255, 255, 0.22)) !important;
  color: var(--header-btn-active-text-hover, #ffffff) !important;
  box-shadow: var(--header-btn-active-shadow-hover, none) !important;
}

.header-btn:active,
.btn-action:active,
.btn-notify-hub:active {
  transform: scale(0.96) !important;
}

.header-btn svg,
.btn-action svg,
.btn-notify-hub svg {
  width: 14px !important;
  height: 14px !important;
  flex-shrink: 0 !important;
}

/* 4. BADGE DO USUÁRIO LOGADO NO CABEÇALHO (markup montado por auth.js; important intencional: o
   cabecalho dos modulos redefine botoes e spans e o badge nao pode ser alterado por eles) */
.auth-user-badge {
  display: inline-flex !important;
  align-items: center !important;
  gap: var(--space-6) !important;
  height: 32px !important;
  background: var(--auth-badge-bg, rgba(15, 23, 42, 0.65)) !important;
  border: 1px solid var(--auth-badge-border, rgba(255, 255, 255, 0.10)) !important;
  backdrop-filter: blur(12px) !important;
  -webkit-backdrop-filter: blur(12px) !important;
  border-radius: var(--radius-pill, 999px) !important;
  padding: 0 var(--space-8) 0 var(--space-4) !important;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1) !important;
  flex-shrink: 0 !important;
  box-shadow: var(--auth-badge-shadow, none) !important;
  cursor: pointer !important;
  user-select: none !important;
}

/* Perfil pendente (settings-profile.js, syncProfilePending): ponto de aviso no canto do badge até salvar o perfil */
.auth-user-badge.has-pending {
  position: relative !important;
}

.auth-user-badge.has-pending::after {
  content: '';
  position: absolute;
  top: -2px;
  right: -2px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--status-warning-text);
  box-shadow: 0 0 0 2px var(--bg-main);
  pointer-events: none;
}

.auth-user-badge:hover {
  background: rgba(30, 41, 59, 0.8);
  border-color: rgba(255, 255, 255, 0.2);
  transform: translateY(-1px);
}

.auth-user-avatar {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  object-fit: cover;
  background: #1e293b;
  border: 1px solid #60a5fa;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  font-weight: 700;
  color: #f8fafc;
  flex-shrink: 0;
}

.auth-user-name {
  font-size: 0.76rem;
  font-weight: var(--auth-name-weight, 600);
  color: var(--auth-name-text, #cbd5e1);
  max-width: 80px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: -0.01em;
}

/* 5. RESPONSIVIDADE MOBILE IMPECÁVEL (important intencional: precisa vencer as regras da secao 3 e dos modulos) */
@media (max-width: 640px) {
  /* Em telas médias/pequenas, recolhe rótulos textuais dos botões para deixar apenas ícones elegantes */
  .header-btn-text {
    display: none;
  }

  .btn-action span,
  .btn-notify-hub span {
    display: none !important;
  }

  .header-btn,
  .btn-action,
  .btn-notify-hub {
    width: 32px;
    padding: 0 !important;
    justify-content: center;
  }
}

@media (max-width: 480px) {
  /* No smartphone, esconde o nome do usuário para caber tudo em 1 linha sem quebra */
  .auth-user-name {
    display: none !important;
  }

  /* Sem o nome, o badge vira um circulo (32x32) com a foto centralizada; important para vencer o padding da secao 4 */
  .auth-user-badge {
    width: 32px !important;
    padding: 0 !important;
    gap: 0 !important;
    justify-content: center !important;
  }

  .header-left h1,
  .header-brand h1,
  .app-header h1,
  .hub-header h1 {
    font-size: 0.98rem !important;
  }

  .header-right,
  .header-actions {
    gap: var(--space-4) !important;
  }
}

@media (max-width: 380px) {
  .header-right,
  .header-actions {
    gap: var(--space-2) !important;
  }

  .brand-icon,
  .app-header-cat {
    width: 22px;
    height: 22px;
  }

  .brand-cat-img {
    width: 22px !important;
    height: 22px !important;
  }
}

/* Link "Entrar" do badge local: important para vencer o style inline do auth.js */
.auth-login-link {
  background: var(--auth-login-bg, transparent) !important;
  border-color: var(--auth-login-border, currentcolor) !important;
  color: var(--auth-login-text, #94a3b8) !important;
}

.auth-login-link:hover {
  background: var(--auth-login-bg-hover, transparent) !important;
  color: var(--auth-login-text-hover, #94a3b8) !important;
}
