/* ==========================================================================
   1. VARIÁVEIS DE TEMA (CLARO / ESCURO)
   Define a paleta de cores, gradientes e sombras globais do sistema
   ========================================================================== */
:root {
  --bg-color: #0b0f19;
  --bg-card: rgba(18, 26, 43, 0.75);
  --bg-card-hover: rgba(26, 38, 64, 0.95);
  --border-color: rgba(255, 255, 255, 0.08);
  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --primary: #3b82f6;
  --primary-gradient: linear-gradient(135deg, #3b82f6, #6366f1);
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  --topbar-bg: rgba(11, 15, 25, 0.85);
}

[data-theme="light"] {
  --bg-color: #f1f5f9;
  --bg-card: rgba(255, 255, 255, 0.85);
  --bg-card-hover: rgba(255, 255, 255, 1);
  --border-color: rgba(0, 0, 0, 0.08);
  --text-main: #0f172a;
  --text-muted: #64748b;
  --primary: #2563eb;
  --primary-gradient: linear-gradient(135deg, #2563eb, #4f46e5);
  --shadow: 0 10px 25px rgba(0, 0, 0, 0.06);
  --topbar-bg: rgba(241, 245, 249, 0.85);
}

/* Reset universal */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  transition: background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease;
}

/* ==========================================================================
   2. ESTRUTURA GLOBAL E TRAVAMENTO DE JANELA (100% VIEWPORT)
   ========================================================================== */
html, body {
  height: 100vh;
  width: 100vw;
  overflow: hidden;
  background-color: var(--bg-color);
  color: var(--text-main);
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
}

/* ==========================================================================
   3. BARRA SUPERIOR COM TÍTULO 100% CENTRALIZADO
   ========================================================================== */
.top-nav {
  position: relative;
  flex-shrink: 0;
  z-index: 100;
  display: flex;
  justify-content: center; /* Centraliza a marca no eixo horizontal */
  align-items: center;
  padding: 0.85rem 2.5rem;
  background-color: var(--topbar-bg);
  border-bottom: 1px solid var(--border-color);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

/* Logotipo / Marca Principal Centralizada */
.brand {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 0.75rem;
  font-size: 1.3rem;
  font-weight: 700;
  background: var(--primary-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand i {
  font-size: 1.6rem;
  -webkit-text-fill-color: initial;
  color: var(--primary);
}

.nav-left {
  display: flex;
  align-items: center;
  gap: 1rem;
}

/* Botão Home */
.home-btn {
  text-decoration: none;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  transition: all 0.2s ease;
}

.home-btn:hover {
  color: var(--primary);
  border-color: var(--primary);
  transform: translateY(-2px);
}

/* Botões de Ação (Fixados no Canto Direito) */
.actions {
  position: absolute;
  right: 2.5rem;
  display: flex;
  gap: 0.75rem;
}

.icon-btn {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  width: 40px;
  height: 40px;
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  box-shadow: var(--shadow);
  transition: all 0.2s ease;
}

.icon-btn:hover {
  transform: translateY(-2px);
  border-color: var(--primary);
  color: var(--primary);
}

/* ==========================================================================
   4. CONTAINER PRINCIPAL (CENTRALIZADO VERTICAL E HORIZONTALMENTE)
   ========================================================================== */
.container {
  flex: 1;
  width: 100% !important;
  max-width: 100% !important;
  margin: 0 !important;
  padding: 1.5rem 3rem !important;
  display: flex !important;
  flex-direction: column !important;
  justify-content: center !important;
  align-items: center !important;
  gap: 2.2rem !important;
  box-sizing: border-box !important;
}

.welcome-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  width: 100%;
  max-width: 100%;
}

.welcome-section h1 {
  font-size: clamp(1.7rem, 2.3vw, 2.4rem);
  font-weight: 800;
  margin-bottom: 0.5rem;
  white-space: nowrap;
}

.welcome-section p {
  color: var(--text-muted);
  font-size: clamp(0.95rem, 1.1vw, 1.1rem);
  white-space: nowrap;
  line-height: 1.5;
}

/* ==========================================================================
   5. GRADE DE MÓDULOS (4 COLUNAS CENTRALIZADAS NO PORTAL)
   ========================================================================== */
.grid-modules {
  width: 100%;
  max-width: 1600px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1.75rem;
  justify-content: center;
}

.module-card {
  text-decoration: none;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 18px;
  padding: 2.2rem 1.8rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  justify-content: space-between;
  gap: 1.5rem;
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-sizing: border-box;
}

.module-card:hover {
  background: var(--bg-card-hover);
  transform: translateY(-6px);
  border-color: var(--primary);
  box-shadow: 0 15px 35px rgba(59, 130, 246, 0.15);
}

.card-icon {
  width: 64px;
  height: 64px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  margin: 0 auto;
}

.card-icon.blue   { background: rgba(59, 130, 246, 0.15); color: #3b82f6; }
.card-icon.green  { background: rgba(34, 197, 94, 0.15);  color: #22c55e; }
.card-icon.orange { background: rgba(249, 115, 22, 0.15); color: #f97316; }
.card-icon.red    { background: rgba(239, 68, 68, 0.15);  color: #ef4444; }
.card-icon.purple { background: rgba(168, 85, 247, 0.15); color: #a855f7; }

.card-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  width: 100%;
  gap: 0.5rem;
}

.card-content h3 {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-main);
  white-space: nowrap;
}

.card-content p {
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.5;
  text-align: center;
}

.card-footer {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--primary);
  padding-top: 1rem;
  border-top: 1px solid var(--border-color);
  white-space: nowrap;
}

/* ==========================================================================
   6. RESPONSIVIDADE E TELAS MENORES
   ========================================================================== */
@media (max-width: 1200px) {
  html, body {
    overflow-y: auto;
  }
  .welcome-section h1,
  .welcome-section p,
  .card-content h3 {
    white-space: normal;
  }
  .grid-modules {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  .top-nav {
    flex-direction: column;
    padding: 1rem;
    gap: 0.75rem;
  }
  .actions {
    position: static;
  }
  .grid-modules {
    grid-template-columns: 1fr;
  }
  .container {
    padding: 2rem 1.5rem !important;
  }
}

/* ==========================================================================
   RODAPÉ INSTITUCIONAL
   ========================================================================== */
.portal-footer {
  flex-shrink: 0;
  text-align: center;
  padding: 0.65rem 1.5rem 0.85rem 1.5rem;
  border-top: 1px solid var(--border-color);
  background-color: var(--topbar-bg);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.2rem;
  z-index: 10;
  user-select: none;
}

.portal-footer .footer-author {
  font-size: 0.72rem;
  color: var(--text-muted);
  opacity: 0.9;
  margin: 0;
}

.portal-footer .footer-author strong {
  color: var(--primary);
  font-weight: 700;
}