/* ==========================================================================
   1. RESET E ESTILOS GERAIS
   ========================================================================== */

/* Remove margens padrão e define box-sizing global */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: Arial, sans-serif;
}

/* Configuração base do corpo e altura total para o "Sticky Footer" */
html, body {
  height: 100%;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh; /* Garante que o corpo ocupe pelo menos 100% da tela */
}

/* Evita que imagens e elementos de input estourem o container */
img, table, pre, textarea, input, select, button {
  max-width: 100%;
  box-sizing: border-box;
}

/* ==========================================================================
   2. VARIÁVEIS DE CORES (CSS VARIABLES)
   ========================================================================== */

:root {
  --heading-color: #222;
  --subtitle-color: #555;
}

@media (prefers-color-scheme: dark) {
  :root {
    --heading-color: #ddd;
    --subtitle-color: #aaa;
  }
}

/* ==========================================================================
   3. HEADER (CABEÇALHO)
   ========================================================================== */

/* Estilo do container fixo do topo */
.header {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  background-color: #ffffff;
  border-bottom: 1px solid #ddd;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
  z-index: 1000;
  padding: 0;
}

/* Container interno centralizado */
.header-inner {
  max-width: 1200px;
  height: 57px;
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: nowrap;
}

/* --- Logo --- */
.logo {
  display: flex;
  align-items: center;
}

/* Unificação das regras da imagem do logo */
.logo img {
  display: block;
  height: 40px;
  width: auto;         /* Mantém proporção */
  max-width: 150px;    /* Limite de segurança */
  opacity: 1;
  transition: opacity .25s ease, transform .25s ease;
}

/* Efeito de fade-out opcional */
.logo img.logo-fade-out {
  opacity: 0;
  transform: scale(.98);
}

/* --- Navegação Principal (Desktop) --- */
.header .nav-menu {
  list-style: none;
  display: flex;
  gap: 20px;
}

.header .nav-menu li a {
  text-decoration: none;
  color: #333;
  font-size: 16px;
  font-weight: bold;
}

.header .nav-menu li a:hover {
  color: #ff9900;
}

/* --- Ações do Header (Direita) --- */
.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Botões: Tema e Hambúrguer */
.theme-toggle,
.nav-toggle {
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 18px;
  color: #333;
  padding: 0;
  display: inline-flex; /* Alinhamento melhor dos ícones */
  align-items: center;
  justify-content: center;
}

.nav-toggle {
  display: none; /* Escondido no desktop */
  font-size: 22px;
}

/* Impede eventos de mouse nos ícones internos */
.theme-toggle i,
.nav-toggle i {
  pointer-events: none;
}

/* Hover suave nos botões */
.theme-toggle:hover,
.nav-toggle:hover {
  opacity: .7;
}

/* --- Header no Modo Escuro --- */
body.dark-mode .header {
  background-color: #1f1f1f;
  border-bottom-color: #333;
}

body.dark-mode .header-nav {
  background-color: #1f1f1f;
  border-bottom-color: #333;
}

body.dark-mode .header .nav-menu li a {
  color: #f2f2f2;
}

body.dark-mode .header .nav-menu li a:hover {
  color: #ffcc66;
}

body.dark-mode .theme-toggle,
body.dark-mode .nav-toggle {
  color: #f5f5f5;
  background: transparent;
}

body.dark-mode .theme-toggle:hover,
body.dark-mode .nav-toggle:hover {
  opacity: .8;
}

/* ==========================================================================
   4. CONTEÚDO INSTITUCIONAL
   ========================================================================== */

.content-institutional {
  flex: 1;
  padding: 100px 20px 50px; /* Topo maior para compensar header fixo */
  box-sizing: border-box;
  color: #333;
  text-align: justify;
  margin: 0 auto;
  max-width: 1200px;
  width: 100%;
  line-height: 1.6;
  font-size: 16px;
  letter-spacing: normal;
  -webkit-font-smoothing: antialiased;
  overflow-wrap: break-word;
  word-break: normal;
}

/* Títulos do Institucional */
.content-institutional h1 {
  text-align: center;
  margin: 0 0 24px;
  font-size: 1.6rem;
  line-height: 1.2;
  color: inherit;
}

/* Parágrafos do Institucional */
.content-institutional p {
  margin-bottom: 8px;
  text-align: justify;
  text-align-last: left;
  hyphens: auto;
}

/* Backgrounds de Páginas Específicas */
.page-institucional {
  background-image: url("/img/background-url.webp");
  background-repeat: no-repeat;
  background-position: left;
  background-attachment: fixed;
  background-size: cover;
}

.page-institucional-about {
  background-image: url("/img/about11.webp");
  background-repeat: no-repeat;
  background-position: left top;
  background-attachment: fixed;
  background-size: cover;
}

/* --- Institucional: Modo Escuro --- */
body.dark-mode.page-institucional {
  background-image: url("/img/background-url-dark.webp");
}
/* Fallback/Overlay para dark mode */
body.dark-mode.page-institucional::before,
body.dark-mode.page-institucional-about::before {
  background: rgba(0,0,0,0.35);
}

body.dark-mode.page-institucional-about {
  background-image: url("/img/about-dark3.webp");
}

/* Cores de texto no Dark Mode Institucional */
body.dark-mode .content-institutional,
body.dark-mode .content-institutional p,
body.dark-mode .content-institutional h1,
body.dark-mode .content-institutional strong {
  color: #f5f5f5;
}

body.dark-mode .content-institutional a {
  color: #ffd57a;
  text-decoration: underline;
}

/* ==========================================================================
   5. CONTEÚDO PRINCIPAL E FERRAMENTAS
   ========================================================================== */

.content,
.content-tools {
  flex: 1;
  padding: 80px 20px 60px !important;
  text-align: center;
}

/* Fundo do conteúdo no modo escuro */
body.dark-mode .content {
  background-color: #121212;
}

/* --- Tipografia (H1 e Subtítulos) --- */
.content h1,
.content-tools h1 {
  font-size: 2.5rem;
  color: var(--heading-color);
  text-align: center;
  margin-bottom: 10px;
}

.content .subtitle,
.content-tools .subtitle {
  font-size: 1.2rem;
  color: var(--subtitle-color);
  text-align: center;
  margin-bottom: 10px;
}

/* Sobrescritas de Tipografia (H3, H4 alternativos) */
.content h3, .content-tools h3,
.content h4, .content-tools h4 {
  font-size: 1.2rem;
  color: #555555;
  text-align: center;
  margin-top: 0;
  margin-bottom: 20px;
}

/* Sobrescritas Estritas de Cor (Conforme solicitado para garantir contraste) */
body:not(.dark-mode) .content h1,
body:not(.dark-mode) .content-tools h1 {
   color: #222 !important;
}
body:not(.dark-mode) .content .subtitle,
body:not(.dark-mode) .content-tools .subtitle {
   color: #555 !important;
}

body.dark-mode .content h1,
body.dark-mode .content-tools h1 {
   color: #f5f5f5 !important;
}
body.dark-mode .content .subtitle,
body.dark-mode .content-tools .subtitle {
   color: #ccc !important;
}

/* --- Grid de Ferramentas --- */
.tools-grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 20px;
}

/* Card Individual */
.tool-card {
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 20px;
  width: 300px;
  text-align: center;
  transition: transform 0.3s ease-in-out;
  box-shadow: 0 2px 10px rgba(0,0,0,0.1);
  text-decoration: none;
  color: #333;
}

.tool-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 5px 15px rgba(0,0,0,0.2);
}

.tool-card img {
  max-width: 100%;
  height: auto;
  object-fit: cover;
  border-radius: 8px;
}

.tool-card i {
  font-size: 40px;
  color: #007BFF;
}

.tool-card h2 {
  margin: 15px 0;
  font-size: 22px;
}

.tool-card p {
  font-size: 16px;
  color: #666;
}

/* Ícone dentro do Card (Container Fixo) */
.tool-card .icon-bg {
  width: 80px;
  height: 80px;
  margin: 0 auto 12px;
  background-repeat: no-repeat;
  background-position: center center;
  background-size: contain;
  display: block;
  border-radius: 8px;
  background-color: transparent;
}

/* --- Ferramentas: Modo Escuro --- */
body.dark-mode .tools-grid {
  background: transparent;
}

body.dark-mode .tool-card {
  background-color: #1e1e1e;
  border-color: #333;
  color: #f5f5f5;
  box-shadow: 0 2px 10px rgba(0,0,0,0.6);
}

body.dark-mode .tool-card h2 {
  color: #ffffff;
}

body.dark-mode .tool-card p {
  color: #cccccc;
}

body.dark-mode .tool-card i {
  color: #ffcc66;
}

/* ==========================================================================
   6. FOOTER (RODAPÉ)
   ========================================================================== */

.footer {
  background-color: #333;
  color: #fff;
  padding: 20px 40px;
  text-align: center;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  width: 100%;
  box-sizing: border-box;
  position: relative;
  bottom: 0;
}

.footer-left {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 15px;
  flex-wrap: nowrap;
  text-align: center;
}

.footer-left p {
  font-size: 14px;
  white-space: nowrap;
}

.footer-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

.footer .social-menu,
.footer .nav-menu {
  list-style: none;
  display: flex;
  gap: 15px;
}

.footer .social-menu li a,
.footer .nav-menu li a {
  color: #ccc;
  text-decoration: none;
  font-size: 12px;
}

.footer .social-menu li a:hover,
.footer .nav-menu li a:hover {
  color: #fff;
}

/* --- Footer: Modo Escuro --- */
body.dark-mode .footer {
  background-color: #111;
  color: #eee;
}

body.dark-mode .footer .social-menu li a,
body.dark-mode .footer .nav-menu li a {
  color: #ccc;
}

body.dark-mode .footer .social-menu li a:hover,
body.dark-mode .footer .nav-menu li a:hover {
  color: #fff;
}

/* ==========================================================================
   7. ELEMENTOS GERAIS EM MODO ESCURO (Inputs, Botões)
   ========================================================================== */

body.dark-mode {
  background-color: #121212;
  color: #f2f2f2;
}

body.dark-mode input,
body.dark-mode textarea,
body.dark-mode select {
  background-color: #1e1e1e;
  color: #f5f5f5;
  border: 1px solid #444;
}

body.dark-mode input::placeholder,
body.dark-mode textarea::placeholder {
  color: #888;
}

/* Botões genéricos no conteúdo */
body.dark-mode .content button,
body.dark-mode .content input[type="button"],
body.dark-mode .content input[type="submit"],
body.dark-mode .content input[type="reset"] {
  background-color: #333;
  color: #f5f5f5;
  border: 1px solid #555;
}

body.dark-mode button:hover {
  background-color: #444;
}

/* Contêineres de texto genéricos */
body.dark-mode .text-container,
body.dark-mode .content-text {
  background-color: transparent;
  color: #f5f5f5;
}

/* ==========================================================================
   8. WIDGETS E COMPONENTES ESPECÍFICOS
   ========================================================================== */

/* --- Widget de Clima --- */
.weather-widget {
  display: none; /* Padrão mobile: escondido */
  align-items: center;
  white-space: nowrap;
  padding: 0;
  margin-right: 6px;
  background: transparent;
  border: none;
  box-shadow: none;
  font-size: 13px;
  line-height: 1;
}

.weather-widget img {
  height: 20px;
  width: 20px;
  vertical-align: middle;
  margin-left: 6px;
  display: inline-block;
}

/* Ajuste de cor do widget baseado no tema */
body.dark-mode .weather-widget { color: #ffffff !important; }
body:not(.dark-mode) .weather-widget { color: #111111 !important; }

/* Desktop: Mostra widget de clima */
@media (min-width: 769px) {
  .weather-widget { display: inline-flex; }
  .header-actions { gap: 8px; }
}

/* --- Botão "Voltar ao Topo" --- */
.back-to-top {
  position: fixed;
  right: 20px;
  bottom: 25px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  outline: none;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: #333;
  color: #fff;
  box-shadow: 0 3px 10px rgba(0,0,0,0.35);
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition: opacity .25s ease, transform .25s ease, background-color .2s ease, box-shadow .2s ease;
  z-index: 1100;
}

.back-to-top i {
  font-size: 18px;
}

.back-to-top.visivel {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.back-to-top:hover {
  background-color: #000;
  box-shadow: 0 5px 15px rgba(0,0,0,0.45);
}

/* Voltar ao topo: Dark Mode */
body.dark-mode .back-to-top {
  background-color: #222;
  color: #f5f5f5;
  box-shadow: 0 3px 12px rgba(0,0,0,0.6);
}

body.dark-mode .back-to-top:hover {
  background-color: #444;
}

/* --- Widget de Consentimento de Cookies (Fixado) --- */
#cc-widget {
  position: fixed !important;
  right: 12px !important;
  bottom: 12px !important;
  display: flex !important;
  flex-direction: column !important;
  align-items: flex-start !important;
  gap: 10px !important;
  max-width: 360px !important;
  width: auto !important;
  box-sizing: border-box !important;
  background: #000000 !important;
  color: #ffffff !important;
  border-left: 6px solid #ff9900 !important;
  border-radius: 8px !important;
  padding: 12px 14px !important;
  box-shadow: 0 8px 28px rgba(0,0,0,0.45) !important;
  z-index: 2147483647 !important;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial !important;
  font-size: 13px !important;
  line-height: 1.35 !important;
  transition: opacity 180ms ease, transform 180ms ease !important;
  opacity: 1 !important;
}

#cc-widget .cc-accept {
  margin-left: 0 !important;
  margin-right: 0 !important;
  align-self: center !important;
  display: inline-block !important;
  background: #ff9900 !important;
  color: #ffffff !important;
  border: none !important;
  padding: 8px 12px !important;
  border-radius: 6px !important;
  cursor: pointer !important;
  font-weight: 700 !important;
  text-decoration: none !important;
  box-shadow: 0 4px 10px rgba(255,153,0,0.12) !important;
  margin-top: 4px !important;
}

#cc-widget .cc-msg {
  color: #ffffff !important;
  margin: 0 !important;
  padding: 0 !important;
  word-break: break-word !important;
}

#cc-widget a.cc-link {
  color: #ff9900 !important;
  text-decoration: underline !important;
}

/* --- Sidebar de Emojis (Modo Escuro Exclusivo) --- */
body.dark-mode .emoji-layout > .emoji-sidebar {
  background-color: #1e1e1e;
  border-right: 1px solid #444;
  color: #f5f5f5;
}

body.dark-mode .emoji-sidebar h3,
body.dark-mode .emoji-sidebar p,
body.dark-mode .emoji-sidebar a {
  color: #f5f5f5;
}

body.dark-mode .emoji-sidebar a:hover {
  color: #ffcc66;
}

body.dark-mode .emoji-sidebar .copied-box {
  background-color: #1e1e1e;
  border-color: #444;
}

body.dark-mode .emoji-sidebar #btn-copiar-tudo {
  background-color: #333;
  border-color: #555;
  color: #eee;
}

body.dark-mode .emoji-sidebar #btn-copiar-tudo:hover {
  border-color: #ffcc66;
}

body.dark-mode .emoji-sidebar .copied-list {
  background-color: #1e1e1e;
  border-color: #444;
  color: #eee;
}

body.dark-mode .emoji-sidebar .copied-tag {
  background-color: #2b2b2b;
  border-color: #555;
  color: #eee;
}

body.dark-mode .emoji-sidebar .emoji-menu-grid .menu-categoria {
  background-color: #1e1e1e;
  border-color: #555;
  color: #f5f5f5;
}

body.dark-mode .emoji-sidebar .emoji-menu-grid .menu-categoria:hover {
  border-color: #ffcc66;
}

/* ==========================================================================
   9. RESPONSIVIDADE (MEDIA QUERIES)
   ========================================================================== */

/* --- Telas Médias/Tablets (max-width: 900px) --- */
@media (max-width: 900px) {
  .content-institutional {
    max-width: 720px;
    padding-left: 18px;
    padding-right: 18px;
  }
}

/* --- Telas Mobile (max-width: 768px) --- */
@media (max-width: 768px) {
  .header {
    height: 60px;
    padding: 0 15px;
  }

  .header-inner {
    gap: 10px;
  }

  .logo img {
    max-width: 130px;
  }

  /* Menu Mobile */
  .header-nav {
    position: absolute;
    top: 60px; /* Altura do header mobile */
    left: 0;
    right: 0;
    background-color: #ffffff;
    border-bottom: 1px solid #ddd;
    display: none;
    padding: 10px 20px;
  }

  .header-nav.aberto {
    display: block;
  }

  .header .nav-menu {
    flex-direction: column;
    gap: 10px;
  }

  .header .nav-menu li a {
    display: block;
    padding: 5px 0;
  }

  /* Exibe o hambúrguer e ajusta tamanho do tema */
  .theme-toggle {
    font-size: 18px;
  }

  .nav-toggle {
    display: inline-flex;
  }

  /* Footer responsivo */
  .footer {
    flex-direction: column;
    align-items: center;
    text-align: center;
  }

  .footer-left {
    order: 2;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    margin-top: 20px;
  }

  .footer-left p {
    font-size: 12px;
    text-align: center;
    white-space: normal;
  }

  .footer .social-menu {
    flex-wrap: wrap;
    justify-content: center;
  }

  .footer .nav-menu {
    flex-direction: column;
    align-items: center;
  }

  /* Ajuste do botão Voltar ao Topo */
  .back-to-top {
    right: 16px;
    bottom: 20px;
    width: 40px;
    height: 40px;
  }

  .back-to-top i {
    font-size: 16px;
  }
}

/* --- Telas Pequenas (max-width: 480px) --- */
@media (max-width: 480px) {
  .content-institutional {
    max-width: 100%;
    padding: 80px 16px 40px;
  }

  .content-institutional h1 {
    font-size: 1.6rem;
  }

  .tool-card .icon-bg {
    width: 64px;
    height: 64px;
  }
}

/* --- Telas Muito Pequenas (max-width: 420px) --- */
@media (max-width: 420px) {
  #cc-widget {
    max-width: 90vw !important;
    left: 8px !important;
    bottom: 8px !important;
    padding: 10px !important;
    font-size: 12px !important;
  }
  #cc-widget .cc-accept {
    padding: 7px 10px !important;
  }
}