/**
 * 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;
    }

    /* Compact top bar: logo smaller, tighter gaps */
    .fd-nav-top .container {
        gap: 8px;
        padding-top: 6px;
        padding-bottom: 6px;
    }
    .fd-logo-img {
        width: 30px !important;
        height: 30px !important;
    }
    .fd-logo-text {
        font-size: 17px;
    }

    /* Nav right: tighter, touch-friendly (44px min targets) */
    .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;
    }

    /* Search: compact on mobile, slightly smaller */
    .fd-search input {
        padding: 7px 38px 7px 12px;
        font-size: 14px;
    }
    .fd-search button {
        width: 36px;
    }

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

@media (max-width: 480px) {
    .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, #5B8FB9);
        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(91, 143, 185, 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;
    }
}

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