/**
 * Category Slider Styles - Robust Version
 * Kumrat Tourism OS
 */

/* ========================================
   CATEGORY SLIDER WRAPPER
   ======================================== */
.kt-category-slider-wrapper {
    width: 100%;
    max-width: 100vw;
    overflow: hidden;
    position: relative;
}

/* ========================================
   CATEGORY SLIDER CONTAINER
   ======================================== */
.kt-category-slider {
    background: var(--kt-header-bg, #ffffff);
    border-bottom: 1px solid var(--kt-header-border, #e5e5e5);
    overflow: hidden;
    position: relative;
    width: 100%;
    max-width: 100vw;
    z-index: 100;
}

/* Ensure slider doesn't break page layout */
.kt-category-slider,
.kt-category-slider * {
    box-sizing: border-box;
}

/* ========================================
   SLIDER TRACK - Animation + Manual Scroll
   ======================================== */
.kt-category-slider {
    overflow-x: auto;
    overflow-y: hidden;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}

.kt-category-slider__track {
    display: flex;
    align-items: center;
    width: max-content;
    max-width: none;
    padding: 10px 0;
    gap: var(--kt-cat-gap, 30px);
    will-change: transform;
    animation: kt-cat-scroll var(--kt-scroll-speed, 20s) linear infinite;
}

/* Pause auto-scroll when manually scrolling */
.kt-category-slider:hover .kt-category-slider__track,
.kt-category-slider:active .kt-category-slider__track,
.kt-category-slider:focus-within .kt-category-slider__track {
    animation-play-state: paused;
}

/* Manual scroll active state */
.kt-category-slider.is-scrolling .kt-category-slider__track {
    animation-play-state: paused !important;
}

/* Pause on hover */
.kt-category-slider:hover .kt-category-slider__track {
    animation-play-state: paused;
}

@keyframes kt-cat-scroll {
    0% {
        transform: translate3d(0, 0, 0);
    }
    100% {
        transform: translate3d(-50%, 0, 0);
    }
}

/* ========================================
   CATEGORY ITEM
   ======================================== */
.kt-category-slider__item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 10px 15px;
    text-decoration: none;
    border-radius: 12px;
    transition: all 0.3s ease;
    min-width: 90px;
    max-width: 120px;
    flex-shrink: 0;
    text-align: center;
}

.kt-category-slider__item:hover {
    background: rgba(0, 168, 232, 0.1);
    transform: translateY(-2px);
}

/* ========================================
   ICON CONTAINER
   ======================================== */
.kt-category-slider__icon {
    width: var(--kt-cat-icon-size, 50px);
    height: var(--kt-cat-icon-size, 50px);
    min-width: var(--kt-cat-icon-size, 50px);
    min-height: var(--kt-cat-icon-size, 50px);
    border-radius: 50%;
    overflow: hidden;
    background: linear-gradient(135deg, #f5f5f5 0%, #e8e8e8 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s ease;
    position: relative;
    flex-shrink: 0;
    border: 2px solid transparent;
}

.kt-category-slider__item:hover .kt-category-slider__icon {
    transform: scale(1.1);
}

/* ========================================
   ICON IMAGE
   ======================================== */
.kt-category-slider__icon img {
    width: 100% !important;
    height: 100% !important;
    max-width: 100% !important;
    max-height: 100% !important;
    object-fit: contain !important;
    object-position: center !important;
    display: block !important;
    position: absolute;
    top: 0;
    left: 0;
}

/* Image loading error state */
.kt-category-slider__icon img[src=""],
.kt-category-slider__icon img:not([src]),
.kt-category-slider__icon img[src*="data:image"],
.kt-category-slider__icon img.error {
    display: none !important;
}

/* ========================================
   FALLBACK LETTER
   ======================================== */
.kt-cat-fallback {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    font-size: 22px;
    font-weight: 700;
    color: #00a8e8;
    text-transform: uppercase;
    background: linear-gradient(135deg, rgba(0,168,232,0.15) 0%, rgba(0,168,232,0.3) 100%);
    border-radius: 50%;
    position: relative;
    z-index: 2;
}

.kt-category-slider__icon img + .kt-cat-fallback {
    display: none;
    position: absolute;
    top: 0;
    left: 0;
}

.kt-category-slider__icon img[style*="display: none"] + .kt-cat-fallback,
.kt-category-slider__icon img.error + .kt-cat-fallback {
    display: flex !important;
}

/* ========================================
   CATEGORY NAME
   ======================================== */
.kt-category-slider__name {
    font-size: var(--kt-cat-text-size, 13px);
    font-weight: 600;
    color: #333;
    text-align: center;
    white-space: nowrap;
    max-width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ========================================
   DRAG/SCROLL SUPPORT - ENHANCED
   ======================================== */
.kt-category-slider {
    cursor: grab;
    touch-action: pan-x pan-left pan-right; /* Enable horizontal touch scrolling */
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    /* Enable smooth scrolling for manual scroll */
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}

.kt-category-slider.is-dragging {
    cursor: grabbing;
}

.kt-category-slider.is-dragging .kt-category-slider__track {
    animation-play-state: paused !important;
    cursor: grabbing;
}

.kt-category-slider__track {
    /* Hardware acceleration for smooth scrolling */
    will-change: transform;
    transform: translateZ(0);
    backface-visibility: hidden;
    perspective: 1000px;
}

/* Smooth drag transition */
.kt-category-slider__track.dragging {
    transition: none;
}

/* Category item touch feedback */
.kt-category-slider__item {
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.kt-category-slider__item:active {
    transform: scale(0.95);
}

/* Hide scrollbar */
.kt-category-slider::-webkit-scrollbar {
    display: none;
}

.kt-category-slider {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

/* ========================================
   RESPONSIVE
   ======================================== */
@media (max-width: 768px) {
    .kt-category-slider {
        height: auto !important;
        min-height: 70px;
    }
    
    .kt-category-slider__item {
        min-width: 70px;
        max-width: 90px;
        padding: 8px 10px;
    }
    
    .kt-category-slider__icon {
        width: 40px;
        height: 40px;
        min-width: 40px;
        min-height: 40px;
    }
    
    .kt-category-slider__name {
        font-size: 11px;
        max-width: 70px;
    }
    
    .kt-cat-fallback {
        font-size: 16px;
    }
}

/* ========================================
   ACCESSIBILITY
   ======================================== */
@media (prefers-reduced-motion: reduce) {
    .kt-category-slider__track {
        animation: none !important;
    }
}
