/* ===== TOP BAR ===== */
.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
    height: 55px;
    background: var(--primary-color);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.12);
    position: sticky; /* também âncora pro .top-bar-center absoluto abaixo */
    top: 0;
    z-index: 1000;
    color: var(--primary-text-color);
}
.top-bar-left, .top-bar-right { display: flex; align-items: center; }
/* Centralizado por position:absolute (independente da largura de
   .top-bar-left/.top-bar-right) em vez de grid — a tentativa com grid
   (1fr auto 1fr) quebrou a altura da barra: o padding-top do
   .datetime-display forçava a row do grid a crescer além dos 55px fixos
   da barra, empurrando os elementos pra fora dela. Position:absolute tira
   o center do fluxo inteiramente, então não afeta nem é afetado pela
   altura/largura dos irmãos. */
.top-bar-center {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    align-items: center;
}
.top-bar-center .datetime-display { padding-top: 10px; font-size: 0.7em; font-weight: 500; }
.top-bar i { color: var(--primary-text-color); }

.brand-mark { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.brand-mark img { width: 32px; height: 32px; border-radius: 8px; display: block; }
.brand-mark-text {
    font-weight: 600; font-size: 1.2em; color: var(--primary-text-color);
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.2);
}

/* Botão de tema na sidebar (era na barra superior — ficava por cima do
   relógio centralizado em telas estreitas, já que o center é position:absolute
   e não reserva espaço pros irmãos). */
.sidebar-links li button.theme-toggle-link {
    display: flex;
    align-items: center;
    width: 100%;
    padding: 16px 20px 16px 16px;
    margin: 4px 12px;
    background: none;
    border: none;
    font: inherit;
    text-align: left;
    color: var(--text-color);
    border-radius: 12px;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease, transform 0.15s ease;
}
.sidebar-links li button.theme-toggle-link:hover {
    background: var(--primary-color);
    color: var(--primary-text-color);
    transform: translateX(4px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}
.theme-toggle-link .theme-icon-dark { display: none; }
.theme-toggle-link .theme-icon-light,
.theme-toggle-link .theme-icon-dark {
    margin-right: 14px;
    width: 20px;
    text-align: center;
    opacity: 0.65;
}
.theme-toggle-link:hover .theme-icon-light,
.theme-toggle-link:hover .theme-icon-dark { opacity: 1; }
.theme-toggle-link .theme-toggle-texto-escuro { display: none; }
html[data-theme="dark"] .theme-toggle-link .theme-icon-light { display: none; }
html[data-theme="dark"] .theme-toggle-link .theme-icon-dark { display: inline-block; }
html[data-theme="dark"] .theme-toggle-link .theme-toggle-texto-claro { display: none; }
html[data-theme="dark"] .theme-toggle-link .theme-toggle-texto-escuro { display: inline; }

.hamburger-btn {
    background: none;
    border: none;
    font-size: 1.5em;
    cursor: pointer;
    color: var(--primary-text-color);
    padding: 10px;
    position: relative;
}

.top-bar-auth-btn {
    background-color: rgba(255, 255, 255, 0.15);
    color: var(--primary-text-color);
    border: 1px solid rgba(255, 255, 255, 0.3);
    padding: 8px 15px;
    border-radius: 5px;
    text-decoration: none;
    font-size: 0.9em;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
}
.top-bar-auth-btn:hover { background-color: rgba(255, 255, 255, 0.25); }

/* ===== SIDEBAR ===== */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100%;
    width: 240px;
    background: var(--card-bg);
    box-shadow: 4px 0 15px rgba(0, 0, 0, 0.12);
    transform: translateX(-100%);
    transition: transform 0.3s ease-in-out;
    z-index: 1002;
    display: flex;
    flex-direction: column;
    border-radius: 0 20px 20px 0;
}
.sidebar.active { transform: translateX(0); }

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 2px solid color-mix(in srgb, var(--primary-color) 80%, transparent);
    background: var(--primary-color);
    border-radius: 0 20px 0 0;
}
.sidebar-header h3 {
    margin: 0;
    color: var(--primary-text-color);
    font-weight: 600;
    font-size: 1.3em;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.2);
}

.close-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    font-size: 1.5em;
    font-weight: 300;
    cursor: pointer;
    color: var(--primary-text-color);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease, transform 0.2s ease;
}
.close-btn:hover { background: rgba(255, 255, 255, 0.35); transform: scale(1.1); }

/* ===== SIDEBAR LINKS ===== */
.sidebar-links {
    list-style: none;
    padding: 15px 0;
    margin: 0;
    overflow-y: auto;
}
.sidebar-links li a {
    display: flex;
    align-items: center;
    padding: 16px 20px 16px 16px;   /* recuo esquerdo menor pra diferenciar do submenu */
    margin: 4px 12px;
    color: var(--text-color);
    text-decoration: none;
    border-radius: 12px;
    transition: background 0.2s ease, color 0.2s ease, transform 0.15s ease;
}
.sidebar-links li a:hover {
    background: var(--primary-color);
    color: var(--primary-text-color);
    transform: translateX(4px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}
.sidebar-links li a:hover i { color: var(--primary-text-color); transform: scale(1.1); }

.sidebar-links i {
    margin-right: 14px;
    width: 20px;
    text-align: center;
    color: var(--text-color);
    opacity: 0.65;
    transition: color 0.2s ease, transform 0.15s ease;
}

/* Active link — uses --link-color per design system */
.sidebar-links li a.active {
    background: color-mix(in srgb, var(--link-color) 12%, transparent);
    color: var(--link-color);
    font-weight: 600;
    box-shadow: inset 4px 0 0 0 var(--link-color);
}
.sidebar-links li a.active i { color: var(--link-color); opacity: 1; }
.sidebar-links li a.active:hover {
    background: color-mix(in srgb, var(--link-color) 20%, transparent);
    color: var(--link-color);
}

/* Badge de contagem nos links da sidebar */
.sidebar-badge {
    margin-left: auto;
    background: var(--danger);
    color: #fff;
    min-width: 22px;
    height: 22px;
    border-radius: 11px;
    padding: 0 5px;
    font-size: 0.73em;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 6px rgba(220, 53, 69, 0.4);
}

/* ===== SUBMENU (Entretenimento) ===== */
.sidebar-submenu-toggle {
    display: flex;
    align-items: center;
    width: calc(100% - 24px);
    margin: 4px 12px;
    padding: 16px 20px;
    border: none;
    background: transparent;
    color: var(--text-color);
    font: inherit;
    text-align: left;
    cursor: pointer;
    border-radius: 12px;
    transition: background 0.2s ease, color 0.2s ease, transform 0.15s ease;
}
.sidebar-submenu-toggle:hover {
    background: var(--primary-color);
    color: var(--primary-text-color);
    transform: translateX(4px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}
.sidebar-submenu-toggle:hover i { color: var(--primary-text-color); }
.sidebar-submenu-toggle i {
    margin-right: 14px;
    width: 20px;
    text-align: center;
    color: var(--text-color);
    opacity: 0.65;
    transition: color 0.2s ease, transform 0.2s ease;
}
.sidebar-submenu-label { flex: 1; }
.sidebar-submenu-caret {
    margin-right: 0 !important;
    font-size: 0.8em;
    opacity: 0.5;
}
.sidebar-submenu-toggle[aria-expanded="true"] .sidebar-submenu-caret {
    transform: rotate(180deg);
}
.sidebar-submenu-toggle.active {
    color: var(--link-color);
    font-weight: 600;
}
.sidebar-submenu-toggle.active i { color: var(--link-color); opacity: 1; }

/* O submenu colapsa via max-height para animar a abertura. */
.sidebar-submenu {
    list-style: none;
    margin: 0;
    padding: 0;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.28s ease;
}
.sidebar-submenu.is-open { max-height: 320px; }
.sidebar-submenu li a {
    padding-left: 28px;       /* recuo de hierarquia (menor, sobra mais espaço à direita) */
    margin-top: 2px;
    margin-bottom: 2px;
    font-size: 0.95em;
    white-space: nowrap;      /* não quebrar "Gerador de BBCode" em 2 linhas */
}
.sidebar-submenu li a i { flex-shrink: 0; }
.sidebar-submenu li a i { opacity: 0.55; }

/* ===== OVERLAY ===== */
.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.55);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease-in-out, visibility 0.3s;
    z-index: 1001;
    backdrop-filter: blur(3px);
}
.sidebar-overlay.active { opacity: 1; visibility: visible; }

/* ===== HAMBURGER BADGE ===== */
.hamburger-badge {
    position: absolute;
    top: 5px;
    right: 5px;
    background-color: var(--danger);
    color: #fff;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: none;
    justify-content: center;
    align-items: center;
    font-size: 11px;
    font-weight: 700;
    border: 2px solid var(--primary-text-color);
}

/* ===== USER MENU (top-right dropdown) ===== */
.user-menu-container { position: relative; }
.user-menu-container i { color: var(--text-color); }

/* Reusa o componente _avatar.html — o botão é só o wrapper clicável. */
.user-avatar-trigger {
    background: none;
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    padding: 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}
.user-avatar-trigger .avatar-container { transform: scale(0.7); }

.user-menu {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    background-color: var(--card-bg);
    border-radius: 10px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    min-width: 200px;
    z-index: 1010;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s;
}
.user-menu.active { opacity: 1; visibility: visible; transform: translateY(0); }

.user-menu a,
.user-menu button {
    box-sizing: border-box;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    text-decoration: none;
    color: var(--text-color);
    font-size: 0.95em;
    background: none;
    border: none;
    width: 100%;
    text-align: left;
    cursor: pointer;
    transition: background 0.15s ease;
}
.user-menu a:hover,
.user-menu button:hover {
    background-color: color-mix(in srgb, var(--text-color) 6%, transparent);
}

.user-menu .logout-form-menu {
    border-top: 1px solid color-mix(in srgb, var(--text-color) 10%, transparent);
}

/* Cabeçalho de gameficação no topo do menu (acesso rápido a Meus Pontos):
   saldo resumido (sistema k) à esquerda, nível à direita. */
.user-menu a.user-menu-header {
    justify-content: space-between;
    gap: 10px;
    padding: 12px 16px;
    background: color-mix(in srgb, var(--text-color) 5%, transparent);
    border-bottom: 1px solid color-mix(in srgb, var(--text-color) 10%, transparent);
}
.user-menu a.user-menu-header:hover {
    background: color-mix(in srgb, var(--text-color) 9%, transparent);
}
.user-menu-header .umh-coins {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-weight: 700;
}
.user-menu-header .umh-coins i { color: #c8871a; }
.user-menu-header .umh-level {
    font-size: 0.82em;
    font-weight: 600;
    padding: 2px 9px;
    border-radius: 999px;
    background: color-mix(in srgb, var(--text-color) 12%, transparent);
    white-space: nowrap;
}

/* ===== NOTIFICATION BELL (header) ===== */
.top-bar-right { gap: 4px; }
.notif-bell-container { position: relative; display: flex; }

.notif-bell-btn {
    background: none;
    border: none;
    color: var(--primary-text-color);
    font-size: 1.25em;
    cursor: pointer;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    border-radius: 50%;
    transition: background 0.2s ease;
}
.notif-bell-btn:hover { background: rgba(255, 255, 255, 0.15); }
.notif-bell-btn i { color: var(--primary-text-color); }

.notif-bell-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    background: var(--danger);
    color: #fff;
    min-width: 15px;
    height: 15px;
    padding: 0 3px;
    border-radius: 8px;
    font-size: 9px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1.5px solid var(--primary-color-start);
    box-sizing: content-box;
}

/* Dropdown ancorado ao viewport p/ nunca estourar em telas estreitas */
.notif-dropdown {
    position: fixed;
    top: 58px;
    right: 8px;
    width: min(360px, calc(100vw - 16px));
    background: var(--card-bg);
    border-radius: 14px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.22);
    z-index: 1010;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s;
}
.notif-dropdown.active { opacity: 1; visibility: visible; transform: translateY(0); }

.notif-dropdown-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid color-mix(in srgb, var(--text-color) 10%, transparent);
    font-weight: 600;
    color: var(--text-color);
}
.notif-dropdown-header > span i { color: var(--text-color); opacity: 0.7; }
.notif-dropdown-header a {
    font-size: 0.82em;
    font-weight: 600;
    color: var(--link-color);
    text-decoration: none;
}

.notif-dropdown-body {
    max-height: min(60vh, 360px);
    overflow-y: auto;
}

.notif-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 13px 16px;
    text-decoration: none;
    color: var(--text-color);
    border-bottom: 1px solid color-mix(in srgb, var(--text-color) 6%, transparent);
    transition: background 0.15s ease;
}
.notif-item:last-child { border-bottom: none; }
.notif-item:hover { background: color-mix(in srgb, var(--text-color) 5%, transparent); }

/* ===== Bolha flutuante de acesso rápido às PMs (estilo Messenger) ===== */
.pm-quick-access-container { position: fixed; bottom: 25px; right: 25px; z-index: 999; }
.pm-quick-access-container .floating-refresh-btn { position: static; }
.pm-quick-access-popup {
    position: absolute;
    top: auto;
    bottom: calc(100% + 12px);
    right: 0;
    /* o container fica a 25px da borda direita — o width herdado de
       .notif-dropdown (100vw - 16px) estourava a borda ESQUERDA em telas
       estreitas; aqui desconta o offset + um respiro */
    width: min(360px, calc(100vw - 41px));
}
/* altura: bolha + header + body não podem passar do topo da tela em
   telas baixas (ex.: celular na horizontal) */
.pm-quick-access-popup .notif-dropdown-body {
    max-height: min(360px, 60vh, calc(100vh - 170px));
}

/* Linhas de conversa (_inbox_conversation_row.html) dentro do popup: o
   layout flex delas (.inbox-conversation-item/.convo-content/...) só existe
   em chat.css, carregado apenas em inbox.html/view_conversation.html — sem
   isso aqui, o popup (que vive em base.html, sem chat.css) renderizava os
   filhos em bloco empilhado (avatar sozinho numa linha, texto centralizado
   embaixo) em vez de avatar+texto lado a lado como no inbox de verdade. */
.pm-quick-access-popup .inbox-conversation-item {
    padding: 13px 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid color-mix(in srgb, var(--text-color) 6%, transparent);
    transition: background 0.15s ease;
}
.pm-quick-access-popup .inbox-conversation-item:last-child { border-bottom: none; }
.pm-quick-access-popup .inbox-conversation-item:hover {
    background: color-mix(in srgb, var(--text-color) 5%, transparent);
}
.pm-quick-access-popup .inbox-conversation-item.unread {
    background: color-mix(in srgb, var(--link-color) 12%, transparent);
    box-shadow: inset 4px 0 0 var(--link-color);
}
.pm-quick-access-popup .inbox-conversation-item.unread .convo-timestamp {
    color: var(--link-color);
    font-weight: 700;
}
.pm-quick-access-popup .inbox-conversation-item.unread:hover {
    background: color-mix(in srgb, var(--link-color) 14%, transparent);
}
.pm-quick-access-popup .convo-content { flex-grow: 1; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.pm-quick-access-popup .convo-line-top {
    display: flex; justify-content: space-between; align-items: flex-start;
    font-weight: 600; font-size: 0.92em; gap: 6px;
}
.pm-quick-access-popup .convo-line-top > span:first-child { word-break: break-word; }
.pm-quick-access-popup .convo-line-bottom {
    font-size: 0.82em;
    color: var(--text-muted-color, #888);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    margin: 0;
    text-align: left;
}
.pm-quick-access-popup .convo-timestamp {
    font-size: 0.75em;
    color: var(--text-muted-color, #888);
    flex-shrink: 0; white-space: nowrap;
    display: flex; align-items: center; gap: 3px;
}
.pm-quick-access-popup .unread-badge {
    display: inline-flex; align-items: center; justify-content: center;
    background-color: var(--link-color);
    color: #fff;
    font-size: 0.72em; font-weight: 700;
    min-width: 18px; height: 18px;
    border-radius: 9px; padding: 0 5px;
    margin-left: 4px; vertical-align: middle;
}
.pm-quick-access-popup .message-status-sent { opacity: 0.6; font-size: 0.85em; margin-right: 3px; }
.pm-quick-access-popup .message-status-read { color: var(--link-color); font-size: 0.85em; margin-right: 3px; }

.notif-item.unread { background: color-mix(in srgb, var(--link-color) 8%, transparent); }
.notif-item.unread:hover { background: color-mix(in srgb, var(--link-color) 14%, transparent); }

.notif-item-icon {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: color-mix(in srgb, var(--link-color) 14%, transparent);
}
.notif-item-icon i { color: var(--link-color); font-size: 0.95em; }

.notif-item-content { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.notif-item-msg {
    font-size: 0.86em;
    line-height: 1.35;
    color: var(--text-color);
    /* limita a 2 linhas para manter o item compacto */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.notif-item.unread .notif-item-msg { font-weight: 600; }
.notif-item-time { font-size: 0.74em; color: var(--text-muted-color, #888); }

.notif-loading, .notif-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 32px 16px;
    color: var(--text-muted-color, #888);
    font-size: 0.85em;
    text-align: center;
}
.notif-loading i { font-size: 1.4em; opacity: 0.6; }
.notif-empty i { font-size: 1.6em; opacity: 0.45; }

/* ===== CTA de cadastro (sidebar, visitante) ===== */
.sidebar-links li a.sidebar-cta {
    background: var(--primary-color);
    color: var(--primary-text-color);
    font-weight: 600;
    margin-top: 10px;
}
.sidebar-links li a.sidebar-cta i { color: var(--primary-text-color); opacity: 1; }
.sidebar-links li a.sidebar-cta:hover { filter: brightness(1.05); }
