/**
 * Portfolio Section Styles - Fixed RTL Mobile Version
 * Primary Color: #234E70
 * Font: Cairo for Arabic, Poppins for English
 * Version: 2.2.1 - CAIRO FONT FIXED
 */

@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;600;700&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@400;600;700&display=swap');

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-blue: #234E70;
    --primary-dark: #1a3a52;
    --primary-light: #2d6090;
    --pure-white: #FFFFFF;
    --border-gray: #E2E8F0;
    --text-dark: #1E293B;
    --text-light: #64748B;
}

/* ========================================
   ARABIC FONT - CAIRO (MAXIMUM PRIORITY)
   ======================================== */

/* Apply to ALL elements - Multiple selectors for maximum specificity */
html[lang="ar"] .cpf-portfolio-section,
html[lang="ar"] .cpf-portfolio-section *,
html[lang="ar"] .cpf-portfolio-section h1,
html[lang="ar"] .cpf-portfolio-section h2,
html[lang="ar"] .cpf-portfolio-section h3,
html[lang="ar"] .cpf-portfolio-section h4,
html[lang="ar"] .cpf-portfolio-section h5,
html[lang="ar"] .cpf-portfolio-section h6,
html[lang="ar"] .cpf-portfolio-section p,
html[lang="ar"] .cpf-portfolio-section span,
html[lang="ar"] .cpf-portfolio-section button,
html[lang="ar"] .cpf-portfolio-section a,
html[lang="ar"] .cpf-portfolio-section div,
html[dir="rtl"] .cpf-portfolio-section,
html[dir="rtl"] .cpf-portfolio-section *,
html[dir="rtl"] .cpf-portfolio-section h1,
html[dir="rtl"] .cpf-portfolio-section h2,
html[dir="rtl"] .cpf-portfolio-section h3,
html[dir="rtl"] .cpf-portfolio-section h4,
html[dir="rtl"] .cpf-portfolio-section h5,
html[dir="rtl"] .cpf-portfolio-section h6,
html[dir="rtl"] .cpf-portfolio-section p,
html[dir="rtl"] .cpf-portfolio-section span,
html[dir="rtl"] .cpf-portfolio-section button,
html[dir="rtl"] .cpf-portfolio-section a,
html[dir="rtl"] .cpf-portfolio-section div,
body[lang="ar"] .cpf-portfolio-section,
body[lang="ar"] .cpf-portfolio-section *,
body[dir="rtl"] .cpf-portfolio-section,
body[dir="rtl"] .cpf-portfolio-section *,
[lang="ar"] .cpf-portfolio-section,
[lang="ar"] .cpf-portfolio-section *,
[dir="rtl"] .cpf-portfolio-section,
[dir="rtl"] .cpf-portfolio-section * {
    font-family: 'Cairo', sans-serif !important;
}

/* Specific elements override */
html[dir="rtl"] .cpf-portfolio-title,
html[dir="rtl"] .cpf-portfolio-description,
html[dir="rtl"] .cpf-filter-btn,
html[dir="rtl"] .cpf-filter-btn span,
html[dir="rtl"] .cpf-project-title,
html[dir="rtl"] .cpf-project-description,
html[dir="rtl"] .cpf-project-tag,
html[dir="rtl"] .cpf-project-category-badge,
[dir="rtl"] .cpf-portfolio-title,
[dir="rtl"] .cpf-portfolio-description,
[dir="rtl"] .cpf-filter-btn,
[dir="rtl"] .cpf-filter-btn span,
[dir="rtl"] .cpf-project-title,
[dir="rtl"] .cpf-project-description,
[dir="rtl"] .cpf-project-tag,
[dir="rtl"] .cpf-project-category-badge {
    font-family: 'Cairo', sans-serif !important;
}

/* Portfolio Section - Compact */
.cpf-portfolio-section {
    width: 100%;
    padding: 30px 0;
    background: var(--pure-white);
    font-family: 'Poppins', sans-serif;
}

/* Full Width Container */
.cpf-portfolio-container {
    width: 100%;
    max-width: 100%;
    padding: 0;
}

/* Header - Centered with padding */
.cpf-portfolio-header {
    text-align: center;
    margin-bottom: 30px;
    padding: 0 40px;
}

.cpf-portfolio-title {
    font-size: 32px;
    font-weight: 700;
    color: var(--primary-blue);
    margin-bottom: 12px;
    letter-spacing: -0.02em;
    line-height: 1.2;
}

.cpf-portfolio-description {
    font-size: 16px;
    font-weight: 400;
    color: var(--text-light);
    max-width: 700px;
    margin: 0 auto;
    line-height: 1.6;
}

/* Filter Buttons */
.cpf-filter-container {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-bottom: 30px;
    flex-wrap: wrap;
    padding: 0 40px;
}

.cpf-filter-btn {
    padding: 10px 24px;
    font-size: 14px;
    font-weight: 600;
    border: 2px solid var(--border-gray);
    background: white;
    color: var(--text-dark);
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.cpf-filter-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 0;
    height: 100%;
    background: var(--primary-blue);
    transition: width 0.3s ease;
    z-index: 0;
}

.cpf-filter-btn span {
    position: relative;
    z-index: 1;
}

.cpf-filter-btn:hover {
    border-color: var(--primary-blue);
    transform: translateY(-2px);
}

.cpf-filter-btn:hover::before {
    width: 100%;
}

.cpf-filter-btn:hover span {
    color: white;
}

.cpf-filter-btn.active {
    background: var(--primary-blue);
    color: white;
    border-color: var(--primary-blue);
}

/* Projects Scroll Container - FULL WIDTH */
.cpf-projects-wrapper {
    position: relative;
    width: 100%;
}

.cpf-projects-scroll-container {
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: thin;
    scrollbar-color: var(--primary-blue) var(--border-gray);
    scroll-behavior: auto;
    padding: 20px 40px;
    cursor: grab;
    width: 100%;
    -webkit-overflow-scrolling: touch;
    direction: ltr !important;
}

.cpf-projects-scroll-container:active {
    cursor: grabbing;
}

.cpf-projects-scroll-container::-webkit-scrollbar {
    height: 6px;
}

.cpf-projects-scroll-container::-webkit-scrollbar-track {
    background: var(--border-gray);
    border-radius: 10px;
}

.cpf-projects-scroll-container::-webkit-scrollbar-thumb {
    background: var(--primary-blue);
    border-radius: 10px;
}

.cpf-projects-scroll-container::-webkit-scrollbar-thumb:hover {
    background: var(--primary-dark);
}

.cpf-projects-grid {
    display: flex;
    gap: 20px;
    width: max-content;
    direction: ltr !important;
}

/* Project Card - 3 Cards Visible */
.cpf-project-card {
    flex: 0 0 calc(33.333vw - 53px);
    max-width: 450px;
    min-width: 350px;
    background: white;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    transition: all 0.3s ease;
    cursor: pointer;
    text-decoration: none;
    color: inherit;
    display: block;
    border: 1px solid var(--border-gray);
}

.cpf-project-card:hover {
    transform: translateY(-6px);
    box-shadow: 0 8px 24px rgba(35, 78, 112, 0.15);
    border-color: var(--primary-blue);
}

.cpf-project-card.hidden {
    display: none !important;
}

.cpf-project-image-container {
    position: relative;
    height: 220px;
    overflow: hidden;
    background: var(--primary-blue);
}

.cpf-project-image-container::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(180deg, transparent 0%, rgba(35, 78, 112, 0.3) 100%);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.cpf-project-card:hover .cpf-project-image-container::after {
    opacity: 1;
}

.cpf-project-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.4s ease;
}

.cpf-project-card:hover .cpf-project-image {
    transform: scale(1.05);
}

.cpf-project-category-badge {
    position: absolute;
    top: 15px;
    right: 15px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    color: var(--primary-blue);
    z-index: 2;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.cpf-project-content {
    padding: 20px;
    background: white;
}

.cpf-project-title {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-dark);
    margin-bottom: 10px;
    line-height: 1.3;
}

.cpf-project-description {
    font-size: 14px;
    color: var(--text-light);
    line-height: 1.6;
    margin-bottom: 15px;
}

.cpf-project-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.cpf-project-tag {
    padding: 5px 12px;
    background: #F1F5F9;
    color: var(--text-dark);
    font-size: 12px;
    font-weight: 500;
    border-radius: 12px;
    transition: all 0.3s ease;
}

.cpf-project-card:hover .cpf-project-tag {
    background: rgba(35, 78, 112, 0.1);
    color: var(--primary-blue);
}

/* Scroll Hint */
.cpf-scroll-hint {
    text-align: center;
    margin-top: 20px;
    padding: 0 40px;
    color: var(--text-light);
    font-size: 13px;
    opacity: 0.7;
}

.cpf-scroll-hint svg {
    width: 20px;
    height: 20px;
    margin: 0 6px;
    vertical-align: middle;
    animation: slideLeftRight 2s ease-in-out infinite;
}

/* Empty State */
.cpf-empty-state {
    text-align: center;
    padding: 60px 40px;
    display: none;
}

.cpf-empty-state.active {
    display: block;
}

.cpf-empty-state-icon {
    width: 60px;
    height: 60px;
    margin: 0 auto 15px;
    opacity: 0.3;
    color: var(--primary-blue);
}

.cpf-empty-state-title {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-dark);
    margin-bottom: 10px;
}

.cpf-empty-state-text {
    font-size: 14px;
    color: var(--text-light);
}

/* Animations */
@keyframes slideLeftRight {
    0%, 100% {
        transform: translateX(-5px);
    }
    50% {
        transform: translateX(5px);
    }
}

/* Responsive - Tablet */
@media (max-width: 1024px) {
    .cpf-project-card {
        flex: 0 0 calc(50vw - 50px);
        min-width: 320px;
    }
}

/* Responsive - Mobile */
@media (max-width: 768px) {
    .cpf-portfolio-section {
        padding: 25px 0;
    }
    
    .cpf-portfolio-header {
        margin-bottom: 20px;
        padding: 0 20px;
    }

    .cpf-portfolio-title {
        font-size: 24px;
    }

    .cpf-portfolio-description {
        font-size: 14px;
    }
    
    .cpf-filter-container {
        padding: 0 20px;
        margin-bottom: 20px;
        gap: 8px;
    }
    
    .cpf-projects-scroll-container {
        padding: 15px 20px;
    }

    .cpf-filter-btn {
        padding: 8px 18px;
        font-size: 13px;
    }

    .cpf-project-card {
        flex: 0 0 280px;
        min-width: 280px;
    }
    
    .cpf-project-image-container {
        height: 180px;
    }
    
    .cpf-project-content {
        padding: 15px;
    }
    
    .cpf-project-title {
        font-size: 18px;
    }
    
    .cpf-project-description {
        font-size: 13px;
    }
    
    .cpf-scroll-hint {
        padding: 0 20px;
        font-size: 12px;
    }
}

/* Extra Small Mobile */
@media (max-width: 480px) {
    .cpf-portfolio-title {
        font-size: 22px;
    }
    
    .cpf-project-card {
        flex: 0 0 260px;
        min-width: 260px;
    }
}

/* ========================================
   RTL SUPPORT - ARABIC FIXES
   ======================================== */

/* RTL Badge Position */
[dir="rtl"] .cpf-project-category-badge {
    right: auto;
    left: 15px;
}

/* RTL Content Direction */
[dir="rtl"] .cpf-project-card {
    direction: rtl;
    text-align: right;
}

[dir="rtl"] .cpf-project-title,
[dir="rtl"] .cpf-project-description {
    text-align: right;
}

[dir="rtl"] .cpf-project-tags {
    direction: rtl;
    justify-content: flex-start;
}

/* ========================================
   CRITICAL FIX: RTL Mobile Scroll Issue
   PROJECTS START FROM RIGHT ON MOBILE
   ======================================== */

/* RTL Grid Direction - Projects flow from right to left */
[dir="rtl"] .cpf-projects-grid {
    direction: rtl !important;
    justify-content: flex-start;
}

/* RTL Scroll Container - Scroll starts from right */
[dir="rtl"] .cpf-projects-scroll-container {
    direction: rtl !important;
}

/* Mobile RTL - Ensure first project is visible on the right */
@media (max-width: 768px) {
    [dir="rtl"] .cpf-projects-scroll-container {
        direction: rtl !important;
    }
    
    [dir="rtl"] .cpf-projects-grid {
        direction: rtl !important;
        flex-direction: row;
    }
}

/* Animation for RTL */
[dir="rtl"] .cpf-scroll-hint svg {
    animation: slideRightLeft 2s ease-in-out infinite;
}

@keyframes slideRightLeft {
    0%, 100% {
        transform: translateX(5px);
    }
    50% {
        transform: translateX(-5px);
    }
}
