/* ═══════════════════════════════════════════════════════════════
   NAV.CSS — Menu principal aprimorado + Mega-menu + Busca
   365 de Graça & Adoração
   ═══════════════════════════════════════════════════════════════ */

/* ── Topbar aprimorado ─────────────────────────────────────────── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 200;
  backdrop-filter: blur(16px) saturate(1.4);
  -webkit-backdrop-filter: blur(16px) saturate(1.4);
  background: rgba(8, 10, 18, 0.88);
  border-bottom: 1px solid rgba(255,255,255,0.07);
  box-shadow: 0 1px 24px rgba(0,0,0,0.4);
}

.topbar .inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 20px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

/* ── Brand ─────────────────────────────────────────────────────── */
.brand a {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: inherit;
}

.brand img { height: 38px; width: auto; }

.brand span {
  font-weight: 800;
  font-size: 0.95rem;
  letter-spacing: 0.2px;
  color: var(--text, #f0f0f0);
  white-space: nowrap;
}

/* ── Nav principal ─────────────────────────────────────────────── */
.nav {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: nowrap;
}

.nav > a,
.nav > .nav-item > a {
  color: rgba(240,240,240,0.65);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.875rem;
  padding: 7px 12px;
  border-radius: 8px;
  transition: all 0.18s ease;
  white-space: nowrap;
  position: relative;
}

.nav > a:hover,
.nav > .nav-item > a:hover {
  color: #fff;
  background: rgba(255,255,255,0.07);
}

.nav > a.active,
.nav > .nav-item > a.active {
  color: #fff;
  background: rgba(0,168,225,0.18);
  border: 1px solid rgba(0,168,225,0.25);
}

/* ── Botão de busca na nav ─────────────────────────────────────── */
.nav-search-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  color: rgba(240,240,240,0.65);
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  padding: 7px 12px;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.18s ease;
  text-decoration: none;
  white-space: nowrap;
}

.nav-search-btn:hover {
  color: #fff;
  background: rgba(255,255,255,0.1);
  border-color: rgba(255,255,255,0.2);
}

.nav-search-btn svg {
  width: 15px;
  height: 15px;
  opacity: 0.7;
}

/* ── Dropdown item ─────────────────────────────────────────────── */
.nav-item {
  position: relative;
}

.nav-item > a::after {
  content: '▾';
  font-size: 0.7rem;
  margin-left: 4px;
  opacity: 0.5;
  transition: transform 0.2s;
}

.nav-item:hover > a::after {
  transform: rotate(180deg);
  opacity: 1;
}

/* ── Mega-menu ─────────────────────────────────────────────────── */
.mega-menu {
  position: absolute;
  top: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  width: 680px;
  background: rgba(12, 14, 22, 0.98);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 14px;
  padding: 20px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.6), 0 0 0 1px rgba(255,255,255,0.04);
  backdrop-filter: blur(20px);
  opacity: 0;
  visibility: hidden;
  transform: translateX(-50%) translateY(-6px);
  transition: all 0.22s cubic-bezier(0.16, 1, 0.3, 1);
  pointer-events: none;
  z-index: 300;
}

.nav-item:hover .mega-menu,
.nav-item:focus-within .mega-menu {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
  pointer-events: auto;
}

.mega-menu-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(255,255,255,0.07);
}

.mega-menu-header h4 {
  margin: 0;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: rgba(255,255,255,0.35);
}

.mega-menu-header a {
  font-size: 0.8rem;
  color: rgba(0,168,225,0.8);
  text-decoration: none;
  font-weight: 600;
}

.mega-menu-header a:hover { color: #0ea5e9; }

.mega-menu-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.mega-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 9px;
  text-decoration: none;
  transition: background 0.15s;
  border: 1px solid transparent;
}

.mega-link:hover {
  background: rgba(255,255,255,0.06);
  border-color: rgba(255,255,255,0.08);
}

.mega-num {
  font-size: 0.75rem;
  font-weight: 800;
  width: 28px;
  height: 28px;
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: rgba(255,255,255,0.06);
}

.mega-info { flex: 1; min-width: 0; }

.mega-info strong {
  display: block;
  font-size: 0.82rem;
  font-weight: 700;
  color: rgba(255,255,255,0.9);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mega-info span {
  display: block;
  font-size: 0.72rem;
  color: rgba(255,255,255,0.38);
  margin-top: 1px;
}

/* Cores por grupo no mega-menu */
.mega-link[data-grupo="fundacao"] .mega-num { color: #d97706; background: rgba(217,119,6,0.12); }
.mega-link[data-grupo="at"] .mega-num { color: #059669; background: rgba(5,150,105,0.12); }
.mega-link[data-grupo="inter"] .mega-num { color: #6366f1; background: rgba(99,102,241,0.12); }
.mega-link[data-grupo="nt"] .mega-num { color: #0ea5e9; background: rgba(14,165,233,0.12); }
.mega-link[data-grupo="historia"] .mega-num { color: #8b5cf6; background: rgba(139,92,246,0.12); }
.mega-link[data-grupo="conflito"] .mega-num { color: #e11d48; background: rgba(225,29,72,0.12); }
.mega-link[data-grupo="escato"] .mega-num { color: #7c3aed; background: rgba(124,58,237,0.12); }

/* ── Barra de busca rápida (overlay) ───────────────────────────── */
.search-overlay {
  position: fixed;
  inset: 0;
  z-index: 500;
  background: rgba(0,0,0,0.75);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 80px;
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s ease;
}

.search-overlay.open {
  opacity: 1;
  visibility: visible;
}

.search-box {
  width: 100%;
  max-width: 640px;
  background: rgba(14, 16, 26, 0.98);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 24px 80px rgba(0,0,0,0.7);
  transform: translateY(-12px);
  transition: transform 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

.search-overlay.open .search-box {
  transform: translateY(0);
}

.search-input-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.07);
}

.search-input-wrap svg {
  width: 20px;
  height: 20px;
  color: rgba(255,255,255,0.4);
  flex-shrink: 0;
}

#search-input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  font-size: 1.1rem;
  color: #fff;
  font-family: inherit;
}

#search-input::placeholder { color: rgba(255,255,255,0.3); }

.search-close {
  background: rgba(255,255,255,0.07);
  border: none;
  border-radius: 6px;
  color: rgba(255,255,255,0.5);
  font-size: 0.8rem;
  padding: 4px 8px;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
}

.search-close:hover {
  background: rgba(255,255,255,0.12);
  color: #fff;
}

.search-results {
  max-height: 420px;
  overflow-y: auto;
  padding: 8px;
}

.search-results::-webkit-scrollbar { width: 4px; }
.search-results::-webkit-scrollbar-track { background: transparent; }
.search-results::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 2px; }

.search-empty {
  padding: 32px;
  text-align: center;
  color: rgba(255,255,255,0.3);
  font-size: 0.9rem;
}

.search-result-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 9px;
  text-decoration: none;
  transition: background 0.12s;
  cursor: pointer;
}

.search-result-item:hover,
.search-result-item.selected {
  background: rgba(255,255,255,0.07);
}

.search-result-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 800;
  flex-shrink: 0;
  background: rgba(255,255,255,0.06);
  color: rgba(255,255,255,0.7);
}

.search-result-body { flex: 1; min-width: 0; }

.search-result-title {
  font-size: 0.88rem;
  font-weight: 700;
  color: rgba(255,255,255,0.9);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.search-result-sub {
  font-size: 0.75rem;
  color: rgba(255,255,255,0.38);
  margin-top: 2px;
}

.search-result-tag {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(255,255,255,0.07);
  color: rgba(255,255,255,0.45);
  flex-shrink: 0;
}

.search-footer {
  padding: 10px 20px;
  border-top: 1px solid rgba(255,255,255,0.06);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.search-hint {
  font-size: 0.72rem;
  color: rgba(255,255,255,0.25);
  display: flex;
  align-items: center;
  gap: 8px;
}

.search-hint kbd {
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 0.68rem;
  font-family: inherit;
}

/* ── Hamburger mobile ──────────────────────────────────────────── */
.nav-toggle {
  display: none;
  background: none;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 8px;
  padding: 8px 10px;
  cursor: pointer;
  color: rgba(255,255,255,0.7);
  flex-direction: column;
  gap: 4px;
  align-items: center;
  justify-content: center;
}

.nav-toggle span {
  display: block;
  width: 18px;
  height: 2px;
  background: currentColor;
  border-radius: 2px;
  transition: all 0.2s;
}

/* ── Mobile ────────────────────────────────────────────────────── */
@media (max-width: 860px) {
  .nav-toggle { display: flex; }

  .nav {
    display: none;
    position: absolute;
    top: 60px;
    left: 0;
    right: 0;
    background: rgba(8, 10, 18, 0.98);
    border-bottom: 1px solid rgba(255,255,255,0.07);
    padding: 12px 16px;
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
    z-index: 199;
  }

  .nav.open { display: flex; }

  .nav > a,
  .nav > .nav-item > a,
  .nav-search-btn {
    padding: 12px 14px;
    border-radius: 8px;
    width: 100%;
    text-align: left;
  }

  .mega-menu {
    position: static;
    transform: none;
    width: 100%;
    box-shadow: none;
    border: none;
    border-top: 1px solid rgba(255,255,255,0.07);
    border-radius: 0;
    padding: 12px 0;
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    display: none;
  }

  .nav-item.open .mega-menu { display: block; }

  .mega-menu-grid { grid-template-columns: repeat(2, 1fr); }

  .nav-item > a::after { float: right; }
}

@media (max-width: 480px) {
  .mega-menu-grid { grid-template-columns: 1fr; }
  .brand span { display: none; }
}
