/* 
    FUMA DropShip - Responsive Styles
    Optimized for Mobile, Tablets, and Social Media Influencers
    Focus: Balance, Touch-friendliness, and Aesthetic Polish
*/

/* --- Global Mobile Optimization --- */
html, body {
    width: 100%;
    margin: 0;
    padding: 0;
    overflow-x: hidden;
    -webkit-text-size-adjust: 100%;
}

/* --- Tablets and Large Mobiles (992px and below) --- */
@media (max-width: 992px) {
    :root {
        --sidebar-width: 280px;
    }

    .sidebar {
        transform: translateX(-100%);
        width: var(--sidebar-width);
        box-shadow: none;
        transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    }

    .sidebar.open {
        transform: translateX(0);
        box-shadow: 15px 0 40px rgba(0,0,0,0.25);
    }

    .sidebar-header img {
        max-width: 180px; /* Ensure logo doesn't bleed out */
        height: auto;
    }

    .main-content {
        margin-left: 0;
        width: 100%;
        padding: 15px;
        min-height: calc(100vh - 60px);
    }

    .mobile-toggle {
        display: flex !important;
        align-items: center;
        justify-content: center;
        background: white;
        border: 1px solid var(--border-color);
        box-shadow: var(--shadow-sm);
    }

    .topbar {
        justify-content: flex-start;
        gap: 12px;
        margin-bottom: 20px;
        flex-wrap: nowrap; /* Keep it in one row if possible */
        overflow-x: auto; /* Allow scrolling for many buttons */
        padding-bottom: 5px;
        -webkit-overflow-scrolling: touch;
    }

    /* Hide scrollbar for topbar while allowing scroll */
    .topbar::-webkit-scrollbar { display: none; }

    .topbar > div:not(.mobile-toggle) {
        margin-left: 0; /* Reset for better alignment */
    }

    /* Target specific grids used in dashboard.js and others */
    div[style*="display: grid"], 
    div[style*="display:grid"] {
        grid-template-columns: 1fr !important;
        gap: 15px !important;
    }

    /* Ensure specific 2-column needs (if any) are met */
    .grid-2-mobile {
        grid-template-columns: 1fr 1fr !important;
    }

    .topbar h2 {
        font-size: 1.15rem;
        white-space: nowrap;
    }

    /* Edit Drawers and Side Panels */
    #edit-drawer, #order-detail-panel {
        width: 100% !important;
        right: -100% !important;
        max-width: none !important;
        transition: right 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    }

    #edit-drawer[style*="right: 0"], #edit-drawer[style*="right:0"],
    #order-detail-panel[style*="right: 0"], #order-detail-panel[style*="right:0"] {
        right: 0 !important;
    }
}

/* --- Small Mobiles (576px and below) --- */
@media (max-width: 576px) {
    .main-content {
        padding: 12px;
    }

    .topbar {
        padding: 8px 0;
        gap: 10px;
    }

    /* Search Input responsiveness */
    #prod-search, #order-search, #mkt-search {
        width: 120px !important;
        font-size: 0.8rem;
    }

    .topbar .btn, .topbar a.btn {
        padding: 8px 12px;
        font-size: 0.75rem;
        white-space: nowrap;
    }

    /* Cards optimization for mobile influencers */
    .card {
        padding: 16px;
        border-radius: 12px;
        margin-bottom: 16px;
    }

    /* Table Responsiveness - The final solution */
    .card:has(table) {
        padding: 0;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
        border-radius: 8px;
    }

    table {
        min-width: 750px; /* Prevents text clashing */
    }

    th, td {
        padding: 12px 10px;
        font-size: 0.8rem;
    }

    /* KPI Cards - Stack them nicely */
    .kpi-value {
        font-size: 1.6rem !important;
        margin-top: 4px;
    }

    /* Marketplace Grid Adjustments */
    #mkt-grid {
        grid-template-columns: 1fr !important;
        gap: 20px !important;
    }

    /* Marketplace Product Images */
    #mkt-grid img {
        height: 220px !important; /* Larger images for influencers */
    }

    /* Form Elements - Crucial for touch */
    input, textarea, select {
        font-size: 16px !important; /* Prevents iOS auto-zoom */
        padding: 12px 14px;
        border-radius: 8px;
    }

    /* Modals - Centers and sizes them for mobile */
    #import-modal .card, #remove-modal > div, .payout-modal {
        width: 92% !important;
        margin: 10px auto !important;
        padding: 20px !important;
        max-height: 85vh;
    }

    /* Calculator in import modal */
    div[style*="grid-template-columns: 1fr 1fr"],
    div[style*="grid-template-columns:1fr 1fr"] {
        grid-template-columns: 1fr !important;
        gap: 10px !important;
    }

    /* Navigation touch targets */
    .nav-item {
        padding: 16px 20px;
        font-size: 0.95rem;
    }

    /* Charts height adjustment */
    canvas {
        max-height: 250px;
    }
}

/* --- Extra Small Devices (360px and below) --- */
@media (max-width: 360px) {
    .topbar h2 {
        display: none; /* Hide title if screen is too narrow, icon/toggle is more important */
    }
    
    #prod-search, #order-search, #mkt-search {
        width: 100px !important;
    }
}

/* --- Influence/Visual Polish --- */
.btn:active {
    transform: scale(0.96);
    transition: transform 0.1s;
}

.card {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

@media (hover: hover) {
    .card:hover {
        box-shadow: var(--shadow-md);
    }
}

/* Fix for overlapping elements in flex containers */
.flex-wrap-mobile {
    flex-wrap: wrap !important;
}

/* Animation for the mobile toggle pulse (Subtle) */
@keyframes pulse-subtle {
    0% { box-shadow: 0 0 0 0 rgba(255, 111, 0, 0.4); }
    70% { box-shadow: 0 0 0 6px rgba(255, 111, 0, 0); }
    100% { box-shadow: 0 0 0 0 rgba(255, 111, 0, 0); }
}

.mobile-toggle {
    animation: pulse-subtle 2s infinite;
}

