/* Peniel App — Header + navegação principal
 * Rollback: ver _rollback/header-primary-nav/ROLLBACK.md */

/* Alturas vêm de peniel-critical.css (--peniel-topbar-h / --peniel-logo-px) */

#sidebar {
  border-right: none !important;
}

#sidebar::after {
  display: none !important;
}

#app-header {
  position: sticky;
  z-index: 30;
  border: none !important;
  border-bottom: none !important;
  overflow: visible !important;
}

.app-header__grid {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  height: 100%;
  min-height: 0;
  padding: 0 1rem;
}

.app-header__start {
  display: flex;
  min-width: 0;
  flex: 1;
  align-items: center;
  gap: 0.5rem;
}

.app-header__title {
  min-width: 0;
  flex: 1;
}

.app-header__actions {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  gap: 0.35rem;
  position: relative;
  z-index: 40;
  overflow: visible;
}

.app-header__actions--end {
  margin-left: auto;
  justify-content: flex-end;
}

.app-header__tools {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
}

.peniel-avisos-bell {
  position: relative;
}

.peniel-avisos-badge {
  position: absolute;
  top: -0.3rem;
  right: -0.35rem;
  min-width: 1.05rem;
  height: 1.05rem;
  padding: 0 0.28rem;
  border-radius: 999px;
  border: 1.5px solid #0a0a0a;
  background: #9b1b1b;
  color: #fff;
  font-family: Montserrat, system-ui, sans-serif;
  font-size: 0.58rem;
  font-weight: 700;
  line-height: 1.05rem;
  text-align: center;
  pointer-events: none;
}

.peniel-avisos-badge.is-hidden {
  display: none;
}

.peniel-avisos-bell.has-unread {
  border-color: rgba(155, 27, 27, 0.55);
  color: #e88a8a;
}

html.theme-light .peniel-avisos-badge {
  border-color: #fff;
}

html.theme-light .peniel-avisos-bell.has-unread {
  border-color: rgba(155, 27, 27, 0.45);
  color: #9b1b1b;
}

#app-config-btn .pi {
  font-size: 1rem;
}

.app-header__actions .btn-icon--header {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 2.15rem;
  height: 2.15rem;
  padding: 0;
  border-radius: 0.65rem;
  border: 1px solid rgba(42, 42, 42, 0.9);
  background: transparent;
  color: #a3a3a3;
  font-size: 0.9rem;
  line-height: 1;
  transition: border-color 0.2s ease, color 0.2s ease, background 0.2s ease;
}

.app-header__actions .btn-icon--header:hover,
.app-header__actions .btn-icon--header:focus-visible {
  border-color: #9b1b1b;
  background: rgba(155, 27, 27, 0.08);
  color: #9b1b1b;
  outline: none;
}

.app-header__actions .btn-icon--header.is-open,
.app-header__actions #social-pill.is-open {
  border-color: #9b1b1b;
  background: rgba(155, 27, 27, 0.12);
  color: #9b1b1b;
}

.app-header__avatar {
  padding: 0;
  overflow: hidden;
}

.app-header__avatar img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

html.theme-light .app-header__actions .btn-icon--header {
  background: #ffffff;
  border-color: #b8b5b0;
  color: #2f2f35;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

html.theme-light .app-header__actions .btn-icon--header:hover,
html.theme-light .app-header__actions .btn-icon--header.is-open,
html.theme-light .app-header__actions #social-pill.is-open {
  border-color: var(--p-grena, #9b1b1b);
  color: var(--p-grena, #9b1b1b);
  background: #fff8f8;
}

html.theme-light #app-header,
html.theme-light #sidebar {
  border: none !important;
}

html.theme-light #app-shell {
  background: var(--p-sidebar-bg, #ebe6e2) !important;
}

html.theme-light #app-shell > main[role="main"] {
  border: none !important;
  border-radius: 0 !important;
  border-top-left-radius: 1.25rem !important;
  box-shadow: none !important;
  background-color: var(--p-surface, #ffffff) !important;
}

/* —— Primary nav: só desktop —— */
.peniel-primary-nav {
  display: none;
}

@media (min-width: 1024px) {
  .app-header__grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    align-items: center;
    gap: 1rem;
    padding: 0 1.25rem;
    height: 100%;
    min-height: 0;
  }

  .app-header__start {
    flex: none;
    justify-self: start;
    max-width: 100%;
  }

  .app-header__title {
    max-width: min(18rem, 100%);
  }

  .peniel-primary-nav {
    display: flex;
    position: relative;
    transform: none;
    justify-self: center;
    align-items: center;
    gap: 0.2rem;
    padding: 0.15rem;
    border-radius: 9999px;
    border: 1px solid rgba(42, 42, 42, 0.7);
    background: rgba(10, 10, 10, 0.55);
    backdrop-filter: blur(8px);
    max-width: 100%;
  }

  .app-header__actions {
    justify-self: end;
  }

  .holyrics-header-live-status {
    position: absolute;
    z-index: 35;
    top: 50%;
    left: 75%;
    display: inline-flex;
    min-height: 1.8rem;
    padding: 0.28rem 0.65rem;
    font-size: 0.65rem;
    letter-spacing: 0.1em;
    white-space: nowrap;
    transform: translate(-50%, -50%);
    transition: left 220ms ease, opacity 160ms ease;
  }
}

@media (min-width: 1280px) {
  .app-header__title {
    max-width: min(22rem, 100%);
  }
}

.peniel-primary-pill {
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  border-radius: 9999px;
  padding: 0.3rem 0.7rem;
  font-family: Montserrat, system-ui, sans-serif;
  font-size: 0.8125rem;
  font-weight: 600;
  white-space: nowrap;
  color: var(--p-muted, #a3a3a3);
  transition: color 0.22s ease, transform 0.18s ease;
}

.peniel-primary-pill:hover,
.peniel-primary-pill:focus-visible {
  color: var(--p-text, #fff);
  background: transparent;
  outline: none;
}

.peniel-primary-pill.is-active {
  color: var(--p-grena, #9b1b1b);
  background: transparent;
  box-shadow: none;
}

.peniel-primary-pill .pi {
  font-size: 0.9rem;
}

.peniel-primary-indicator {
  position: absolute;
  z-index: 0;
  top: 0.15rem;
  left: 0;
  width: 0;
  height: calc(100% - 0.3rem);
  border: 1px solid rgb(var(--p-grena-rgb, 155 27 27) / 0.35);
  border-radius: 9999px;
  background: rgb(var(--p-grena-rgb, 155 27 27) / 0.12);
  box-shadow: 0 2px 9px rgba(0, 0, 0, 0.16);
  opacity: 0;
  pointer-events: none;
  transform: translate3d(0, 0, 0);
  transition:
    transform 320ms cubic-bezier(0.22, 1, 0.36, 1),
    width 320ms cubic-bezier(0.22, 1, 0.36, 1),
    opacity 150ms ease;
  will-change: transform, width;
}

.peniel-primary-indicator.is-visible {
  opacity: 1;
}

.holyrics-header-live-status {
  display: none;
}

.holyrics-header-live-status[hidden] {
  display: none !important;
}

@media (min-width: 1024px) {
  #app-header .holyrics-header-live-status:not([hidden]) {
    display: inline-flex;
  }
}

.peniel-primary-divider {
  position: relative;
  z-index: 1;
  width: 1px;
  height: 1.35rem;
  margin: 0 0.25rem;
  flex: 0 0 1px;
  background: var(--p-border, #2a2a2a);
  opacity: 0.8;
}

/* —— Bottom bar (mobile) —— */
.peniel-bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  display: flex;
  align-items: stretch;
  justify-content: space-around;
  gap: 0.25rem;
  border-top: 1px solid rgba(42, 42, 42, 0.85);
  background: rgba(10, 10, 10, 0.94);
  backdrop-filter: blur(10px);
  padding: 0.35rem 0.5rem calc(0.35rem + env(safe-area-inset-bottom, 0px));
}

@media (min-width: 1024px) {
  .peniel-bottom-nav {
    display: none !important;
  }
}

@media (max-width: 1023px) {
  #app-shell {
    padding-bottom: calc(4.25rem + env(safe-area-inset-bottom, 0px));
  }

  #peniel-watermark {
    bottom: calc(4.5rem + env(safe-area-inset-bottom, 0px));
  }
}

.peniel-bottom-nav-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.2rem;
  min-height: 3.25rem;
  border-radius: 0.75rem;
  padding: 0.35rem 0.25rem;
  font-size: 0.625rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--p-muted, #a3a3a3);
  transition: color 0.15s ease, background 0.15s ease;
}

.peniel-bottom-nav-btn .pi {
  font-size: 1.15rem;
}

.peniel-bottom-nav-btn.is-active {
  color: var(--p-grena, #9b1b1b);
  background: rgba(155, 27, 27, 0.1);
}

body.biblia-fullscreen-active .peniel-bottom-nav,
body.biblia-fullscreen-active .peniel-primary-nav {
  display: none !important;
}

html.theme-light .peniel-primary-nav,
html.theme-light .peniel-bottom-nav {
  background: rgba(255, 255, 255, 0.94);
  border-color: var(--p-border, #d0c9c3);
}

html.theme-light .peniel-primary-indicator {
  background: rgb(var(--p-grena-rgb, 143 22 22) / 0.09);
  border-color: rgb(var(--p-grena-rgb, 143 22 22) / 0.28);
  box-shadow: 0 2px 8px rgba(40, 25, 25, 0.08);
}

@media (min-width: 1024px) and (max-width: 1180px) {
  .app-header__grid {
    gap: 0.55rem;
    padding-inline: 0.75rem;
  }

  .app-header__title {
    max-width: 9rem;
  }

  .peniel-primary-pill {
    gap: 0.25rem;
    padding-inline: 0.5rem;
    font-size: 0.75rem;
  }

  .peniel-primary-divider {
    margin-inline: 0.1rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .peniel-primary-indicator,
  .peniel-primary-pill {
    transition: none !important;
  }
}

html.theme-light #page-header-label {
  color: var(--p-text, #1a1212) !important;
}
