/*
  ===================================================================
  Aura 1.0 - Design System
  Inspirado no SMID (Sistema Municipal de Inteligência de Dados)
  -------------------------------------------------------------------
  PAPEL DESTE ARQUIVO
  - Repositório único de aparência do Aura OS
  - Design system global (Tokens, Layout, Componentes)
  - Compatibilidade com sistema de mensagens e módulos futuros
  ===================================================================
*/

/* ==================================================================
   1) RESET E BASE
   ================================================================== */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
  overflow: hidden; /* Evita scroll no body, usamos no #tela */
}

/* ==================================================================
   2) DESIGN TOKENS (Design System)
   ================================================================== */
:root {
  /* --- Brand Tokens --- */
  --brand-green-500: #00A650; /* Verde Aura Principal */
  --brand-green-700: #00723A; /* Verde Aura Escuro */
  --brand-sand-050:  #f7f9f8; 
  --brand-sand-100:  #f5f5f5; 
  --brand-sand-200:  #e9e9e9; 
  --brand-gray-300:  #cccccc; 
  --brand-gray-500:  #666666; 
  --brand-gray-900:  #2b2b2b; 
  --brand-white:     #ffffff; 
  --brand-black-rgb: 0, 0, 0; 
  --brand-warn-500:  #d19a00; 

  /* --- Semantic Tokens --- */
  --color-bg-page: var(--brand-sand-050);
  --color-bg-surface: var(--brand-white);
  --color-bg-surface-alt: var(--brand-sand-200);
  --color-bg-overlay-soft: rgba(var(--brand-black-rgb), 0.01);

  --color-text-default: #222222;
  --color-text-strong: var(--brand-gray-900);
  --color-text-muted: var(--brand-gray-500);
  --color-text-inverse: var(--brand-white);

  --color-border-soft: rgba(var(--brand-black-rgb), 0.04);
  --color-border-default: rgba(var(--brand-black-rgb), 0.06);
  --color-border-strong: var(--brand-gray-300);
  --color-border-interactive: rgba(0, 166, 80, 0.35);

  --color-primary: var(--brand-green-500);
  --color-primary-strong: var(--brand-green-700);
  --color-primary-soft: rgba(0, 166, 80, 0.12);
  --color-primary-soft-strong: rgba(0, 166, 80, 0.22);

  --color-success: var(--brand-green-500);
  --color-warning: var(--brand-warn-500);
  --color-focus-ring: 0 0 0 3px rgba(0, 166, 80, 0.22);

  /* --- Typography Tokens --- */
  --font-title: "Segoe UI", "Inter", system-ui, sans-serif;
  --font-body: "Segoe UI", "Inter", system-ui, sans-serif;
  --font-mono: "Cascadia Mono", "SFMono-Regular", Menlo, monospace;

  --font-size-xs: 0.78rem;
  --font-size-sm: 0.86rem;
  --font-size-md: 0.92rem;
  --font-size-base: 1rem;
  --font-size-lg: 1.05rem;
  --font-size-xl: 1.25rem;
  --font-size-2xl: 1.35rem;

  --font-weight-medium: 600;
  --font-weight-bold: 700;
  --font-weight-strong: 800;

  /* --- Spacing Tokens --- */
  --space-2: 0.25rem;
  --space-4: 0.45rem;
  --space-8: 0.7rem;
  --space-12: 1rem;
  --space-15: 1.25rem;
  --space-20: 1.75rem;

  /* --- Radius Tokens --- */
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 18px;
  --radius-xl: 999px;

  /* --- Shadow Tokens --- */
  --shadow-soft: 0 10px 30px rgba(var(--brand-black-rgb), 0.04);
  --shadow-strong: 0 18px 45px rgba(var(--brand-black-rgb), 0.08);
  --shadow-premium: 0 4px 15px rgba(var(--brand-black-rgb), 0.1);

  /* --- Component Tokens --- */
  --btn-radius: var(--radius-xl);
  --input-radius: 1.25rem;
  --card-radius: var(--radius-lg);
}

/* ==================================================================
   3) DARK MODE (Padrão Aura)
   ================================================================== */
body.tema-escuro {
  --color-bg-page: #0f1412;
  --color-bg-surface: #151b18;
  --color-bg-surface-alt: #1c2420;

  --color-text-default: #e6f2ed;
  --color-text-strong: #ffffff;
  --color-text-muted: #cfe6dc;

  --color-border-soft: rgba(255, 255, 255, 0.05);
  --color-border-default: rgba(255, 255, 255, 0.08);
  --color-border-strong: rgba(255, 255, 255, 0.12);

  --color-primary-soft: rgba(0, 166, 80, 0.18);
  --color-primary-soft-strong: rgba(0, 166, 80, 0.28);

  --shadow-soft: 0 10px 30px rgba(0, 0, 0, 0.45);
  --shadow-strong: 0 18px 45px rgba(0, 0, 0, 0.6);
  
  --brand-black-rgb: 255, 255, 255; /* Inverte apoio rgba se necessário */
}

/* ==================================================================
   4) BASE GLOBAL
   ================================================================== */
body {
  font-family: var(--font-body);
  background: var(--color-bg-page);
  color: var(--color-text-default);
  line-height: 1.5;
  transition: background 0.3s ease, color 0.3s ease;
}

/* ==================================================================
   5) LAYOUT AURA (Header, Main, Footer, Nav)
   ================================================================== */

/* Header (Topbar) */
#cabecalho {
  height: 80px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-15);
  background: var(--color-bg-surface);
  box-shadow: var(--shadow-strong);
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  backdrop-filter: blur(15px);
  -webkit-backdrop-filter: blur(15px);
  border-bottom: 1px solid var(--color-border-default);
}

.brand-block {
  display: flex;
  align-items: center;
  gap: var(--space-12);
}

.logo-badge {
  width: 50px;
  height: 50px;
  border-radius: var(--radius-md);
  background: radial-gradient(circle at 30% 20%, var(--color-primary), var(--color-primary-strong));
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-inverse);
  font-weight: var(--font-weight-strong);
  font-size: 1.3rem;
  box-shadow: 0 4px 15px rgba(0, 166, 80, 0.25);
}

.brand-title h1 {
  font-size: 1.1rem;
  letter-spacing: 0.1em;
  font-weight: var(--font-weight-strong);
  color: var(--color-primary-strong);
  margin-bottom: 2px;
}

#status-conexao {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.7rem;
  font-weight: var(--font-weight-bold);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
}

#status-conexao::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-success);
  box-shadow: 0 0 8px var(--color-success);
}

.header-acoes {
  display: flex;
  align-items: center;
  gap: var(--space-12);
}

/* Tela (Área de Mensagens) */
#tela {
  height: calc(100dvh - 80px - 80px - 60px); /* Header - Barra Ação - Menu */
  margin-top: 80px;
  padding: var(--space-15);
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--color-border-strong) transparent;
  display: flex;
  flex-direction: column;
  gap: var(--space-12);
  max-width: 900px;
  margin-left: auto;
  margin-right: auto;
}

/* Barra de Ação (Input) */
#barra-acao {
  position: fixed;
  bottom: 60px; /* Acima do menu */
  left: 0;
  right: 0;
  height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 var(--space-12);
  background: linear-gradient(to top, var(--color-bg-page) 70%, transparent);
  z-index: 900;
}

/* Menu Principal (Bottom Nav) */
#menu-principal {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 60px;
  background: var(--brand-gray-900); /* Chumbo premium */
  display: flex;
  justify-content: space-around;
  align-items: center;
  border-top: 2px solid var(--color-primary);
  z-index: 1000;
  box-shadow: 0 -2px 10px rgba(0,0,0,0.3);
}

/* ==================================================================
   6) COMPONENTES AURA
   ================================================================== */

/* Botões */
.btn-primario, .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-4);
  padding: 0.6rem 1.25rem;
  border-radius: var(--btn-radius);
  border: none;
  cursor: pointer;
  font-weight: var(--font-weight-medium);
  font-family: inherit;
  transition: all 0.2s ease;
  background: var(--color-primary-strong);
  color: white;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
}

.btn-primario:hover {
  transform: translateY(-1px);
  filter: brightness(1.1);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
}

#btn-tema {
  background: var(--color-bg-surface-alt);
  border: none;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  transition: transform 0.3s ease;
}

#btn-tema:hover {
  transform: rotate(20deg);
  background: var(--color-border-strong);
}

/* Mensagens (Chat) */
.mensagem-wrapper {
  display: flex;
  width: 100%;
  margin-bottom: var(--space-4);
  animation: slideUp 0.3s ease-out;
}

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

.mensagem-wrapper.usuario { justify-content: flex-end; }
.mensagem-wrapper.aura { justify-content: flex-start; }

.mensagem-corpo {
  max-width: 80%;
  padding: 1rem 1.25rem;
  border-radius: var(--radius-lg);
  font-size: var(--font-size-md);
  line-height: 1.5;
  box-shadow: var(--shadow-soft);
  position: relative;
}

.usuario .mensagem-corpo {
  background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-strong) 100%);
  color: white;
  border-bottom-right-radius: 4px;
}

.aura .mensagem-corpo {
  background: var(--color-bg-surface);
  color: var(--color-text-default);
  border-bottom-left-radius: 4px;
  border: 1px solid var(--color-border-default);
}

/* Input Container */
.input-container {
  width: 100%;
  max-width: 800px;
  display: flex;
  align-items: flex-end;
  gap: var(--space-8);
  background: var(--color-bg-surface);
  padding: 0.6rem 0.8rem;
  border-radius: var(--input-radius);
  box-shadow: var(--shadow-premium);
  border: 1px solid var(--color-border-strong);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.input-container:focus-within {
  border-color: var(--color-primary);
  box-shadow: var(--color-focus-ring);
}

#input-msg {
  flex: 1;
  border: none;
  background: transparent;
  padding: 0.5rem;
  resize: none;
  max-height: 150px;
  font-family: inherit;
  font-size: var(--font-size-base);
  color: var(--color-text-default);
  outline: none;
}

#btn-enviar {
  background: var(--color-primary);
  color: white;
  border: none;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.2s, background 0.2s;
}

#btn-enviar:hover {
  background: var(--color-primary-strong);
  transform: scale(1.05);
}

/* Menu Principal Buttons */
#menu-principal button {
  background: transparent;
  border: none;
  color: #a0a0a0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex: 1;
  height: 100%;
  transition: all 0.2s;
}

#menu-principal button span {
  font-size: 0.65rem;
  margin-top: 4px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

#menu-principal button:hover {
  color: var(--color-primary);
}

#menu-principal button.ativo {
  color: var(--brand-white);
}

/* Utilitários */
.escondido { display: none !important; }

/* Status de Conexão (Ponto SMID) */
#status-conexao {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-bold);
  color: var(--color-text-muted);
}

#status-conexao::before {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--color-success);
  display: inline-block;
}

/* Perfil Usuário (Chip SMID) */
#perfil-usuario {
  display: flex;
  align-items: center;
  gap: var(--space-8);
  padding: 4px 12px 4px 4px;
  border-radius: var(--radius-xl);
  background: var(--color-bg-surface-alt);
  border: 1px solid var(--color-border-default);
  box-shadow: var(--shadow-soft);
}

#foto-usuario {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 2px solid var(--brand-white);
  object-fit: cover;
}

#nome-usuario {
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  color: var(--color-text-strong);
}

/* ==================================================================
   7) RESPONSIVIDADE
   ================================================================== */
@media (max-width: 600px) {
  #cabecalho {
    padding: 0 var(--space-8);
  }
  
  .mensagem-corpo {
    max-width: 90%;
  }

  #nome-usuario {
    display: none; /* Esconde nome no mobile muito pequeno */
  }
}
