/*
 * TM01GPT — Mobile Branding
 * Identidade visual herdada do TM Branding universal.
 * Não substitui os componentes globais.
 */

@media (max-width: 1024px) {

    main,
    section,
    article {
        min-width: 0;
    }

    img,
    video,
    canvas {
        max-width: 100%;
    }

    pre {
        max-width: 100%;
        overflow-x: auto;
    }
}

@media (max-width: 760px) {

    html {
        -webkit-text-size-adjust: 100%;
        text-size-adjust: 100%;
    }

    *,
    *::before,
    *::after {
        box-sizing: border-box;
    }

    body {
        max-width: 100%;
        margin: 0;
    }

    main,
    section,
    article,
    form {
        min-width: 0;
        max-width: 100%;
    }

    input,
    textarea,
    select {
        max-width: 100%;
        font-family: inherit;
        font-size: 16px;
    }

    button {
        font-family: inherit;
        touch-action: manipulation;
    }

    img,
    video,
    iframe {
        max-width: 100%;
    }

    pre {
        max-width: 100%;
        overflow-x: auto;
        white-space: pre;
        -webkit-overflow-scrolling: touch;
    }

    code {
        overflow-wrap: anywhere;
    }

    table {
        display: block;
        max-width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    td,
    th {
        overflow-wrap: anywhere;
    }

    :where(
        button,
        a,
        input,
        select,
        textarea
    ):focus-visible {
        outline: 2px solid var(
            --tm-accent,
            currentColor
        );
        outline-offset: 2px;
    }
}

@media (max-width: 380px) {

    h1,
    h2,
    h3 {
        overflow-wrap: anywhere;
    }
}

@media (prefers-reduced-motion: reduce) {

    html {
        scroll-behavior: auto;
    }
}

/* ==========================================
   TM01GPT MOBILE — BRANDING UNIVERSAL
   ========================================== */

@media (max-width: 760px) {

    :root {
        --tm-mobile-gap: var(--tm-space-3, 12px);
        --tm-mobile-padding: var(--tm-space-4, 16px);
        --tm-mobile-radius: var(--tm-radius-lg, 12px);
    }

    body {
        font-family: var(
            --tm-font-family,
            Arial,
            sans-serif
        );
        -webkit-tap-highlight-color: transparent;
    }

    /* Conteúdo adaptável */

    :where(main, section, article) {
        min-width: 0;
    }

    :where(
        .container,
        .content,
        .page-content,
        .main-content,
        .dashboard,
        .settings-container,
        .projects-container,
        .tools-container
    ) {
        max-width: 100%;
        min-width: 0;
    }

    /* Cartões e painéis */

    :where(
        .card,
        .panel,
        .dashboard-card,
        .project-card,
        .tool-card,
        .settings-card
    ) {
        min-width: 0;
        max-width: 100%;
        border-radius: var(--tm-mobile-radius);
    }

    /* Grelhas responsivas */

    :where(
        .cards-grid,
        .projects-grid,
        .tools-grid,
        .dashboard-grid,
        .settings-grid
    ) {
        grid-template-columns: minmax(0, 1fr);
    }

    /* Botões compatíveis com toque */

    :where(
        button,
        input[type="submit"],
        input[type="button"],
        .btn,
        .tm-btn
    ) {
        min-height: var(--tm-control-height, 44px);
        max-width: 100%;
        touch-action: manipulation;
    }

    /* Formulários */

    :where(
        input:not([type="checkbox"]):not([type="radio"]),
        textarea,
        select
    ) {
        font-size: 16px;
        min-width: 0;
    }

    /* Navegação: não alterar a lógica dos menus */

    :where(
        nav,
        .navbar,
        .nav-links,
        .tm-nav
    ) {
        max-width: 100%;
    }

    /* Títulos e textos */

    :where(h1, h2, h3, p) {
        overflow-wrap: break-word;
    }

    /* Tabelas e código */

    :where(pre, .code-block, .table-wrapper) {
        max-width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Foco com cor oficial TM */

    :where(
        a,
        button,
        input,
        select,
        textarea
    ):focus-visible {
        outline: 2px solid var(--tm-brand, #B51783);
        outline-offset: 2px;
    }

}

/* Smartphones compactos */

@media (max-width: 420px) {

    :where(
        .cards-grid,
        .projects-grid,
        .tools-grid,
        .dashboard-grid,
        .settings-grid
    ) {
        gap: var(--tm-space-3, 12px);
    }

    :where(
        .card,
        .panel,
        .dashboard-card,
        .project-card,
        .tool-card
    ) {
        min-width: 0;
    }
}
