/**
 * FullDeck - Mobile CSS
 * Loaded after theme.css and admin.css.
 * Contains: card overlay, mobile card layouts, responsive utilities.
 */

/* ===== Card Preview Overlay (Touch/Mobile) ===== */
.fd-card-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 99999;
}
.fd-card-overlay.active {
    display: flex;
    align-items: center;
    justify-content: center;
}
.fd-card-overlay-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}
.fd-card-overlay-content {
    position: relative;
    z-index: 1;
    max-width: 90vw;
    max-height: 90vh;
    transform: translateY(0);
    transition: transform 0.25s ease, opacity 0.25s ease;
}
.fd-card-overlay-content img {
    max-width: 90vw;
    max-height: 85vh;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.8);
    object-fit: contain;
}
.fd-card-overlay-close {
    position: absolute;
    top: -12px;
    right: -12px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(8px);
    color: #fff;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    z-index: 2;
}
.fd-card-overlay-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* ===== Public Header Mobile Enhancements ===== */

@media (max-width: 768px) {
    /* Sticky search bar — stays visible while scrolling */
    .fd-nav {
        position: sticky;
        top: 0;
        z-index: 1000;
    }

    /* Estória Correção Busca Mobile 01 — fd-nav-top em 2 linhas:
     *   Linha 1: logo (esquerda) + nav-right (direita)
     *   Linha 2: fd-search ocupando toda a largura útil
     * O dropdown de autocomplete (criado por vitrine.js como
     * position:absolute; width:100% dentro de .fd-search) acompanha o
     * full-width naturalmente — permite ver o nome completo das opções.
     */
    .fd-nav-top .container {
        display: grid !important;
        grid-template-columns: auto 1fr;
        grid-template-areas:
            "logo navright"
            "search search";
        align-items: center;
        column-gap: 10px;
        row-gap: 8px;
        padding-top: 6px;
        padding-bottom: 6px;
    }
    .fd-nav-top .fd-logo      { grid-area: logo;     justify-self: start; }
    .fd-nav-top .fd-nav-right { grid-area: navright; justify-self: end;   }
    .fd-nav-top .fd-search {
        grid-area: search;
        order: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
        min-width: 0;
    }
    .fd-search input {
        padding: 7px 38px 7px 12px;
        font-size: 14px;
    }
    .fd-search button {
        width: 36px;
    }

    .fd-logo-img {
        width: 30px !important;
        height: 30px !important;
    }
    .fd-logo-text {
        font-size: 17px;
    }

    /* Nav right: tighter, touch-friendly */
    .fd-nav-right {
        gap: 2px;
    }
    .fd-nav-action {
        min-width: 38px;
        min-height: 38px;
        padding: 6px 8px;
        justify-content: center;
    }
    .fd-nav-cart {
        min-width: 38px;
        min-height: 38px;
        padding: 6px 8px;
    }
    .fd-nav-user {
        padding: 4px 8px;
    }
    .fd-nav-user-code {
        display: none;
    }

    /* Guest area: compact login/register buttons */
    .fd-nav-action-primary {
        padding: 6px 10px;
        font-size: 12px;
    }

    /* Mini-cart: full width on small screens */
    .fd-minicart {
        width: calc(100vw - 20px) !important;
        right: -10px !important;
        max-width: 360px;
    }
}

@media (max-width: 480px) {
    /* Nav mobile: mostrar o texto do logo em TODOS os browsers mobile.
       O grid de ≤768px já mantém logo (esquerda) + fd-nav-right (direita) na
       linha 1 em largura total; aqui só reduzimos a fonte para caber. */
    .fd-logo-text {
        font-size: 15px;
    }
    /* Full-width mini-cart as bottom sheet */
    .fd-minicart {
        position: fixed !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        top: auto !important;
        width: 100vw !important;
        max-width: 100vw !important;
        max-height: 70vh;
        border-radius: 16px 16px 0 0 !important;
        overflow-y: auto;
    }
}

/* ===== Mobile Utility Classes ===== */

/* Hide on mobile, show on desktop */
.desktop-only { display: initial; }
.mobile-only { display: none !important; }

/* ===== Admin Header Mobile Refinements ===== */

@media (max-width: 768px) {
    /* Compact admin header */
    .admin-header {
        padding: 10px 12px !important;
        gap: 8px;
    }
    .admin-header-title {
        font-size: 15px !important;
        gap: 8px !important;
    }
    .admin-header-title i:not(.bi-list) {
        font-size: 16px;
    }

    /* Sidebar overlay: cover entire screen */
    .admin-overlay.active {
        background: rgba(0, 0, 0, 0.6);
        backdrop-filter: blur(4px);
        -webkit-backdrop-filter: blur(4px);
    }

    /* Admin card padding reduction */
    .admin-card-body {
        padding: 12px !important;
    }
    .admin-card-header {
        padding: 10px 12px !important;
    }

    /* Inline grid layouts → stack on mobile */
    .admin-card-body > [style*="grid-template-columns"],
    .admin-card-body > div > [style*="grid-template-columns"] {
        display: flex !important;
        flex-direction: column !important;
        gap: 10px !important;
    }
}

/* ===== Mobile Cards (replaces tables on small screens) ===== */
.mobile-card {
    display: none;
}

@media (max-width: 768px) {
    .desktop-only { display: none !important; }
    .mobile-only { display: initial !important; }

    /* Mobile card visible, table hidden */
    .mobile-card {
        display: block;
        background: var(--admin-card, #16202d);
        border: 1px solid var(--admin-border, #2a475e);
        border-radius: 10px;
        padding: 14px;
        margin-bottom: 12px;
    }
    .mobile-cards-container .admin-table-container {
        display: none;
    }

    /* Mobile card header: left (title) + right (actions) */
    .mobile-card-header {
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        margin-bottom: 10px;
    }
    .mobile-card-title {
        font-weight: 600;
        color: var(--admin-text-light, #fff);
        font-size: 14px;
    }
    .mobile-card-subtitle {
        font-size: 12px;
        color: var(--admin-text-muted, #8f98a0);
        margin-top: 2px;
    }
    .mobile-card-actions {
        display: flex;
        gap: 8px;
        flex-shrink: 0;
    }
    .mobile-card-actions .admin-btn {
        min-width: 36px;
        min-height: 36px;
        padding: 6px 8px;
        font-size: 14px;
    }

    /* Mobile card body: key-value rows */
    .mobile-card-body {
        display: flex;
        flex-direction: column;
        gap: 6px;
    }
    .mobile-card-row {
        display: flex;
        justify-content: space-between;
        align-items: center;
        font-size: 13px;
    }
    .mobile-card-label {
        color: var(--admin-text-muted, #8f98a0);
    }
    .mobile-card-value {
        color: var(--admin-text-light, #fff);
        font-weight: 500;
        text-align: right;
    }

    /* Mobile card with image (for listings/cards) */
    .mobile-card-img {
        width: 100%;
        border-radius: 8px;
        object-fit: contain;
        background: rgba(0, 0, 0, 0.2);
        margin-bottom: 10px;
        max-height: 300px;
    }

    /* Mobile card footer */
    .mobile-card-footer {
        display: flex;
        gap: 8px;
        margin-top: 12px;
        padding-top: 10px;
        border-top: 1px solid var(--admin-border, #2a475e);
        flex-wrap: wrap;
    }
    .mobile-card-footer .admin-btn {
        flex: 1;
        min-width: 0;
        font-size: 12px;
        padding: 8px 10px;
        text-align: center;
    }

    /* Collapsible filters */
    .mobile-filters-toggle {
        width: 100%;
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 12px 15px;
        background: var(--admin-card, #16202d);
        border: 1px solid var(--admin-border, #2a475e);
        border-radius: 8px;
        color: var(--admin-text, #c7d5e0);
        font-size: 13px;
        font-weight: 500;
        cursor: pointer;
        margin-bottom: 12px;
    }
    .mobile-filters-toggle i.chevron {
        transition: transform 0.2s;
    }
    .mobile-filters-toggle[aria-expanded="true"] i.chevron {
        transform: rotate(180deg);
    }
    .mobile-filters-body {
        display: none;
        margin-bottom: 15px;
    }
    .mobile-filters-body.show {
        display: block;
    }
    .mobile-filters-body .admin-form-input,
    .mobile-filters-body .admin-form-select {
        margin-bottom: 8px;
        width: 100%;
    }

    /* Stats cards: 2 columns on mobile */
    .admin-stats-grid {
        grid-template-columns: 1fr 1fr !important;
        gap: 8px !important;
    }

    /* Modals: single column layout */
    .modal-body .row,
    .modal-body [style*="grid-template-columns"] {
        display: flex !important;
        flex-direction: column !important;
    }
    .modal-body .modal-card-img {
        max-width: 100%;
        max-height: 280px;
        object-fit: contain;
        margin: 0 auto 15px;
        display: block;
        border-radius: 8px;
    }

    /* Endereços: list first, form second on mobile */
    #addressFormCard {
        order: 2 !important;
    }

    /* Accordion for forms (like new address) */
    .mobile-accordion-btn {
        width: 100%;
        padding: 14px 16px;
        background: var(--admin-card, #16202d);
        border: 1px dashed var(--admin-border, #2a475e);
        border-radius: 8px;
        color: var(--admin-blue, #2680EB);
        font-size: 14px;
        font-weight: 500;
        cursor: pointer;
        display: flex;
        align-items: center;
        gap: 8px;
        transition: background 0.2s;
    }
    .mobile-accordion-btn:hover {
        background: rgba(38, 128, 235, 0.08);
    }

    /* Admin nav pills horizontal scroll */
    .admin-nav-pills {
        flex-wrap: nowrap !important;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 4px;
    }
    .admin-nav-pills .nav-link {
        white-space: nowrap;
        flex-shrink: 0;
    }
}

/* Small phones */
@media (max-width: 480px) {
    .mobile-card {
        padding: 12px;
    }
    .mobile-card-img {
        max-height: 250px;
    }
    .admin-stats-grid {
        grid-template-columns: 1fr 1fr !important;
    }
}

@media (max-width: 375px) {
    .admin-stats-grid {
        grid-template-columns: 1fr !important;
    }
}

/* ===== Mobile Catalog Filters ===== */

/* Botão abrir filtros — visível apenas no mobile */
.fd-filters-mobile-btn {
    display: none;
}

/* Header dentro do painel — visível apenas no mobile */
.fd-filters-mobile-header {
    display: none;
}

@media (max-width: 992px) {
    /* Botão "Filtros" visível no mobile */
    .fd-filters-mobile-btn {
        display: inline-flex;
        align-items: center;
        gap: 8px;
        padding: 10px 18px;
        background: var(--fd-card-bg, #16202d);
        border: 1px solid var(--fd-border, #2a475e);
        border-radius: 8px;
        color: var(--fd-text-light, #e5e5e5);
        font-size: 14px;
        font-weight: 500;
        cursor: pointer;
        margin-bottom: 12px;
        transition: background 0.2s, border-color 0.2s;
    }
    .fd-filters-mobile-btn:hover,
    .fd-filters-mobile-btn:active {
        background: rgba(38, 128, 235, 0.15);
        border-color: var(--fd-blue, #2680EB);
    }
    .fd-filters-mobile-btn i {
        font-size: 16px;
        color: var(--fd-blue, #2680EB);
    }

    /* Badge de contagem de filtros ativos */
    .fd-filters-mobile-count {
        background: var(--fd-blue, #2680EB);
        color: #fff;
        font-size: 11px;
        font-weight: 700;
        min-width: 20px;
        height: 20px;
        border-radius: 10px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        padding: 0 6px;
    }

    /* Header fixo no topo do painel de filtros */
    .fd-filters-mobile-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        position: sticky;
        top: 0;
        z-index: 2;
        background: var(--fd-card-bg, #16202d);
        padding: 16px 0;
        margin: -20px -20px 16px -20px;
        padding: 16px 20px;
        border-bottom: 1px solid var(--fd-border, #2a475e);
    }
    .fd-filters-mobile-title {
        font-size: 16px;
        font-weight: 600;
        color: var(--fd-text-light, #e5e5e5);
    }
    .fd-filters-mobile-title i {
        color: var(--fd-blue, #2680EB);
        margin-right: 6px;
    }
    .fd-filters-mobile-close {
        width: 40px;
        height: 40px;
        border: none;
        border-radius: 8px;
        background: rgba(255, 255, 255, 0.08);
        color: var(--fd-text-light, #e5e5e5);
        font-size: 18px;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        transition: background 0.2s;
    }
    .fd-filters-mobile-close:hover {
        background: rgba(255, 255, 255, 0.15);
    }
}

/* ===== Carrinho: table → card layout on mobile ===== */
@media (max-width: 768px) {
    .cart-table-mobile .table { display: none; }
    .cart-mobile-cards { display: block !important; }
}

.cart-mobile-cards { display: none; }

.cart-mobile-item {
    background: var(--fd-card-bg, #16202d);
    border: 1px solid var(--fd-border, #2a475e);
    border-radius: 10px;
    padding: 14px;
    margin-bottom: 10px;
}
.cart-mobile-item-top {
    display: flex;
    gap: 12px;
    align-items: flex-start;
}
.cart-mobile-item-img {
    width: 50px;
    height: 70px;
    object-fit: cover;
    border-radius: 6px;
    flex-shrink: 0;
}
.cart-mobile-item-img-placeholder {
    width: 50px;
    height: 70px;
    border-radius: 6px;
    background: var(--fd-border, #2a475e);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.cart-mobile-item-info {
    flex: 1;
    min-width: 0;
}
.cart-mobile-item-name {
    font-weight: 600;
    color: var(--fd-text-light, #fff);
    font-size: 14px;
    margin-bottom: 4px;
}
.cart-mobile-item-name a {
    color: inherit;
    text-decoration: none;
}
.cart-mobile-item-details {
    font-size: 12px;
    color: var(--fd-text-muted, #8f98a0);
    margin-bottom: 8px;
}
.cart-mobile-item-bottom {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid var(--fd-border, #2a475e);
    gap: 10px;
}
.cart-mobile-item-price {
    font-size: 13px;
    color: var(--fd-text-muted, #8f98a0);
}
.cart-mobile-item-price span {
    color: var(--fd-blue, #2680EB);
    font-weight: 600;
}
.cart-mobile-item-qty {
    display: flex;
    align-items: center;
    gap: 0;
}
.cart-mobile-item-qty .btn {
    min-width: 36px;
    min-height: 36px;
}
.cart-mobile-item-qty .form-control {
    width: 44px;
    text-align: center;
    min-height: 36px;
}
.cart-mobile-item-subtotal {
    text-align: right;
    font-weight: 700;
    color: var(--fd-blue, #2680EB);
    font-size: 15px;
    white-space: nowrap;
}
.cart-mobile-item-remove {
    min-width: 36px;
    min-height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ===== Wants: table responsive on mobile ===== */
@media (max-width: 768px) {
    .wants-mobile .admin-table thead { display: none; }
    .wants-mobile .admin-table tbody tr {
        display: grid;
        grid-template-columns: 50px 1fr auto;
        gap: 4px 10px;
        padding: 12px;
        border-bottom: 1px solid var(--admin-border, #2a475e);
    }
    /* Image: row 1-2, col 1 */
    .wants-mobile .admin-table tbody td:nth-child(1) {
        grid-row: 1 / 3;
        grid-column: 1;
        display: flex;
        align-items: center;
    }
    /* Name: row 1, col 2 */
    .wants-mobile .admin-table tbody td:nth-child(2) {
        grid-column: 2;
        grid-row: 1;
    }
    /* Edition: row 2, col 2 */
    .wants-mobile .admin-table tbody td:nth-child(3) {
        grid-column: 2;
        grid-row: 2;
        font-size: 12px;
    }
    /* Date: hide on mobile */
    .wants-mobile .admin-table tbody td:nth-child(4) {
        display: none;
    }
    /* Notify: row 1, col 3 */
    .wants-mobile .admin-table tbody td:nth-child(5) {
        grid-column: 3;
        grid-row: 1;
    }
    /* Delete: row 2, col 3 */
    .wants-mobile .admin-table tbody td:nth-child(6) {
        grid-column: 3;
        grid-row: 2;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    .wants-mobile .admin-table tbody td:nth-child(6) .admin-btn {
        min-width: 36px;
        min-height: 36px;
        padding: 6px 10px;
    }
}

/* ===== Perfil: sidebar grid stack on mobile ===== */
@media (max-width: 768px) {
    .admin-grid[style*="grid-template-columns: 280px"] {
        display: flex !important;
        flex-direction: column !important;
        gap: 16px !important;
    }
    .perfil-grid-cep,
    .perfil-grid-addr,
    .perfil-grid-foto,
    .perfil-grid-bank,
    .perfil-grid-titular-cep,
    .perfil-grid-titular-addr {
        display: flex !important;
        flex-direction: column !important;
        gap: 12px !important;
    }
}

/* ===== Print: hide overlay ===== */
@media print {
    .fd-card-overlay { display: none !important; }
}

/* ================================================================
 * Phase 2 Mobile Audit — Fase 1 quick wins
 * Aplicado em: todos os painéis (admin/lojista/comprador/público)
 * ================================================================ */

/* --- Inputs: font-size ≥ 16px previne zoom automático no iOS --- */
@media (max-width: 480px) {
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="number"],
    input[type="tel"],
    input[type="search"],
    input[type="url"],
    input[type="date"],
    input[type="datetime-local"],
    input[type="month"],
    input[type="time"],
    input[type="week"],
    textarea,
    select,
    .form-control,
    .form-select,
    .admin-form-input,
    .admin-form-select {
        font-size: 16px !important;
    }
}

/* --- Botões: touch target ≥ 44px em mobile --- */
@media (max-width: 480px) {
    .admin-btn,
    .btn {
        min-height: 44px;
    }
    .admin-btn-sm,
    .btn-sm {
        min-height: 40px;
        padding: 8px 14px;
    }
    /* Ícones circulares em ações de tabela — forçar alvo de toque */
    .admin-btn.btn-icon,
    .admin-action-badge,
    .admin-btn-eye {
        min-width: 40px;
        min-height: 40px;
    }
}

/* --- Modais: altura máxima + footer buttons sempre alcançáveis --- */
@media (max-width: 768px) {
    .modal-dialog {
        margin: 10px auto;
        max-width: calc(100vw - 20px);
    }
    .modal-dialog.modal-lg,
    .modal-dialog.modal-xl {
        max-width: calc(100vw - 20px);
    }
    .modal-content {
        max-height: calc(100vh - 20px);
        display: flex;
        flex-direction: column;
    }
    .modal-body {
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        flex: 1 1 auto;
    }
    .modal-header,
    .modal-footer {
        flex-shrink: 0;
    }
    .modal-header .btn-close {
        min-width: 44px;
        min-height: 44px;
    }
}

@media (max-width: 480px) {
    .modal-dialog {
        margin: 0;
        max-width: 100vw;
        min-height: 100vh;
    }
    .modal-content {
        border-radius: 0;
        min-height: 100vh;
        max-height: 100vh;
    }
    /* Footer buttons stack em full-width para ficar ergonômico */
    .modal-footer {
        flex-wrap: wrap;
        gap: 8px;
        padding: 12px 15px;
        padding-bottom: calc(12px + env(safe-area-inset-bottom, 0));
    }
    .modal-footer .admin-btn,
    .modal-footer .btn {
        min-height: 44px;
        flex: 1 1 calc(50% - 4px);
        min-width: 0;
    }
    .modal-footer .admin-btn:only-child,
    .modal-footer .btn:only-child {
        flex: 1 1 100%;
    }
}

/* --- Safe-area-insets (iOS notch/home indicator) --- */
body {
    padding-left: env(safe-area-inset-left, 0);
    padding-right: env(safe-area-inset-right, 0);
}

.fd-nav,
.admin-sidebar-header {
    padding-top: calc(var(--fd-nav-pad-top, 0.75rem) + env(safe-area-inset-top, 0));
}

.admin-sidebar {
    padding-left: env(safe-area-inset-left, 0);
}

/* Se houver barra de ação fixa no bottom (bulk bar, CTAs) respeitar home indicator */
.admin-bulk-action-bar,
.fd-bottom-cta {
    padding-bottom: calc(10px + env(safe-area-inset-bottom, 0)) !important;
}

/* ================================================================
 * Phase 2 Mobile Audit — Fase 2 componentes críticos
 * ================================================================ */

/* --- Phase tracker: scroll horizontal no lugar de wrap ---
 * Mantém a metáfora linear dos 7 passos em telas pequenas.
 * Afeta: lojista/envios-armazem, comprador/envios-armazem, admin/receber-envio
 */
@media (max-width: 480px) {
    .shipment-steps {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        flex-wrap: nowrap;
        padding-bottom: 6px;
    }
    .shipment-steps::-webkit-scrollbar {
        height: 4px;
    }
    .shipment-steps::-webkit-scrollbar-thumb {
        background: var(--admin-border);
        border-radius: 2px;
    }
    .shipment-step,
    .phase-step {
        flex: 0 0 72px;
        min-width: 72px;
        padding: 4px 0;
    }
    .shipment-step-line {
        flex: 0 0 12px;
        min-width: 12px;
        max-width: 12px;
    }
    .shipment-step-label {
        font-size: 9px;
        max-width: 66px;
        line-height: 1.15;
    }
    .shipment-step-dot {
        width: 32px;
        height: 32px;
    }
    .shipment-step-line {
        margin-top: 15px;
    }
}

/* --- Status badge: libera min-width:155px em <480px ---
 * admin-status-badge em tabelas quebra layout quando 2+ badges aparecem
 * lado a lado. Permite wrap + padding menor.
 */
@media (max-width: 480px) {
    .admin-status-badge {
        min-width: auto;
        white-space: normal;
        padding: 4px 8px;
        font-size: 10px;
        line-height: 1.3;
    }
}

/* --- Form columns com min-width:300px stack em <480px ---
 * Atinge: cadastrar-produto, criar-anuncio, upload-cards (inline flex)
 */
@media (max-width: 480px) {
    [style*="min-width: 300px"],
    [style*="min-width:300px"] {
        min-width: 100% !important;
    }
    /* Também pega min-width:260px e 220px comuns em filtros de tabela */
    [style*="min-width: 260px"],
    [style*="min-width: 220px"] {
        min-width: 100% !important;
    }
}

/* ================================================================
 * Phase 3 Mobile Audit — Fase 3a: Table → Cards opt-in
 * ================================================================
 * Páginas que querem cards no mobile adicionam a classe
 *    `admin-table-mobile-cards` ao seu <table>.
 * O script mobile-tables.min.js popula data-label em cada <td> a partir
 * do texto do <th> correspondente — sem precisar editar cada célula.
 * Linhas com colspan (estado vazio, tfoot TOTAL) viram cards-full.
 */
@media (max-width: 480px) {
    table.admin-table-mobile-cards {
        display: block;
        width: 100%;
        border: none;
        background: transparent;
    }
    table.admin-table-mobile-cards thead {
        position: absolute;
        top: -9999px;
        left: -9999px;
        width: 1px;
        height: 1px;
        overflow: hidden;
    }
    table.admin-table-mobile-cards tbody,
    table.admin-table-mobile-cards tfoot {
        display: block;
        width: 100%;
    }
    table.admin-table-mobile-cards tbody tr,
    table.admin-table-mobile-cards tfoot tr {
        display: block;
        width: 100%;
        background: var(--admin-card, #16202d);
        border: 1px solid var(--admin-border, #2a475e);
        border-radius: 8px;
        padding: 10px 12px;
        margin: 0 0 10px 0;
    }
    table.admin-table-mobile-cards tbody td,
    table.admin-table-mobile-cards tfoot td {
        display: flex;
        justify-content: space-between;
        align-items: baseline;
        gap: 10px;
        padding: 5px 0 5px 0;
        border: none;
        text-align: right;
        min-height: 0;
        width: 100%;
    }
    table.admin-table-mobile-cards tbody td + td,
    table.admin-table-mobile-cards tfoot td + td {
        border-top: 1px solid rgba(255,255,255,0.04);
    }
    table.admin-table-mobile-cards tbody td[data-label]::before,
    table.admin-table-mobile-cards tfoot td[data-label]::before {
        content: attr(data-label);
        color: var(--admin-text-muted, #8f98a0);
        font-size: 11px;
        text-transform: uppercase;
        letter-spacing: 0.3px;
        font-weight: 500;
        text-align: left;
        flex: 0 0 auto;
        max-width: 45%;
        padding-right: 10px;
    }
    /* Linhas com colspan (estado vazio, tfoot TOTAL) render em bloco */
    table.admin-table-mobile-cards tr.admin-table-card-full {
        text-align: center;
        padding: 16px 12px;
    }
    table.admin-table-mobile-cards tr.admin-table-card-full td {
        display: block;
        text-align: center;
        padding: 0;
        border: none;
    }
    table.admin-table-mobile-cards tr.admin-table-card-full td::before {
        display: none;
    }
    /* Totais (tfoot): destaque visual */
    table.admin-table-mobile-cards tfoot tr {
        background: rgba(38,128,235,0.08);
        border-color: var(--admin-blue, #2680eb);
    }
    table.admin-table-mobile-cards tfoot tr td::before {
        font-weight: 700;
        color: var(--admin-text-light, #fff);
    }
    /* Botão de ação dentro de <td> ocupa largura total para ficar tocável.
       #B63 (D14): a regra dizia flex: 0 0 auto — que ENCOLHE até o conteúdo,
       o contrário do que este comentário promete. */
    table.admin-table-mobile-cards tbody td .admin-btn,
    table.admin-table-mobile-cards tbody td .btn {
        flex: 1 1 100%;
        width: 100%;
        justify-content: center;
    }
}

/* ================================================================
 * Phase 3b — Scroll horizontal para tabelas com inputs/botões inline
 * (estoque, produtos, despachar, envios-armazem, meus-anuncios, etc.)
 * Usa :has() — no-op em browsers antigos, não quebra nada.
 * ================================================================ */
@media (max-width: 768px) {
    .admin-card-body:has(> table.admin-table:not(.admin-table-mobile-cards)) {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    .admin-card-body:has(> table.admin-table:not(.admin-table-mobile-cards)) > table.admin-table {
        min-width: max-content;
    }

    /* Fase 4: sticky first column para não perder contexto ao rolar horizontalmente.
       Background opaco porque sticky exige pintura própria (senão a coluna some
       sobre as demais durante o scroll).                                           */
    .admin-card-body:has(> table.admin-table:not(.admin-table-mobile-cards)) > table.admin-table thead th:first-child {
        position: sticky;
        left: 0;
        z-index: 2;
        background: var(--admin-card, #16202d);
    }
    .admin-card-body:has(> table.admin-table:not(.admin-table-mobile-cards)) > table.admin-table tbody td:first-child {
        position: sticky;
        left: 0;
        z-index: 1;
        background: var(--admin-card, #16202d);
    }
}

/* ================================================================
 * Phase 4 — Polish
 * ================================================================ */

/* --- Stats grid 1-col em <420px (iPhone 14=390px, Pixel=412px) ---
 * Antes: 2 cols até 375px, depois 1-col. Números monetários longos
 * (ex: "R$ 1.234.567,89") apertam na 2-col entre 375-420.             */
@media (max-width: 420px) {
    .admin-stats,
    .admin-stats-grid {
        grid-template-columns: 1fr !important;
        gap: 10px !important;
    }
}

/* --- Dashboard grids genéricos (admin-grid com inline style) ---
 * Grids fixos tipo "repeat(3, 1fr)" em dashboards apertam textos em
 * telas pequenas. A regra abaixo só age em <420px e em grids com
 * inline style que explicitamente usa mais de 1 coluna.               */
@media (max-width: 420px) {
    .admin-grid[style*="grid-template-columns: repeat(3"],
    .admin-grid[style*="grid-template-columns: repeat(4"],
    .admin-grid[style*="grid-template-columns: repeat(5"] {
        grid-template-columns: 1fr !important;
    }
}

/* ================================================================
 * Phase 5a — Correção mobile (Update mobile 01)
 * ================================================================ */

/* --- Regra 1: Filtros colapsam para coluna única em ≤480px ---
 * Alvo: linhas flex usadas como barras de filtro nas páginas de
 * listagem (lojista/pedidos, estoque, creditos, repasses,
 * enviar-armazem, envios-armazem; comprador/enviar-armazem,
 * despachar). O projeto não usa uma classe dedicada — as barras
 * são <form> com style inline "display:flex; flex-wrap:wrap".
 * Cobrimos ambos: classes nominais (se existirem) e o padrão
 * inline real.                                                     */
@media (max-width: 480px) {
    .admin-filters-row,
    .admin-card-header .filters-inline,
    .admin-card-body > form[style*="flex-wrap: wrap"],
    .admin-card-body > form[style*="flex-wrap:wrap"] {
        flex-direction: column !important;
        gap: 8px !important;
    }
    .admin-filters-row > *,
    .admin-card-header .filters-inline > *,
    .admin-card-body > form[style*="flex-wrap: wrap"] > *,
    .admin-card-body > form[style*="flex-wrap:wrap"] > * {
        width: 100% !important;
        min-width: 0 !important;
    }
}

/* --- Regra 2: Grids de 2 colunas em modais colapsam em ≤480px ---
 * Alvo: layouts grid 1fr 1fr dentro de modais (disputas, estoque,
 * despachar).                                                       */
@media (max-width: 480px) {
    .modal-body .grid-2col,
    .modal-body [class*="grid"][class*="col-2"],
    .modal-body [style*="grid-template-columns: 1fr 1fr"],
    .modal-body [style*="grid-template-columns:1fr 1fr"] {
        grid-template-columns: 1fr !important;
    }
}

/* --- Regra 3: Barra de progresso do Vault ocupa 100% em ≤480px ---
 * Alvo: lojista/vault.php usa .vault-bin-row com progress bar de
 * largura fixa 180px. Em mobile precisa ocupar 100%.                */
@media (max-width: 480px) {
    .vault-bin-row .progress,
    .vault-bin-row [class*="progress"],
    .vault-bin-row [style*="width: 180px"],
    .vault-bin-row [style*="width:180px"] {
        width: 100% !important;
        min-width: 0 !important;
    }
}

/* ================================================================
 * Phase 5c — Correção mobile (Update mobile 03)
 * ================================================================ */

/* --- Empilhar form + preview em upload-cards e cadastrar-produto --- */
@media (max-width: 768px) {
    .upload-form-preview-wrap {
        flex-direction: column;
    }
    .upload-form-preview-wrap > * {
        width: 100% !important;
        min-width: 0 !important;
    }
    /* UX-52 (D38 §3.4): no celular a prévia vem primeiro (DOM), compacta
     * (~120px) e SEM sticky, para o campo "Nome do Card" ficar acima da dobra.
     * Toque na imagem amplia via hover-preview.js ([data-hover-img]). */
    .upload-form-preview-wrap > #cardPreview {
        position: static !important;
    }
    .upload-form-preview-wrap #previewPlaceholder {
        width: 100% !important;
        height: 120px !important;
    }
    .upload-form-preview-wrap #previewPlaceholder i {
        font-size: 24px !important;
        margin-bottom: 4px !important;
    }
    .upload-form-preview-wrap .upload-preview-img {
        width: auto !important;
        max-height: 120px;
        margin: 0 auto;
    }
}

/* --- Linha 3-col Qty/Preço/Peso em cadastrar-produto colapsa em ≤480px --- */
@media (max-width: 480px) {
    .cadastrar-produto-qtd-row {
        flex-direction: column !important;
    }
    .cadastrar-produto-qtd-row > * {
        width: 100% !important;
    }
}

/* --- Inputs em comprador/enderecos.php ---
 * Número: remove largura fixa
 * UF: mínimo 80px com crescimento permitido
 * CEP + botão: ambos 100% empilhados em ≤480px                       */
@media (max-width: 480px) {
    .enderecos-numero-row .enderecos-numero-col {
        width: auto !important;
        flex: 1 !important;
    }
    .enderecos-cidade-row .enderecos-uf-col {
        width: auto !important;
        min-width: 80px !important;
        flex: 0 1 auto !important;
    }
    .enderecos-cep-row {
        flex-direction: column !important;
    }
    .enderecos-cep-row > * {
        width: 100% !important;
        flex: none !important;
    }
}

/* ================================================================
 * Phase 5d — Correção mobile (Update mobile 04)
 * ================================================================ */

/* --- Sidebar backdrop com transição opacity 0.2s --- */
.admin-overlay {
    opacity: 0;
    transition: opacity 0.2s ease;
    pointer-events: none;
}
.admin-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

/* --- Phase tracker tooltips: substituir por label inline em touch --- */
@media (max-width: 480px) {
    .shipment-step .phase-touch-label {
        display: none;
        position: absolute;
        left: 50%;
        transform: translateX(-50%);
        top: calc(100% + 4px);
        background: var(--admin-card, #16202d);
        border: 1px solid var(--admin-blue, #2680eb);
        border-radius: 6px;
        padding: 6px 10px;
        font-size: 11px;
        line-height: 1.3;
        color: var(--admin-text-light, #fff);
        white-space: normal;
        min-width: 140px;
        max-width: 220px;
        text-align: center;
        z-index: 50;
        box-shadow: 0 4px 12px rgba(0,0,0,0.4);
    }
    .shipment-step.show-touch-label .phase-touch-label {
        display: block;
    }
    .shipment-step {
        position: relative;
    }
}

/* --- Bottom-sheet pattern em ≤480px para modais específicos --- */
@media (max-width: 480px) {
    .modal.bottom-sheet-modal .modal-dialog {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        top: auto;
        margin: 0;
        max-width: 100vw;
        width: 100vw;
        min-height: 0;
        max-height: 92vh;
        transform: translateY(100%);
        transition: transform 0.28s ease-out;
    }
    .modal.bottom-sheet-modal.show .modal-dialog {
        transform: translateY(0);
    }
    .modal.bottom-sheet-modal .modal-content {
        border-radius: 16px 16px 0 0;
        min-height: 60vh;
        max-height: 92vh;
        padding-bottom: env(safe-area-inset-bottom, 0);
        border: none;
    }
    .modal.bottom-sheet-modal .bottom-sheet-drag-handle {
        display: block;
        width: 40px;
        height: 4px;
        margin: 8px auto 4px;
        background: var(--admin-border, #2a475e);
        border-radius: 2px;
        flex-shrink: 0;
        touch-action: none;
        cursor: grab;
    }
    .modal.bottom-sheet-modal .modal-body {
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        flex: 1 1 auto;
    }
    /* Ship detail modal: thead não-sticky em mobile (cards são mais úteis) */
    #shipmentModal #shipmentColHeaders.ship-col-headers,
    #shipmentModal .ship-col-headers {
        display: none !important;
    }
}
