/* Additional CSS fixes for mobile genre navigation buttons */
@media (max-width: 480px) {
    /* Fix for the genre pill width issue in portrait mode - optimized for space */
    .genre-pill {
        max-width: 100px !important; /* Reduced from 110px to have more pills in view */
        padding: 5px 7px !important; /* Slightly more compact */
        font-size: 0.7rem !important;
        box-shadow: 0 1px 3px rgba(0,0,0,0.08) !important; /* Lighter shadow for mobile */
        width: auto !important; /* Allow buttons to size based on content */
        flex-basis: auto !important; /* Auto flex basis */
        overflow: hidden !important;
        border-radius: 8px !important; /* Further reduced border radius for modern look */
        touch-action: manipulation !important; /* Improve touch response */
        -webkit-tap-highlight-color: transparent !important; /* Remove tap highlight on iOS */
    }
    
    /* Ensure genre name doesn't overflow - improved text handling */
    .genre-name {
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        max-width: 70px !important; /* Slightly increased for better readability */
        white-space: nowrap !important;
    }
    
    /* Fix for the genre count badge */
    .genre-count {
        padding: 1px 4px !important;
        font-size: 0.65rem !important;
        margin-left: 3px !important;
        box-shadow: none !important; /* Remove shadow from the count badge */
        min-width: 18px !important;
        text-align: center !important;
        border-radius: 8px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
    }
    
    /* Adjust spacing for better arrangement */
    .genre-list {
        gap: 5px !important; /* Reduced from 6px for more compact layout */
        justify-content: flex-start !important; /* Ensure proper alignment */
        padding-bottom: 3px !important;
        overscroll-behavior-x: contain !important; /* Prevent page overscroll */
        scroll-padding: 0.5rem !important; /* Better scroll experience */
    }
    
    /* Fix for multiple genre pills in a row */
    .mobile-categories-container {
        padding: 8px 4px !important;
    }
    
    /* Fix for the active state of genre pills */
    .genre-pill.active, .genre-pill.selected {
        box-shadow: 0 2px 5px rgba(var(--primary-rgb), 0.2) !important;
    }
    
    /* Improve touch feedback */
    .genre-pill:active {
        transform: scale(0.95) !important;
        box-shadow: 0 1px 2px rgba(0,0,0,0.1) !important;
    }
}

/* Additional fixes for very small screens (iPhone SE, etc.) */
@media (max-width: 375px) {
    .genre-pill {
        max-width: 85px !important; /* Reduced from 90px for better screen usage */
        padding: 4px 5px !important; /* More compact padding */
        margin: 0 !important; /* Remove any margin */
    }
    
    .genre-name {
        max-width: 58px !important; /* Slightly increased */
        font-size: 0.65rem !important; /* Slightly smaller text */
    }
    
    .genre-count {
        min-width: 14px !important; /* Smaller count badge */
        font-size: 0.55rem !important; /* Smaller font for badge */
        padding: 1px 3px !important; /* Tighter padding */
    }
    
    .genre-list {
        gap: 3px !important; /* Further reduced gap */
        padding: 0 2px !important; /* Minimal padding */
    }
}

/* Fix for portrait mode container */
.mobile-categories-container.portrait-mode {
    padding: 6px 3px !important;
}

/* Fix the mobile navigation shadow rendering */
.mobile-nav-control {
    box-shadow: 0 2px 6px rgba(0,0,0,0.15) !important;
}

/* Ottimizzazioni per lo schermo intero sui dispositivi mobili */
@media (max-width: 768px) {
    /* Ottimizzazione della griglia di contenuti per occupare tutto lo spazio disponibile */
    .audiobook-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)) !important;
        gap: 10px !important;
        padding: 0 8px !important;
        width: 100% !important;
        max-width: 100vw !important;
    }
    
    /* Card dei contenuti ottimizzate per la visualizzazione mobile */
    .audiobook-card {
        width: 100% !important;
        min-height: 220px !important;
        margin: 0 !important;
    }
    
    /* Immagine di copertina ridimensionata per adattarsi meglio */
    .audiobook-cover {
        height: 140px !important;
        object-fit: cover !important;
    }
    
    /* Ridurre lo spazio occupato dall'intestazione */
    .site-header {
        padding: 8px 12px !important;
    }
    
    /* Migliorare l'esperienza di ricerca su mobile */
    .search-container {
        width: 100% !important;
        max-width: 100% !important;
        margin: 8px 0 !important;
    }
    
    .search-input {
        height: 40px !important;
        font-size: 0.9rem !important;
    }
}
