/* Minimal Elegant Subcategory Design */

/* Container */
.refine-items.auto-grid {
    position: relative;
    overflow: visible;
    padding: 20px 0;
}

.refine-items.auto-grid .auto-grid-items {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    padding: 0;
}

/* Ultra Modern Cards */
.refine-items.auto-grid .refine-item {
    flex: 1 1 calc(20% - 13px);
    min-width: 160px;
    max-width: 280px;
    background: #ffffff;
    border: 1px solid #f1f5f9;
    border-radius: 20px;
    transition: all 0.4s cubic-bezier(0.23, 1, 0.32, 1);
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.03);
    overflow: hidden;
    position: relative;
}

.refine-items.auto-grid .refine-item:hover {
    border-color: #e2e8f0;
    box-shadow: 0 10px 40px rgba(15, 23, 42, 0.08), 0 4px 16px rgba(15, 23, 42, 0.04);
    transform: translateY(-6px);
    background: #fefefe;
}

.refine-items.auto-grid .refine-item a {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px 20px;
    text-decoration: none;
    color: inherit;
    height: 100%;
    min-height: 100px;
    position: relative;
}

/* Modern accent line */
.refine-items.auto-grid .refine-item:before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(135deg, #3b82f6 0%, #8b5cf6 50%, #ec4899 100%);
    opacity: 0;
    transition: all 0.4s ease;
    border-radius: 20px 20px 0 0;
}

.refine-items.auto-grid .refine-item:hover:before {
    opacity: 1;
}

/* Modern Typography */
.refine-name {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    text-align: center;
    width: 100%;
}

.refine-name .links-text {
    font-size: 15px;
    font-weight: 600;
    color: #0f172a;
    line-height: 1.3;
    letter-spacing: -0.025em;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    margin-bottom: 2px;
}

/* Modern Badge Design */
.refine-name .count-badge {
    font-size: 12px;
    background: #f1f5f9;
    color: #64748b;
    padding: 6px 12px;
    border-radius: 12px;
    font-weight: 600;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    letter-spacing: -0.01em;
    border: 1px solid #e2e8f0;
    transition: all 0.3s ease;
}

.refine-name .count-badge.count-zero {
    background: #f8fafc;
    color: #94a3b8;
    border-color: #f1f5f9;
}

.refine-items.auto-grid .refine-item:hover .count-badge {
    background: #e0e7ff;
    color: #6366f1;
    border-color: #c7d2fe;
}

/* Mobile Responsive Breakpoints */

/* Modern Mobile First - Clean 2 Column Layout */
@media (max-width: 479px) {
    .refine-items.auto-grid {
        padding: 24px 0;
    }
    
    .refine-items.auto-grid .auto-grid-items {
        gap: 12px;
        padding: 0 16px;
        display: grid;
        grid-template-columns: 1fr 1fr;
        grid-auto-rows: 1fr;
    }
    
    .refine-items.auto-grid .refine-item {
        flex: none;
        width: 100%;
        min-width: 0;
        max-width: none;
        border-radius: 16px;
        border: 1px solid #f1f5f9;
        box-shadow: 0 1px 3px rgba(15, 23, 42, 0.03);
        background: #ffffff;
        position: relative;
        overflow: hidden;
        transition: all 0.3s cubic-bezier(0.23, 1, 0.32, 1);
    }
    
    .refine-items.auto-grid .refine-item:hover {
        border-color: #e2e8f0;
        box-shadow: 0 8px 25px rgba(15, 23, 42, 0.06), 0 3px 10px rgba(15, 23, 42, 0.03);
        transform: translateY(-4px);
        background: #fefefe;
    }
    
    .refine-items.auto-grid .refine-item a {
        padding: 18px 12px;
        min-height: 90px;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        text-align: center;
    }
    
    .refine-name {
        gap: 6px;
    }
    
    .refine-name .links-text {
        font-size: 13px;
        font-weight: 600;
        line-height: 1.2;
        color: #0f172a;
        letter-spacing: -0.02em;
    }
    
    .refine-name .count-badge {
        font-size: 10px;
        padding: 4px 8px;
        border-radius: 10px;
        background: #f1f5f9;
        color: #64748b;
        border: 1px solid #e2e8f0;
        font-weight: 600;
    }
    
    /* Modern gradient accent for mobile */
    .refine-items.auto-grid .refine-item:before {
        content: '';
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        height: 3px;
        background: linear-gradient(135deg, #3b82f6 0%, #8b5cf6 50%, #ec4899 100%);
        opacity: 0;
        transition: all 0.3s ease;
        border-radius: 16px 16px 0 0;
    }
    
    .refine-items.auto-grid .refine-item:hover:before {
        opacity: 1;
    }
    
    .refine-items.auto-grid .refine-item:hover .count-badge {
        background: #e0e7ff;
        color: #6366f1;
        border-color: #c7d2fe;
    }
}

/* Large Mobile - Modern 2 Column Grid */
@media (min-width: 480px) and (max-width: 767px) {
    .refine-items.auto-grid {
        padding: 28px 0;
    }
    
    .refine-items.auto-grid .auto-grid-items {
        gap: 16px;
        padding: 0 20px;
        display: grid;
        grid-template-columns: 1fr 1fr;
        grid-auto-rows: 1fr;
    }
    
    .refine-items.auto-grid .refine-item {
        flex: none;
        width: 100%;
        min-width: 0;
        max-width: none;
        border-radius: 18px;
        border: 1px solid #f1f5f9;
        box-shadow: 0 2px 4px rgba(15, 23, 42, 0.04);
        background: #ffffff;
        position: relative;
        overflow: hidden;
        transition: all 0.35s cubic-bezier(0.23, 1, 0.32, 1);
    }
    
    .refine-items.auto-grid .refine-item:hover {
        border-color: #e2e8f0;
        box-shadow: 0 12px 32px rgba(15, 23, 42, 0.08), 0 4px 12px rgba(15, 23, 42, 0.04);
        transform: translateY(-5px);
        background: #fefefe;
    }
    
    .refine-items.auto-grid .refine-item a {
        padding: 22px 16px;
        min-height: 100px;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
    }
    
    .refine-name .links-text {
        font-size: 14px;
        font-weight: 600;
        line-height: 1.25;
        color: #0f172a;
        letter-spacing: -0.02em;
    }
    
    .refine-name .count-badge {
        font-size: 11px;
        padding: 5px 10px;
        border-radius: 11px;
        background: #f1f5f9;
        color: #64748b;
        border: 1px solid #e2e8f0;
        font-weight: 600;
    }
    
    .refine-items.auto-grid .refine-item:hover .count-badge {
        background: #e0e7ff;
        color: #6366f1;
        border-color: #c7d2fe;
    }
}

/* Tablet - 3 columns elegant */
@media (min-width: 768px) and (max-width: 991px) {
    .refine-items.auto-grid .auto-grid-items {
        gap: 16px;
        padding: 0 8px;
    }
    
    .refine-items.auto-grid .refine-item {
        flex: 1 1 calc(33.333% - 11px);
        min-width: 0;
        max-width: none;
    }
    
    .refine-items.auto-grid .refine-item a {
        padding: 20px 16px;
        min-height: 90px;
    }
    
    .refine-name .links-text {
        font-size: 14px;
    }
    
    .refine-name .count-badge {
        font-size: 11px;
        padding: 4px 8px;
    }
}

/* Small Desktop - 4 columns refined */
@media (min-width: 992px) and (max-width: 1199px) {
    .refine-items.auto-grid .refine-item {
        flex: 1 1 calc(25% - 12px);
        min-width: 180px;
    }
    
    .refine-items.auto-grid .refine-item a {
        padding: 22px 18px;
        min-height: 95px;
    }
    
    .refine-name .links-text {
        font-size: 14px;
        font-weight: 500;
    }
    
    .refine-name .count-badge {
        font-size: 11px;
        padding: 4px 9px;
    }
}

/* Large Desktop - 5 columns luxury */
@media (min-width: 1200px) {
    .refine-items.auto-grid .refine-item {
        flex: 1 1 calc(20% - 13px);
        min-width: 200px;
        max-width: 300px;
    }
    
    .refine-items.auto-grid .refine-item a {
        padding: 24px 20px;
        min-height: 100px;
    }
    
    .refine-name .links-text {
        font-size: 15px;
        font-weight: 500;
        letter-spacing: -0.01em;
    }
    
    .refine-name .count-badge {
        font-size: 11px;
        padding: 5px 10px;
    }
}

/* Auto-carousel controls - hide on mobile, show on desktop */
.refine-items.auto-grid .auto-carousel-controls {
    display: none;
}

@media (min-width: 1200px) {
    .refine-items.auto-grid .auto-carousel-controls {
        display: block;
    }
}

/* Fix for NaN transform issue */
.auto-carousel-fill {
    transform: translate3d(0, -50%, 0) scaleX(0) !important;
}

/* Touch Device Optimizations */
@media (hover: none) and (pointer: coarse) {
    .refine-items.auto-grid .refine-item {
        -webkit-tap-highlight-color: transparent;
        touch-action: manipulation;
    }
    
    .refine-items.auto-grid .refine-item:hover {
        transform: none;
    }
    
    .refine-items.auto-grid .refine-item:active {
        transform: scale(0.97);
        transition: transform 0.15s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    }
    
    .refine-items.auto-grid .refine-item a {
        user-select: none;
        -webkit-user-select: none;
        -webkit-touch-callout: none;
    }
}

/* Premium Mobile Experience */
@media (max-width: 767px) {
    /* Enhanced visual hierarchy */
    .refine-items.auto-grid .refine-item {
        transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }
    
    .refine-items.auto-grid .refine-item:hover,
    .refine-items.auto-grid .refine-item:focus {
        transform: translateY(-2px) scale(1.02);
    }
    
    /* Typography optimization for mobile */
    .refine-name .links-text {
        text-shadow: 0 1px 2px rgba(0,0,0,0.02);
        font-feature-settings: "kern" 1, "liga" 1;
    }
    
    /* Premium badge styling */
    .refine-name .count-badge {
        backdrop-filter: blur(8px);
        -webkit-backdrop-filter: blur(8px);
        text-shadow: 0 1px 1px rgba(255,255,255,0.5);
    }
    
    /* Enhanced grid layout for mobile */
    .refine-items.auto-grid .auto-grid-items {
        align-items: stretch;
    }
    
    .refine-items.auto-grid .refine-item {
        display: flex;
        flex-direction: column;
    }
    
    .refine-items.auto-grid .refine-item a {
        flex: 1;
        display: flex;
        flex-direction: column;
        justify-content: center;
    }
}

/* Special effects for high-end devices */
@media (max-width: 767px) and (-webkit-min-device-pixel-ratio: 2) {
    .refine-items.auto-grid .refine-item {
        backdrop-filter: saturate(180%) blur(20px);
        -webkit-backdrop-filter: saturate(180%) blur(20px);
    }
    
    .refine-name .links-text {
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
    }
}

/* High DPI displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .refine-name .links-text {
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
    }
}