/* ================================================================
 * structure.css — Esqueleto do layout (posicionamento e dimensões)
 * Não contém cores, backgrounds ou imagens de tema.
 * Para responsividade: editar as larguras fixas aqui.
 * ================================================================ */

/* Reset */
* { margin: 0; padding: 0; }
a img { border: 0; }
a:focus  { outline: none; -moz-outline-style: none; }
a:hover  { text-decoration: none; }
object   { outline: none; -moz-outline-style: none; }
p        { margin: 1.8em 0; }
p.lead   { margin-top: 0; }
em em    { font-style: normal; }

/* Utilidades */
.relative { position: relative; }
.left     { float: left; }
.right    { float: right; }
.clean_5  { height: 5px;  width: 100%; float: left; }
.clean_20 { height: 20px; width: 100%; float: left; }

/* Body */
body {
    font-size: 11px;
    font-family: Verdana, sans-serif;
    padding: 0;
    margin: 0;
}

/* Página */
#page {
    width: 1309px;
    margin: auto;
}

#logo {
    height: 240px;
    width: 100%;
    margin: 0;
    position: relative;
    background-image:
        url('https://static.tibia-old.com/layouts/cyber/_img/background/tibia-old-logo.png'),
        url('https://static.tibia-old.com/layouts/cyber/_img/background/background_clear.png');
    background-position: center center, center center;
    background-size: auto 70%, cover;
    background-repeat: no-repeat, no-repeat;
}

/* Área central + rodapé */
#content {
    margin: auto;
    width: 1168px;
    margin-top: 24px;
    margin-left: 62px;
    float: left;
}

#content_bot {
    height: 74px;
    width: 1168px;
    margin: auto;
    float: left;
    margin-left: 162px;
}

/* ==============================
 * Menu superior (topnav)
 * Layout via CSS puro — visual em theme.css.
 * Block normal (não float) para forçar que sidebar/content fiquem abaixo.
 *
 * `margin-top: -50px` faz a topnav sobrepor a metade inferior do hero (#logo):
 * com `#content { margin-top: 24px }` e topnav de 52px de altura, o centro
 * vertical da topnav fica exatamente no final do hero. Resultado: o hero
 * "termina" na metade da topnav, criando integração visual.
 * ============================== */
#menu_top {
    width: 100%;
    margin: -50px 0 22px 0;
    position: relative;
    z-index: 250;
}

/* ==============================
 * Menu esquerdo
 * ============================== */
#menu_left { margin: 0 0 10px 19px; width: 182px; float: left; }

#themeboxnews { width: 100%; position: relative; margin-bottom: 10px; z-index: 10; }
#menu-title   { width: 100%; height: 45px; position: relative; }

/* Header das seções da sidebar (esq + dir): flex unificado em todos os breakpoints.
   Imagens-rótulo legadas (#text-*) ficam ocultas; o texto vem de <span class="section-label">.
   Filtro por pai (`#menu_left`, `#menu_right`) — o ID `menu-title` está duplicado e também
   aparece em `#textnew_content`, que NÃO deve ganhar este layout. */
#menu_left #menu-title,
#menu_right #menu-title,
.sidebar-section-title {
    display: flex;
    align-items: center;
    height: 45px;
    padding: 0 10px;
    box-sizing: border-box;
}
/* Os antigos `<div id="icon-*">` e `<div id="text-*">` foram removidos dos
   templates — substituídos por `<i data-lucide="..." class="section-icon">`
   e `<span class="section-label">`. Regras CSS órfãs daqueles IDs também
   foram limpas. */

.section-label {
    display: block;
    flex: 1;
    min-width: 0;
    font-family: var(--font-body);
    font-size: 13px;
    font-weight: 700;
    color: var(--color-accent-text);
    letter-spacing: 0.3px;
    text-shadow: 1px 1px #000;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#themeboxews-content,
#themeboxaccount-content,
#themeboxcomm-content {
    overflow: hidden;
    padding-bottom: 5px;
    margin-left: 10px;
    margin-right: 10px;
    margin-bottom: 12px;
}

/* ---------------------------------------------------------------------------
 * Sidebar accordion — seções colapsáveis em TODOS os breakpoints.
 * Header clicável abre/fecha o conteúdo com slide suave (max-height).
 * Estado inicial: recolhido. O JS (app.js) reabre as seções que o usuário
 * deixou abertas (persistidas em localStorage). O media query ≤680px só
 * ajusta tamanhos/área de toque; a mecânica vive aqui.
 * Escopo em #menu_left para não afetar o sidebar direito (que não usa
 * as classes .sidebar-section*). */
#menu_left .sidebar-section-title {
    cursor: pointer;
    user-select: none;
    position: relative;
    transition: background-color 0.15s ease;
}
#menu_left .sidebar-section-title:hover { background-color: rgba(255,255,255,0.04); }

/* Espaço à direita do rótulo para a seta indicadora */
#menu_left .section-label { margin-right: 26px; }

/* Chevron desenhado em CSS (duas bordas de um quadrado girado) — mais limpo
   que um glifo de texto. Fechado aponta pra baixo ("abrir"); aberto gira
   pra cima ("fechar"). translateY(-50%) mantém o centro fixo na rotação. */
#menu_left .sidebar-section-title::after {
    content: '';
    position: absolute;
    right: 14px;
    top: 50%;
    width: 7px;
    height: 7px;
    border-right: 2px solid #8a96a8;
    border-bottom: 2px solid #8a96a8;
    border-radius: 1px;
    transform-origin: center;
    transform: translateY(-70%) rotate(45deg);   /* aponta pra baixo */
    transition: transform 0.28s ease, border-color 0.15s ease;
    pointer-events: none;
}
#menu_left .sidebar-section-title.open::after {
    transform: translateY(-30%) rotate(225deg);  /* aponta pra cima */
    border-color: #cfd8e3;
}
#menu_left .sidebar-section-title:hover::after { border-color: #cfd8e3; }

/* Conteúdo recolhido por padrão. O max-height real é definido inline pelo JS
   (= altura exata do conteúdo) para não haver "tempo morto" na animação; os
   valores abaixo são só fallback/estado. `padding-bottom`/`margin-bottom`
   animam JUNTO com o max-height (senão a faixa sob os links some de estalo).
   Recolher (estado fechado) é um pouco MAIS RÁPIDO que abrir. */
#menu_left .sidebar-section-content {
    max-height: 0;
    padding-bottom: 0;
    margin-bottom: 0;
    overflow: hidden;
    visibility: hidden;
    transition: max-height 0.22s ease,
                padding-bottom 0.22s ease,
                margin-bottom 0.22s ease,
                visibility 0s 0.22s;
}
#menu_left .sidebar-section-content.open {
    max-height: 1500px;
    padding-bottom: 5px;
    margin-bottom: 12px;
    visibility: visible;
    transition: max-height 0.3s ease,
                padding-bottom 0.3s ease,
                margin-bottom 0.3s ease,
                visibility 0s 0s;
}

.corner_lt { position: absolute; width: 64px; height: 64px; left: -19px;  top: -17px; }
.corner_rt { position: absolute; width: 64px; height: 64px; right: -19px; top: -17px; }
.corner_lb { position: absolute; width: 64px; height: 64px; left: -19px;  bottom: -18px; }
.corner_rb { position: absolute; width: 64px; height: 64px; right: -19px; bottom: -18px; }
.border_bottom { width: 100%; display: block; height: 20px; }

#menu-label { float: left; height: 34px; width: 171px; margin-left: 5px; }

#menu_links {
    width: 182px;
    float: left;
    font-size: 11px;
    font-weight: bold;
    text-align: justify;
}
#menu_links ul         { list-style: none outside none; margin: 0; padding: 0; }
#menu_links li         { width: 162px; display: block; padding: 3px 0; margin: 0 auto; }
#menu_links li:hover   { width: 162px; display: block; padding: 3px 0; margin: 0 auto; }
#menu_links li a {
    display: block;
    text-decoration: none;
    padding: 0 6px 0 8px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ==============================
 * Área de conteúdo (centro)
 * ============================== */
.textcorner_lt { position: absolute; width: 64px; height: 64px; left: -19px;  top: -17px;    z-index: 12; }
.textcorner_rt { position: absolute; width: 64px; height: 64px; right: -19px; top: -17px; }
.textcorner_lb { position: absolute; width: 64px; height: 64px; left: -19px;  bottom: -18px; }
.textcorner_rb { position: absolute; width: 64px; height: 64px; right: -19px; bottom: -18px; }
.textborder_bottom { width: 100%; display: block; height: 20px; }

#content_text {
    margin: 0 0 5px 12px;
    width: 741px;
    float: left;
    position: relative;
    z-index: 201;
}

#textnew_content {
    position: relative;
    width: 741px;
}

/* Cobre o pixel transparente no fim de border_top.png */
#textnew_content #menu-title { margin-bottom: -1px; }

#textnew_content_inside {
    padding-bottom: 32px;
    padding-top: 5px;
    margin-left: 20px;
    margin-right: 20px;
}

#text_inner {
    border-radius: 25px;
    padding: 10px;
    box-sizing: border-box;
    margin: 15px 15px 20px;
}

/* ==============================
 * Menu direito
 * ============================== */
#menu_right { margin: 0 0 10px 13px; width: 182px; float: left; }

/* Campo de busca */
.search { border: 1px solid black; padding: 3px; }

/* Seções presentes apenas no mobile (Worlds, Search, Social no sidebar esquerdo) */
.mobile-only-section { display: none; }

/* Mobile topbar — oculto em desktop */
#mobile-topbar { display: none; }
#hamburger     { display: none; }

/* Login / My Account CTA no topo da sidebar left — aparece SO' na faixa
   681-1340px, a "zona morta" onde o top-nav ja' sumiu (<=1340) mas a barra
   mobile com login ainda nao apareceu (>680). Compacto, dourado do tema (mesmo
   glow do "My Account" mobile). Os dois estados apontam pra accountmanagement. */
#sidebar-login { display: none; }
@media (min-width: 681px) and (max-width: 1340px) {
    #sidebar-login {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 6px;
        margin: 0 0 10px;
        padding: 7px 10px;
        font-size: 11.5px;
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: 0.4px;
        border-radius: 4px;
        text-decoration: none;
        transition: background-color .15s ease, color .15s ease, border-color .15s ease;
        background-color: var(--surface-soft);
        border: 1px solid var(--border-soft);
        color: var(--color-accent-soft);
        text-shadow: 0 0 4px rgba(255, 200, 110, 0.35);
    }
    #sidebar-login:hover {
        background-color: var(--surface-soft-hover);
        border-color: var(--border-soft-hover);
        color: #ffffff;
    }
    #sidebar-login i { width: 14px; height: 14px; }
}

/* Drawer overlay */
#drawer-overlay {
    position: fixed;
    top: 48px; right: 0; bottom: 0; left: 0;
    background: rgba(0, 0, 0, 0.55);
    z-index: 999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}
#drawer-overlay.visible {
    opacity: 1;
    pointer-events: auto;
}

/* ================================================================
 * RESPONSIVIDADE
 * ≤1340px : página deixa de ter largura fixa
 * ≤1240px : 2 colunas (sidebar esq. + conteúdo); menu top e sidebar
 *           direita somem. Limite calibrado pelo somatório horizontal
 *           dos floats do desktop:
 *             #menu_left:    margin-left 19 + width 182 = 201px
 *             #content_text: margin-left 12 + width 741 = 753px
 *             #menu_right:   margin-left 13 + width 182 = 195px
 *             ----------------------------------------------------
 *             Total: 1149px
 *           Mais o `width: calc(100% - 62px)` do #content (62px de
 *           margem) e ~15px de scrollbar → viewport mínimo pra caber:
 *           1149 + 62 + 15 = 1226px. Folga de 14px pra não pegar
 *           viewports limítrofes que renderizam off-by-1 → cutoff 1240.
 *           Abaixo disso o #menu_right não cabe horizontalmente e
 *           desce com float wrap pro canto inferior-esquerdo.
 * ≤680px  : mobile — coluna única; nav acima do conteúdo
 * ================================================================ */

@media (max-width: 1340px) {
    #page        { width: 100%; }
    #menu_top    { display: none; }
    #content     { width: calc(100% - 62px); }
    #content_bot { width: calc(100% - 62px); }
    #logo        { width: 100%; }
}

/* Tablet: usa flexbox para evitar colapso de container com float */
@media (max-width: 1240px) {
    /* `overflow-x: hidden` quebra `position: sticky` em descendants. Usar
       `overflow-x: clip` no html — efeito visual igual (corta extravasamento
       horizontal) mas NÃO cria contexto de scroll, permitindo sticky funcionar.
       Suporte: Chrome 90+, Firefox 81+, Safari 16+. */
    html         { overflow-x: clip; }
    #content     {
        width: 100%;
        margin-left: 0;
        margin-top: 0;
        float: none;
        display: flex;
        align-items: flex-start;
    }
    #content_bot { width: 100%; margin-left: 0; float: none; }
    #menu_top    { display: none; }
    #menu_right  { display: none; }
    #menu_left   { float: none; flex-shrink: 0; width: 170px; margin: 8px 0 10px 10px; }
    .mobile-only-section { display: block; }
    #menu_links  { width: 150px; }
    #content_text    { float: none; flex: 1; min-width: 0; margin: 0 8px 5px 8px; }
    #textnew_content { width: 100%; }
}

/* Mobile: drawer lateral + topbar fixa */
@media (max-width: 680px) {
    /* Sem padding-top: topbar se sobrepõe ao #logo (hero area).
       O #logo tem 200px = 48px cobertos pela topbar + 152px visíveis (mais respiro
       em torno da logo do que os 168px anteriores). */
    body          { padding-top: 0; }
    #logo         { display: block; height: 200px; width: 100%; margin: 0; }
    #content      { flex-direction: column; }
    #menu_top     { display: none; }
    #menu_right   { display: none; }

    /* Com a `#mobile-navbar` agora entre o hero e o conteúdo, não cabe mais o
       margin-top negativo de -16px (que sobrepunha o final do gradient).
       Margem zero ou pequena suficiente para respiro. */
    #content_text {
        width: 100%;
        margin: 12px 0 0 0;
        position: relative;
        z-index: 1;
    }
    #textnew_content {
        border-radius: 12px 12px 8px 8px;
        box-shadow: 0 -6px 24px rgba(0, 0, 0, 0.45);
    }

    /* ---- Mobile topbar ----
       Layout: hamburger (left) | online (center, absolute) | account (right).
       O online fica position:absolute centralizado em relação ao topbar para
       não ser empurrado pela largura desigual dos botões esquerda/direita. */
    #mobile-topbar {
        display: flex;
        align-items: center;
        justify-content: space-between;
        position: fixed;
        top: 0; left: 0; right: 0;
        height: 48px;
        z-index: 1002;
        padding: 0 10px;
        gap: 8px;
        overflow: visible;
    }
    /* Online pill mobile — usa tokens accent (mesmos do .topnav-online e
       .section-icon). Posicionada absoluta no centro da topbar. */
    #mobile-online-count {
        position: absolute;
        left: 50%;
        top: 50%;
        transform: translate(-50%, -50%);
        display: inline-flex;
        align-items: center;
        gap: 6px;
        white-space: nowrap;
        font-size: 12px;
        font-weight: 700;
        padding: 5px 12px;
        border-radius: var(--radius-pill);
        background-color: var(--surface-soft);
        border: 1px solid var(--border-soft);
        text-decoration: none;
        transition: background-color 0.15s ease, color 0.15s ease;
    }
    #mobile-online-count i[data-lucide],
    #mobile-online-count svg.lucide {
        width: 14px;
        height: 14px;
        stroke-width: 1.7;
        flex-shrink: 0;
        color: inherit;
        filter: var(--glow-accent);
    }

    /* Botão Account/Login — pill discreta no canto direito */
    #mobile-account-link {
        font-size: 11px;
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: 0.5px;
        padding: 6px 12px;
        border-radius: 4px;
        background-color: rgba(255, 255, 255, 0.06);
        border: 1px solid rgba(255, 255, 255, 0.12);
        color: #d8dde5;
        text-decoration: none;
        transition: background-color 0.15s ease, color 0.15s ease;
    }
    #mobile-account-link:hover,
    #mobile-account-link:active {
        background-color: rgba(255, 255, 255, 0.12);
        color: #ffffff;
    }

    /* "My Account" quando logado — destaque sutil cinza-azul + glow dourado,
       consistente com o tratamento do topnav web. */
    #mobile-account-link.is-logged {
        background-color: var(--surface-soft);
        border-color: var(--border-soft);
        color: var(--color-accent-soft);
        text-shadow: 0 0 4px rgba(255, 200, 110, 0.35);
    }
    #mobile-account-link.is-logged:hover,
    #mobile-account-link.is-logged:active {
        background-color: var(--surface-soft-hover);
        border-color: var(--border-soft-hover);
        color: #ffffff;
    }

    /* ---- Hamburger ---- */
    #hamburger {
        display: flex;
        flex-direction: column;
        justify-content: space-between;
        flex-shrink: 0;
        width: 44px;
        height: 44px;
        padding: 10px 8px;
        background: none;
        border: none;
        cursor: pointer;
    }
    #hamburger span {
        display: block;
        height: 2px;
        border-radius: 2px;
        transition: transform 0.3s ease, opacity 0.3s ease;
    }
    #hamburger.open span:nth-child(1) { transform: translateY(11px) rotate(45deg); }
    #hamburger.open span:nth-child(2) { opacity: 0; }
    #hamburger.open span:nth-child(3) { transform: translateY(-11px) rotate(-45deg); }

    /* ---- Drawer ---- */
    /* max-height + overflow-y:auto: quando conteúdo total das seções excede o
       viewport (ex: admin logado expande Account em 2 itens, somando 9 itens),
       o usuário consegue scrollar dentro do drawer pra ver tudo. Sem isso,
       items extras ficam fora da tela sem forma de acesso. */
    #menu_left {
        position: fixed;
        top: 48px; left: 0;
        bottom: 0;
        width: 260px;
        max-height: calc(100vh - 48px);
        overflow-y: auto;
        overflow-x: hidden;
        -webkit-overflow-scrolling: touch;
        z-index: 1001;
        margin: 0;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }
    #menu_left.drawer-open { transform: translateX(0); }

    #textnew_content         { width: 100%; }
    /* Padding lateral confortável para o conteúdo da página — antes ficava
       em 10px e o texto colava na borda do card em algumas páginas. */
    #textnew_content_inside  {
        margin-left: 0;
        margin-right: 0;
        padding-left: 14px;
        padding-right: 14px;
    }

    /* ---- Sidebar: elimina espaços entre seções ---- */
    /* display:none em vez de height:0 — floats com height:0 ainda podem
       deixar 1px de espaço por renderização sub-pixel */
    #menu_left .clean_5,
    #menu_left .clean_20 { display: none; }
    /* -2px de sobreposição entre seções para cobrir qualquer sub-pixel transparente
       das bordas das imagens repeat-y. Sem padding-bottom — qualquer px extra no
       centro do #themeboxnews apareceria vazio (só as bordas esq/dir têm background). */
    #themeboxnews { margin-bottom: -2px; }

    /* Cantos decorativos: pointer-events:none em todos.
       Cantos superiores com z-index maior — cada #themeboxnews cria stacking context (z-index:10),
       e seções posteriores no DOM ficam na frente das anteriores, então corner_lt da section N+1
       naturalmente cobre o corner_rb da section N. z-index interno reforça a ordem dentro de cada seção. */
    .sidebar-section .corner_lt,
    .sidebar-section .corner_rt { pointer-events: none; z-index: 2; }
    .sidebar-section .corner_lb,
    .sidebar-section .corner_rb { pointer-events: none; z-index: 1; }

    /* ---- Sidebar accordion — título ---- */
    /* Mobile só sobrescreve as diferenças do header desktop:
       altura compacta, padding maior (área de toque), cursor + estados de toque,
       fonte um pouco maior. */
    .sidebar-section-title {
        height: 44px;
        padding: 0 14px;
        cursor: pointer;
        user-select: none;
        font-size: 14px;
        font-weight: 600;
        letter-spacing: 0.2px;
        transition: background-color 0.15s ease;
    }
    .sidebar-section-title:hover,
    .sidebar-section-title:active { background-color: rgba(255,255,255,0.04); }
    .sidebar-section-title.open   { background-color: rgba(255,255,255,0.05); }

    /* No mobile o .section-icon (Lucide) fica um pouco menor para combinar
       com o header de 44px do drawer. */
    .section-icon { width: 20px; height: 20px; margin-right: 12px; }

    /* Espaço para a seta à direita */
    .section-label { margin-right: 28px; }

    .sidebar-section-title::after {
        content: '\25B8'; /* ▸ */
        position: absolute;
        right: 12px;
        top: 50%;
        transform: translateY(-50%) rotate(0deg);
        transform-origin: center;
        color: #8a96a8;
        font-size: 13px;
        pointer-events: none;
        transition: transform 0.25s ease, color 0.15s ease;
    }
    .sidebar-section-title.open::after {
        transform: translateY(-50%) rotate(90deg);
        color: #cfd8e3;
    }

    /* ---- Sidebar accordion — slide animation ----
       `visibility: hidden` quando colapsado garante que o conteúdo dentro
       não vaze para fora (alguns elementos com flex/padding interno
       conseguiam mostrar parte do conteúdo apesar do max-height:0).
       `visibility` muda sem transição quando abre, com delay quando fecha. */
    .sidebar-section-content {
        display: block;
        max-height: 0;
        overflow: hidden;
        visibility: hidden;
        transition: max-height 0.2s ease-out, visibility 0s 0.2s;
    }
    .sidebar-section-content.open {
        max-height: 1500px;
        visibility: visible;
        transition: max-height 0.3s ease-in, visibility 0s 0s;
    }

    /* ---- Conteúdo: preenche a seção, elimina o gap ---- */
    /* padding-bottom:5px do CSS base contribui 5px de layout mesmo com
       max-height:0 + overflow:hidden (o padding fica fora do content-box
       mas dentro do padding-box, portanto visível). Isso criava o gap
       entre o header e o corpo da seção. */
    #themeboxews-content,
    #themeboxaccount-content,
    #themeboxcomm-content {
        margin-left: 0;
        margin-right: 0;
        margin-bottom: 0;
        padding: 4px 0 6px 0;
    }
    /* Subitens: indentação leve para hierarquia visual, fonte normal (não bold),
       área de toque confortável. Cores e bordas vêm do theme.css. */
    #menu_links          { width: 100%; float: none; font-weight: normal; }
    #menu_links ul       { padding: 0; margin: 0; }
    #menu_links li       {
        width: auto;
        padding: 0;
        margin: 0;
    }
    #menu_links li:hover { width: auto; padding: 0; }
    #menu_links li a       {
        display: block;
        padding: 9px 14px 9px 48px;
        font-size: 12.5px;
        font-weight: normal;
        line-height: 1.2;
        transition: background-color 0.12s ease;
    }
    #menu_links li a:hover,
    #menu_links li a:active { padding: 9px 14px 9px 48px; }
}
