/* ============================================
   XFERA MEDIA - Portfolio
   ============================================ */

:root {
    --primary: #E63946;
    --white: #ffffff;
    --black: #0a0a0a;
    --gray-100: #f5f5f5;
    --gray-200: #e5e5e5;
    --gray-400: #a3a3a3;
    --gray-600: #525252;
    --radius: 20px;
    --radius-sm: 12px;
    --transition: 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Tajawal', sans-serif;
    background: var(--gray-100);
    color: var(--black);
    direction: rtl;
    min-height: 100vh;
}

/* ============================================
   HEADER
   ============================================ */
.header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    padding: 20px 40px;
    background: rgba(245, 245, 245, 0.8);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

.header-container {
    max-width: 1600px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo {
    font-size: 1.8rem;
    font-weight: 900;
    color: var(--black);
    text-decoration: none;
    letter-spacing: -0.02em;
}

.logo span {
    color: var(--primary);
}

/* Filter Navigation */
.filter-nav {
    display: flex;
    gap: 8px;
    padding: 6px;
    background: var(--white);
    border-radius: 50px;
    box-shadow: 0 2px 20px rgba(0,0,0,0.06);
}

.filter-btn {
    padding: 12px 24px;
    border: none;
    background: transparent;
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--gray-600);
    border-radius: 50px;
    cursor: pointer;
    transition: var(--transition);
}

.filter-btn:hover {
    color: var(--black);
}

.filter-btn.active {
    background: var(--black);
    color: var(--white);
}

.contact-link {
    padding: 12px 28px;
    background: var(--primary);
    color: var(--white);
    text-decoration: none;
    font-weight: 600;
    border-radius: 50px;
    transition: var(--transition);
}

.contact-link:hover {
    transform: scale(1.05);
    box-shadow: 0 10px 30px rgba(230, 57, 70, 0.3);
}

/* ============================================
   PORTFOLIO GRID
   ============================================ */
.portfolio {
    padding: 120px 40px 60px;
    max-width: 1600px;
    margin: 0 auto;
}

.portfolio-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 24px;
    grid-auto-flow: dense;
}

/* ============================================
   PROJECT CARDS
   ============================================ */
.project-card {
    position: relative;
    border-radius: var(--radius);
    overflow: hidden;
    cursor: pointer;
    min-height: 320px;
    transition: var(--transition);
}

.project-card:hover {
    transform: translateY(-8px) scale(1.02);
    z-index: 10;
}

.project-card.large {
    grid-column: span 2;
    grid-row: span 2;
    min-height: 664px;
}

.project-card.wide {
    grid-column: span 2;
}

.project-card.hide {
    display: none;
}

/* Card Background - Gradients */
.card-bg {
    position: absolute;
    inset: 0;
    transition: var(--transition);
}

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

/* Category Gradients */
.gradient-realestate { background: linear-gradient(135deg, #1a365d 0%, #2d5a87 100%); }
.gradient-ecommerce { background: linear-gradient(135deg, #7c3aed 0%, #a78bfa 100%); }
.gradient-ecommerce-2 { background: linear-gradient(135deg, #059669 0%, #34d399 100%); }
.gradient-ecommerce-3 { background: linear-gradient(135deg, #dc2626 0%, #f87171 100%); }
.gradient-ecommerce-4 { background: linear-gradient(135deg, #b45309 0%, #fbbf24 100%); }
.gradient-ecommerce-5 { background: linear-gradient(135deg, #0891b2 0%, #22d3ee 100%); }
.gradient-ecommerce-6 { background: linear-gradient(135deg, #be185d 0%, #f472b6 100%); }
.gradient-apps { background: linear-gradient(135deg, #ea580c 0%, #fb923c 100%); }
.gradient-hospitality { background: linear-gradient(135deg, #7c2d12 0%, #c2410c 100%); }
.gradient-design { background: linear-gradient(135deg, #4f46e5 0%, #818cf8 100%); }

/* Card Content */
.card-content {
    position: relative;
    height: 100%;
    padding: 28px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    z-index: 2;
}

/* Results Badges */
.card-results {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.result-badge {
    padding: 8px 16px;
    background: var(--white);
    color: var(--black);
    font-size: 0.9rem;
    font-weight: 700;
    border-radius: 50px;
}

/* Card Info */
.card-info {
    color: var(--white);
}

.card-niche {
    display: inline-block;
    padding: 6px 14px;
    background: rgba(255,255,255,0.2);
    backdrop-filter: blur(10px);
    border-radius: 50px;
    font-size: 0.85rem;
    font-weight: 500;
    margin-bottom: 12px;
}

.card-title {
    font-size: 1.6rem;
    font-weight: 800;
    margin-bottom: 8px;
    line-height: 1.3;
}

.project-card.large .card-title {
    font-size: 2.2rem;
}

.card-headline {
    font-size: 1rem;
    opacity: 0.9;
    line-height: 1.6;
}

.project-card.large .card-headline {
    font-size: 1.1rem;
}

/* ============================================
   MODAL - New Design
   ============================================ */
.modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
}

.modal.active {
    opacity: 1;
    visibility: visible;
}

.modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(10px);
}

.modal-content {
    position: relative;
    max-width: 700px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    background: var(--white);
    border-radius: var(--radius);
    transform: scale(0.9) translateY(20px);
    transition: var(--transition);
}

.modal.active .modal-content {
    transform: scale(1) translateY(0);
}

.modal-close {
    position: absolute;
    top: 20px;
    left: 20px;
    width: 48px;
    height: 48px;
    background: var(--gray-100);
    border: none;
    border-radius: 50%;
    font-size: 28px;
    cursor: pointer;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.modal-close:hover {
    background: var(--primary);
    color: var(--white);
    transform: rotate(90deg);
}

/* Modal Header */
.modal-header {
    padding: 40px 40px 30px;
    border-bottom: 1px solid var(--gray-200);
}

.modal-niche {
    display: inline-block;
    padding: 8px 18px;
    background: var(--primary);
    color: var(--white);
    font-size: 0.9rem;
    font-weight: 600;
    border-radius: 50px;
    margin-bottom: 16px;
}

.modal-title {
    font-size: 2rem;
    font-weight: 900;
    color: var(--black);
    margin-bottom: 12px;
}

.modal-headline {
    font-size: 1.15rem;
    color: var(--gray-600);
    line-height: 1.7;
}

/* Modal Body */
.modal-body {
    padding: 30px 40px;
}

.modal-section {
    margin-bottom: 28px;
}

.modal-section:last-child {
    margin-bottom: 0;
}

.modal-section h3 {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--gray-400);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 12px;
}

.modal-section p {
    font-size: 1.05rem;
    color: var(--black);
    line-height: 1.8;
}

/* Modal Results */
.modal-results {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.modal-results .result-item {
    padding: 12px 20px;
    background: linear-gradient(135deg, var(--primary) 0%, #ff6b6b 100%);
    color: var(--white);
    font-size: 1rem;
    font-weight: 700;
    border-radius: 12px;
}

/* Modal Footer */
.modal-footer {
    padding: 24px 40px 40px;
}

.modal-cta {
    display: block;
    width: 100%;
    padding: 18px;
    background: var(--black);
    color: var(--white);
    text-align: center;
    text-decoration: none;
    font-size: 1.1rem;
    font-weight: 700;
    border-radius: 14px;
    transition: var(--transition);
}

.modal-cta:hover {
    background: var(--primary);
    transform: translateY(-2px);
}

/* ============================================
   GALLERY IN MODAL
   ============================================ */
.gallery-section {
    margin-bottom: 32px;
}

.gallery-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.gallery-tab {
    padding: 10px 20px;
    border: 2px solid var(--gray-200);
    background: transparent;
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--gray-600);
    border-radius: 50px;
    cursor: pointer;
    transition: var(--transition);
}

.gallery-tab:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.gallery-tab.active {
    background: var(--primary);
    border-color: var(--primary);
    color: var(--white);
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.gallery-item {
    position: relative;
    aspect-ratio: 4/3;
    border-radius: var(--radius-sm);
    overflow: hidden;
    cursor: pointer;
    transition: var(--transition);
}

.gallery-item:hover {
    transform: scale(1.03);
    box-shadow: 0 10px 30px rgba(0,0,0,0.15);
}

.gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: var(--transition);
}

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

.gallery-item-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, rgba(0,0,0,0.7) 0%, transparent 50%);
    opacity: 0;
    transition: var(--transition);
    display: flex;
    align-items: flex-end;
    padding: 12px;
}

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

.gallery-item-type {
    padding: 4px 12px;
    background: var(--primary);
    color: var(--white);
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 50px;
}

.gallery-item.hide {
    display: none;
}

.gallery-empty {
    grid-column: 1 / -1;
    text-align: center;
    padding: 40px 20px;
    color: var(--gray-400);
    font-size: 1rem;
}

/* ============================================
   LIGHTBOX
   ============================================ */
.lightbox {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
}

.lightbox.active {
    opacity: 1;
    visibility: visible;
}

.lightbox-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.95);
}

.lightbox-close {
    position: absolute;
    top: 20px;
    left: 20px;
    width: 50px;
    height: 50px;
    background: rgba(255,255,255,0.1);
    border: none;
    border-radius: 50%;
    font-size: 32px;
    color: var(--white);
    cursor: pointer;
    z-index: 10;
    transition: var(--transition);
}

.lightbox-close:hover {
    background: var(--primary);
    transform: rotate(90deg);
}

.lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 50px;
    height: 50px;
    background: rgba(255,255,255,0.1);
    border: none;
    border-radius: 50%;
    font-size: 24px;
    color: var(--white);
    cursor: pointer;
    z-index: 10;
    transition: var(--transition);
}

.lightbox-nav:hover {
    background: var(--primary);
}

.lightbox-prev {
    right: 20px;
}

.lightbox-next {
    left: 20px;
}

.lightbox-image {
    max-width: 90%;
    max-height: 85vh;
    object-fit: contain;
    border-radius: var(--radius-sm);
    z-index: 5;
    transform: scale(0.9);
    transition: var(--transition);
}

.lightbox.active .lightbox-image {
    transform: scale(1);
}

/* ============================================
   FOOTER
   ============================================ */
.footer {
    padding: 60px 40px;
    text-align: center;
    background: var(--black);
}

.footer-content p {
    color: var(--gray-400);
    font-size: 1.1rem;
    margin-bottom: 16px;
}

.footer-cta {
    color: var(--white);
    font-size: 2rem;
    font-weight: 800;
    text-decoration: none;
    transition: var(--transition);
}

.footer-cta:hover {
    color: var(--primary);
}

/* ============================================
   ANIMATIONS
   ============================================ */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.project-card {
    animation: fadeIn 0.6s ease backwards;
}

.project-card:nth-child(1) { animation-delay: 0.1s; }
.project-card:nth-child(2) { animation-delay: 0.15s; }
.project-card:nth-child(3) { animation-delay: 0.2s; }
.project-card:nth-child(4) { animation-delay: 0.25s; }
.project-card:nth-child(5) { animation-delay: 0.3s; }
.project-card:nth-child(6) { animation-delay: 0.35s; }
.project-card:nth-child(7) { animation-delay: 0.4s; }
.project-card:nth-child(8) { animation-delay: 0.45s; }
.project-card:nth-child(9) { animation-delay: 0.5s; }
.project-card:nth-child(10) { animation-delay: 0.55s; }

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 1200px) {
    .portfolio-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .project-card.large {
        grid-column: span 2;
        grid-row: span 2;
        min-height: 500px;
    }

    .filter-nav {
        gap: 4px;
    }

    .filter-btn {
        padding: 10px 16px;
        font-size: 0.85rem;
    }
}

@media (max-width: 900px) {
    .header {
        padding: 16px 24px;
    }

    .header-container {
        flex-wrap: wrap;
        gap: 16px;
    }

    .filter-nav {
        order: 3;
        width: 100%;
        justify-content: center;
        flex-wrap: wrap;
    }

    .contact-link {
        padding: 10px 20px;
        font-size: 0.9rem;
    }

    .portfolio {
        padding: 160px 24px 40px;
    }

    .portfolio-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 16px;
    }

    .project-card {
        min-height: 280px;
    }

    .project-card.large {
        grid-column: span 2;
        grid-row: span 1;
        min-height: 350px;
    }

    .modal {
        padding: 20px;
    }

    .modal-header,
    .modal-body,
    .modal-footer {
        padding-left: 24px;
        padding-right: 24px;
    }

    .modal-title {
        font-size: 1.5rem;
    }
}

@media (max-width: 600px) {
    .logo {
        font-size: 1.4rem;
    }

    .filter-btn {
        padding: 8px 14px;
        font-size: 0.8rem;
    }

    .portfolio-grid {
        grid-template-columns: 1fr;
    }

    .project-card,
    .project-card.large,
    .project-card.wide {
        grid-column: span 1;
        grid-row: span 1;
        min-height: 280px;
    }

    .card-content {
        padding: 20px;
    }

    .card-title {
        font-size: 1.3rem;
    }

    .project-card.large .card-title {
        font-size: 1.5rem;
    }

    .result-badge {
        padding: 6px 12px;
        font-size: 0.8rem;
    }

    .footer-cta {
        font-size: 1.4rem;
    }

    .gallery-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .gallery-tabs {
        justify-content: center;
    }

    .gallery-tab {
        padding: 8px 14px;
        font-size: 0.8rem;
    }

    .lightbox-nav {
        width: 40px;
        height: 40px;
        font-size: 20px;
    }

    .lightbox-prev {
        right: 10px;
    }

    .lightbox-next {
        left: 10px;
    }
}
