/**
 * ========================================
 * PREMIUM PHONE PRODUCT IMAGE GALLERY
 * Professional ecommerce gallery system
 * Similar to: Apple Store, Samsung Store, Jumia
 * ========================================
 */

/* ========================================
   MAIN GALLERY CONTAINER
   ======================================== */

.phone-gallery-container {
    position: relative;
    background: linear-gradient(135deg, #f5f7fa 0%, #ffffff 100%);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    transition: all 0.3s ease-in-out;
    width: 100%;
    max-width: 100%;
    display: flex !important;
    flex-direction: column !important;
}

.phone-gallery-container:hover {
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
}

/* Ensure card wrapper respects max sizes */
.card .phone-gallery-container {
    max-height: none;
}

/* ========================================
   MAIN IMAGE DISPLAY AREA
   ======================================== */

.gallery-main-image-wrapper {
    position: relative;
    width: 100% !important;
    height: 380px !important;
    background: #ffffff;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    overflow: hidden;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.gallery-main-image {
    position: relative;
    width: 100% !important;
    height: 100% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    background: linear-gradient(135deg, #f5f7fa 0%, #ffffff 50%, #f5f7fa 100%);
    border-radius: 0;
}

.gallery-main-image img {
    max-width: 90% !important;
    max-height: 90% !important;
    width: auto !important;
    height: auto !important;
    object-fit: contain !important;
    display: block !important;
    user-select: none;
    -webkit-user-drag: none;
    animation: fadeInScale 0.5s ease-in-out;
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.gallery-main-image img:hover {
    transform: scale(1.05);
}

@keyframes fadeInScale {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Image counter */
.gallery-image-counter {
    position: absolute;
    top: 16px;
    right: 16px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 8px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    backdrop-filter: blur(10px);
    z-index: 10;
    animation: slideDown 0.3s ease-out;
}

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

/* Image zoom indicator */
.gallery-zoom-indicator {
    position: absolute;
    bottom: 16px;
    right: 16px;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    padding: 8px 12px;
    border-radius: 20px;
    font-size: 11px;
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
    backdrop-filter: blur(10px);
    z-index: 10;
}

.gallery-main-image-wrapper:hover .gallery-zoom-indicator {
    opacity: 1;
}

/* ========================================
   AUTO-MOVING THUMBNAILS SECTION
   ======================================== */

.gallery-thumbnails-wrapper {
    padding: 16px;
    background: #ffffff;
    border-top: 1px solid rgba(0, 0, 0, 0.05);
    overflow: hidden;
}

.gallery-thumbnails-container {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    overflow: hidden;
}

/* Thumbnail scroller */
.gallery-thumbnails-scroller {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    scroll-behavior: smooth;
    padding: 4px 0;
    margin: 0;
    list-style: none;
    border-radius: 8px;
    scroll-snap-type: x mandatory;
}

/* Hide scrollbar */
.gallery-thumbnails-scroller::-webkit-scrollbar {
    display: none;
    height: 4px;
}

.gallery-thumbnails-scroller {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

/* Individual thumbnail */
.gallery-thumbnail-item {
    flex: 0 0 auto;
    scroll-snap-align: start;
}

.gallery-thumbnail-button {
    position: relative;
    display: block;
    width: 80px;
    height: 80px;
    padding: 2px;
    border: 2px solid transparent;
    border-radius: 8px;
    background: #ffffff;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    overflow: hidden;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
}

.gallery-thumbnail-button:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transform: translateY(-2px);
}

.gallery-thumbnail-button img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #f5f7fa;
    user-select: none;
    -webkit-user-drag: none;
    display: block;
    border-radius: 6px;
}

/* Active thumbnail state */
.gallery-thumbnail-button.active {
    border-color: #0066cc;
    box-shadow: 0 0 0 3px rgba(0, 102, 204, 0.1), 0 4px 12px rgba(0, 102, 204, 0.25);
    transform: scale(1.05);
}

.gallery-thumbnail-button.active::after {
    content: '';
    position: absolute;
    inset: 0;
    border: 2px solid #0066cc;
    border-radius: 6px;
    box-shadow: inset 0 0 0 1px rgba(0, 102, 204, 0.2);
}

/* Thumbnail loading state */
.gallery-thumbnail-button.loading {
    opacity: 0.6;
}

/* ========================================
   AUTO-SLIDER CONTROLS
   ======================================== */

.gallery-controls-wrapper {
    padding: 12px 16px;
    background: #f8f9fa;
    border-top: 1px solid rgba(0, 0, 0, 0.05);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
}

.gallery-slider-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: #333;
    cursor: pointer;
    user-select: none;
}

.gallery-slider-toggle input[type="checkbox"] {
    width: 40px;
    height: 24px;
    cursor: pointer;
    accent-color: #0066cc;
}

.gallery-slider-toggle-label {
    font-weight: 500;
    color: #555;
}

.gallery-slider-speed {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: #666;
}

.gallery-slider-speed input[type="range"] {
    width: 80px;
    height: 4px;
    cursor: pointer;
    accent-color: #0066cc;
}

.gallery-indicator-dots {
    display: flex;
    gap: 6px;
    justify-content: center;
}

.gallery-indicator-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #ccc;
    cursor: pointer;
    transition: all 0.3s ease-in-out;
}

.gallery-indicator-dot.active {
    background: #0066cc;
    width: 24px;
    border-radius: 4px;
}

/* ========================================
   SWIPE GESTURES (Mobile)
   ======================================== */

.gallery-swipe-hint {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 8px 12px;
    border-radius: 20px;
    font-size: 11px;
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
    pointer-events: none;
    z-index: 20;
}

@media (max-width: 768px) {
    .gallery-swipe-hint {
        opacity: 1;
    }
}

/* ========================================
   NAVIGATION ARROWS
   ======================================== */

.gallery-nav-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.9);
    color: #0066cc;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease-in-out;
    z-index: 15;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.gallery-nav-arrow:hover {
    background: rgba(0, 102, 204, 0.1);
    transform: translateY(-50%) scale(1.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.gallery-nav-arrow.prev {
    left: 12px;
}

.gallery-nav-arrow.next {
    right: 12px;
}

.gallery-nav-arrow:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

/* ========================================
   RESPONSIVE DESIGN
   ======================================== */

@media (max-width: 992px) {
    .gallery-main-image-wrapper {
        height: 340px;
    }

    .gallery-thumbnail-button {
        width: 70px;
        height: 70px;
    }

    .gallery-controls-wrapper {
        flex-direction: column;
    }
}

@media (max-width: 768px) {
    .phone-gallery-container {
        border-radius: 12px;
    }

    .gallery-main-image-wrapper {
        height: 300px;
    }

    .gallery-main-image img {
        max-width: 85%;
        max-height: 85%;
    }

    .gallery-thumbnails-wrapper {
        padding: 12px;
    }

    .gallery-thumbnails-scroller {
        gap: 8px;
    }

    .gallery-thumbnail-button {
        width: 65px;
        height: 65px;
        padding: 2px;
    }

    .gallery-thumbnail-button.active {
        transform: scale(1.08);
    }

    .gallery-nav-arrow {
        width: 36px;
        height: 36px;
        font-size: 18px;
    }

    .gallery-controls-wrapper {
        padding: 10px 12px;
        font-size: 12px;
    }

    .gallery-image-counter {
        font-size: 11px;
        padding: 6px 10px;
    }
}

@media (max-width: 480px) {
    .gallery-thumbnail-button {
        width: 60px;
        height: 60px;
    }

    .gallery-nav-arrow {
        width: 32px;
        height: 32px;
        font-size: 16px;
    }

    .gallery-main-image-wrapper {
        height: 260px;
    }

    .gallery-thumbnail-button img {
        padding: 2px;
    }

    .gallery-controls-wrapper {
        padding: 8px 12px;
        gap: 8px;
    }
}

/* ========================================
   ACCESSIBILITY
   ======================================== */

.gallery-thumbnail-button:focus,
.gallery-nav-arrow:focus {
    outline: 2px solid #0066cc;
    outline-offset: 2px;
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .gallery-main-image img,
    .gallery-thumbnail-button,
    .gallery-nav-arrow,
    .gallery-image-counter {
        animation: none !important;
        transition: none !important;
    }
}

/* ========================================
   PREMIUM EFFECTS
   ======================================== */

.gallery-container-premium {
    border: 1px solid rgba(0, 102, 204, 0.1);
}

.gallery-container-premium .gallery-main-image-wrapper {
    background: linear-gradient(135deg, #f8fafb 0%, #ffffff 50%, #f8fafb 100%);
}

.gallery-shimmer {
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    0% {
        background-position: -1000px 0;
    }
    100% {
        background-position: 1000px 0;
    }
}

/* ========================================
   LANDSCAPE MODE
   ======================================== */

@media (orientation: landscape) and (max-height: 600px) {
    .gallery-main-image-wrapper {
        aspect-ratio: auto;
        min-height: 300px;
        max-height: 80vh;
    }

    .gallery-thumbnail-button {
        width: 60px;
        height: 60px;
    }
}

/* ========================================
   FINAL SAFETY RULES - ENFORCE SIZE LIMITS
   ======================================== */

/* Override any Bootstrap or other CSS that might conflict */
.phone-gallery-container .gallery-main-image-wrapper {
    height: 380px !important;
}

.phone-gallery-container .gallery-main-image img {
    max-width: 90% !important;
    max-height: 90% !important;
    width: auto !important;
    height: auto !important;
}

/* Block Bootstrap's img-fluid if applied */
.phone-gallery-container img.img-fluid {
    max-width: 90% !important;
    height: auto !important;
}
