/* Mobile Category Filters Optimization - Daha Düzenli ve Temiz Tasarım */

/* Mobil cihazlar için özel optimizasyonlar */
@media (max-width: 768px) {
    /* Ana container'ı daha kompakt yap */
    .search-and-filters {
        margin: 1.5rem 0;
        border-radius: 16px;
        box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
        background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
    }

    /* Arama bölümünü optimize et */
    .search-container {
        padding: 1.25rem;
        border-bottom: 1px solid #e2e8f0;
        background: #ffffff;
        border-radius: 16px 16px 0 0;
    }

    .search-box {
        height: 50px;
        border-radius: 12px;
        border: 2px solid #e2e8f0;
        background: #f8fafc;
        transition: all 0.3s ease;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    }

    .search-box:focus-within {
        border-color: #8b5cf6;
        background: #ffffff;
        box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.1), 0 2px 8px rgba(0, 0, 0, 0.1);
        transform: translateY(-1px);
    }

    #productSearch {
        padding: 0.875rem 1rem;
        font-size: 0.9rem;
        font-weight: 400;
    }

    #productSearch::placeholder {
        color: #94a3b8;
        font-size: 0.85rem;
    }

    .search-btn, .clear-search {
        width: 42px;
        height: 42px;
        border-radius: 10px;
        margin: 4px;
        font-size: 0.95rem;
        transition: all 0.2s ease;
    }

    .search-btn:hover, .clear-search:hover {
        transform: scale(1.05);
    }

    /* Kategori filtreleri - Daha düzenli layout */
    .filter-buttons {
        padding: 1.5rem 1.25rem;
        gap: 0.75rem;
        justify-content: flex-start;
        overflow-x: auto;
        overflow-y: hidden;
        background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
        border-bottom: 1px solid #e2e8f0;
        
        /* Smooth scrolling */
        scroll-behavior: smooth;
        -webkit-overflow-scrolling: touch;
        
        /* Custom scrollbar */
        scrollbar-width: thin;
        scrollbar-color: #cbd5e1 #f1f5f9;
    }

    .filter-buttons::-webkit-scrollbar {
        height: 3px;
    }

    .filter-buttons::-webkit-scrollbar-track {
        background: #f1f5f9;
        border-radius: 2px;
    }

    .filter-buttons::-webkit-scrollbar-thumb {
        background: linear-gradient(90deg, #cbd5e1, #94a3b8);
        border-radius: 2px;
    }

    .filter-buttons::-webkit-scrollbar-thumb:hover {
        background: linear-gradient(90deg, #94a3b8, #64748b);
    }

    /* Kategori butonları - Daha kompakt ve düzenli */
    .filter-btn {
        flex-shrink: 0;
        padding: 0.625rem 1rem;
        font-size: 0.8rem;
        font-weight: 600;
        border-radius: 12px;
        gap: 0.5rem;
        min-height: 38px;
        white-space: nowrap;
        
        /* Daha yumuşak geçişler */
        transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        
        /* Daha iyi görsel hiyerarşi */
        background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
        border: 1.5px solid #e2e8f0;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    }

    .filter-btn:hover {
        transform: translateY(-1px);
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
        border-color: #cbd5e1;
        background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    }

    .filter-btn.active {
        background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
        border-color: #8b5cf6;
        color: white;
        transform: translateY(-2px);
        box-shadow: 
            0 4px 12px rgba(139, 92, 246, 0.3),
            0 0 0 1px rgba(139, 92, 246, 0.1);
    }

    .filter-btn.active:hover {
        transform: translateY(-2px) scale(1.02);
        box-shadow: 
            0 6px 16px rgba(139, 92, 246, 0.4),
            0 0 0 1px rgba(139, 92, 246, 0.2);
    }

    /* Sayaç badge'leri */
    .filter-count {
        background: rgba(71, 85, 105, 0.1);
        color: #64748b;
        padding: 0.2rem 0.45rem;
        border-radius: 8px;
        font-size: 0.7rem;
        font-weight: 700;
        min-width: 18px;
        text-align: center;
        border: 1px solid rgba(71, 85, 105, 0.1);
    }

    .filter-btn.active .filter-count {
        background: rgba(255, 255, 255, 0.25);
        color: white;
        border-color: rgba(255, 255, 255, 0.3);
    }

    /* Sıralama bölümü - Daha kompakt */
    .sort-options {
        padding: 1.25rem;
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        gap: 1rem;
        background: #ffffff;
        border-radius: 0 0 16px 16px;
    }

    .sort-label {
        font-size: 0.8rem;
        font-weight: 600;
        color: #64748b;
        white-space: nowrap;
        display: flex;
        align-items: center;
        gap: 0.5rem;
    }

    .sort-label::before {
        content: '⚡';
        font-size: 0.9rem;
    }

    #sortSelect {
        min-width: 160px;
        max-width: 200px;
        padding: 0.625rem 2.5rem 0.625rem 1rem;
        font-size: 0.8rem;
        font-weight: 500;
        border-radius: 10px;
        border: 1.5px solid #e2e8f0;
        background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    }

    #sortSelect:focus {
        border-color: #8b5cf6;
        box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.1);
        background: #ffffff;
    }

    /* Gradient fade effect for scrollable filters */
    .filter-buttons {
        position: relative;
    }

    .filter-buttons::before,
    .filter-buttons::after {
        content: '';
        position: absolute;
        top: 0;
        bottom: 0;
        width: 15px;
        pointer-events: none;
        z-index: 2;
        transition: opacity 0.3s ease;
    }

    .filter-buttons::before {
        left: 0;
        background: linear-gradient(to right, rgba(248, 250, 252, 0.9), transparent);
        opacity: 0;
    }

    .filter-buttons::after {
        right: 0;
        background: linear-gradient(to left, rgba(241, 245, 249, 0.9), transparent);
        opacity: 1;
    }

    .filter-buttons.scroll-start::before {
        opacity: 0;
    }

    .filter-buttons.scroll-end::after {
        opacity: 0;
    }

    .filter-buttons:not(.scroll-start)::before {
        opacity: 1;
    }

    .filter-buttons:not(.scroll-end)::after {
        opacity: 1;
    }

    /* Mobile layout class for JavaScript control */
    .search-and-filters.mobile-layout {
        position: relative;
    }

    /* Improved touch targets */
    .filter-btn {
        min-height: 44px; /* iOS recommended touch target size */
        touch-action: manipulation; /* Prevent double-tap zoom */
    }

    .search-btn, .clear-search {
        min-width: 44px;
        min-height: 44px;
        touch-action: manipulation;
    }

    #sortSelect {
        min-height: 44px;
        touch-action: manipulation;
    }
}

/* Çok küçük ekranlar için ek optimizasyonlar */
@media (max-width: 480px) {
    .search-and-filters {
        margin: 1rem 0;
        border-radius: 14px;
    }

    .search-container {
        padding: 1rem;
    }

    .search-box {
        height: 46px;
        border-radius: 10px;
    }

    #productSearch {
        padding: 0.75rem 0.875rem;
        font-size: 0.85rem;
    }

    #productSearch::placeholder {
        font-size: 0.8rem;
    }

    .search-btn, .clear-search {
        width: 38px;
        height: 38px;
        font-size: 0.9rem;
    }

    .filter-buttons {
        padding: 1.25rem 1rem;
        gap: 0.625rem;
    }

    .filter-btn {
        padding: 0.5rem 0.875rem;
        font-size: 0.75rem;
        border-radius: 10px;
        min-height: 34px;
    }

    .filter-count {
        font-size: 0.65rem;
        padding: 0.15rem 0.35rem;
        border-radius: 6px;
        min-width: 16px;
    }

    .sort-options {
        padding: 1rem;
        flex-direction: column;
        gap: 0.75rem;
        align-items: stretch;
    }

    .sort-label {
        font-size: 0.75rem;
        justify-content: center;
    }

    #sortSelect {
        width: 100%;
        max-width: none;
        min-width: auto;
        padding: 0.5rem 2rem 0.5rem 0.875rem;
        font-size: 0.75rem;
    }
}

/* Landscape orientation optimizations for mobile */
@media (max-width: 768px) and (orientation: landscape) {
    .search-and-filters {
        margin: 1rem 0;
    }

    .search-container {
        padding: 1rem 1.25rem;
    }

    .filter-buttons {
        padding: 1.25rem;
    }

    .sort-options {
        padding: 1rem 1.25rem;
        flex-direction: row;
    }

    #sortSelect {
        min-width: 140px;
        max-width: 180px;
    }
}

/* Accessibility improvements for mobile */
@media (max-width: 768px) {
    .filter-btn:focus {
        outline: 2px solid #8b5cf6;
        outline-offset: 2px;
    }

    #sortSelect:focus {
        outline: 2px solid #8b5cf6;
        outline-offset: 2px;
    }

    .search-btn:focus,
    .clear-search:focus {
        outline: 2px solid #ffffff;
        outline-offset: 2px;
    }
}

/* Animation for smooth transitions */
@media (max-width: 768px) {
    .filter-btn {
        animation: fadeInUp 0.3s ease-out;
    }

    .filter-btn:nth-child(1) { animation-delay: 0.05s; }
    .filter-btn:nth-child(2) { animation-delay: 0.1s; }
    .filter-btn:nth-child(3) { animation-delay: 0.15s; }
    .filter-btn:nth-child(4) { animation-delay: 0.2s; }
    .filter-btn:nth-child(5) { animation-delay: 0.25s; }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Loading state optimizations */
@media (max-width: 768px) {
    .filter-btn.loading {
        opacity: 0.6;
        pointer-events: none;
        position: relative;
    }

    .filter-btn.loading::after {
        content: '';
        position: absolute;
        top: 50%;
        left: 50%;
        width: 16px;
        height: 16px;
        margin: -8px 0 0 -8px;
        border: 2px solid transparent;
        border-top: 2px solid currentColor;
        border-radius: 50%;
        animation: spin 1s linear infinite;
    }
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}
