/* ================================================
   GALLERY MODAL - FIXED FULL COVERAGE BACKDROP
   File: assets/css/components/gallery-modal.css
   ================================================ */

/* 🎯 MAIN MODAL OVERLAY - COVERS ENTIRE PAGE (matches Cookie/Privacy Modal) */
.gallery-modal {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    z-index: 999999 !important;
    /* Always high z-index like privacy/cookie modals */

    /* MUST keep display: flex always for transitions to work */
    /* display: none breaks CSS transitions - use visibility instead */
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;

    /* Hidden by default with opacity and visibility ONLY */
    /* DO NOT use display: none - it breaks transitions */
    opacity: 0;
    visibility: hidden;
    pointer-events: none;

    overflow-y: auto !important;
    overflow-x: hidden !important;

    /* Clean white background - matches cookie/privacy modal */
    background: white !important;

    /* Smooth scrolling */
    -webkit-overflow-scrolling: touch;

    /* Hardware acceleration for smooth transitions */
    transform: translateZ(0);
    backface-visibility: hidden;
    will-change: opacity, visibility;

    /* Smooth transition - opacity and visibility for proper fade */
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

/* Circuit pattern overlay - matches cookie/privacy modal */
.gallery-modal::after {
    content: '' !important;
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    background-image: url('../../images/circuit-bg.jpg') !important;
    background-size: 400px 400px !important;
    background-position: center !important;
    background-repeat: repeat !important;
    opacity: 0;
    pointer-events: none;
    z-index: 1 !important;
    transition: opacity 0.3s ease;
}

/* ✅ ACTIVE STATE */
.gallery-modal.active {
    opacity: 1;
    visibility: visible;
    pointer-events: all;
}

.gallery-modal.active::after {
    opacity: 0.18;
}

@keyframes modalFadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

/* 📦 MODAL CONTENT CONTAINER - White card matching Cookie/Privacy Modal */
.gallery-modal .modal-content {
    position: relative !important;
    z-index: 10 !important;
    background: white !important;
    border-radius: 16px !important;
    max-width: 1200px !important;
    width: 96% !important;
    height: 90vh !important;
    max-height: 90vh !important;
    margin: 40px auto !important;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.3) !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
}

/* 🎯 MODAL HEADER - Clean white style matching Cookie/Privacy Modal */
.gallery-modal .modal-header {
    position: relative !important;
    z-index: 10 !important;
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    padding: 30px 40px 20px 40px !important;
    background: white !important;
    border-bottom: 1px solid #e5e7eb !important;
    flex-shrink: 0 !important;
    gap: 20px !important;
}

.gallery-modal .modal-title {
    font-size: 28px !important;
    font-weight: 700 !important;
    color: #111827 !important;
    margin: 0 !important;
    text-align: center !important;
    display: flex !important;
    align-items: center !important;
    gap: 12px !important;
    background: none !important;
    background-color: transparent !important;
    background-image: none !important;
    border: none !important;
    border-radius: 0 !important;
    padding: 0 !important;
    box-shadow: none !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
}

.gallery-modal .modal-title i,
.gallery-modal .modal-title svg,
.gallery-modal .modal-icon {
    width: 28px !important;
    height: 28px !important;
    color: #3b82f6 !important;
    stroke: #3b82f6 !important;
    display: inline-block !important;
}

/* Blue Close Button - matching cookie/privacy modal */
.gallery-modal .modal-close {
    position: absolute !important;
    top: 20px !important;
    right: 20px !important;
    width: 44px !important;
    height: 44px !important;
    border-radius: 50% !important;
    background: linear-gradient(135deg, #3b82f6, #1d4ed8) !important;
    border: none !important;
    color: white !important;
    font-size: 24px !important;
    cursor: pointer !important;
    z-index: 20 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    transition: all 0.3s ease !important;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4) !important;
}

.gallery-modal .modal-close:hover {
    background: linear-gradient(135deg, #2563eb, #1e40af) !important;
    transform: rotate(90deg) scale(1.05) !important;
    box-shadow: 0 6px 16px rgba(59, 130, 246, 0.5) !important;
}

/* 🔍 DEVICE FILTER - Base styles */
.gallery-modal-filter {
    display: flex !important;
    align-items: center !important;
}

/* 🖥️ DEVICE FILTER - Desktop styles (spacious design) */
@media (min-width: 769px) {
    .gallery-modal-filter {
        gap: 12px !important;
        flex-shrink: 0 !important;
        margin: 0 !important;
        padding: 10px 20px !important;
        background: #f9fafb !important;
        border: 1px solid #e5e7eb !important;
        border-radius: 12px !important;
    }

    .gallery-modal-filter label {
        font-size: 14px !important;
        font-weight: 600 !important;
        color: #374151 !important;
        white-space: nowrap !important;
        margin: 0 !important;
    }

    .gallery-modal-filter select {
        padding: 8px 36px 8px 14px !important;
        border: 1.5px solid #d1d5db !important;
        border-radius: 8px !important;
        font-size: 14px !important;
        font-weight: 500 !important;
        color: #111827 !important;
        background: white !important;
        cursor: pointer !important;
        transition: all 0.2s ease !important;
        appearance: none !important;
        background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%233b82f6' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m6 8 4 4 4-4'/%3e%3c/svg%3e") !important;
        background-position: right 10px center !important;
        background-repeat: no-repeat !important;
        background-size: 16px !important;
        min-width: 180px !important;
    }

    .gallery-modal-filter select:hover {
        border-color: #3b82f6 !important;
        box-shadow: 0 2px 8px rgba(59, 130, 246, 0.15) !important;
    }

    .gallery-modal-filter select:focus {
        outline: none !important;
        border-color: #3b82f6 !important;
        box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1) !important;
    }
}

/* 📱 MODAL BODY - Scrollable content area */
.gallery-modal .modal-body {
    position: relative !important;
    z-index: 10 !important;
    padding: 30px 40px !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    flex: 1 !important;
    background: #ffffff !important;
    -webkit-overflow-scrolling: touch !important;
}

/* 🎨 GALLERY GRID - 3 columns on desktop */
.gallery-modal-grid {
    display: grid !important;
    grid-template-columns: repeat(3, 1fr) !important;
    grid-auto-rows: 1fr !important;
    gap: 24px !important;
    margin: 0 !important;
}

/* Fallback for smaller screens */
@media (max-width: 1024px) and (min-width: 769px) {
    .gallery-modal-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}

.modal-gallery-item {
    background: white !important;
    border-radius: 16px !important;
    overflow: hidden !important;
    box-shadow: 0 4px 20px rgba(59, 130, 246, 0.1) !important;
    border: 1px solid rgba(59, 130, 246, 0.15) !important;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1) !important;
    cursor: pointer !important;
    position: relative !important;
    /* For overlay positioning */
    height: 280px !important;
    /* Fixed height for consistency */
    max-height: 280px !important;
}

/* Hidden by filter - backup CSS class */
.modal-gallery-item.filtered-hidden {
    display: none !important;
}

.modal-gallery-item:hover {
    transform: translateY(-8px);
    box-shadow: 0 12px 40px rgba(59, 130, 246, 0.2);
}

.modal-item-image {
    position: absolute !important;
    /* Fill entire card */
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    overflow: hidden;
    background: linear-gradient(135deg, #e2e8f0, #cbd5e1);
}

.image-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 72px;
    transition: transform 0.4s ease;
}

/* Image element styling - ensure images fill the container */
.modal-item-image img {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    object-position: center !important;
    display: block !important;
}

/* Video element styling with loading background */
.modal-item-image video,
.image-placeholder video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    background: linear-gradient(135deg, #1e3a8a 0%, #3b82f6 50%, #1e3a8a 100%);
    background-size: 200% 200%;
    animation: gradientShift 3s ease infinite;
}

@keyframes gradientShift {
    0% {
        background-position: 0% 50%;
    }

    50% {
        background-position: 100% 50%;
    }

    100% {
        background-position: 0% 50%;
    }
}

.modal-gallery-item:hover .image-placeholder {
    transform: scale(1.15);
}

.quick-view-badge {
    position: absolute;
    top: 15px;
    right: 15px;
    background: rgba(59, 130, 246, 0.9);
    backdrop-filter: blur(10px);
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    opacity: 0;
    transform: translateY(-10px);
    transition: all 0.3s ease;
    z-index: 10;
}

.modal-gallery-item:hover .quick-view-badge {
    opacity: 1;
    transform: translateY(0);
}

/* Gallery thumbnail images */
.gallery-thumbnail {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    object-position: center !important;
    display: block !important;
    border-radius: 8px;
}

/* Video placeholder for modal gallery (smaller) */
.video-placeholder-small {
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #1e3a8a, #3b82f6);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
}

.play-button-small {
    width: 80px;
    height: 80px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

.play-triangle-small {
    width: 0;
    height: 0;
    border-left: 28px solid white;
    border-top: 18px solid transparent;
    border-bottom: 18px solid transparent;
    margin-left: 6px;
}

/* OVERLAY STYLE INFO - Like slider cards */
.modal-item-info {
    position: absolute !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    padding: 50px 20px 20px !important;
    /* Gradient padding */
    background: linear-gradient(to top, rgba(0, 0, 0, 0.9) 0%, rgba(0, 0, 0, 0.4) 60%, transparent 100%) !important;
    color: white !important;
    z-index: 5 !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 8px !important;
}

.modal-item-info h4 {
    font-size: 16px !important;
    font-weight: 700 !important;
    color: white !important;
    margin: 0 !important;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    /* Standard property for compatibility */
    -webkit-box-orient: vertical;
    line-height: 1.3;
}

/* HIDE description in modal cards - save for detail modal */
.modal-item-description {
    display: none !important;
}

.repair-type {
    font-size: 13px !important;
    color: rgba(255, 255, 255, 0.9) !important;
    margin: 0 !important;
    display: flex;
    align-items: center;
    gap: 6px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.repair-type i {
    flex-shrink: 0;
    color: rgba(255, 255, 255, 0.9) !important;
}

.item-meta {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 4px !important;
}

.price-badge {
    display: inline-block;
    padding: 8px 16px;
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 700;
    box-shadow: 0 2px 10px rgba(16, 185, 129, 0.3);
    text-align: center;
}

.duration-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px;
    background: rgba(59, 130, 246, 0.1);
    color: #3b82f6;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 600;
    border: 2px solid rgba(59, 130, 246, 0.2);
}

/* 📝 MODAL FOOTER */
.modal-footer {
    position: relative;
    z-index: 10;
    text-align: center;
    padding: 30px;
    margin-top: 40px;

    /* Blue-tinted glass effect - matching title */
    background: rgba(59, 130, 246, 0.1);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 20px;
    box-shadow:
        0 4px 30px rgba(59, 130, 246, 0.15),
        inset 0 1px 0 rgba(59, 130, 246, 0.2);
    border: 1px solid rgba(59, 130, 246, 0.25);
}

.modal-note {
    font-size: 15px;
    color: #6b7280;
    line-height: 1.6;
}

.modal-note strong {
    color: #3b82f6;
}

.modal-back-to-site {
    margin-top: 24px;
    padding: 14px 32px;
    background: linear-gradient(135deg, #3b82f6, #1d4ed8);
    color: white;
    border: 2px solid transparent;
    border-radius: 30px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(59, 130, 246, 0.3);
    display: inline-flex;
    align-items: center;
    gap: 10px;
    position: relative;
    overflow: hidden;
}

.modal-back-to-site::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #2563eb, #1e40af);
    transition: left 0.4s ease;
    z-index: -1;
    border-radius: 30px;
}

.modal-back-to-site:hover::before {
    left: 0;
}

.modal-back-to-site:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(59, 130, 246, 0.4);
}

.modal-back-to-site:active {
    transform: translateY(0);
    box-shadow: 0 4px 15px rgba(59, 130, 246, 0.4);
}

.modal-back-to-site svg {
    transition: transform 0.3s ease;
}

.modal-back-to-site:hover svg {
    transform: translateX(-4px);
}

/* Compact Footer for Gallery Modal */
.modal-footer-compact {
    position: relative;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 16px 24px;
    margin-top: 30px;
    background: rgba(249, 250, 251, 0.8);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 12px;
    border: 1px solid rgba(59, 130, 246, 0.15);
}

.modal-note-compact {
    font-size: 13px;
    color: #6b7280;
    line-height: 1.5;
    margin: 0;
    flex: 1;
}

.modal-back-to-site-compact {
    padding: 8px 16px;
    background: rgba(59, 130, 246, 0.1);
    color: #3b82f6;
    border: 1px solid rgba(59, 130, 246, 0.3);
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.modal-back-to-site-compact:hover {
    background: #3b82f6;
    color: white;
    border-color: #3b82f6;
    transform: translateX(-2px);
}

.modal-back-to-site-compact svg {
    transition: transform 0.3s ease;
}

.modal-back-to-site-compact:hover svg {
    transform: translateX(-3px);
}

/* 📱 MOBILE RESPONSIVE - Matching Cookie/Privacy Modal */
@media (max-width: 768px) {

    /* INSTANT transitions on mobile - no fade animation */
    .gallery-modal {
        transition: none !important;
    }

    .gallery-modal::after {
        transition: none !important;
    }

    /* Full screen on mobile - truly fill viewport */
    .gallery-modal .modal-content {
        width: 100% !important;
        max-width: 100% !important;
        height: 100vh !important;
        min-height: 100vh !important;
        max-height: 100vh !important;
        border-radius: 0 !important;
        margin: 0 !important;
    }

    /* Compact header on mobile - with filter inline */
    .gallery-modal .modal-header {
        position: sticky !important;
        top: 0 !important;
        padding: 8px 70px 8px 20px !important;
        min-height: auto !important;
        display: flex !important;
        flex-direction: column !important;
        gap: 6px !important;
        background: white !important;
        z-index: 100 !important;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05) !important;
    }

    .gallery-modal .modal-title {
        font-size: 16px !important;
        line-height: 1.2 !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    .gallery-modal .modal-title i,
    .gallery-modal .modal-title svg,
    .gallery-modal .modal-icon {
        width: 20px !important;
        height: 20px !important;
    }

    .gallery-modal .modal-close {
        position: fixed !important;
        top: 15px !important;
        right: 15px !important;
        width: 40px !important;
        height: 40px !important;
        font-size: 20px !important;
        z-index: 101 !important;
    }

    /* Mobile filter - inline with header, compact */
    .gallery-modal-filter {
        flex-direction: row !important;
        align-items: center !important;
        gap: 8px !important;
        padding: 0 !important;
        margin: 0 !important;
        background: transparent !important;
        border: none !important;
    }

    /* Hide clear filters button on mobile to save space */
    .gallery-clear-filters-btn {
        display: none !important;
    }

    .gallery-modal-filter label {
        font-size: 12px !important;
        font-weight: 600 !important;
        color: #3b82f6 !important;
        white-space: nowrap !important;
        flex-shrink: 0 !important;
    }

    .gallery-modal-filter select {
        flex: 1 !important;
        font-size: 12px !important;
        padding: 6px 28px 6px 10px !important;
        border: 1px solid #3b82f6 !important;
        border-radius: 6px !important;
        background: rgba(59, 130, 246, 0.05) !important;
        color: #1f2937 !important;
    }

    .gallery-modal-filter select:focus {
        outline: none !important;
        border-color: #2563eb !important;
        box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15) !important;
    }

    /* Compact body on mobile */
    .gallery-modal .modal-body {
        padding: 4px 16px 80px 16px !important;
    }

    /* IMPROVED: Single column for better mobile UX */
    .gallery-modal-grid {
        grid-template-columns: 1fr !important;
        /* Single column like main gallery */
        gap: 20px !important;
        /* More breathing room */
    }

    /* Vertical card layout on mobile - overlay style */
    .modal-gallery-item {
        position: relative !important;
        height: 240px !important;
        /* Slightly shorter on mobile */
    }

    /* Allow JavaScript filtering to hide items */
    .modal-gallery-item[style*="display: none"] {
        display: none !important;
    }

    .modal-item-image {
        position: absolute !important;
        top: 0 !important;
        left: 0 !important;
        width: 100% !important;
        height: 100% !important;
    }

    .image-placeholder {
        font-size: 56px !important;
        /* Larger icon */
    }

    /* Overlay info on mobile */
    .modal-item-info {
        position: absolute !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        padding: 40px 16px 16px !important;
        background: linear-gradient(to top, rgba(0, 0, 0, 0.95) 0%, rgba(0, 0, 0, 0.5) 60%, transparent 100%) !important;
    }

    .modal-item-info h4 {
        font-size: 14px !important;
        margin: 0 0 6px 0 !important;
        line-height: 1.3 !important;
        font-weight: 700 !important;
        color: white !important;
    }

    .repair-type {
        font-size: 12px !important;
        margin: 0 0 6px 0 !important;
        gap: 4px !important;
        color: rgba(255, 255, 255, 0.9) !important;
    }

    .repair-type i,
    .repair-type svg {
        width: 13px !important;
        height: 13px !important;
        color: rgba(255, 255, 255, 0.9) !important;
    }

    .item-meta {
        gap: 6px !important;
        flex-wrap: wrap !important;
        justify-content: flex-start !important;
    }

    .price-badge,
    .duration-badge {
        padding: 4px 8px !important;
        font-size: 10px !important;
    }

    .duration-badge i,
    .duration-badge svg {
        width: 12px !important;
        height: 12px !important;
    }

    /* Hide quick view badge on mobile (takes up space) */
    .quick-view-badge {
        display: none !important;
    }

    .modal-footer {
        padding: 20px 20px 30px 20px;
        /* Compact footer - button removed */
        border-radius: 15px;
    }

    .modal-footer-compact {
        display: none !important;
    }

    .modal-note-compact {
        display: none !important;
    }

    .modal-back-to-site-compact {
        width: 100%;
        justify-content: center;
        padding: 10px 16px;
    }

    .modal-note {
        font-size: 14px;
    }
}

@media (max-width: 480px) {
    .modal-header {
        padding: 15px 60px 15px 15px;
    }

    .modal-title {
        font-size: 18px;
    }

    .modal-close {
        right: 15px;
        width: 40px;
        height: 40px;
        font-size: 18px;
    }

    .modal-item-image {
        height: 180px;
    }

    .image-placeholder {
        font-size: 50px;
    }

    .modal-item-info {
        padding: 18px;
    }

    .item-meta {
        flex-direction: row !important;
        flex-wrap: wrap !important;
        gap: 6px !important;
    }

    .price-badge,
    .duration-badge {
        flex: 1;
        min-width: fit-content;
        text-align: center;
    }
}

/* 🎭 PREVENT BODY SCROLL WHEN MODAL OPEN */
body.modal-open {
    overflow: hidden;
    height: 100vh;
}

/* ================================================
   FULLSCREEN VIDEO - MAINTAIN ASPECT RATIO
   Clean solution using native fullscreen API
   ================================================ */
video:fullscreen,
video:-webkit-full-screen,
video:-moz-full-screen,
video:-ms-fullscreen {
    width: 100% !important;
    height: 100% !important;
    object-fit: contain !important;
    background: #000 !important;
}

img:fullscreen,
img:-webkit-full-screen,
img:-moz-full-screen,
img:-ms-fullscreen {
    width: 100% !important;
    height: 100% !important;
    object-fit: contain !important;
    background: #000 !important;
}