/**
 * Elementor 3D Gallery - Styles
 * 
 * @since 1.0.0
 */

/* ============================================
   CSS VARIABLES
   ============================================ */

:root {
    --gallery-gap: 10px;
    --gallery-item-height: 250px;
    --gallery-overlay-padding: 20px;
    --gallery-title-size: 16px;
    --gallery-desc-size: 13px;
    --gallery-zoom-size: 50px;
    --gallery-border-radius: 8px;
    --gallery-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    --transition-speed: 0.3s;
}

/* ============================================
   CONTAINER & LAYOUTS
   ============================================ */

.elementor-gallery-3d-container {
    width: 100%;
    position: relative;
}

.gallery-3d-side-by-side {
    display: flex;
    gap: 20px;
    align-items: stretch;
}

.gallery-3d-side-by-side .gallery-3d-side-item {
    flex: 1;
    min-width: 0;
}

/* ============================================
   RESPONSIVE - SIDE BY SIDE
   ============================================ */

@media (max-width: 1024px) {
    .gallery-3d-side-by-side {
        gap: 15px;
    }
}

@media (max-width: 768px) {
    .gallery-3d-side-by-side {
        flex-direction: column;
        gap: 20px;
    }
    
    .gallery-3d-side-by-side .gallery-3d-side-item {
        width: 100% !important;
    }
}

/* ============================================
   TABS LAYOUT
   ============================================ */

.gallery-3d-tabs {
    width: 100%;
}

.gallery-3d-tabs-nav {
    display: flex;
    gap: 5px;
    margin-bottom: 20px;
    border-bottom: 2px solid #e0e0e0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.gallery-3d-tabs-nav::-webkit-scrollbar {
    display: none;
}

.gallery-3d-tab-btn {
    padding: 14px 28px;
    background: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    color: #666;
    transition: all var(--transition-speed) ease;
    margin-bottom: -2px;
    white-space: nowrap;
    flex-shrink: 0;
}

.gallery-3d-tab-btn:hover {
    color: #333;
}

.gallery-3d-tab-btn.active {
    color: #61dafb;
    border-bottom-color: #61dafb;
}

.gallery-3d-tab-panel {
    display: none;
}

.gallery-3d-tab-panel.active {
    display: block;
}

/* Mobile tabs adjustments */
@media (max-width: 480px) {
    .gallery-3d-tabs-nav {
        gap: 0;
        justify-content: space-between;
    }
    
    .gallery-3d-tab-btn {
        padding: 12px 16px;
        font-size: 13px;
        flex: 1;
        text-align: center;
    }
}

/* ============================================
   3D MODEL VIEWER - RESPONSIVE
   ============================================ */

.elementor-3d-model-wrapper {
    position: relative;
    width: 100%;
    min-height: 400px;
    max-height: 70vh;
    border-radius: 12px;
    overflow: hidden;
    background-color: #f0f0f0;
}

.elementor-3d-model-wrapper model-viewer {
    width: 100%;
    height: 100%;
    min-height: inherit;
    background-color: transparent;
    --progress-bar-color: #61dafb;
    --progress-bar-height: 4px;
}

/* AR Button */
.ar-button {
    position: absolute;
    bottom: 16px;
    right: 16px;
    padding: 12px 24px;
    background-color: #000;
    color: #fff;
    border: none;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-speed) ease;
    z-index: 10;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.ar-button:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.ar-button:active {
    transform: scale(0.98);
}

/* Mobile AR button */
@media (max-width: 768px) {
    .ar-button {
        padding: 10px 18px;
        font-size: 12px;
        bottom: 12px;
        right: 12px;
    }
}

@media (max-width: 480px) {
    .ar-button {
        padding: 8px 14px;
        font-size: 11px;
        bottom: 10px;
        right: 10px;
    }
}

/* Progress Bar */
.progress-bar {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background-color: rgba(255, 255, 255, 0.3);
    z-index: 5;
}

.progress-bar.hide {
    display: none;
}

.update-bar {
    height: 100%;
    background: linear-gradient(90deg, #61dafb, #4fc3f7);
    width: 0%;
    transition: width 0.3s ease;
}

/* Loading State */
.elementor-3d-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    color: #666;
    font-size: 14px;
    text-align: center;
    padding: 20px;
}

.elementor-3d-loading-spinner {
    width: 48px;
    height: 48px;
    border: 3px solid #e0e0e0;
    border-top-color: #61dafb;
    border-radius: 50%;
    animation: elementor-3d-spin 1s linear infinite;
}

@keyframes elementor-3d-spin {
    to {
        transform: rotate(360deg);
    }
}

/* Error State */
.elementor-3d-error {
    padding: 40px;
    text-align: center;
    background-color: #fee;
    border: 1px solid #fcc;
    border-radius: 8px;
    color: #c00;
    margin: 20px 0;
}

/* Responsive 3D wrapper */
@media (max-width: 768px) {
    .elementor-3d-model-wrapper {
        min-height: 350px;
        max-height: 50vh;
        border-radius: 8px;
    }
}

@media (max-width: 480px) {
    .elementor-3d-model-wrapper {
        min-height: 280px;
        max-height: 45vh;
        border-radius: 6px;
    }
    
    .elementor-3d-loading {
        font-size: 12px;
    }
    
    .elementor-3d-loading-spinner {
        width: 36px;
        height: 36px;
    }
}

/* ============================================
   GALLERY - GRID LAYOUT (RESPONSIVE)
   ============================================ */

.elementor-gallery {
    width: 100%;
}

.gallery-layout-grid {
    display: grid;
    gap: var(--gallery-gap);
}

.gallery-layout-grid .gallery-item {
    position: relative;
    overflow: hidden;
}

/* Desktop columns */
.gallery-layout-grid[data-columns="1"] { grid-template-columns: repeat(1, 1fr); }
.gallery-layout-grid[data-columns="2"] { grid-template-columns: repeat(2, 1fr); }
.gallery-layout-grid[data-columns="3"] { grid-template-columns: repeat(3, 1fr); }
.gallery-layout-grid[data-columns="4"] { grid-template-columns: repeat(4, 1fr); }
.gallery-layout-grid[data-columns="5"] { grid-template-columns: repeat(5, 1fr); }
.gallery-layout-grid[data-columns="6"] { grid-template-columns: repeat(6, 1fr); }

/* Tablet - Large (1024px) */
@media (max-width: 1024px) {
    .gallery-layout-grid { 
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Tablet - Medium (768px) */
@media (max-width: 768px) {
    .gallery-layout-grid { 
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Mobile - Small (480px) */
@media (max-width: 480px) {
    .gallery-layout-grid { 
        grid-template-columns: 1fr !important;
        gap: calc(var(--gallery-gap) * 0.8);
    }
}

/* Force specific columns at breakpoints */
.gallery-layout-grid.cols-tablet-1 { grid-template-columns: repeat(1, 1fr) !important; }
.gallery-layout-grid.cols-tablet-2 { grid-template-columns: repeat(2, 1fr) !important; }
.gallery-layout-grid.cols-tablet-3 { grid-template-columns: repeat(3, 1fr) !important; }

.gallery-layout-grid.cols-mobile-1 { grid-template-columns: repeat(1, 1fr) !important; }
.gallery-layout-grid.cols-mobile-2 { grid-template-columns: repeat(2, 1fr) !important; }

/* ============================================
   GALLERY - MASONRY LAYOUT (RESPONSIVE)
   ============================================ */

.gallery-layout-masonry {
    display: block;
    column-count: 3;
    column-gap: var(--gallery-gap);
}

.gallery-layout-masonry .gallery-item {
    break-inside: avoid;
    margin-bottom: var(--gallery-gap);
}

@media (max-width: 1024px) {
    .gallery-layout-masonry {
        column-count: 2;
    }
}

@media (max-width: 600px) {
    .gallery-layout-masonry {
        column-count: 1;
    }
}

@media (max-width: 480px) {
    .gallery-layout-masonry {
        column-count: 1;
        column-gap: calc(var(--gallery-gap) * 0.8);
    }
    
    .gallery-layout-masonry .gallery-item {
        margin-bottom: calc(var(--gallery-gap) * 0.8);
    }
}

/* ============================================
   GALLERY - SLIDER LAYOUT (RESPONSIVE)
   ============================================ */

.gallery-layout-slider {
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    gap: var(--gallery-gap);
    padding-bottom: var(--gallery-gap);
    scrollbar-width: thin;
    scrollbar-color: #888 #f1f1f1;
}

.gallery-layout-slider::-webkit-scrollbar {
    height: 6px;
}

.gallery-layout-slider::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.gallery-layout-slider::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 3px;
}

.gallery-layout-slider::-webkit-scrollbar-thumb:hover {
    background: #555;
}

.gallery-layout-slider .gallery-item {
    flex: 0 0 300px;
    scroll-snap-align: start;
}

/* Tablet slider */
@media (max-width: 768px) {
    .gallery-layout-slider .gallery-item {
        flex: 0 0 250px;
    }
}

/* Mobile slider */
@media (max-width: 480px) {
    .gallery-layout-slider {
        gap: calc(var(--gallery-gap) * 0.8);
        padding-bottom: calc(var(--gallery-gap) * 0.8);
    }
    
    .gallery-layout-slider .gallery-item {
        flex: 0 0 200px;
    }
}

/* Hide scrollbar on very small devices */
@media (max-width: 360px) {
    .gallery-layout-slider .gallery-item {
        flex: 0 0 160px;
    }
}

/* ============================================
   GALLERY - JUSTIFIED LAYOUT (RESPONSIVE)
   ============================================ */

.gallery-layout-justified {
    display: flex;
    flex-wrap: wrap;
    gap: var(--gallery-gap);
}

.gallery-layout-justified .gallery-item {
    flex: 1 1 auto;
    min-width: 200px;
    max-width: 400px;
    height: 250px;
}

.gallery-layout-justified .gallery-item .gallery-image {
    height: 100%;
    object-fit: cover;
}

@media (max-width: 768px) {
    .gallery-layout-justified .gallery-item {
        min-width: 150px;
        height: 200px;
    }
}

@media (max-width: 480px) {
    .gallery-layout-justified {
        gap: calc(var(--gallery-gap) * 0.8);
    }
    
    .gallery-layout-justified .gallery-item {
        min-width: 100%;
        max-width: 100%;
        height: 180px;
    }
}

/* ============================================
   GALLERY ITEM (RESPONSIVE)
   ============================================ */

.gallery-item {
    position: relative;
}

.gallery-item-inner {
    position: relative;
    overflow: hidden;
    border-radius: var(--gallery-border-radius);
    box-shadow: var(--gallery-shadow);
}

.gallery-lightbox-link {
    display: block;
    text-decoration: none;
}

.gallery-image {
    width: 100%;
    height: var(--gallery-item-height);
    object-fit: cover;
    display: block;
    transition: transform 0.5s ease, opacity var(--transition-speed) ease;
    background-color: #f0f0f0;
}

.gallery-layout-masonry .gallery-image {
    height: auto;
}

.gallery-item:hover .gallery-image {
    transform: scale(1.1);
}

/* Responsive image heights */
@media (max-width: 768px) {
    .gallery-image {
        height: 200px;
    }
}

@media (max-width: 480px) {
    .gallery-image {
        height: 180px;
    }
}

@media (max-width: 360px) {
    .gallery-image {
        height: 150px;
    }
}

/* ============================================
   GALLERY ITEM OVERLAY (RESPONSIVE)
   ============================================ */

.gallery-item-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        to top,
        rgba(0, 0, 0, 0.85) 0%,
        rgba(0, 0, 0, 0.4) 40%,
        rgba(0, 0, 0, 0) 100%
    );
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    padding: var(--gallery-overlay-padding);
    opacity: 0;
    transition: opacity var(--transition-speed) ease;
}

.gallery-item:hover .gallery-item-overlay {
    opacity: 1;
}

/* Always show overlay on touch devices */
@media (hover: none) {
    .gallery-item-overlay {
        opacity: 1;
        background: linear-gradient(
            to top,
            rgba(0, 0, 0, 0.7) 0%,
            rgba(0, 0, 0, 0.2) 50%,
            rgba(0, 0, 0, 0) 100%
        );
    }
    
    .gallery-item-zoom {
        display: none;
    }
}

.gallery-item-title {
    margin: 0 0 4px;
    font-size: var(--gallery-title-size);
    font-weight: 600;
    color: #fff;
    line-height: 1.3;
}

.gallery-item-description {
    margin: 0 0 8px;
    font-size: var(--gallery-desc-size);
    color: rgba(255, 255, 255, 0.85);
    line-height: 1.4;
}

.gallery-item-zoom {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0);
    width: var(--gallery-zoom-size);
    height: var(--gallery-zoom-size);
    background-color: rgba(255, 255, 255, 0.95);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform var(--transition-speed) ease;
    color: #333;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.gallery-item:hover .gallery-item-zoom {
    transform: translate(-50%, -50%) scale(1);
}

.gallery-item-zoom svg {
    width: 24px;
    height: 24px;
}

/* Responsive overlay */
@media (max-width: 768px) {
    .gallery-item-overlay {
        padding: 15px;
    }
    
    .gallery-item-title {
        font-size: 14px;
    }
    
    .gallery-item-description {
        font-size: 12px;
        display: none;
    }
    
    .gallery-item-zoom {
        width: 44px;
        height: 44px;
    }
    
    .gallery-item-zoom svg {
        width: 20px;
        height: 20px;
    }
}

@media (max-width: 480px) {
    .gallery-item-overlay {
        padding: 12px;
    }
    
    .gallery-item-title {
        font-size: 13px;
    }
    
    .gallery-item-description {
        display: none;
    }
    
    .gallery-item-zoom {
        width: 36px;
        height: 36px;
    }
    
    .gallery-item-zoom svg {
        width: 18px;
        height: 18px;
    }
}

/* ============================================
   LIGHTBOX (Magnific Popup) - RESPONSIVE
   ============================================ */

.mfp-bg {
    background: rgba(0, 0, 0, 0.95) !important;
}

.mfp-container {
    padding: 0 15px;
}

.mfp-content {
    max-width: 90vw;
    max-height: 90vh;
}

.mfp-content .gallery-image {
    max-width: 100%;
    max-height: 85vh;
    object-fit: contain;
    border-radius: 4px;
}

.mfp-title {
    padding: 15px 20px;
    color: #fff;
    font-size: 14px;
    text-align: center;
}

.mfp-figure .mfp-img {
    padding: 15px;
}

.mfp-close {
    color: #fff !important;
    font-size: 40px;
    opacity: 0.7;
    transition: opacity var(--transition-speed) ease;
    right: 10px !important;
    top: 10px !important;
}

.mfp-close:hover {
    opacity: 1;
}

.mfp-counter {
    color: rgba(255, 255, 255, 0.7);
    font-size: 12px;
}

/* Mobile lightbox */
@media (max-width: 768px) {
    .mfp-container {
        padding: 0 10px;
    }
    
    .mfp-content {
        max-width: 95vw;
        max-height: 95vh;
    }
    
    .mfp-figure .mfp-img {
        padding: 10px;
    }
    
    .mfp-title {
        padding: 10px 15px;
        font-size: 12px;
    }
    
    .mfp-close {
        font-size: 30px;
        right: 5px !important;
        top: 5px !important;
    }
}

@media (max-width: 480px) {
    .mfp-close {
        font-size: 28px;
        width: 40px;
        height: 40px;
        line-height: 40px;
    }
}

/* ============================================
   ANIMATIONS
   ============================================ */

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

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.gallery-item {
    animation: fadeInUp 0.5s ease forwards;
}

.gallery-item:nth-child(1) { animation-delay: 0s; }
.gallery-item:nth-child(2) { animation-delay: 0.05s; }
.gallery-item:nth-child(3) { animation-delay: 0.1s; }
.gallery-item:nth-child(4) { animation-delay: 0.15s; }
.gallery-item:nth-child(5) { animation-delay: 0.2s; }
.gallery-item:nth-child(6) { animation-delay: 0.25s; }
.gallery-item:nth-child(7) { animation-delay: 0.3s; }
.gallery-item:nth-child(8) { animation-delay: 0.35s; }
.gallery-item:nth-child(n+9) { animation-delay: 0.4s; }

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    .gallery-item {
        animation: none;
    }
    
    .gallery-image {
        transition: none;
    }
    
    .gallery-item-overlay {
        transition: none;
    }
}

/* ============================================
   UTILITIES
   ============================================ */

.hide {
    display: none !important;
}

.visible {
    display: block !important;
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
    .gallery-item-inner {
        -webkit-tap-highlight-color: transparent;
    }
    
    .gallery-item:active .gallery-image {
        transform: scale(1.05);
    }
}

/* High DPI displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .gallery-image {
        image-rendering: -webkit-optimize-contrast;
    }
}

/* Print styles */
@media print {
    .gallery-item-overlay,
    .ar-button,
    .progress-bar,
    .gallery-item-zoom {
        display: none !important;
    }
    
    .gallery-image {
        height: auto !important;
    }
}
