/* =====================================================================
   main.css — variáveis, tipografia, layout e responsividade.

   Paleta (Adobe Color, enviada pelo usuário) — todas partilham o mesmo
   canal azul (214), o que faz o conjunto soar como uma família só:
     #2D4ED6  azul-real   → profundidade, gradientes, brilho de foco
     #2D83D6  azul-céu    → informação, links, estados de leitura
     #6150D6  índigo      → AÇÃO: botões, itens ativos, seleção
     #4CBED6  ciano       → "ao vivo": chamada conectada, tela compartilhada
     #7729D6  violeta     → energia: hover da ação, ponta dos gradientes

   Direção visual: "profundidade fria". Os fundos têm subtom azul-violeta
   que escurece conforme o painel fica mais ao fundo (barra de servidores →
   sidebar → área principal), criando hierarquia por profundidade em vez de
   por borda. A cor saturada é gasta só onde há ação ou estado ao vivo.
   ===================================================================== */

/* ===================== VARIÁVEIS ===================== */
:root {
  /* Superfícies, da mais profunda para a mais elevada.
     O subtom agora puxa para o azul-real da paleta em vez de um cinza neutro. */
  --bg-sidebar: #0A0D18;   /* barra de servidores — o "fundo do poço" */
  --bg-channels: #111623;  /* sidebar de canais/amigos */
  --bg-main: #161B2B;      /* área principal */
  --bg-elevated: #1E2438;  /* cards, dock, superfícies levantadas */
  --bg-input: #242B42;     /* campos de entrada */
  --bg-hover: rgba(255, 255, 255, .045);
  --bg-active: rgba(255, 255, 255, .075);

  /* Traços sutis: em fundos escuros, uma borda clara de 1px lê como luz
     tocando a quina de uma superfície — dá volume sem pesar. */
  --line: rgba(255, 255, 255, .07);
  --line-strong: rgba(255, 255, 255, .13);

  /* Cores da paleta */
  --blue-royal: #2D4ED6;
  --blue-sky: #2D83D6;
  --indigo: #6150D6;
  --cyan: #4CBED6;
  --violet: #7729D6;

  /* Papéis semânticos */
  --accent: #6150D6;              /* índigo: a cor da ação */
  --accent-hover: #7729D6;        /* violeta: a ação "acesa" */
  --accent-soft: rgba(97, 80, 214, .18);
  --accent-glow: rgba(97, 80, 214, .5);
  --info: #2D83D6;                /* azul-céu: informação e links */
  --live: #4CBED6;                /* ciano: em chamada / compartilhando */

  --text-primary: #ECEFF7;
  --text-muted: #99A1BA;
  --text-faint: #626A84;

  --online: #3FD68C;   /* verde de presença: convenção que as pessoas já leem
                          sem legenda, então fica fora da paleta de propósito */
  --danger: #F05252;
  --danger-hover: #C8393A;
  --warn: #F5B544;

  --radius-sm: 7px;
  --radius: 11px;
  --radius-lg: 18px;

  --shadow-sm: 0 1px 2px rgba(0,0,0,.3);
  --shadow: 0 12px 32px -8px rgba(0,0,0,.55), 0 2px 8px rgba(0,0,0,.3);
  --shadow-lg: 0 28px 70px -16px rgba(0,0,0,.7), 0 4px 14px rgba(0,0,0,.35);

  --font-size-base: 15px;
  --density-gap: 3px;
  --font-display: "Space Grotesk", "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-body: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;

  --icon-speaker: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M11 5L6.5 9H3v6h3.5L11 19V5z'/%3E%3Cpath d='M16 9.4a3.5 3.5 0 0 1 0 5.2'/%3E%3C/svg%3E");

  --transition: 200ms cubic-bezier(.32, .72, 0, 1);
  --transition-slow: 380ms cubic-bezier(.32, .72, 0, 1);
}

[data-theme="light"] {
  --bg-sidebar: #E6E8EF;
  --bg-channels: #EFF1F6;
  --bg-main: #FBFCFE;
  --bg-elevated: #FFFFFF;
  --bg-input: #E9ECF3;
  --bg-hover: rgba(15, 20, 40, .045);
  --bg-active: rgba(15, 20, 40, .08);
  --line: rgba(15, 20, 40, .09);
  --line-strong: rgba(15, 20, 40, .16);
  --accent-soft: rgba(97, 80, 214, .13);
  --accent-glow: rgba(97, 80, 214, .32);
  --text-primary: #141721;
  --text-muted: #565D72;
  --text-faint: #858BA0;
  --shadow-sm: 0 1px 2px rgba(20, 23, 33, .07);
  --shadow: 0 12px 32px -10px rgba(20, 23, 33, .18), 0 2px 6px rgba(20, 23, 33, .06);
  --shadow-lg: 0 28px 70px -18px rgba(20, 23, 33, .24), 0 4px 12px rgba(20, 23, 33, .08);
}

[data-density="compact"] { --density-gap: 0px; }

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0; height: 100%;
  font-family: var(--font-body);
  font-size: var(--font-size-base);
  background: var(--bg-main);
  color: var(--text-primary);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
}
button, input, textarea, select { font-family: inherit; font-size: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; }
a { color: inherit; }
.hidden { display: none !important; }

/* Estilo base de <select> — precisa ser global (e não só dentro de .field),
   senão qualquer seletor solto na interface volta pro visual padrão do
   navegador, que é branco e ilegível sobre o tema escuro. A seta é
   desenhada como background porque `appearance:none` remove a nativa. */
select {
  appearance: none; -webkit-appearance: none;
  width: 100%; padding: 11px 38px 11px 13px;
  border-radius: var(--radius-sm);
  background-color: var(--bg-input);
  background-image: linear-gradient(45deg, transparent 50%, var(--text-muted) 50%),
                    linear-gradient(135deg, var(--text-muted) 50%, transparent 50%);
  background-position: calc(100% - 19px) calc(50% + 2px), calc(100% - 14px) calc(50% + 2px);
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  border: 1px solid var(--line);
  color: var(--text-primary); cursor: pointer; outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}
select:hover { border-color: var(--line-strong); }
select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
select:disabled { opacity: .5; cursor: not-allowed; }
/* O menu aberto é desenhado pelo sistema operacional; forçar as cores nas
   <option> é o que evita texto branco sobre fundo branco no Linux/Windows. */
select option { background: var(--bg-elevated); color: var(--text-primary); }

input[type=range] {
  accent-color: var(--accent); height: 4px; cursor: pointer;
}
input[type=checkbox] { accent-color: var(--accent); cursor: pointer; }

h1, h2, h3, .msg-author, .logo-mark {
  font-family: var(--font-display);
  letter-spacing: -.02em;
}

/* Foco visível e consistente para navegação por teclado */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

/* Barras de rolagem discretas, no tom da interface */
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--line-strong); border-radius: 99px;
  border: 2px solid transparent; background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover { background: var(--text-faint); background-clip: content-box; }

/* ===================== TELAS ===================== */
.screen { width: 100%; height: 100%; }

/* --- Autenticação ---
   Assinatura visual do app: uma aurora lenta ao fundo. É o único momento
   com movimento ambiente — o resto da interface é quieto de propósito,
   porque é onde a pessoa vai passar horas. */
.screen-auth {
  display: flex; align-items: center; justify-content: center;
  position: relative; overflow: hidden;
  background: var(--bg-sidebar);
}
.auth-bg {
  position: absolute; inset: -20%;
  background:
    radial-gradient(42% 46% at 20% 22%, rgba(45, 78, 214, .46), transparent 70%),
    radial-gradient(36% 40% at 80% 72%, rgba(76, 190, 214, .26), transparent 70%),
    radial-gradient(40% 38% at 66% 16%, rgba(119, 41, 214, .32), transparent 70%),
    radial-gradient(34% 36% at 34% 82%, rgba(45, 131, 214, .22), transparent 70%);
  filter: blur(28px);
  animation: auroraDrift 26s ease-in-out infinite alternate;
}
.auth-card {
  position: relative;
  width: min(408px, 90vw);
  background: color-mix(in srgb, var(--bg-main) 88%, transparent);
  backdrop-filter: blur(24px) saturate(1.4);
  border: 1px solid var(--line-strong);
  border-radius: 22px;
  padding: 38px 34px 32px;
  box-shadow: var(--shadow-lg);
}
.auth-logo { display: flex; align-items: center; gap: 13px; margin-bottom: 10px; }
.logo-mark {
  width: 42px; height: 42px; border-radius: 13px;
  background: linear-gradient(145deg, var(--blue-royal), var(--indigo) 55%, var(--violet));
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 21px; color: #fff;
  box-shadow: 0 6px 20px -4px var(--accent-glow);
}
.auth-logo h1 { font-size: 25px; margin: 0; font-weight: 600; }
.auth-sub { color: var(--text-muted); font-size: 13.5px; margin: 4px 0 26px; line-height: 1.6; }

.field { display: block; margin-bottom: 16px; }
.field span {
  display: block; font-size: 11px; font-weight: 600; text-transform: uppercase;
  color: var(--text-muted); margin-bottom: 7px; letter-spacing: .07em;
}
.field input, .field select {
  width: 100%; padding: 12px 14px; border-radius: var(--radius);
  border: 1px solid var(--line); background: var(--bg-input);
  color: var(--text-primary); outline: none;
  transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
}
.field input::placeholder { color: var(--text-faint); }
.field input:focus, .field select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3.5px var(--accent-soft);
}
.field-error { color: var(--danger); font-size: 13px; margin: -6px 0 14px; }

/* --- Estrutura do app --- */
.screen-app { display: flex; height: 100%; }

.server-rail {
  width: 76px; flex-shrink: 0; background: var(--bg-sidebar);
  display: flex; flex-direction: column; align-items: center;
  padding: 12px 0; gap: 9px; overflow-y: auto; overflow-x: hidden;
}
.server-rail::-webkit-scrollbar { width: 0; }
.rail-sep { width: 28px; height: 1.5px; background: var(--line-strong); border-radius: 2px; margin: 3px 0; }
.server-list { display: flex; flex-direction: column; gap: 9px; align-items: center; width: 100%; }

.side-panel {
  width: 252px; flex-shrink: 0; background: var(--bg-channels);
  display: flex; flex-direction: column; min-width: 0;
  border-right: 1px solid var(--line);
}
.side-header { padding: 13px 12px; border-bottom: 1px solid var(--line); }
.quick-search {
  width: 100%; padding: 8px 11px; border-radius: var(--radius-sm);
  border: 1px solid transparent; background: var(--bg-sidebar);
  color: var(--text-primary); outline: none; font-size: 13px;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.quick-search::placeholder { color: var(--text-faint); }
.quick-search:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.side-content { flex: 1; overflow-y: auto; padding: 10px 8px; }

.user-dock {
  flex-shrink: 0; background: var(--bg-sidebar); border-top: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between;
  padding: 9px 9px; gap: 6px;
}
.user-dock-info {
  display: flex; align-items: center; gap: 9px; min-width: 0; cursor: pointer;
  padding: 5px 6px; border-radius: var(--radius-sm); transition: background var(--transition);
}
.user-dock-info:hover { background: var(--bg-hover); }
.user-dock-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.user-dock-text strong { font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 104px; }
.user-dock-text small { font-size: 11px; color: var(--text-muted); }
.user-dock-actions { display: flex; gap: 1px; }

.main-area { flex: 1; display: flex; flex-direction: column; min-width: 0; background: var(--bg-main); }
.main-header {
  height: 54px; flex-shrink: 0; display: flex; align-items: center; justify-content: space-between;
  padding: 0 18px; border-bottom: 1px solid var(--line); gap: 12px;
}
.main-header-title {
  font-family: var(--font-display); font-weight: 600; font-size: 15.5px; letter-spacing: -.01em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.main-header-actions { display: flex; gap: 3px; }
.main-body { flex: 1; display: flex; min-height: 0; }

.empty-state {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  color: var(--text-muted); text-align: center; padding: 28px;
}
.empty-emoji {
  font-size: 44px; margin-bottom: 16px; width: 84px; height: 84px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 26px; background: var(--bg-elevated); border: 1px solid var(--line);
}
.empty-state h2 { margin: 0 0 8px; color: var(--text-primary); font-size: 20px; font-weight: 600; }
.empty-state p { margin: 0; font-size: 14px; max-width: 320px; line-height: 1.6; }

.chat-view { flex: 1; display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.members-panel {
  width: 232px; flex-shrink: 0; background: var(--bg-channels);
  border-left: 1px solid var(--line); overflow-y: auto; padding: 14px 9px;
}

.nav-toggle {
  position: fixed; top: 9px; left: 9px; z-index: 50;
  background: var(--bg-elevated); border: 1px solid var(--line); box-shadow: var(--shadow-sm);
}
/* Seletor por ID: sempre vence qualquer regra de classe (ex: .icon-btn
   { display:flex } definida depois em components.css), então o botão fica
   realmente escondido no desktop independentemente da ordem de
   carregamento das folhas de estilo. */
#mobile-nav-toggle { display: none; }
.mobile-only { display: none; }

/* ===================== RESPONSIVO ===================== */
@media (max-width: 860px) {
  .mobile-only { display: flex; }
  #mobile-nav-toggle { display: flex; }
  .server-rail, .side-panel {
    position: fixed; top: 0; bottom: 0; z-index: 40;
    transform: translateX(-100%); transition: transform var(--transition-slow);
  }
  .server-rail { left: 0; }
  .side-panel { left: 76px; box-shadow: var(--shadow-lg); }
  .screen-app.nav-open .server-rail,
  .screen-app.nav-open .side-panel { transform: translateX(0); }
  .members-panel { position: fixed; right: 0; top: 0; bottom: 0; z-index: 40; box-shadow: var(--shadow-lg); }
  .main-header { padding-left: 56px; }
  .icon-btn { min-height: 40px; min-width: 40px; }
  .call-controls { padding-bottom: calc(18px + env(safe-area-inset-bottom)); }
  .side-panel { width: min(268px, 82vw); }
  .user-dock { padding-bottom: calc(9px + env(safe-area-inset-bottom)); }
}
@media (min-width: 861px) {
  .server-rail, .side-panel { transform: none !important; position: relative; }
}
