/* Gallery Modal Overhaul - Behance Style */
.portfolio-modal {
    padding: 20px;
    align-items: center;
    justify-content: center;
    display: none;
}

.portfolio-modal.active {
    display: flex;
}

.gallery-modal-wrapper {
    width: 95%;
    max-width: 1400px;
    height: 90vh;
    max-height: 90vh;
    background: var(--bg);
    position: relative;
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 30px 60px rgba(0, 0, 0, 0.5);
    border: 1px solid var(--border);
}

.gallery-layout {
    display: grid;
    grid-template-columns: 1fr 380px;
    height: 100%;
}

/* Left Column: Images with Toggle */
.gallery-images-column {
    padding: 0;
    overflow-y: auto;
    background: var(--bg-alt);
    position: relative;
    display: flex;
    flex-direction: column;
}

.gallery-view-controls {
    display: flex;
    gap: 10px;
    padding: 20px 30px;
    position: sticky;
    top: 0;
    z-index: 50;
    background: var(--bg-alt);
    border-bottom: 1px solid var(--border);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.05);
}

.view-btn {
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--text-light);
    padding: 10px 20px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.view-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

#gallery-items-container {
    padding: 60px 30px 60px;
    transition: all 0.3s ease;
}

#gallery-items-container img {
    cursor: pointer;
    transition: transform 0.3s ease, opacity 0.3s ease;
}

#gallery-items-container img:hover {
    transform: scale(1.02);
    opacity: 0.9;
}

/* List View (Vertical) */
.view-list {
    display: flex;
    flex-direction: column;
    gap: 30px;
}

.view-list img {
    width: 100%;
    height: auto;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    display: block;
}

/* Grid View */
.view-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}

.view-grid img {
    aspect-ratio: 1/1;
    object-fit: cover;
    width: 100%;
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    display: block;
}

/* Right Column: Sticky Sidebar */
.gallery-info-sidebar {
    padding: 40px;
    background: var(--bg);
    border-left: 1px solid var(--border);
    position: relative;
    overflow-y: auto;
}

.sidebar-content-sticky {
    position: sticky;
    top: 0;
}

.project-info-header {
    margin-bottom: 30px;
}

.project-info-header h2 {
    font-size: 2.2rem;
    font-weight: 800;
    margin-bottom: 15px;
    line-height: 1.1;
    color: var(--text);
}

.project-stats {
    display: flex;
    gap: 15px;
}

.like-btn {
    background: var(--secondary);
    border: 1px solid rgba(var(--primary-rgb), 0.2);
    color: var(--text);
    padding: 10px 20px;
    border-radius: 50px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    transition: all 0.3s ease;
}

.like-btn i {
    width: 18px;
    height: 18px;
}

.like-btn.active {
    background: #ff4757;
    color: white;
    border-color: #ff4757;
}

.project-description-wrapper {
    margin-bottom: 40px;
}

.project-desc-content {
    font-size: 1.1rem;
    line-height: 1.7;
    color: var(--text-light);
    max-height: 300px;
    overflow: hidden;
    position: relative;
    transition: max-height 0.5s ease;
}

.project-desc-content.expanded {
    max-height: 2000px;
}

.read-more-link {
    background: none;
    border: none;
    color: var(--primary);
    font-weight: 600;
    padding: 0;
    margin-top: 10px;
    text-decoration: underline;
    display: none;
}

.project-tools-wrapper h4 {
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #999;
    margin-bottom: 15px;
}

.tools-grid-mini {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 40px;
}

.project-footer-actions .btn {
    width: 100%;
    padding: 14px 28px;
    font-size: 1rem;
    border-radius: 12px;
}

.close-modal {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 40px;
    height: 40px;
    background: var(--bg);
    color: var(--text);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    border: 1px solid var(--border);
    transition: all 0.3s ease;
}

.close-modal:hover {
    background: var(--primary);
    color: white;
    transform: rotate(90deg) scale(1.1);
}

/* Image Lightbox Viewer */
.image-lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    z-index: 10000;
    display: none;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.image-lightbox.active {
    display: flex;
    opacity: 1;
}

.lightbox-content {
    position: relative;
    width: 90%;
    height: 90%;
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: pan-x;
}

.lightbox-image {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    user-select: none;
    transition: transform 0.3s ease;
}

.lightbox-close {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 50px;
    height: 50px;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 10001;
    border: 1px solid rgba(255, 255, 255, 0.2);
    transition: all 0.3s ease;
    color: white;
}

.lightbox-close:hover {
    background: var(--primary);
    transform: rotate(90deg) scale(1.1);
}

.lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 50px;
    height: 50px;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border: 1px solid rgba(255, 255, 255, 0.2);
    transition: all 0.3s ease;
    color: white;
    z-index: 10001;
}

.lightbox-nav:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-50%) scale(1.1);
}

.lightbox-nav-prev {
    left: 20px;
}

.lightbox-nav-next {
    right: 20px;
}

.lightbox-counter {
    position: absolute;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(10px);
    padding: 10px 20px;
    border-radius: 20px;
    color: white;
    font-size: 0.9rem;
    font-weight: 600;
}

/* Mobile Responsive */
@media (max-width: 992px) {
    .portfolio-modal {
        padding: 0;
    }

    .gallery-modal-wrapper {
        width: 100%;
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
        border: none;
    }

    .gallery-layout {
        grid-template-columns: 1fr;
        height: 100%;
        overflow-y: auto;
        display: block;
    }

    .gallery-images-column {
        padding: 0;
        overflow-y: visible;
        background: var(--bg-alt);
    }

    .gallery-view-controls {
        top: 0;
        padding: 15px 20px;
    }

    #gallery-items-container {
        padding: 20px;
        padding-top: 10px;
    }

    .view-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    .view-grid img {
        border-radius: 8px;
    }

    .gallery-info-sidebar {
        padding: 40px 20px 100px;
        border-left: none;
        border-top: 1px solid var(--border);
        background: var(--bg);
        overflow-y: visible;
    }

    .sidebar-content-sticky {
        position: static;
    }

    .close-modal {
        position: fixed;
        /* Force fixed on mobile */
        top: 15px;
        right: 15px;
        background: rgba(var(--bg-rgb), 0.9);
        /* Use variable or fallback */
        background: #121212;
        border: 1px solid var(--border);
        box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
        z-index: 2005;
        /* Highest */
    }

    .project-info-header h2 {
        font-size: 1.8rem;
    }

    .lightbox-nav {
        width: 40px;
        height: 40px;
    }

    .lightbox-nav-prev {
        left: 10px;
    }

    .lightbox-nav-next {
        right: 10px;
    }

    .lightbox-close {
        top: 10px;
        right: 10px;
        width: 40px;
        height: 40px;
    }
}