/* BeatFridge - Mobile Responsive Fixes */

/* ===== Global Overflow Prevention ===== */
html, body {
    max-width: 100vw;
    overflow-x: hidden;
}

/* ===== Bottom Tab Bar (injected by app.js, these are overrides) ===== */
@media (max-width: 767px) {
    .bottom-tab-bar {
        padding-bottom: env(safe-area-inset-bottom, 0px) !important;
    }
    
    .bottom-tab-center {
        top: -12px !important;
        width: 52px !important;
        height: 52px !important;
    }
    
    .bottom-tab span {
        font-size: 9px !important;
    }
}

@media (min-width: 768px) {
    /* On desktop, ensure content doesn't have extra bottom padding for tab bar */
    body {
        padding-bottom: 6rem !important;
    }
}

img {
    max-width: 100%;
    height: auto;
}

/* ===== Mobile Navigation Panel ===== */
@media (max-width: 767px) {
    .mobile-nav-panel {
        position: fixed;
        top: 0;
        right: 0;
        bottom: 0;
        width: 280px;
        max-width: 85vw;
        background: #111111;
        border-left: 1px solid rgba(255, 255, 255, 0.1);
        z-index: 55;
        padding: 1.5rem;
        transform: translateX(100%);
        transition: transform 0.3s ease;
        overflow-y: auto;
    }
    
    .mobile-nav-panel.open {
        transform: translateX(0);
    }
    
    .mobile-nav-overlay {
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.7);
        backdrop-filter: blur(4px);
        -webkit-backdrop-filter: blur(4px);
        z-index: 54;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.3s ease;
    }
    
    .mobile-nav-overlay.open {
        opacity: 1;
        pointer-events: all;
    }
}

/* ===== Sticky Player Mobile ===== */
@media (max-width: 767px) {
    .sticky-player {
        padding-left: 0.5rem !important;
        padding-right: 0.5rem !important;
        padding-top: 0.375rem !important;
        padding-bottom: 0.375rem !important;
    }
    
    /* Inner flex container */
    .sticky-player > div {
        flex-wrap: wrap;
        gap: 0.25rem;
    }
    
    /* Track info - responsive */
    .sticky-player > div > div:first-child {
        width: auto !important;
        max-width: 55% !important;
        flex: 1 1 0 !important;
        min-width: 0 !important;
        gap: 0.5rem !important;
    }
    
    /* Smaller art on mobile */
    .sticky-player > div > div:first-child > div:first-child {
        width: 2.5rem !important;
        height: 2.5rem !important;
    }
    
    /* Hide maximize overlay on mobile */
    .sticky-player .group:hover .opacity-0.group-hover\:opacity-100 {
        display: none !important;
    }
    
    /* Volume section - hidden on mobile */
    .sticky-player > div > div:last-child {
        display: none !important;
    }
    
    /* Controls section */
    .sticky-player > div > div:nth-child(2) {
        flex: 0 0 auto !important;
        max-width: 45% !important;
        width: auto !important;
    }
    
    /* Hide progress bar on mobile */
    .sticky-player > div > div:nth-child(2) > div:last-child {
        display: none !important;
    }
    
    /* Compact buttons */
    .sticky-player > div > div:nth-child(2) > div:first-child {
        gap: 0.375rem !important;
        margin-bottom: 0 !important;
    }
    
    /* Smaller play button */
    .sticky-player .w-10.h-10.rounded-full.bg-white {
        width: 2.25rem !important;
        height: 2.25rem !important;
    }
    
    .sticky-player .w-10.h-10.rounded-full.bg-white svg,
    .sticky-player .w-10.h-10.rounded-full.bg-white i {
        width: 1rem !important;
        height: 1rem !important;
    }
    
    /* Hide shuffle/repeat on very small screens */
    @media (max-width: 374px) {
        .sticky-player > div > div:nth-child(2) > div:first-child > button:first-child,
        .sticky-player > div > div:nth-child(2) > div:first-child > button:last-child {
            display: none !important;
        }
    }
}

/* ===== General Mobile Layout Fixes ===== */
@media (max-width: 767px) {
    /* Ensure main layout containers don't overflow */
    .max-w-\[1600px\] {
        padding-left: 1rem !important;
        padding-right: 1rem !important;
    }
    
    /* Prevent flex children from overflowing */
    .flex {
        min-width: 0;
    }
    
    /* Filter buttons wrap */
    .flex.items-center.gap-2:not(.flex-shrink-0) {
        flex-wrap: wrap;
    }
    
    /* Action buttons wrap */
    .flex.items-center.gap-3.mb-2,
    .flex.items-center.gap-3.mb-4 {
        flex-wrap: wrap;
    }
    
    /* Stats rows wrap */
    .flex.items-center.gap-8.mt-6.pt-6,
    .flex.items-center.gap-6.mt-6.pt-6 {
        flex-wrap: wrap;
        gap: 1rem !important;
    }
    
    /* Artist info links wrap */
    .flex.items-center.gap-4.text-sm.text-gray-300,
    .flex.items-center.gap-6.text-sm.text-gray-300 {
        flex-wrap: wrap;
        gap: 0.5rem !important;
    }
    
    /* Smaller heading sizes on mobile */
    .text-3xl {
        font-size: 1.5rem !important;
    }
    
    .text-4xl {
        font-size: 1.75rem !important;
    }
    
    .text-5xl {
        font-size: 2rem !important;
    }
}

/* ===== Tabs Scrollable ===== */
@media (max-width: 767px) {
    .mobile-tabs-scroll {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        -ms-overflow-style: none;
    }
    
    .mobile-tabs-scroll::-webkit-scrollbar {
        display: none;
    }
}

/* ===== Analytics Specific ===== */
@media (max-width: 767px) {
    .flex.items-end.justify-between {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }
    
    .flex.items-center.gap-3:not(.flex-shrink-0) {
        flex-wrap: wrap;
    }
}

/* ===== Track Page Mobile ===== */
@media (max-width: 767px) {
    .h-24.bg-white\/5 {
        height: 4rem;
    }
    
    /* Comment input responsive */
    .flex.gap-4.mb-6 {
        gap: 0.75rem;
    }
}

/* ===== Upload Page Mobile ===== */
@media (max-width: 767px) {
    .flex.items-start.gap-6 {
        flex-direction: column;
        gap: 1rem;
    }
    
    .w-32.h-32,
    .w-40.h-40 {
        width: 100% !important;
        height: auto !important;
        aspect-ratio: 1;
    }
}

/* ===== Wallet Summary Mobile ===== */
@media (max-width: 767px) {
    .glass-panel.rounded-2xl.p-4.mb-6.flex.items-center.justify-between {
        flex-wrap: wrap;
        gap: 0.75rem;
    }
    
    .glass-panel.rounded-2xl.p-4.mb-6 .flex.items-center.gap-4 {
        flex-wrap: wrap;
    }
}

/* ===== Discover Filter Buttons ===== */
@media (max-width: 480px) {
    .flex.items-center.gap-2 .px-4 {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }
}

/* ===== Prevent Any Fixed-Width Element from Overflowing ===== */
@media (max-width: 767px) {
    [class*="w-64"] {
        max-width: 100% !important;
    }
    
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="number"],
    select,
    textarea {
        max-width: 100% !important;
    }
}