/* =====================================================================
   Navegação no estilo do admin do Psicodrica:
   - computador: barra lateral fixa, só com ícones (recolhida) ou com os nomes (expandida), e submenus por assunto;
   - celular: barra superior fina, barra de abas embaixo e painel "Menu" que entra pela direita, com grupos como no Ajustes do iOS.
   ===================================================================== */
:root { --altura-aba: 3.25rem; --seguro-baixo: env(safe-area-inset-bottom, 0px); --seguro-cima: env(safe-area-inset-top, 0px); --side-w: 0px; }

/* ---------- Barra superior ---------- */
.app-top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: center;
    min-height: calc(3rem + var(--seguro-cima)); padding: var(--seguro-cima) .5rem 0;
    background: var(--ios-bar); -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
    border-bottom: .5px solid var(--ios-separator); }
.app-title { display: inline-flex; align-items: center; gap: .5rem; min-height: 44px; color: var(--bs-body-color) !important;
    font-size: 1.05rem; font-weight: 600; letter-spacing: -.01em; }
.app-title:hover { opacity: 1; }
.app-logo { flex: none; display: grid; place-items: center; width: 1.75rem; height: 1.75rem; border-radius: .45rem;
    background: var(--ios-blue); color: var(--acento-texto); font-size: 1.1rem; }
.top-exit-form { position: absolute; right: .5rem; top: calc(var(--seguro-cima) + .125rem); margin: 0; }
.top-exit { display: grid; place-items: center; width: 44px; height: 44px; color: var(--ios-label2); font-size: 1.35rem;
    background: none; border: 0; border-radius: .75rem; }
.top-exit:active { opacity: .55; }
@media (hover: hover) { .top-exit:hover { color: var(--ios-red); background: var(--ios-fill); } }

/* ---------- Barra de abas (celular) ---------- */
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: flex; padding-bottom: var(--seguro-baixo);
    background: var(--ios-bar); -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
    border-top: .5px solid var(--ios-separator); }
.tab { position: relative; flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .15rem;
    height: var(--altura-aba); color: var(--ios-label2) !important; font-size: .72rem; font-weight: 500;
    background: none; border: 0; cursor: pointer; user-select: none; -webkit-tap-highlight-color: transparent; transition: color .15s ease; }
.tab:hover { opacity: 1; }
.tab:active { opacity: .55; }
.tab.active { color: var(--ios-blue) !important; }
.tab-icone { display: grid; place-items: center; height: 1.6rem; font-size: 1.4rem; line-height: 1; }
.tab .on { display: none; }
.tab.active .off { display: none; }
.tab.active .on { display: block; }
.ponto-alerta { position: absolute; top: .3rem; left: calc(50% + .55rem); width: .55rem; height: .55rem; border-radius: 50%; background: var(--ios-red); }

main.conteudo { padding-bottom: calc(var(--altura-aba) + var(--seguro-baixo) + 1.5rem) !important; }

/* ---------- Painel "Menu" (celular): entra pela direita ---------- */
.drawer-backdrop { position: fixed; inset: 0; z-index: 40; background: rgba(0, 0, 0, .35); opacity: 0; visibility: hidden;
    transition: opacity .25s ease, visibility 0s linear .25s; }
.drawer-backdrop.open { opacity: 1; visibility: visible; transition: opacity .25s ease, visibility 0s; }
.drawer { position: fixed; top: 0; bottom: 0; right: 0; z-index: 50; display: flex; flex-direction: column; width: min(86vw, 22rem);
    padding: var(--seguro-cima) 0 var(--seguro-baixo); background: var(--ios-bg); box-shadow: 0 0 40px rgba(0, 0, 0, .22);
    border-radius: 1rem 0 0 1rem; transform: translateX(100%); visibility: hidden;
    transition: transform .32s cubic-bezier(.32, .72, 0, 1), visibility 0s linear .32s; }
.drawer.open { transform: none; visibility: visible; transition: transform .32s cubic-bezier(.32, .72, 0, 1), visibility 0s; }
.drawer-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1rem 1rem .5rem 1.25rem; }
.drawer-user { display: flex; align-items: center; gap: .7rem; min-width: 0; }
.drawer-user > span:last-child { display: flex; flex-direction: column; min-width: 0; }
.drawer-user strong { font-size: 1.2rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.drawer-user small { color: var(--ios-label2); }
.drawer-close { position: relative; flex: none; display: grid; place-items: center; width: 2rem; height: 2rem; color: var(--ios-label2);
    background: var(--ios-fill); border: 0; border-radius: 50%; font-size: 1.1rem; }
.drawer-close::before { content: ""; position: absolute; inset: -.4rem; }
.drawer-nav { flex: 1; padding: .75rem 1rem 1rem; overflow-y: auto; overscroll-behavior: contain; }
.drawer-secao { margin: 0 0 .4rem .9rem; color: var(--ios-label2); font-size: .78rem; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; }
.drawer-grupo { margin-bottom: 1.25rem; overflow: hidden; background: var(--ios-surface); border-radius: .8rem; }
.drawer-grupo form { margin: 0; }
.row-link { display: flex; align-items: center; gap: .75rem; width: 100%; min-height: 48px; padding: .6rem 1rem;
    color: var(--bs-body-color) !important; font-size: 1rem; text-align: left; background: none; border: 0;
    border-bottom: .5px solid var(--ios-separator); cursor: pointer; -webkit-tap-highlight-color: transparent; }
.row-link:hover { opacity: 1; background: var(--ios-fill); }
.row-link:active { background: var(--ios-fill); }
.row-ico { display: grid; place-items: center; font-size: 1.25rem; color: var(--ios-blue); }
.row-label { flex: 1; }
.row-link::after { content: "›"; color: var(--ios-label2); font-size: 1.4rem; line-height: 1; }
.row-link.active { color: var(--ios-blue) !important; font-weight: 600; }
.drawer-grupo > .row-link:last-child, .drawer-grupo > :last-child > .row-link { border-bottom: 0; }
.row-perigo, .row-perigo .row-ico { color: var(--ios-red) !important; }
.row-perigo::after { content: none; }

.contador { flex: none; min-width: 1.3rem; padding: .05rem .4rem; border-radius: 999px; background: var(--ios-red); color: #fff;
    font-size: .72rem; font-weight: 700; text-align: center; line-height: 1.35; }

/* ---------- Barra lateral (computador) ---------- */
.sidebar { display: none; }

@media (min-width: 768px) {
    .tabbar, .drawer, .drawer-backdrop, .top-exit-form { display: none; }
    main.conteudo { padding-bottom: 2rem !important; }

    :root { --side-w: 4.5rem; }
    :root[data-menu="expandido"] { --side-w: 15.5rem; }
    .app-shell { padding-left: var(--side-w); transition: padding-left .25s cubic-bezier(.32, .72, 0, 1); }

    .sidebar { position: fixed; top: 0; bottom: 0; left: 0; z-index: 35; display: flex; flex-direction: column; width: var(--side-w);
        padding: calc(var(--seguro-cima) + .75rem) .75rem calc(var(--seguro-baixo) + .75rem);
        background: var(--ios-bar); -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
        border-right: .5px solid var(--ios-separator); overflow: hidden; transition: width .25s cubic-bezier(.32, .72, 0, 1); }

    .side-brand, .side-link { position: relative; display: flex; align-items: center; gap: .85rem; width: 100%; min-height: 44px; padding: 0 .75rem;
        color: var(--ios-label2) !important; font-size: .98rem; font-weight: 500; white-space: nowrap; text-align: left;
        background: none; border: 0; border-radius: .8rem; cursor: pointer; -webkit-tap-highlight-color: transparent; }
    .side-brand { margin-bottom: .75rem; padding: 0 .5rem; color: var(--bs-body-color) !important; font-weight: 700; letter-spacing: -.01em; }
    .side-brand:hover { opacity: 1; }
    .side-ico { flex: none; display: grid; place-items: center; width: 1.5rem; font-size: 1.35rem; }
    .side-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; opacity: 0; transition: opacity .15s ease; }
    :root[data-menu="expandido"] .side-label { opacity: 1; transition-delay: .1s; }

    .side-toggle { margin-bottom: .35rem; }
    .side-nav { display: flex; flex-direction: column; gap: .2rem; flex: 1; overflow-y: auto; overflow-x: hidden; scrollbar-width: none; }
    .side-nav::-webkit-scrollbar { display: none; }
    .side-foot { display: grid; gap: .2rem; padding-top: .6rem; border-top: .5px solid var(--ios-separator); }
    .side-foot form { margin: 0; }

    .side-link:active { opacity: .6; }
    .side-link:hover { opacity: 1; }
    @media (hover: hover) { .side-link:hover { background: var(--ios-fill); color: var(--bs-body-color) !important; } }
    .side-link.active { color: var(--ios-blue) !important; background: color-mix(in srgb, var(--ios-blue) 14%, transparent); font-weight: 600; }
    .side-perigo:hover { color: var(--ios-red) !important; }
    .side-user .avatar-iniciais { width: 1.75rem; height: 1.75rem; margin-left: -.125rem; font-size: .72rem; }
    .side-user { cursor: default; }
    .side-user:hover { background: none !important; }

    /* Contador de alertas: no menu recolhido vira um ponto sobre o ícone. */
    .side-ponto { position: absolute; top: .45rem; left: 2rem; width: .55rem; height: .55rem; border-radius: 50%; background: var(--ios-red); }
    :root[data-menu="expandido"] .side-ponto { display: none; }
    :root:not([data-menu="expandido"]) .side-link .contador { display: none; }

    /* Submenus por assunto. Recolhido: os ícones dos itens ficam visíveis, separados por um traço. Expandido: o grupo abre e fecha. */
    .side-grupo { display: flex; flex-direction: column; gap: .2rem; }
    .side-sub { display: flex; flex-direction: column; gap: .2rem; }
    .side-seta { flex: none; font-size: 1.1rem; transition: transform .2s ease; }
    .side-grupo-cab[aria-expanded="true"] .side-seta { transform: rotate(90deg); }
    :root:not([data-menu="expandido"]) .side-grupo { margin: .25rem 0; padding-top: .45rem; border-top: .5px solid var(--ios-separator); }
    :root:not([data-menu="expandido"]) .side-grupo-cab { display: none; }
    :root[data-menu="expandido"] .side-grupo:not(.aberto) .side-sub { display: none; }
    :root[data-menu="expandido"] .side-sub .side-link { padding-left: 1.6rem; min-height: 40px; font-size: .94rem; }
    :root[data-menu="expandido"] .side-sub .side-ico { font-size: 1.2rem; }
    .side-grupo-cab.contem-ativo { color: var(--bs-body-color) !important; font-weight: 600; }
}

@media (prefers-reduced-motion: reduce) {
    .drawer, .drawer-backdrop, .tab, .sidebar, .side-label, .app-shell, .side-seta { transition: none !important; }
}

/* ---------- Personalização: amostras de cor ---------- */
.segmentado-grande button { min-height: 44px; font-size: .95rem; }
.temas { display: grid; grid-template-columns: repeat(auto-fill, minmax(5.5rem, 1fr)); gap: 1rem .5rem; padding: 1rem; }
.tema-opcao { display: flex; flex-direction: column; align-items: center; gap: .4rem; min-height: 44px; font-size: .85rem;
    color: var(--bs-body-color); background: none; border: 0; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.tema-cor { display: grid; place-items: center; width: 2.75rem; height: 2.75rem; color: var(--amostra-texto, #fff); background: var(--amostra);
    border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .12); font-size: 1.4rem; transition: transform .12s ease-out, box-shadow .15s ease; }
.tema-cor i { opacity: 0; }
.tema-opcao:active .tema-cor { transform: scale(.94); }
.tema-opcao[aria-checked="true"] { font-weight: 600; }
.tema-opcao[aria-checked="true"] .tema-cor { box-shadow: 0 0 0 2px var(--ios-surface), 0 0 0 4px var(--amostra); }
.tema-opcao[aria-checked="true"] .tema-cor i { opacity: 1; }
.tema-salvia  { --amostra: #3d6b5e; }
.tema-azul    { --amostra: #0066d6; }
.tema-verde   { --amostra: #1f7a3a; }
.tema-roxo    { --amostra: #8944ab; }
.tema-laranja { --amostra: #b45309; }
.tema-rosa    { --amostra: #c2185b; }
.tema-grafite { --amostra: #48484a; }
[data-bs-theme="dark"] .tema-salvia  { --amostra: #6fb7a3; --amostra-texto: #000; }
[data-bs-theme="dark"] .tema-azul    { --amostra: #0a84ff; }
[data-bs-theme="dark"] .tema-verde   { --amostra: #30d158; --amostra-texto: #000; }
[data-bs-theme="dark"] .tema-roxo    { --amostra: #bf5af2; }
[data-bs-theme="dark"] .tema-laranja { --amostra: #ff9f0a; --amostra-texto: #000; }
[data-bs-theme="dark"] .tema-rosa    { --amostra: #ff375f; }
[data-bs-theme="dark"] .tema-grafite { --amostra: #aeaeb2; --amostra-texto: #000; }

/* ---------- Ícone próprio: orador na tribuna (o símbolo de Reuniões do wol.jw.org), no traço do Remix Icon ----------
   Usa máscara com currentColor, então pega a cor do texto como os outros ícones "ri-". */
.ri-tribuna-line::before, .ri-tribuna-fill::before {
    content: ""; display: inline-block; width: 1.1em; height: 1.1em; vertical-align: -.17em; background-color: currentColor;
    -webkit-mask: var(--icone-tribuna) center / contain no-repeat; mask: var(--icone-tribuna) center / contain no-repeat; }
.ri-tribuna-line { --icone-tribuna: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.7' stroke-linejoin='round' stroke-linecap='round'%3E%3Ccircle cx='12' cy='4.9' r='3'/%3E%3Cpath d='M5.6 13.6v-1.2c0-2.1 1.6-3.4 3.6-3.4h5.6c2 0 3.6 1.3 3.6 3.4v1.2'/%3E%3Cpath d='M12 9v4.6'/%3E%3Cpath d='M2.2 13.6h19.6l-3 8.2H5.2z'/%3E%3C/svg%3E"); }
.ri-tribuna-fill { --icone-tribuna: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='black' stroke='black' stroke-width='1.7' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='4.9' r='3'/%3E%3Cpath d='M5.6 13.6v-1.2c0-2.1 1.6-3.4 3.6-3.4h5.6c2 0 3.6 1.3 3.6 3.4v1.2z'/%3E%3Cpath d='M2.2 13.6h19.6l-3 8.2H5.2z'/%3E%3C/svg%3E"); }
