/* E-Gallery Projects Styles - High Specificity to Override Theme Styles */

.egp-projects-container {
    margin: 20px 0 !important;
    direction: rtl !important;
    text-align: right !important;
    box-sizing: border-box !important;
}

.egp-projects-container * {
    direction: rtl !important;
    box-sizing: border-box !important;
}

/* No Projects Section */
.egp-no-projects {
    text-align: center;
    padding: 40px 20px;
    margin: 30px 0;
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    color: #6c757d;
}

.egp-no-projects p {
    margin: 0;
    font-size: 18px;
    font-weight: 500;
    color: #6c757d;
}

/* RTL Font and Text Support - Override Theme Fonts */
.egp-projects-container,
.egp-projects-container *,
.egp-projects-container h1,
.egp-projects-container h2,
.egp-projects-container h3,
.egp-projects-container h4,
.egp-projects-container h5,
.egp-projects-container h6,
.egp-projects-container p,
.egp-projects-container span,
.egp-projects-container div,
.egp-projects-container a,
.egp-projects-container button {
    font-family: 'Cairo', 'Tajawal', 'Amiri', 'IBM Plex Sans Arabic', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif !important;
    unicode-bidi: embed !important;
    text-decoration: none !important;
}

/* Ensure proper Arabic/RTL text rendering - Override Theme Styles */
.egp-projects-container .egp-project-title,
.egp-projects-container .egp-gallery-title,
.egp-projects-container .egp-category-tab,
.egp-projects-container .egp-overlay-category,
.egp-projects-container .egp-project-excerpt {
    text-rendering: optimizeLegibility !important;
    -webkit-font-feature-settings: "liga", "kern" !important;
    font-feature-settings: "liga", "kern" !important;
    line-height: 1.6 !important;
}

/* Category Tabs - High Specificity */
.egp-projects-container .egp-category-tabs {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 15px !important;
    margin-bottom: 30px !important;
    border-bottom: 2px solid #e1e1e1 !important;
    padding-bottom: 20px !important;
    justify-content: center !important;
    align-items: center !important;
    direction: rtl !important;
    text-align: center !important;
    list-style: none !important;
}

.egp-projects-container .egp-category-tab {
    background: #f7f7f7;
    /* border: 2px solid #dee2e6 !important; */
    color: #495057 !important;
    cursor: pointer !important;
    padding: 12px 24px !important;
    border-radius: 0px !important;
    transition: all 0.3s ease !important;
    font-weight: 600 !important;
    text-decoration: none !important;
    display: inline-block !important;
    /* box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1) !important; */
    text-align: center !important;
    min-width: 120px !important;
    direction: rtl !important;
    font-size: 14px !important;
    line-height: 1.4 !important;
    margin: 0 !important;
}

.egp-projects-container .egp-category-tab:hover,
.egp-projects-container .egp-category-tab.active {
    background: #F7921E;
    color: white !important;
    /* border-color: #007cba !important; */
    text-decoration: none !important;
    transform: translateY(-2px) !important;
    /* box-shadow: 0 6px 20px rgba(0, 124, 186, 0.3) !important; */
}

/* Projects Grid - High Specificity */
.egp-projects-container .egp-projects-grid {
    display: grid !important;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)) !important;
    gap: 24px !important;
    margin-top: 30px !important;
    padding: 20px 0 !important;
    justify-items: center !important;
    list-style: none !important;
}

.egp-projects-container .egp-project-item {
    background: white !important;
    border-radius: 8px !important;
    overflow: hidden !important;
    /* box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1) !important; */
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1) !important;
    cursor: pointer !important;
    position: relative !important;
    width: 100% !important;
    max-width: 400px !important;
    direction: rtl !important;
    text-align: right !important;
    border: 1px solid rgba(0, 0, 0, 0.05) !important;
    margin: 0 !important;
    padding: 0 !important;
}

.egp-projects-container .egp-project-item:hover {
    transform: translateY(-4px) !important;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15) !important;
    border-color: rgba(0, 124, 186, 0.2) !important;
}

.egp-projects-container .egp-project-thumbnail {
    position: relative !important;
    overflow: hidden !important;
    height: 240px !important;
    /* border-radius: 16px 16px 0 0 !important; */
    /* aspect-ratio: 4/3 !important; */
    margin: 0 !important;
    padding: 0 !important;
}

.egp-projects-container .egp-project-thumbnail img {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    transition: transform 0.4s cubic-bezier(0.25, 0.8, 0.25, 1) !important;
    border-radius: 8px 8px 0 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
    box-shadow: none !important;
}

.egp-projects-container .egp-project-item:hover .egp-project-thumbnail img {
    transform: scale(1.05) !important;
}

.egp-projects-container .egp-project-overlay {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    background: linear-gradient(135deg, rgba(0, 0, 0, 0.6), rgb(6 17 59 / 70%)) !important;
    opacity: 0 !important;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1) !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    text-align: center !important;
    border-radius: 8px 0 !important;
    margin: 0 !important;
    padding: 0 !important;
}

.egp-projects-container .egp-project-item:hover .egp-project-overlay {
    opacity: 1 !important;
}

.egp-projects-container .egp-view-gallery {
    background: rgba(255, 255, 255, 0.95) !important;
    color: #333 !important;
    border: 2px solid rgba(255, 255, 255, 0.8) !important;
    padding: 14px 24px !important;
    border-radius: 30px !important;
    font-weight: 600 !important;
    font-size: 14px !important;
    cursor: pointer !important;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1) !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    gap: 6px !important;
    min-width: 130px !important;
    text-align: center !important;
    text-transform: uppercase !important;
    letter-spacing: 0.5px !important;
    direction: rtl !important;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2) !important;
    text-decoration: none !important;
    margin: 0 !important;
    line-height: 1.2 !important;
}

.egp-projects-container .egp-view-gallery:hover {
    background: rgba(255, 255, 255, 1) !important;
    transform: scale(1.05) !important;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25) !important;
    border-color: rgba(255, 255, 255, 1) !important;
    text-decoration: none !important;
}

.egp-projects-container .egp-overlay-content {
    color: white !important;
    text-align: center !important;
    max-width: 90% !important;
    direction: rtl !important;
    margin: 0 !important;
    padding: 0 !important;
}

.egp-projects-container .egp-overlay-category {
    background: rgba(255, 255, 255, 0.9) !important;
    color: #333 !important;
    padding: 6px 14px !important;
    border-radius: 20px !important;
    font-size: 11px !important;
    font-weight: 600 !important;
    margin-bottom: 16px !important;
    display: inline-block !important;
    border: 1px solid rgba(255, 255, 255, 0.8) !important;
    text-transform: uppercase !important;
    letter-spacing: 0.8px !important;
    direction: rtl !important;
    text-align: center !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15) !important;
    text-decoration: none !important;
    line-height: 1.2 !important;
}

.egp-projects-container .egp-view-gallery .egp-image-count {
    font-size: 0.8em !important;
    opacity: 0.8 !important;
    margin-top: 2px !important;
    margin-bottom: 0 !important;
    color: inherit !important;
}

.egp-projects-container .egp-project-content {
    padding: 20px 24px !important;
    text-align: right !important;
    direction: rtl !important;
    background: white !important;
    border-top: 1px solid rgba(0, 0, 0, 0.05) !important;
    margin: 0 !important;
}

.egp-projects-container .egp-project-title {
    font-size: 1.2em !important;
    font-weight: 700 !important;
    margin: 0 0 12px 0 !important;
    color: #2c3e50 !important;
    direction: rtl !important;
    text-align: right !important;
    line-height: 1.4 !important;
    text-decoration: none !important;
    padding: 0 !important;
    border: none !important;
}

.egp-projects-container .egp-project-excerpt {
    color: #718096 !important;
    line-height: 1.6 !important;
    margin: 0 !important;
    direction: rtl !important;
    text-align: right !important;
    font-size: 0.8em !important;
    padding: 0 !important;
    border: none !important;
}

/* RTL specific spacing adjustments */
.egp-category-tab {
    margin-left: 0;
    margin-right: 0;
}

/* RTL image captions and content alignment */
.egp-project-content h3,
.egp-project-content p {
    direction: rtl;
    text-align: right;
}

/* RTL Modal content alignment */
.egp-gallery-modal h3,
.egp-gallery-modal p,
.egp-gallery-modal div {
    direction: rtl;
}

/* Gallery Modal - High Specificity Override */
.egp-gallery-modal {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    background: rgba(0, 0, 0, 0.96) !important; /* Slightly darker for better contrast */
    z-index: 9999999 !important;
    display: none !important;
    opacity: 0 !important;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1) !important;
    align-items: center !important;
    justify-content: center !important;
    pointer-events: none !important;
    backdrop-filter: blur(20px) !important;
    direction: rtl !important;
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
    box-shadow: none !important;
}

.egp-gallery-modal.active {
    display: flex !important;
    opacity: 1 !important;
    pointer-events: auto !important;
}

.egp-gallery-modal .egp-gallery-container {
    position: relative !important;
    width: 100% !important;
    height: 100% !important;
    display: flex !important;
    flex-direction: column !important;
    background-color: transparent !important;

    margin: auto !important;
    padding: 0 !important;
    border: none !important;
    box-shadow: none !important;
}

.egp-gallery-modal .egp-gallery-header {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.05)) !important;
    padding: 20px 30px !important;
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    backdrop-filter: blur(20px) !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1) !important;
    direction: rtl !important;
    text-align: right !important;
    margin: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
}

.egp-gallery-modal .egp-gallery-title {
    color: white !important;
    font-size: 1.5em !important;
    font-weight: 700 !important;
    margin: 0 !important;
    letter-spacing: 0.5px !important;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3) !important;
    direction: rtl !important;
    text-align: right !important;
    padding: 0 !important;
    border: none !important;
    text-decoration: none !important;
    line-height: 1.4 !important;
}

.egp-gallery-modal .egp-close-gallery {
    position: absolute !important;
    top: 10px !important;
    right: 10px !important;
    background-color: rgba(255, 255, 255, 0.9) !important;
    color: #333 !important;
    border: none !important;
    border-radius: 50% !important;
    width: 36px !important;
    height: 36px !important;
    font-size: 24px !important;
    line-height: 1 !important;
    cursor: pointer !important;
    z-index: 10001 !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2) !important;
    transition: all 0.2s ease !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 0 !important;
    outline: none !important;
    touch-action: manipulation !important;
    right: auto !important;
    left: 15px !important;
    margin: 0 !important;
    text-decoration: none !important;
    font-weight: normal !important;
    font-family: inherit !important;
}

.egp-gallery-modal .egp-close-gallery:hover,
.egp-gallery-modal .egp-close-gallery:focus {
    background-color: #fff !important;
    color: #e53935 !important;
    transform: scale(1.1) !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3) !important;
    text-decoration: none !important;
}

.egp-gallery-modal .egp-close-gallery:active {
    transform: scale(0.95) !important;
}

.egp-gallery-content {
    flex: 1;
    position: relative;
    padding: 20px;
    direction: rtl;
}

/* Main Swiper */
.egp-gallery-swiper {
    height: calc(100vh - 200px);
    margin: 20px 0;
}

.egp-gallery-swiper .swiper-slide {
    display: flex;
    align-items: center;
    justify-content: center;
    /* padding: 20px; */
}

.egp-gallery-swiper .swiper-slide img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
    transition: transform 0.3s ease;
}

.egp-gallery-swiper .swiper-slide img:hover {
    transform: scale(1.02);
}

/* Thumbs Swiper */
.egp-thumbs-swiper {
    height: 100px;
    margin-top: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding-top: 20px;
}

.egp-thumbs-swiper .swiper-slide {
    opacity: 0.6;
    transition: all 0.3s ease;
    cursor: pointer;
    border-radius: 8px;
    overflow: hidden;
}

.egp-thumbs-swiper .swiper-slide-thumb-active {
    opacity: 1;
    transform: scale(1.05);
    box-shadow: 0 4px 15px rgba(255, 255, 255, 0.3);
}

.egp-thumbs-swiper .swiper-slide img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 8px;
}

/* Swiper Navigation */
.swiper-button-next,
.swiper-button-prev {
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    width: 50px !important;
    height: 50px !important;
    margin-top: -25px !important;
    backdrop-filter: blur(10px);
    transition: all 0.3s ease;
}

.swiper-button-next:hover,
.swiper-button-prev:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.4);
    transform: scale(1.1);
}

.swiper-button-next:after,
.swiper-button-prev:after {
    font-size: 18px !important;
    color: white;
    font-weight: bold;
}

/* Swiper Pagination */
.swiper-pagination-bullet {
    background: rgba(255, 255, 255, 0.4);
    opacity: 1;
    width: 12px;
    height: 12px;
    margin: 0 6px !important;
    transition: all 0.3s ease;
}

.swiper-pagination-bullet-active {
    background: white;
    transform: scale(1.2);
}

/* Loading Spinner */
.egp-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 300px;
    color: white;
}

.egp-spinner {
    width: 50px;
    height: 50px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-top: 3px solid white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

.egp-loading-text {
    font-size: 16px;
    font-weight: 500;
    opacity: 0.8;
    animation: pulse 2s ease-in-out infinite;
    direction: rtl;
    text-align: center;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes pulse {
    0%, 100% { opacity: 0.8; }
    50% { opacity: 1; }
}

/* Column Classes for Different Grid Sizes */
.egp-columns-1 {
    grid-template-columns: 1fr;
}

.egp-columns-2 {
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
}

.egp-columns-3 {
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}

.egp-columns-4 {
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
}

.egp-columns-5 {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
}

.egp-columns-6 {
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
}

/* Mobile Responsive for Column Classes */
@media (max-width: 992px) {
    .egp-columns-4, .egp-columns-5, .egp-columns-6 {
        grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    }
}

@media (max-width: 768px) {
    .egp-columns-3, .egp-columns-4 {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    }
    
    .egp-columns-5, .egp-columns-6 {
        grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    }
}

@media (max-width: 576px) {
    .egp-columns-2, .egp-columns-3 {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    }
    
    .egp-columns-4, .egp-columns-5, .egp-columns-6 {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    }
}

@media (max-width: 480px) {
    .egp-columns-2, .egp-columns-3, .egp-columns-4, .egp-columns-5, .egp-columns-6 {
        grid-template-columns: 1fr;
    }
}

/* Mobile Responsive */
@media (max-width: 992px) {
    .egp-projects-grid {
        grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
        gap: 20px;
    }
    
    .egp-category-tabs {
        justify-content: center;
        gap: 15px;
        flex-wrap: wrap;
    }
    
    .egp-category-tab {
        padding: 10px 20px;
        font-size: 0.95em;
        min-width: 110px;
    }
    
    .egp-project-thumbnail {
        height: 220px;
    }
    
    .egp-project-item {
        max-width: none;
    }
}

@media (max-width: 768px) {
    .egp-projects-grid {
        grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
        gap: 16px;
        padding: 16px 0;
    }
    
    .egp-projects-container .egp-category-tabs {
        display: grid !important;
        grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)) !important;
        gap: 12px !important;
        justify-items: center !important;
        align-items: center !important;
        flex-direction: unset !important;
        flex-wrap: unset !important;
        justify-content: unset !important;
    }
    
    .egp-projects-container .egp-category-tab {
        padding: 10px 18px !important;
        font-size: 0.9em !important;
        min-width: 120px !important;
        width: 100% !important;
        max-width: 180px !important;
    }
    
    .egp-project-thumbnail {
        height: 200px;
    }
    
    .egp-project-content {
        padding: 16px 20px;
    }
    
    .egp-project-title {
        font-size: 1.1em;
    }
    
    .egp-view-gallery {
        padding: 12px 20px;
        min-width: 120px;
        font-size: 13px;
    }
    
    .egp-gallery-header {
        padding: 10px 15px;
    }
    
    .egp-gallery-title {
        font-size: 1.2em;
    }
    
    .egp-gallery-swiper {
        height: calc(100vh - 160px);
    }
    
    .egp-thumbs-swiper {
        height: 80px;
        margin-top: 15px;
    }
    
    .swiper-button-next,
    .swiper-button-prev {
        width: 40px !important;
        height: 40px !important;
        margin-top: -20px !important;
    }
    
    .swiper-button-next:after,
    .swiper-button-prev:after {
        font-size: 14px !important;
    }
}

@media (max-width: 480px) {
    .egp-projects-grid {
        grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
        gap: 16px;
        padding: 16px 8px;
    }

    .egp-projects-container .egp-category-tabs {
        display: grid !important;
        grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)) !important;
        gap: 10px !important;
        justify-items: center !important;
        align-items: center !important;
        margin-bottom: 25px !important;
        padding-bottom: 15px !important;
    }
    
    .egp-projects-container .egp-category-tab {
        padding: 8px 16px !important;
        font-size: 0.85em !important;
        min-width: 140px !important;
        width: 100% !important;
        max-width: 200px !important;
    }
    
    .egp-project-item {
        max-width: 320px;
        margin: 0 auto;
    }
    
    .egp-project-thumbnail {
        height: 180px;
    }
    
    .egp-project-content {
        padding: 16px 18px;
    }
    
    .egp-project-title {
        font-size: 1.05em;
    }
    
    .egp-project-excerpt {
        font-size: 0.9em;
    }
    
    .egp-view-gallery {
        padding: 10px 16px;
        min-width: 100px;
        font-size: 12px;
    }
    
    .egp-gallery-content {
        padding: 10px;
    }
    
    .egp-thumbs-swiper .swiper-slide {
        width: 20%;
    }
}

/* Responsive Modal Improvements */
.egp-gallery-modal {
    overflow: hidden;
}

@media (max-width: 768px) {
    .egp-gallery-close {
        top: 10px;
        right: 10px;
        width: 30px;
        height: 30px;
        font-size: 14px;
    }
    
    .egp-gallery-header {
        flex-direction: column;
        align-items: center;
        padding: 10px;
    }
    
    .egp-gallery-title {
        margin-bottom: 8px;
        text-align: center;
    }
    
    .egp-gallery-swiper .swiper-slide img {
        max-height: 100vh;
    }
}

@media (max-width: 480px) {
    .egp-gallery-modal {
        padding: 0;
    }
    
    .egp-gallery-container {
        width: 100%;
        height: 100%;
        border-radius: 0;
    }
    
    .egp-gallery-swiper {
        height: calc(100vh - 120px);
    }
    
    .egp-thumbs-swiper {
        height: 60px;
    }
}

/* Animation for project items */
.egp-project-item {
    animation: fadeInUp 0.8s cubic-bezier(0.4, 0, 0.2, 1);
    animation-fill-mode: both;
}

.egp-project-item:nth-child(1) { animation-delay: 0.1s; }
.egp-project-item:nth-child(2) { animation-delay: 0.2s; }
.egp-project-item:nth-child(3) { animation-delay: 0.3s; }
.egp-project-item:nth-child(4) { animation-delay: 0.4s; }
.egp-project-item:nth-child(5) { animation-delay: 0.5s; }
.egp-project-item:nth-child(6) { animation-delay: 0.6s; }

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(60px) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Filter animation */
.egp-project-item.filtering-out {
    animation: fadeOutScale 0.4s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.egp-project-item.filtering-in {
    animation: fadeInScale 0.4s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes fadeOutScale {
    to {
        opacity: 0;
        transform: scale(0.8) translateY(20px);
    }
}

@keyframes fadeInScale {
    from {
        opacity: 0;
        transform: scale(0.8) translateY(20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* Mobile-specific grid styles */
.egp-mobile-view {
    gap: 10px;
}

.egp-mobile-view .egp-project-item {
    margin-bottom: 10px;
}

.egp-mobile-view .egp-project-thumbnail {
    height: auto;
    min-height: 180px;
}

/* Touch device optimizations */
@media (hover: none) {
    .egp-project-overlay {
        opacity: 0.8;
        background: linear-gradient(0deg, rgba(0, 0, 0, 0.7) 0%, rgba(0, 0, 0, 0) 70%);
        justify-content: flex-end;
        padding-bottom: 15px;
    }
    
    .egp-overlay-content {
        transform: translateY(0);
    }
    
    .egp-view-gallery {
        opacity: 1;
    }
}

/* Additional responsive fixes */
@media (max-width: 360px) {
    .egp-projects-grid {
        grid-template-columns: 1fr;
        gap: 12px;
        padding: 12px 4px;
    }
    
    .egp-project-item {
        max-width: 100%;
    }
    
    .egp-project-thumbnail {
        height: 160px;
    }
    
    .egp-projects-container .egp-category-tabs {
        display: grid !important;
        grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)) !important;
        gap: 8px !important;
        justify-items: center !important;
        align-items: center !important;
        margin-bottom: 20px !important;
        padding-bottom: 12px !important;
    }
    
    .egp-projects-container .egp-category-tab {
        padding: 6px 12px !important;
        font-size: 0.8em !important;
        min-width: 120px !important;
        width: 100% !important;
        max-width: 160px !important;
    }
    
    .egp-overlay-category {
        padding: 4px 10px;
        font-size: 0.75em;
        margin-bottom: 10px;
    }
    
    .egp-view-gallery {
        padding: 8px 12px;
        min-width: 90px;
        font-size: 11px;
    }
}

/* Fix for z-index and stacking issues */
.egp-gallery-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 9999999; /* Extremely high z-index to ensure it's above everything */
}

/* Body state when modal is open */
body.modal-open {
    overflow: hidden !important;
    position: relative;
}

/* Ensure all modal elements are clickable */
.egp-gallery-modal.active * {
    pointer-events: auto;
}

/* Fix for any lingering overlay issues */
.egp-gallery-overlay {
    display: none !important;
}

/* Ensure Swiper navigation buttons are visible and clickable */
.egp-gallery-swiper .swiper-button-next,
.egp-gallery-swiper .swiper-button-prev {
    z-index: 10;
}

/* Enhanced close button styling */
.egp-close-gallery {
    position: absolute;
    top: 15px;
    right: 15px;
    background: rgba(255, 255, 255, 0.15);
    color: white;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    width: 44px;
    height: 44px;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    z-index: 10001;
    backdrop-filter: blur(15px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    outline: none;
    touch-action: manipulation;
    font-weight: 300;
}

.egp-close-gallery:hover,
.egp-close-gallery:focus {
    background: rgba(229, 57, 53, 0.9);
    border-color: rgba(229, 57, 53, 1);
    color: white;
    transform: scale(1.1) rotate(90deg);
    box-shadow: 0 8px 25px rgba(229, 57, 53, 0.4);
}

.egp-close-gallery:active {
    transform: scale(0.95) rotate(90deg);
}

/* Reset any potential parent styles that might interfere */
.egp-gallery-header {
    position: relative;
    z-index: 10000;
    direction: rtl;
    text-align: right;
}

/* Ensure content is properly visible against dark background */
.egp-gallery-modal.active .egp-gallery-container {
    background-color: transparent;
    max-width: 100%;
    max-height: 100%;
    margin: auto;
}

.egp-gallery-swiper .swiper-slide img {
    max-height: 80vh;
    object-fit: contain;
    display: block;
    margin: 0 auto;
}

/* Enhanced Swiper Gallery Styles */
.egp-gallery-swiper {
    height: calc(98vh - 400px);
    margin: 20px 0;
}

.egp-gallery-swiper .swiper-slide {
    display: flex;
    align-items: center;
    justify-content: center;
    /* padding: 20px; */
}

.egp-gallery-swiper .swiper-slide img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
    transition: transform 0.3s ease;
}

.egp-gallery-swiper .swiper-slide img:hover {
    transform: scale(1.02);
}

/* Enhanced Swiper Navigation */
.swiper-button-next,
.swiper-button-prev {
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    width: 50px !important;
    height: 50px !important;
    margin-top: -25px !important;
    backdrop-filter: blur(10px);
    transition: all 0.3s ease;
}

.swiper-button-next:hover,
.swiper-button-prev:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.4);
    transform: scale(1.1);
}

.swiper-button-next:after,
.swiper-button-prev:after {
    font-size: 18px !important;
    color: white;
    font-weight: bold;
}

/* RTL Support - Main Direction */
.egp-projects-container {
    direction: rtl;
    text-align: right;
}

.egp-projects-container * {
    direction: rtl;
}

/* RTL Category Tabs */
.egp-category-tabs {
    direction: rtl;
    text-align: center;
}

.egp-category-tab {
    direction: rtl;
    text-align: center;
}

/* RTL Gallery Modal */
.egp-gallery-modal {
    direction: rtl;
}

.egp-gallery-header {
    direction: rtl;
    text-align: right;
}

.egp-gallery-title {
    direction: rtl;
    text-align: right;
}

/* RTL Close Button - Position on Left for RTL */
.egp-close-gallery {
    right: auto;
    left: 15px;
}

/* RTL Gallery Content */
.egp-gallery-content {
    direction: rtl;
}

/* RTL Loading Text */
.egp-loading-text {
    direction: rtl;
    text-align: center;
}

/* RTL Project Items */
.egp-project-item {
    direction: rtl;
    text-align: right;
}

.egp-project-content {
    direction: rtl;
    text-align: right;
}

.egp-project-title {
    direction: rtl;
    text-align: right;
}

.egp-project-excerpt {
    direction: rtl;
    text-align: right;
}

/* RTL Overlay Content */
.egp-overlay-content {
    direction: rtl;
    text-align: center;
}

.egp-overlay-category {
    direction: rtl;
    text-align: center;
}

.egp-view-gallery {
    direction: rtl;
}

/* RTL Swiper Navigation - Flip positions for RTL */
.egp-gallery-modal .swiper-button-next {
    left: 10px;
    right: auto;
}

.egp-gallery-modal .swiper-button-prev {
    right: 10px;
    left: auto;
}

/* RTL Responsive Adjustments */
@media (max-width: 768px) {
    .egp-gallery-close {
        left: 10px;
        right: auto;
    }
    
    .egp-gallery-modal .swiper-button-next {
        left: 5px;
        right: auto;
    }
    
    .egp-gallery-modal .swiper-button-prev {
        right: 5px;
        left: auto;
    }
}

@media (max-width: 480px) {
    .egp-category-tabs {
        direction: rtl;
    }
    
    .egp-gallery-header {
        text-align: right;
    }
}
