* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg: #d9dde3;
    --text: #111827;
    --muted: #374151;
    --topbar-h: 70px;
    --white: #ffffff;
    --blue: #2563EB;

    --sidebar: #1F2937;
    --sidebarText: #d1d5db;
    --sidebarTitle: #f3f4f6;
    --cyanHover: #38bdf8;

    --border: #d1d5db;
    --borderLight: #E5E7EB;
}

html {
    scroll-behavior: smooth;
}

body {
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
    font-family: Arial, Helvetica, sans-serif;
}

/* =========================
   TOPBAR
   ========================= */
.topbar {
    height: 70px;
    width: 100%;
    position: sticky;
    top: 0;
    z-index: 30;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 18px;
    background: var(--white);
    border-bottom: 1px solid var(--blue);
    border-top: 1px solid var(--blue);
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo-header {
    height: 40px;
    width: auto;
    display: block;
}

.logo-text {
    font-weight: 800;
    font-size: 16px;
    color: var(--text);
}

/* LINKS HEADER */
.links-header {
    display: flex;
    align-items: center;
    gap: 30px;
}

.links-header a {
    text-decoration: none;
    color: #374151;
    font-weight: 700;
    font-size: 17px;
}

.links-header a:hover {
    color: var(--blue);
    transition: 0.25s;
}

/* HAMBURGER */
.hamburger {
    width: 44px;
    height: 44px;
    border: 1px solid transparent;
    background: var(--white);
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 6px;
    padding: 0 12px;
}

.hamburger:hover {
    border-color: rgba(37, 99, 235, 0.35);
}

.hamburger span {
    display: block;
    height: 2px;
    width: 100%;
    background: var(--text);
    border-radius: 2px;
}

/* =========================
   LAYOUT (GRID)
   ========================= */
.layout {
    display: grid;
    grid-template-columns: 300px 1fr;
    min-height: calc(100vh - 70px);
}

/* =========================
   SIDEBAR
   ========================= */
.sidebar {
    position: sticky;
    top: var(--topbar-h);
    height: calc(100vh - var(--topbar-h));
    background: var(--sidebar);
    border-right: 1px solid var(--blue);
    padding: 16px;
    transition: transform 0.35s ease;
    overflow: auto;
    scrollbar-gutter: stable;
}

/* Estado fechado */
.sidebar.closed {
    transform: translateX(-100%);
}

/* Header do menu */
.title-menu {
    display: flex;
    justify-content: center;
    font-size: 16px;
    font-weight: 900;
    color: var(--sidebarTitle);
    margin-bottom: 12px;
}

.sidebar-line {
    border: none;
    border-top: 1px solid var(--blue);
    margin: 0 0 15px;
}

/* Details */
.menu-content details {
    margin-bottom: 12px;
}

.menu-content summary {
    cursor: pointer;
    font-weight: 800;
    margin-bottom: 8px;
    color: var(--sidebarTitle);
    list-style: none;
    display: flex;
    align-items: center;
    gap: 8px;
    user-select: none;
}

.menu-content summary::-webkit-details-marker {
    display: none;
}

.menu-content summary::before {
    content: "▸";
    display: inline-block;
    transform: translateY(-1px);
    opacity: 0.9;
}

.menu-content details[open] summary::before {
    content: "▾";
}

.menu-content ul {
    list-style: none;
    padding-left: 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.menu-content li {
    padding: 8px 10px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 14px;
    color: var(--sidebarText);
    transition: 0.2s;
}

.menu-content li:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--cyanHover);
    transform: translateX(4px);
}

.tag-item {
    width: 100%;
    text-align: left;
    padding: 8px 10px;
    border-radius: 10px;
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 14px;
    color: var(--sidebarText);
    transition: 0.2s;
}

.tag-item:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--cyanHover);
    transform: translateX(4px);
}

/* =========================
   CONTENT
   ========================= */
.content {
    padding: 28px;
}

.content-center {
    width: min(720px, 100%);
    margin: 0 auto;
    min-height: calc(100vh - 70px);
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 18px;
}

.hero {
    text-align: center;
}

.hero-title {
    font-size: 56px;
    font-weight: 800;
    letter-spacing: 2px;
    margin-bottom: 8px;
}

.hero-subtitle {
    font-size: 16px;
    color: var(--muted);
    margin-bottom: 20px;
}

.search-row {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 14px;
    margin: 18px 0 10px;
}

.tag-input {
    width: min(640px, 90%);
    height: 54px;
    border-radius: 999px;
    border: 1px solid var(--border);
    padding: 0 18px;
    font-size: 16px;
    outline: none;
    background: var(--white);
}

.tag-input:focus {
    border-color: var(--blue);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.18);
}

.search-btn {
    width: 54px;
    height: 54px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--white);
    cursor: pointer;
    font-size: 22px;
    transition: 0.2s;
    display: grid;
    place-items: center;
}

.search-btn:hover {
    transform: translateY(-1px);
    border-color: var(--blue);
    color: var(--blue);
}

.hint {
    margin-top: 10px;
    color: #4b5563;
    font-size: 14px;
}

code {
    background: #EEF2FF;
    padding: 2px 8px;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
    color: #1E3A8A;
    font-weight: 800;
}

/* =========================
   RESULTADO
   ========================= */
.result {
    margin-top: 16px;
    margin-bottom: 20px;
}

.result-card {
    background: rgba(255, 255, 255, 0.6);
    border: 1px solid rgba(17, 24, 39, 0.10);
    border-radius: 18px;
    padding: 22px;
    backdrop-filter: blur(8px);
}

.result-title {
    font-size: 22px;
    margin-bottom: 6px;
}

.result-desc {
    color: var(--muted);
    line-height: 1.6;
    margin-bottom: 12px;
}

.code-box {
    background: #0b1220;
    color: #e5e7eb;
    padding: 14px 16px;
    border-radius: 14px;
    overflow-x: auto;
    border: 1px solid rgba(255, 255, 255, 0.10);
}

/* =========================
   FIX: evitar overflow horizontal quando o exemplo é “largo”
   (ex: <img ...> com linha longa)
   ========================= */
.layout,
.content,
.content-center,
.result,
.result-card,
.result-example,
.code-box {
    min-width: 0;
    max-width: 100%;
}

html,
body {
    overflow-x: hidden;
}

/* garante que o bloco de código nunca estoure a largura */
.code-box {
    max-width: 100%;
    overflow-x: auto;
}

/* em telas pequenas, quebra linhas MUITO longas pra não vazar */
@media (max-width: 600px) {
    .code-box code {
        white-space: pre-wrap;
        /* permite quebrar linha */
        overflow-wrap: anywhere;
        word-break: break-word;
    }
}

.code-box code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    font-size: 14px;
    white-space: pre;
}

/* =========================
   FOOTER
   ========================= */
.main-footer {
    background: var(--white);
    border-top: 1px solid var(--blue);
    padding-top: 40px;
    margin-top: -56px;
}

.footer-container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 20px 40px;
    display: flex;
    justify-content: space-between;
    gap: 40px;
}

.footer-info {
    max-width: 420px;
}

.footer-logo {
    font-size: 22px;
    font-weight: 900;
    margin-bottom: 14px;
    color: var(--text);
}

.footer-description {
    font-size: 15px;
    line-height: 1.6;
    color: #6B7280;
    margin-bottom: 14px;
}

.footer-author {
    font-size: 14px;
    color: #374151;
}

.footer-author a {
    color: var(--blue);
    font-weight: 800;
    cursor: pointer;
    text-decoration: none;
}

.footer-links {
    display: flex;
    gap: 60px;
}

.footer-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.footer-group h4 {
    font-size: 15px;
    font-weight: 900;
    margin-bottom: 6px;
    color: var(--text);
}

.footer-group a {
    text-decoration: none;
    font-size: 14px;
    color: #6B7280;
    transition: 0.25s;
}

.footer-group a:hover {
    color: var(--blue);
}

.footer-bottom {
    border-top: 1px solid var(--borderLight);
    padding: 18px 20px;
    text-align: center;
    font-size: 13px;
    color: #9CA3AF;
}

/* Acessibilidade */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* =========================
          (Sobre mim)
   ========================= */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 18px;
    z-index: 80;
}

.modal-overlay.is-open {
    display: flex;
}

.modal {
    width: min(720px, 92vw);
    max-height: min(80vh, 720px);
    overflow: auto;
    background: var(--white);
    border: 1px solid rgba(37, 99, 235, 0.25);
    border-radius: 16px;
    padding: 22px 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.22);
    position: relative;
}

.modal-title {
    font-size: 22px;
    font-weight: 900;
    color: var(--text);
    margin-bottom: 12px;
}

.modal-content p {
    color: var(--muted);
    line-height: 1.7;
    margin-bottom: 12px;
    font-size: 15px;
}

.modal-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    border: 1px solid rgba(17, 24, 39, 0.12);
    background: var(--white);
    cursor: pointer;
    font-size: 18px;
    display: grid;
    place-items: center;
}

.modal-close:hover {
    border-color: rgba(37, 99, 235, 0.45);
    color: var(--blue);
}

body.modal-open {
    overflow: hidden;
}

/* =========================
   RESPONSIVO
   ========================= */

@media (max-width: 900px) {
    .layout {
        grid-template-columns: 1fr;
    }

    /* Sidebar vira overlay */
    .sidebar {
        position: fixed;
        top: 70px;
        left: 0;
        width: 300px;
        height: calc(100vh - 70px);
        z-index: 40;
        box-shadow: 10px 0 30px rgba(0, 0, 0, 0.12);
        transform: translateX(0);
    }

    .sidebar.closed {
        transform: translateX(-100%);
    }

    /* Ajustes do conteúdo */
    .content {
        padding: 22px 16px;
    }

    .hero-title {
        font-size: 42px;
    }

    .footer-container {
        flex-direction: column;
        gap: 30px;
    }

    .footer-links {
        gap: 40px;
    }
}

/* Mobile menor */
@media (max-width: 600px) {
    .links-header {
        gap: 18px;
    }

    .links-header a {
        font-size: 15px;
    }

    .hero-title {
        font-size: 36px;
        letter-spacing: 1px;
    }

    .search-row {
        gap: 10px;
    }

    .tag-input {
        height: 50px;
    }

    .search-btn {
        width: 50px;
        height: 50px;
    }
    .main-footer{
        margin-top: 0;
    }
}

/* =========================================
   CORRIGE CENTRALIZAÇÃO QUANDO A SIDEBAR FECHA
   ========================================= */
@media (min-width: 901px) {

    .layout:has(.sidebar.closed) {
        grid-template-columns: 0 1fr;
        transition: 1s ease-in-out;
    }

    .layout:has(.sidebar.closed) .sidebar {
        border-right: none;
        padding: 0;
    }
}

/* =========================================================
   RESPONSIVIDADE EXTRA
   - Melhora header, sidebar overlay, hero e modal no mobile/tablet
   ========================================================= */

/* 1) Sidebar overlay mais “inteligente” no mobile/tablet */
@media (max-width: 900px) {
    .sidebar {
        width: min(82vw, 320px);
        position: fixed;
        top: var(--topbar-h);
        height: calc(100vh - var(--topbar-h));
    }
}

/* 2) TOPBAR: evita esmagar links em telas menores
      - Faz a topbar quebrar linha e coloca os links abaixo
*/
@media (max-width: 700px) {
    .topbar {
        height: auto;
        /* deixa crescer */
        flex-wrap: wrap;
        /* permite quebrar */
        gap: 10px;
        padding: 10px 14px;
    }

    .topbar-left {
        flex: 1 1 auto;
        min-width: 180px;
    }

    .links-header {
        order: 3;
        /* links vão pra “linha de baixo” */
        width: 100%;
        justify-content: center;
        flex-wrap: wrap;
        /* quebra em 2 linhas se precisar */
        gap: 14px;
        padding-bottom: 6px;
    }

    .links-header a {
        font-size: 14px;
    }

    .hamburger {
        order: 2;
    }

    /* como a topbar agora pode ser maior que 70px,
     a sidebar fixa precisa acompanhar isso */
    .sidebar {
        top: auto;
        top: calc(0px + 0px);
    }

    /* solução robusta: como a topbar é sticky, usar top: 0 e empurrar pela própria altura
     sem JS é chato medir; então eu garanto que não “coma” conteúdo
     deixando espaço no começo do conteúdo */
    .content {
        padding-top: 18px;
    }
}

/* 3) Mobile: reduz mais ainda e limpa a área do logo */
@media (max-width: 520px) {
    .logo-text {
        display: none;
    }

    .logo-header {
        height: 34px;
    }

    .links-header {
        gap: 10px;
    }

    .links-header a {
        font-size: 13px;
    }

    .hamburger {
        width: 40px;
        height: 40px;
        padding: 0 10px;
    }

    /* Hero e input ficam mais “encaixados” */
    .hero-title {
        font-size: 34px;
        letter-spacing: 1px;
    }

    .hero-subtitle {
        font-size: 14px;
        margin-bottom: 14px;
    }

    .search-row {
        flex-direction: column;
        gap: 10px;
    }

    .tag-input {
        width: 100%;
        height: 48px;
        font-size: 15px;
    }

    .search-btn {
        width: 48px;
        height: 48px;
        font-size: 20px;
    }

    .result-card {
        padding: 18px;
    }

    .code-box {
        padding: 12px 12px;
    }

    .code-box code {
        font-size: 13px;
    }

    /* Sidebar overlay mais confortável */
    .sidebar {
        width: min(86vw, 300px);
    }
}

/* 4) Mobile bem pequeno (tipo 360px / 375px) */
@media (max-width: 380px) {
    .hero-title {
        font-size: 30px;
    }

    .links-header a {
        font-size: 12px;
    }

    .result-title {
        font-size: 18px;
    }

    .modal {
        padding: 18px 14px;
    }

    .modal-title {
        font-size: 18px;
    }

    .modal-content p {
        font-size: 14px;
    }
}

/* 5) Modal no mobile: garante boa rolagem e não “cola” na borda */
@media (max-width: 600px) {
    .modal {
        width: min(720px, 94vw);
        max-height: 82vh;
    }

    .modal-close {
        width: 38px;
        height: 38px;
    }
}

@media (min-width: 901px) {
    body.sidebar-closed .layout {
        grid-template-columns: 0 1fr;
    }

    body.sidebar-closed .sidebar {
        border-right: none;
        padding: 0;
    }
}