/**
 * Bloko Conecta — responsivo global (tablet e smartphone)
 * Breakpoints: 1100px (tablet largo) · 900px (tablet/mobile) · 640px (celular) · 480px (telas pequenas)
 */

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

@media (max-width: 900px) {
    html,
    body {
        overflow-x: clip;
        max-width: 100%;
    }
}

/* ===== Tablet (até 1100px) ===== */
@media (max-width: 1100px) {
    .dashboard-main-grid,
    .dashboard-hero-v2,
    .signature-grid,
    .signature-stats,
    .eng-shell-grid,
    .inspira-layout-grid {
        grid-template-columns: 1fr !important;
    }

    .feed-news-modal__dialog {
        inset: 12px;
    }
}

/* ===== Tablet / mobile (até 900px) — shell do portal ===== */
@media (max-width: 900px) {
    .app {
        display: flex !important;
        flex-direction: column !important;
        grid-template-columns: unset !important;
        min-height: 100vh;
        min-height: 100dvh;
    }

    .content {
        width: 100%;
        max-width: 100%;
        min-width: 0;
        flex: 1 1 auto;
    }

    .content-body {
        padding: 14px 12px 22px;
        max-width: 100%;
        overflow-x: clip;
    }

    .app-topbar {
        position: sticky;
        top: 0;
        z-index: 40;
    }

    .topbar-logo img {
        max-height: 26px;
        width: auto;
    }

    .notification-dropdown {
        max-width: min(360px, calc(100vw - 24px));
        right: 0;
    }

    /* Páginas com padding fixo */
    .signature-page,
    .search-page,
    .ti-premium-page,
    .ti-page,
    .ti-shell,
    .eng-shell,
    .jur-shell,
    .inspira-page,
    [class$="-page"]:not(.login-page):not(.auth-page) {
        padding-left: max(12px, env(safe-area-inset-left)) !important;
        padding-right: max(12px, env(safe-area-inset-right)) !important;
    }

    .signature-hero {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
        padding: 24px 20px;
    }

    .signature-hero h1 {
        font-size: 28px;
    }

    .signature-stats {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 12px;
    }

    .signature-modal__dialog {
        width: min(1040px, 96vw);
        height: min(88vh, 820px);
    }

    /* Configurações (estilos inline na view) */
    .cfg-page {
        grid-template-columns: 1fr !important;
        min-height: 0 !important;
        gap: 14px !important;
    }

    .cfg-filters-card {
        height: auto !important;
        max-height: none !important;
        position: static !important;
    }

    .cfg-main-card {
        height: auto !important;
        min-height: 320px;
    }

    /* Tabelas e grids largos */
    .table-responsive,
    .ti-collab-table-wrap,
    .ti-collab-layout-wide,
    .table-wrap,
    .data-table-wrap,
    .overflow-x-auto {
        display: block;
        width: 100%;
        max-width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .ti-collab-table,
    table {
        max-width: none;
    }

    .dashboard-card--feed,
    .dashboard-card--bi,
    .dashboard-card--bi-full {
        height: auto;
        min-height: 300px;
        max-height: min(480px, 65vh);
    }

    .comercial-workspace,
    .comercial-workspace--with-bi,
    .operacoes-top-bar--with-bi {
        grid-template-columns: 1fr !important;
    }

    .comercial-bi-panel,
    .operacoes-bi-rail {
        min-height: min(380px, 55vh);
        max-height: min(520px, 70vh);
    }

    .operacoes-top-bar__bi {
        position: static !important;
    }

    .sienge-hero {
        flex-direction: column;
    }

    .sienge-page {
        padding: 16px 12px;
    }

    .ti-premium-page.ti-collab-list-page .ti-collab-layout-wide,
    .ti-call-page .ti-call-shell,
    .ti-premium-page .ti-collab-layout-wide {
        grid-template-columns: 1fr !important;
    }

    .form-grid,
    .solicitacoes-grid,
    .travel-grid--2,
    .travel-grid--3,
    .travel-grid--4,
    .travel-grid--5,
    .reembolso-grid--2,
    .reembolso-grid--3,
    .reembolso-grid--4,
    .reembolso-grid--5,
    .quick-grid {
        grid-template-columns: 1fr !important;
    }

    .ch-home-shell,
    .qa-shell,
    .history-shell,
    .travel-shell,
    .approval-shell,
    .reembolso-shell {
        padding-left: 12px;
        padding-right: 12px;
    }
}

/* ===== Smartphone (até 640px) ===== */
@media (max-width: 640px) {
    .content-body {
        padding: 12px 10px 20px;
    }

    .app-topbar {
        padding-left: 10px;
        padding-right: 10px;
        gap: 8px;
    }

    .topbar-left {
        gap: 8px;
    }

    .topbar-right {
        gap: 6px;
    }

    .topbar-search {
        height: 40px;
        padding: 0 12px;
    }

    .topbar-search input {
        font-size: 16px;
    }

    .topbar-icon-btn,
    .topbar-menu-mobile,
    .topbar-user {
        width: 38px;
        height: 38px;
    }

    .theme-toggle-btn__track {
        width: 72px;
        height: 36px;
    }

    .signature-page {
        padding: 12px 10px !important;
    }

    .signature-stats {
        grid-template-columns: 1fr !important;
    }

    .signature-stats article {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
        padding: 16px 18px;
    }

    .signature-stats span {
        font-size: 24px;
    }

    .signature-stats p {
        margin: 0;
    }

    .signature-card {
        padding: 18px 16px;
        border-radius: 20px;
    }

    .signature-card h2 {
        font-size: 18px;
    }

    .signature-doc {
        grid-template-columns: 40px 1fr;
        gap: 10px;
        padding: 14px;
    }

    .signature-doc .signature-doc__actions {
        grid-column: 1 / -1;
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: flex-start;
        width: 100%;
    }

    .signature-btn,
    .signature-hero-btn {
        min-height: 44px;
        padding: 0 16px;
    }

    .signature-user-card {
        flex-direction: row;
        padding: 14px 16px;
    }

    .dashboard-card-head {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .dashboard-card-head h3 {
        font-size: 1.35rem;
    }

    .dashboard-filter,
    .dashboard-card-head .dashboard-filter {
        width: 100%;
        text-align: center;
    }

    .feed-card--hero {
        grid-template-columns: 1fr !important;
        grid-template-rows: auto auto !important;
    }

    .feed-card-media {
        min-height: 120px !important;
    }

    .feed-card-toolbar {
        flex-wrap: wrap;
        gap: 8px;
    }

    .search-hero h1 {
        font-size: 1.5rem;
    }

    .search-card {
        padding: 14px;
    }

    /* Modais em tela cheia */
    .feed-news-modal__dialog {
        inset: 0 !important;
        width: 100% !important;
        height: 100% !important;
        max-height: 100dvh !important;
        border-radius: 0 !important;
        transform: none !important;
    }

    .feed-comment-modal__dialog {
        width: calc(100vw - 20px) !important;
        max-height: calc(100dvh - 24px);
    }

    .publish-modal__dialog {
        width: calc(100vw - 16px) !important;
        max-height: calc(100dvh - 16px);
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
    }

    .signature-modal__dialog {
        width: 100vw !important;
        height: 100dvh !important;
        max-height: 100dvh;
        border-radius: 0 !important;
        transform: translate(-50%, -50%);
    }

    .cfg-page {
        gap: 12px !important;
    }

    .cfg-card-head {
        flex-direction: column;
        align-items: flex-start;
    }

    /* Formulários */
    .content-body input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]),
    .content-body select,
    .content-body textarea,
    .content-body .form-field input,
    .content-body .form-field select,
    .content-body .form-field textarea {
        max-width: 100%;
    }

    .content-body img,
    .content-body video,
    .content-body iframe,
    .content-body embed {
        max-width: 100%;
        height: auto;
    }

    .comercial-hero,
    .operacoes-hero,
    .sienge-hero {
        padding: 20px 16px;
    }

    .comercial-hero__meta,
    .operacoes-hero__meta {
        flex-wrap: wrap;
    }

    .comercial-bi-panel,
    .operacoes-bi-rail {
        min-height: 280px;
        max-height: min(420px, 58vh);
        border-radius: 18px;
    }

    .comercial-bi-panel__head,
    .operacoes-bi-rail__head {
        flex-direction: column;
        align-items: flex-start;
    }

    .sienge-form__actions {
        flex-direction: column;
        align-items: stretch;
    }

    .sienge-form__actions .btn,
    .sienge-form__actions button,
    .sienge-form__actions a.btn {
        width: 100%;
        justify-content: center;
    }

    .ti-call-submit {
        flex-direction: column;
        align-items: stretch;
        padding: 16px;
        gap: 14px;
    }

    .ti-call-submit .ti-call-btn--primary {
        width: 100%;
        min-width: 0;
    }

    .ti-hub-hero,
    .ti-premium-hero {
        flex-direction: column;
        align-items: flex-start;
    }

    .profile-page,
    .perfil-page {
        padding: 12px !important;
    }
}

/* ===== Telas muito pequenas (até 480px) ===== */
@media (max-width: 480px) {
    .brand--motion {
        font-size: 1.2rem;
    }

    .brand__word--conecta {
        animation: brandWordIn 0.62s cubic-bezier(0.22, 1, 0.36, 1) forwards;
    }

    .signature-hero h1 {
        font-size: 24px;
    }

    .signature-hero p {
        font-size: 14px;
    }

    .topbar-center {
        order: 3;
    }

    .notification-dropdown {
        position: fixed;
        left: 10px;
        right: 10px;
        width: auto;
        max-width: none;
    }
}

/* Menu mobile aberto — evita rolagem do fundo */
body.app--mobile-nav-open {
    overflow: hidden;
    touch-action: none;
}

body.app--mobile-nav-open .content {
    touch-action: none;
}

@media (max-width: 900px) {
    .app.app--mobile-menu-open .sidebar-nav-scroll {
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        max-height: calc(100dvh - 120px);
    }

    .menu a,
    .menu-group-trigger,
    .submenu-link {
        min-height: 44px;
    }
}
