/* Case Study Modal Styles */
.madb-post-agency-case-studies-card {
    cursor: pointer;
    transition: transform 0.2s ease;
}

.madb-post-agency-case-studies-card:hover {
    transform: translateY(-5px);
}

.madb-post-agency-case-studies-popup-container {
    display: none;
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    max-height: 100vh !important;
    background: rgba(0, 0, 0, 0.9);
    z-index: 9999999 !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    padding: 0 !important;
    margin: 0 !important;
    flex-direction: column !important;
    -webkit-overflow-scrolling: touch;
    pointer-events: auto !important;
    overscroll-behavior: contain;
    will-change: scroll-position;
    touch-action: pan-y;
}

.madb-post-agency-case-studies-popup-container[style*="display: flex"],
.madb-post-agency-case-studies-popup-container[style*="display:flex"] {
    display: flex !important;
}

/* Remove the overly broad pointer-events rule - let elements handle their own */

body.popup-open {
    overflow: hidden;
}

body.popup-open .madb-main-wrapper,
body.popup-open .madb-content-container,
body.popup-open .madb-main-content,
body.popup-open .madb-sidebar,
body.popup-open .madb-mega-menu,
body.popup-open header,
body.popup-open footer {
    pointer-events: none !important;
    z-index: 1 !important;
}

.popup-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 28px 32px;
    background: linear-gradient(180deg, rgba(20, 20, 20, 0.98) 0%, rgba(20, 20, 20, 0.95) 100%);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    color: #fff;
    position: sticky;
    top: 0;
    z-index: 10;
    flex-shrink: 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.popup-logo-title {
    display: flex;
    align-items: center;
    gap: 20px;
}

.madb-agency-logo img {
    width: 80px;
    height: 80px;
    object-fit: contain;
    border-radius: 8px;
    background: #ffffff;
    padding: 8px;
}

.madb-case-study-title {
    font-size: 32px;
    font-weight: 700;
    margin: 0;
    color: #fff;
    line-height: 1.2;
    letter-spacing: -0.5px;
}

.madb-by-agency {
    color: #fff;
    font-size: 14px;
    margin-top: 5px;
}

.close-popup {
    background: none;
    border: none;
    cursor: pointer;
    padding: 10px;
    transition: opacity 0.2s;
}

.close-popup:hover {
    opacity: 0.7;
}

.popup-content {
    flex: 0 1 auto;
    background: rgba(20, 20, 20, 0.85);
    backdrop-filter: blur(40px);
    -webkit-backdrop-filter: blur(40px);
    max-width: 1485px;
    margin: 24px auto;
    width: calc(100% - 48px);
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
    min-height: auto;
    overflow: visible;
    position: relative;
    padding-bottom: 48px;
    /* Allow content to grow naturally beyond viewport */
}

.popup-inner {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    gap: 40px;
    padding: 40px;
    align-items: flex-start !important;
    overflow: visible;
    min-height: auto;
    pointer-events: auto;
}

.project-details {
    flex: 1 1 auto !important;
    order: 1 !important;
    width: auto !important;
    min-width: 0 !important;
}

/* Original gallery styles - keep for card galleries (not in modal) */
.madb-case-study-gallery {
    position: relative;
    width: 100%;
    overflow: hidden;
    border-radius: 6px 6px 0px 0px;
}

.madb-case-study-gallery img {
    width: 100%;
    height: auto;
    display: block;
    object-fit: cover;
}

/* Hide any old gallery implementations in modals - only show new gallery */
.popup-content .madb-case-study-gallery,
.popup-inner .madb-case-study-gallery,
.project-details .madb-case-study-gallery {
    display: none !important;
}

/* Ensure other-case-studies gallery images are visible - override the above */
.other-case-studies .madb-case-study-gallery,
.other-case-studies-container .madb-case-study-gallery,
.other-case-studies-wrapper .madb-case-study-gallery,
.other-case-studies-scroll-container .madb-case-study-gallery,
.madb-post-agency-case-studies-popup-container .other-case-studies .madb-case-study-gallery,
.popup-content .other-case-studies .madb-case-study-gallery,
.popup-inner .other-case-studies .madb-case-study-gallery {
    display: block !important;
}

/* New gallery implementation - only for modal gallery wrapper */
.madb-case-study-gallery-wrapper.madb-gallery-new {
    position: relative;
    margin-bottom: 30px;
    width: 100%;
    display: block;
}

.madb-gallery-thumbnails {
    display: block !important;
    margin-top: 20px;
    margin-bottom: 0;
    overflow-x: auto;
    padding: 8px 0;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.3) transparent;
    width: 100%;
    white-space: nowrap;
}

.madb-gallery-thumbnails::-webkit-scrollbar {
    height: 6px;
}

.madb-gallery-thumbnails::-webkit-scrollbar-track {
    background: transparent;
}

.madb-gallery-thumbnails::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 3px;
}

.madb-gallery-thumbnails::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.5);
}

.madb-gallery-thumbnail {
    position: relative;
    width: 120px;
    height: 68px;
    border: 2px solid transparent;
    border-radius: 8px;
    overflow: hidden;
    background: rgba(30, 30, 30, 0.6);
    cursor: pointer;
    padding: 0;
    margin-right: 8px;
    transition: all 0.3s ease;
    opacity: 0.6;
    display: inline-block;
    vertical-align: top;
}

.madb-gallery-thumbnail:hover {
    opacity: 0.9;
    transform: translateY(-2px);
    border-color: rgba(255, 255, 255, 0.3);
}

.madb-gallery-thumbnail:last-child {
    margin-right: 0;
}

.madb-gallery-thumbnail.active {
    opacity: 1;
    border-color: #fff;
    box-shadow: 0 0 0 2px rgba(94, 101, 223, 0.86, 0.3);
}

.madb-gallery-thumb-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    pointer-events: none;
}

.madb-gallery-thumb-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(to bottom, transparent 0%, rgba(0, 0, 0, 0.1) 100%);
    pointer-events: none;
}

.madb-gallery-thumbnail.active .madb-gallery-thumb-overlay {
    background: linear-gradient(to bottom, transparent 0%, rgba(94, 101, 223, 0.86, 0.1) 100%);
}

.madb-gallery-viewport {
    position: relative;
    width: 100%;
    overflow: hidden;
    border-radius: 12px;
    background: #f5f5f5;
    aspect-ratio: 16 / 9;
    min-height: 400px;
    margin-bottom: 20px;
    display: block !important;
}

.madb-gallery-track {
    position: relative;
    width: 100%;
    height: 100%;
}

.madb-gallery-slide {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    transition: opacity 0.4s ease;
    display: block;
}

.madb-gallery-slide.active {
    opacity: 1;
    z-index: 1;
}

.madb-gallery-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    border-radius: 12px;
    min-height: 400px;
}

.madb-gallery-slide.active .madb-gallery-image {
    opacity: 1;
}

/* Old gallery styles - keep for backward compatibility with cards */
.madb-case-study-gallery-wrapper:not(.madb-gallery-new) {
    position: relative;
    margin-bottom: 30px;
}

.madb-case-study-gallery-wrapper:not(.madb-gallery-new) .displayed-image {
    position: relative;
    width: 100%;
    overflow: hidden;
    border-radius: 8px;
    background: #f5f5f5;
}

.madb-case-study-gallery-wrapper:not(.madb-gallery-new) .displayed-image img {
    width: 100%;
    height: auto;
    display: block;
}

/* Hide any old gallery implementations in modals */
.madb-post-agency-case-studies-popup-container .madb-case-study-gallery-wrapper:not(.madb-gallery-new) {
    display: none !important;
}

/* Hide any duplicate galleries or old sliders in modal */
.popup-content .madb-case-study-gallery,
.popup-inner .madb-case-study-gallery,
.project-details .madb-case-study-gallery,
.madb-post-agency-case-studies-popup-container .madb-case-study-gallery {
    display: none !important;
}

.carousel-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.5);
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 10;
    transition: background 0.2s;
}

.carousel-arrow:hover {
    background: rgba(0, 0, 0, 0.8);
}

.carousel-arrow.left {
    left: 10px;
}

.carousel-arrow.right {
    right: 10px;
}

.image-bullets {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-top: 15px;
}

.bullet {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #ddd;
    cursor: pointer;
    transition: background 0.2s;
}

.bullet.active {
    background: #fff;
}

.bullet:hover {
    background: #999;
}

.rest-of-images {
    display: none;
}

.details {
    font-size: 17px;
    line-height: 1.8;
    color: rgba(255, 255, 255, 0.9);
    margin-top: 32px;
}

.details p {
    margin-bottom: 15px;
}

.details strong {
    font-weight: 600;
    color: #fff;
}

.details blockquote {
    border-left: 4px solid #fff;
    padding-left: 24px;
    margin: 24px 0;
    font-style: italic;
    color: rgba(255, 255, 255, 0.8);
    background: rgba(94, 101, 223, 0.86, 0.1);
    padding: 20px 24px;
    border-radius: 8px;
    margin-left: 0;
}

.project-client-details {
    flex: 0 0 340px !important;
    min-width: 340px !important;
    width: 340px !important;
    max-width: 340px !important;
    flex-shrink: 0 !important;
    flex-grow: 0 !important;
    background: rgba(30, 30, 30, 0.6);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    padding: 32px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    align-self: flex-start !important;
    order: 2 !important;
    display: block !important;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

.project-client-details p {
    margin-bottom: 20px;
    font-size: 14px;
    line-height: 1.6;
}

.project-client-details p span:first-child {
    display: block;
    font-weight: 600;
    color: #fff;
    margin-bottom: 8px;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    opacity: 0.7;
}

.project-client-details .services {
    margin-top: 30px;
}

.project-client-details .services > span {
    display: block;
    font-weight: 600;
    color: #fff;
    margin-bottom: 16px;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    opacity: 0.7;
}

.services-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.each-service {
    display: inline-block;
    padding: 8px 12px;
    background: #fff;
    border-radius: 4px;
    font-size: 13px;
    color: #333;
}

.other-case-studies-container {
    overflow: hidden;
    margin-top: 48px;
}

.other-case-studies-wrapper {
    position: relative;
    padding-top: 48px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.other-case-studies-wrapper::before {
    content: 'More Case Studies';
    display: block;
    font-size: 20px;
    font-weight: 600;
    color: #fff;
    margin-bottom: 24px;
    letter-spacing: -0.3px;
}

.other-case-studies-scroll-container {
    overflow-x: auto;
    overflow-y: hidden;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.other-case-studies-scroll-container::-webkit-scrollbar {
    display: none;
}

.other-case-studies {
    display: flex;
    gap: 24px;
    padding: 0;
    align-items: stretch;
}

.other-case-studies .madb-post-agency-case-studies-card {
    min-width: 300px;
    max-width: 300px;
    flex-shrink: 0;
    background: rgba(30, 30, 30, 0.6);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: all 0.3s ease;
    cursor: pointer;
    display: flex;
    flex-direction: column;
}

.other-case-studies .madb-post-agency-case-studies-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
    border-color: rgba(255, 255, 255, 0.2);
}

.other-case-studies .madb-post-agency-case-studies-card .madb-case-study-gallery {
    width: 100%;
    height: 180px;
    overflow: hidden;
    border-radius: 12px 12px 0 0;
}

.other-case-studies .madb-post-agency-case-studies-card .madb-case-study-gallery {
    width: 100%;
    height: 180px;
    overflow: hidden;
    border-radius: 12px 12px 0 0;
    display: block !important;
}

.other-case-studies .madb-post-agency-case-studies-card .madb-case-study-gallery img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
}

.other-case-studies .madb-post-agency-case-studies-card .madb-case-study-gallery img.lazyload {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
}

.other-case-studies .madb-post-agency-case-studies-card .content {
    padding: 20px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.other-case-studies .madb-post-agency-case-studies-card .middle-content {
    margin-bottom: 12px;
}

.other-case-studies .madb-post-agency-case-studies-card .middle-content span {
    color: #fff;
    font-size: 16px;
    font-weight: 600;
    line-height: 1.4;
    display: block;
}

.other-case-studies .madb-post-agency-case-studies-card .meta {
    margin-top: auto;
}

.other-case-studies .madb-post-agency-case-studies-card .meta p {
    color: rgba(255, 255, 255, 0.7);
    font-size: 13px;
    margin: 4px 0;
    line-height: 1.5;
}

.other-case-studies .madb-post-agency-case-studies-card .meta p span {
    color: rgba(255, 255, 255, 0.9);
    font-weight: 500;
}

@media (max-width: 768px) {
    .popup-content {
        width: calc(100% - 20px);
        margin: 10px auto;
        min-height: calc(100vh - 80px);
    }
    
    .popup-inner {
        flex-direction: column !important;
        padding: 20px;
    }
    
    .popup-logo-title {
        flex-direction: column;
        text-align: center;
        gap: 10px;
    }
    
    .popup-title {
        padding: 15px;
    }
    
    .madb-case-study-title {
        font-size: 18px;
    }
    
    .project-client-details {
        min-width: 100% !important;
        width: 100% !important;
        max-width: 100% !important;
        padding: 24px;
    }
    
    .details {
        margin-top: 24px;
        font-size: 16px;
    }
    
    .other-case-studies-wrapper {
        margin-top: 32px;
        padding-top: 32px;
    }
    
    .other-case-studies .madb-post-agency-case-studies-card {
        min-width: 250px;
    }
    
    /* New gallery mobile styles - thumbnails */
    .madb-gallery-thumbnails {
        gap: 6px;
        margin-bottom: 12px;
        padding: 6px 0;
    }
    
    .madb-gallery-thumbnail {
        width: 80px;
        height: 45px;
        border-width: 1.5px;
    }
    
    .madb-gallery-viewport {
        min-height: 250px;
    }
}

