/*
 * TigerGo Mobile Foundation V1
 * Camada final compartilhada por páginas públicas e autenticadas.
 * Atua somente em layout, toque, leitura e áreas seguras.
 */
:root {
    --tg-mobile-gutter: clamp(14px, 4vw, 22px);
    --tg-mobile-safe-bottom: max(14px, env(safe-area-inset-bottom));
}
*, *::before, *::after { box-sizing: border-box; }
html { max-width: 100%; overflow-x: clip; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { min-width: 0; min-height: 100dvh; max-width: 100%; overflow-x: clip; }
:is(main, section, article, aside, header, footer, nav, form, fieldset, div) { min-width: 0; }
:is(img, picture, video, svg, canvas, iframe) { max-width: 100%; }
:is(img, video) { height: auto; }
:is(input, textarea, select, button) { max-width: 100%; font: inherit; }
:is(p, li, dd, dt, label, summary, h1, h2, h3, h4, h5, h6) { overflow-wrap: anywhere; }
:is(pre, code, .overflow-x-auto, .tg-mobile-scroll) { max-width: 100%; }
pre, .overflow-x-auto, .tg-mobile-scroll {
    overflow-x: auto;
    overscroll-behavior-inline: contain;
    -webkit-overflow-scrolling: touch;
}
[hidden] { display: none !important; }

@media (max-width: 767px) {
    body { padding-bottom: env(safe-area-inset-bottom); }
    body[data-tg-surface="app"] main,
    body[data-tg-surface="public"] main {
        width: 100%;
        max-width: 100%;
        padding-right: max(var(--tg-mobile-gutter), env(safe-area-inset-right)) !important;
        padding-left: max(var(--tg-mobile-gutter), env(safe-area-inset-left)) !important;
    }
    .shell {
        width: 100%;
        max-width: 100%;
        padding-right: max(var(--tg-mobile-gutter), env(safe-area-inset-right));
        padding-left: max(var(--tg-mobile-gutter), env(safe-area-inset-left));
    }
    :is(input:not([type="checkbox"]):not([type="radio"]), textarea, select) {
        min-height: 44px;
        font-size: 16px !important;
    }
    textarea { resize: vertical; }
    :is(.admin-dashboard-grid, .admin-kpi-grid, .admin-kpi-grid-four, .admin-model-grid, .admin-settings-grid),
    :is(.modules-grid, .essay-competencies-grid, .tigo-chart-grid, .tg-subscription-grid) {
        grid-template-columns: minmax(0, 1fr) !important;
    }
    :is(.admin-hero-actions, .admin-topbar-actions, .dashboard-plan-actions, .tg-dashboard-plan-actions),
    :is(.tigo-topbar__actions, .tigo-message__actions, .hero__actions, .organic-hero__actions, .tg-editorial-actions) {
        max-width: 100%;
        flex-wrap: wrap;
    }
    :is(.admin-hero-actions, .admin-topbar-actions, .dashboard-plan-actions, .tg-dashboard-plan-actions) > :is(a, button),
    :is(.hero__actions, .organic-hero__actions, .tg-editorial-actions) > :is(a, button) {
        min-width: min(100%, 150px);
    }
    table {
        display: block;
        width: 100%;
        max-width: 100%;
        overflow-x: auto;
        overscroll-behavior-inline: contain;
        -webkit-overflow-scrolling: touch;
    }
    :is(th, td) { max-width: min(72vw, 360px); overflow-wrap: anywhere; }
    .modal-overlay { padding: 12px !important; }
    :is(dialog, .tg-subscription-dialog, .tg-ai-consent-dialog) {
        width: min(100%, calc(100vw - 24px)) !important;
        max-width: calc(100vw - 24px) !important;
        max-height: calc(100dvh - 24px) !important;
        overflow-y: auto;
        overscroll-behavior: contain;
    }
    body > .fixed.inset-0 {
        padding-right: max(12px, env(safe-area-inset-right)) !important;
        padding-bottom: max(12px, env(safe-area-inset-bottom)) !important;
        padding-left: max(12px, env(safe-area-inset-left)) !important;
    }
    body > .fixed.inset-0 > :is(.bg-white, [class*="max-w-"]) {
        max-width: calc(100vw - 24px) !important;
        max-height: calc(100dvh - 24px) !important;
        overflow-y: auto;
        overscroll-behavior: contain;
    }
    :is(.tg-subscription-dialog-actions, .tg-ai-consent-dialog__actions) {
        position: sticky;
        bottom: 0;
        z-index: 1;
        padding-bottom: var(--tg-mobile-safe-bottom);
        background: inherit;
    }
    .has-sidebar { padding-left: 0 !important; }
    body[data-tg-surface="app"] > aside.tg-app-sidebar {
        position: fixed !important;
        width: min(88vw, 288px) !important;
        max-width: calc(100vw - 44px);
        height: 100dvh !important;
        padding-bottom: calc(64px + env(safe-area-inset-bottom)) !important;
    }
    body[data-tg-surface="app"] > nav.md\:hidden {
        padding-top: env(safe-area-inset-top);
        padding-right: max(12px, env(safe-area-inset-right));
        padding-left: max(12px, env(safe-area-inset-left));
    }
    .mobile-sidebar-backdrop { position: fixed; inset: 0; overscroll-behavior: contain; }
    .tigo-chart-svg { min-width: 0 !important; }
    :is(.tigo-composer, .tigo-composer-dock, .tigo-composer__surface) { max-width: 100%; }
    .tigo-composer-dock { padding-bottom: max(10px, env(safe-area-inset-bottom)) !important; }
    :is(.tigo-message__body, .tigo-flashcard__content, .tg-ai-markdown) {
        min-width: 0;
        max-width: 100%;
        overflow-wrap: anywhere;
    }
    :is(.fixed.bottom-0, .sticky.bottom-0) { padding-bottom: max(10px, env(safe-area-inset-bottom)); }
}

@media (max-width: 430px) {
    :is(.color-grid, .icon-grid) { grid-template-columns: minmax(0, 1fr) !important; }
    :is(.admin-hero-actions, .admin-topbar-actions, .dashboard-plan-actions, .tg-dashboard-plan-actions),
    :is(.hero__actions, .organic-hero__actions, .tg-editorial-actions),
    :is(.tg-subscription-dialog-actions, .tg-ai-consent-dialog__actions) {
        display: grid !important;
        grid-template-columns: minmax(0, 1fr) !important;
    }
    :is(.admin-hero-actions, .admin-topbar-actions, .dashboard-plan-actions, .tg-dashboard-plan-actions) > *,
    :is(.hero__actions, .organic-hero__actions, .tg-editorial-actions) > *,
    :is(.tg-subscription-dialog-actions, .tg-ai-consent-dialog__actions) > * { width: 100% !important; }
    :is(.p-8, .p-10, .p-12) { padding: 22px !important; }
    :is(.px-8, .px-10, .px-12) { padding-right: 20px !important; padding-left: 20px !important; }
}

@media (pointer: coarse) {
    :is(button, input[type="button"], input[type="submit"], input[type="reset"], [role="button"]) {
        min-width: 44px;
        min-height: 44px;
        touch-action: manipulation;
    }
    :is(input[type="checkbox"], input[type="radio"]) { min-width: 22px; min-height: 22px; }
    :is(a, button, summary, label[for]) { -webkit-tap-highlight-color: rgba(249, 136, 37, 0.18); }
}

@media (max-height: 560px) and (orientation: landscape) {
    :is(dialog, .tg-subscription-dialog, .tg-ai-consent-dialog),
    body > .fixed.inset-0 > :is(.bg-white, [class*="max-w-"]) {
        max-height: calc(100dvh - 16px) !important;
    }
}

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto !important; }
}

