/* ajustes para dispositivos móveis em modo retrato */
@media (max-width: 689px) {
    .content {
        flex-direction: column;
    }

    .cadastro .perfil {
        max-width: none;
    }

    .lista-cadastros .filter-actions {
        align-items: normal;
        flex-direction: column;
        gap: 8px;
    }

    .filtros {
        align-self: stretch;
        overflow: hidden;
        max-height: 0;
        opacity: 0;
        flex: 1;
        transition: opacity, max-height, ease-out 200ms;
    }

    .filtros1 {
        font-size: 16px;
        cursor: pointer;
    }

    .filtros1 label {
        display: block;
        padding: 8px 0 20px;
        font-weight: 500;
        cursor: pointer;
        position: relative;
    }

    .filtros1 label:after {
        content: "";
        position: absolute;
        width: 33px;
        height: 33px;
        background-size: contain;
        background: url(../images/nav-arrow-down.svg) no-repeat center center;
        top: 0px;
        transition: transform, opacity, ease-out 200ms;
        filter: grayscale(1);
    }

    .filtros1 label small {
        font-size: 10px;
        text-transform: lowercase;
        font-weight: 100;
        color: gray;
        float: right;
        margin-right: 4px;
        display: inline;
        font-family: sans-serif;
    }

    .filtros1 label:hover:after,
    .filtros1 label:hover small {
        filter: grayscale(0) invert(50%) sepia(100%) saturate(500%) hue-rotate(0deg);
    }

    #submenu-filtros:checked + div > label:after {
        transform: rotate(180deg);
    }

    #submenu-filtros:checked + div + .filtros {
        max-height: 522px;
        margin-bottom: 40px;
        opacity: 1;
    }

    .indicadores {
        min-width: fit-content;
    }

    .avatar-image-name-dropdo {
        padding-right: 0;
        gap: 2px;
    }

    .avatar-image-name-dropdo .text-container {
        display: none;
    }

    #main-header {
        padding: 14px 13px 14px 25px;
    }

    .notification-area {
        gap: 4px;
    }

    .logo-icon {
        width: 136px;
        height: 30px;
    }

    .header .line {
        gap: 26px;
        justify-content: space-between;
        flex-direction: column;
    }

    .header .actions {
        justify-content: flex-end;
    }

    .detalhes {
        display: flex;
        align-self: flex-start;
    }

    .content-container .container {
        flex-direction: column;
    }

    /* inverte o filtro, mantendo-o fechado por padrão no mobile */
    .lista-cadastros #filter-open:checked ~ .filter-content {
        max-height: 0;
        opacity: 0;
    }

    .lista-cadastros #filter-open:checked ~ .filter-content .filter-row {
        opacity: 0;
    }

    .lista-cadastros #filter-open:checked ~ .filter-open-label .filter-results .icon {
        transform: rotate(0);
    }

    .lista-cadastros #filter-open:checked ~ .filter-open-label .toggle-filter-text .icon {
        transform: rotate(0);
    }

    .lista-cadastros #filter-open:checked ~ .filter-open-label .toggle-filter-text {
        opacity: 1;
        height: 52px;
    }

    .lista-cadastros #filter-open:not(:checked) ~ .filter-content {
        max-height: 1044px;
        opacity: 1;
    }

    .lista-cadastros #filter-open:not(:checked) ~ .filter-content .filter-row {
        opacity: 1;
    }

    .lista-cadastros #filter-open:not(:checked) ~ .filter-open-label .filter-results .icon {
        transform: rotate(180deg);
    }

    .lista-cadastros #filter-open:not(:checked) ~ .filter-open-label .toggle-filter-text .icon {
        transform: rotate(180deg);
    }

    .lista-cadastros #filter-open:not(:checked) ~ .filter-open-label .toggle-filter-text {
        opacity: 0;
        height: 0;
    }
    .notification-area .notifications {
        margin-right: 10px;
    }

    .notification-area .notifications .notifications-wrapper {
        right: -80px;
        background: var(--background-canvas-shaded);
    }
}

/* ============================================================
   iPhone Pro Max e celulares em geral (≤ 480px)
   ============================================================ */
@media (max-width: 480px) {

    /* ── Impede scroll horizontal no root ── */
    html, body {
        overflow-x: hidden;
    }

    /* ── Sidebar: desativa expansão por hover em touch ── */
    .sidebar:hover {
        width: 60px !important;
    }
    .sidebar:hover .nav-items .icon {
        width: 22px !important;
        height: 22px !important;
    }
    .sidebar:hover .icon.sidebar-close {
        transform: rotate(180deg) !important;
    }
    .sidebar:hover .nav-items span,
    .sidebar:hover .nav-items label:after {
        opacity: 0 !important;
    }
    .sidebar:hover .nav-items li.submenu > ul {
        max-height: 0 !important;
    }

    /* ── Body: usa largura total menos a sidebar (60px) ── */
    .body {
        padding-left: 60px !important;
        width: calc(100% - 60px) !important;
        min-width: 0 !important;
        box-sizing: border-box;
        overflow-x: hidden;
    }

    /* ── Header: compacto ── */
    #main-header {
        padding: 10px 10px 10px 14px !important;
        height: 56px !important;
    }
    .logo-icon {
        width: 110px !important;
        height: 26px !important;
    }
    .notification-area {
        gap: 6px !important;
    }
    .text-container {
        display: none !important;
    }

    /* ── Ajuste de padding superior do body e sidebar para bater com o header ── */
    .body {
        padding-top: 56px !important;
    }
    .sidebar {
        padding-top: 56px !important;
        height: calc(100vh - 56px) !important;
    }

    /* ── Cabeçalho de página (título + botão) ── */
    .cabecalho {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 8px !important;
        margin-bottom: 10px !important;
    }
    .cabecalho-left,
    .cabecalho-center,
    .cabecalho-right {
        flex: none !important;
        width: 100% !important;
        justify-content: center !important;
    }
    .cabecalho-center h2 {
        font-size: 1.1rem !important;
        margin: 0 !important;
    }

    /* ── Botões genéricos (.btn) ── */
    .btn {
        display: inline-flex;
        align-items: center;
        gap: 6px;
        padding: 9px 14px;
        border-radius: 6px;
        background: var(--background-on-canvas, #2c2c2c);
        border: 1px solid var(--border-stroke-default, #2f2f30);
        color: var(--text-icon-high-emphasis, #f9f9f9);
        font-size: 14px;
        cursor: pointer;
        white-space: nowrap;
        text-decoration: none;
    }
    .btn:hover, .btn:active {
        border-color: var(--button-primary-default, #d68500);
        color: var(--button-primary-default, #d68500);
    }

    /* ── Filtros (filtro.html) ── */
    #filtros-container {
        gap: 12px;
    }
    .filtro-row {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 8px !important;
    }
    .filtro-row .input,
    .filtro-row select,
    .filtro-row input[type="text"],
    .filtro-row input[type="number"] {
        width: 100% !important;
        min-width: 0 !important;
        box-sizing: border-box !important;
    }
    .remover-filtro {
        align-self: flex-end;
        padding: 6px 12px;
    }

    /* Select2 no mobile */
    .select2-container {
        width: 100% !important;
    }
    .select2-container .select2-selection--single {
        width: 100% !important;
    }

    /* Filtros fixos (Opt-In, Status) */
    .filtros-fixos {
        flex-direction: column !important;
        gap: 10px !important;
        margin-top: 10px !important;
        margin-bottom: 6px !important;
    }
    .filtros-fixos .grupo-filtro-fixo {
        width: 100% !important;
        min-width: 0 !important;
    }
    .filtros-fixos select {
        width: 100% !important;
        min-width: 0 !important;
        box-sizing: border-box !important;
    }

    /* ── Home page ── */
    .home-main-content {
        width: 100% !important;
        padding: 16px 8px 0 8px !important;
        box-sizing: border-box !important;
    }
    .home-bemvindo {
        font-size: 1.4rem !important;
        margin-top: 1vh !important;
        margin-bottom: 20px !important;
    }
    .home-menu-icons {
        gap: 32px 24px !important;
    }
    .home-menu-item {
        min-width: 80px !important;
        max-width: 100px;
    }
    .home-menu-item .menu-icon {
        font-size: 36px !important;
    }
    .home-menu-label {
        font-size: 12px !important;
        text-align: center;
    }
    /* Dropdown: posicionado fixo ao centro-baixo da tela no mobile */
    .home-dropdown {
        position: fixed !important;
        left: 50% !important;
        transform: translateX(-50%) !important;
        top: auto !important;
        bottom: 80px !important;
        z-index: 1001 !important;
        min-width: 200px !important;
        border-radius: 12px !important;
    }
    /* Logo splash: escala para tela menor */
    .splash-logo-svg svg {
        width: 85vw !important;
    }
    .bemvindo-logo-svg svg {
        width: 220px !important;
    }

    /* ── Paginação ── */
    .pagination-info {
        flex-direction: column;
        gap: 8px;
        padding: 10px;
    }
}

/* ── Dispositivos touch: desativa hover da sidebar (qualquer tamanho) ── */
@media (hover: none) and (pointer: coarse) {
    .sidebar:hover {
        width: 60px !important;
    }
    .sidebar:hover .nav-items span,
    .sidebar:hover .nav-items label:after {
        opacity: 0 !important;
    }
    .sidebar:hover .nav-items li.submenu > ul {
        max-height: 0 !important;
    }
    .sidebar:hover .nav-items .icon {
        width: 22px !important;
        height: 22px !important;
    }
}

/* ── Hamburger button (escondido no desktop) ── */
.mobile-menu-btn {
    display: none;
}

/* ── Drawer mobile ── */
@media (max-width: 480px) {

    /* Esconde o botão fechar original da sidebar (substituído pelo hamburguer no header) */
    .sidebar .collapsed-action {
        display: none !important;
    }

    /* Hamburguer */
    .mobile-menu-btn {
        display: flex;
        align-items: center;
        justify-content: center;
        background: none;
        border: none;
        color: var(--text-icon-high-emphasis, #f9f9f9);
        font-size: 20px;
        cursor: pointer;
        padding: 6px 10px;
        flex-shrink: 0;
        border-radius: 6px;
        transition: background 0.15s;
    }
    .mobile-menu-btn:active {
        background: var(--background-on-canvas, #2c2c2c);
    }

    /* Sidebar aberta como drawer overlay */
    .sidebar.is-open {
        width: 240px !important;
        z-index: 601 !important;
        box-shadow: 6px 0 24px rgba(0, 0, 0, 0.55);
        transition: width 0.22s ease-out !important;
    }

    /* Textos e setas visíveis quando drawer está aberto */
    .sidebar.is-open .nav-items span,
    .sidebar.is-open .nav-items label:after {
        opacity: 1 !important;
        transition: opacity 0.15s ease-out !important;
    }

    /* Ícones no tamanho normal quando aberto */
    .sidebar.is-open .nav-items .icon {
        width: 18px !important;
        height: 18px !important;
    }

    /* Botão fechar: sem rotação quando aberto */
    .sidebar.is-open .icon.sidebar-close {
        transform: none !important;
    }

    /* Submenus: respeitam o estado do checkbox quando aberto */
    .sidebar.is-open .nav-items li.submenu > ul {
        max-height: 500px !important;
    }
    .sidebar.is-open .nav-items .submenu-checkbox:not(:checked) ~ ul {
        max-height: 0 !important;
    }

    /* Overlay escuro atrás do drawer */
    #sidebar-mobile-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.52);
        z-index: 600;
        touch-action: none;
    }
    #sidebar-mobile-overlay.active {
        display: block;
    }
}
