/**
 * Testimonial Modal Styles
 * Popup modal for displaying full testimonial details
 */

/* Modal Overlay - Maximum z-index override */
.testimonial-modal {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    z-index: 999999 !important;
    display: flex !important;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    box-sizing: border-box;
    /* Ensure modal creates its own stacking context and is above everything */
    isolation: isolate;
}

/* Force modal above ALL elements including header - ultimate override */
body.testimonial-modal-open .testimonial-modal,
html body.testimonial-modal-open .testimonial-modal {
    z-index: 999999 !important;
    position: fixed !important;
}

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

.testimonial-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    z-index: 1;
}

/* Modal Content Container */
.testimonial-modal-content {
    position: relative !important;
    width: 100%;
    min-width: 300px;
    max-width: 900px;
    max-height: 85vh;
    background: #ffffff;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    overflow: hidden;
    transform: scale(0.9);
    transition: transform 0.3s ease;
    z-index: 1000 !important; /* Ensure content is above overlay */
    margin: auto;
}

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

/* Close Button */
.testimonial-modal-close {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 40px;
    height: 40px;
    border: none;
    background: rgba(0, 0, 0, 0.6);
    color: #ffffff;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100 !important;
    transition: all 0.3s ease;
    padding: 0;
}

.testimonial-modal-close:hover {
    background: rgba(0, 0, 0, 0.8);
    transform: rotate(90deg);
}

.testimonial-modal-close svg {
    width: 20px;
    height: 20px;
}

/* Modal Body */
.testimonial-modal-body {
    display: flex;
    flex-direction: column;
    max-height: 90vh;
    overflow-y: auto;
}

/* Media Section */
.testimonial-modal-media {
    width: 100%;
    background: #f8f9fa;
    position: relative;
    flex-shrink: 0;
    overflow: visible;
}

.testimonial-modal-media-wrapper {
    position: relative;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: #f8f9fa;
    overflow: visible;
}

.testimonial-modal-media-wrapper img {
    max-width: 100%;
    height: auto;
    width: auto;
    max-height: 65vh;
    object-fit: contain;
    display: block;
    margin: 0 auto;
    border-radius: 20px; /* Match slider image border-radius for consistency */
}

.testimonial-modal-media-wrapper video {
    max-width: 100%;
    height: auto;
    width: auto;
    max-height: 65vh;
    object-fit: contain;
    background: #000;
    display: block;
    margin: 0 auto;
    border-radius: 20px; /* Match slider image border-radius for consistency */
}

/* Info Section */
.testimonial-modal-info {
    padding: 30px;
}

/* Header */
.testimonial-modal-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.testimonial-modal-customer-name {
    font-size: 22px;
    font-weight: 700;
    color: #1a1a1a;
    margin: 0;
    line-height: 1.2;
}

.testimonial-modal-verified {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 5px 10px;
    background: #10b981;
    color: #ffffff;
    font-size: 12px;
    font-weight: 600;
    border-radius: 20px;
    white-space: nowrap;
}

/* Rating */
.testimonial-modal-rating {
    display: flex;
    gap: 4px;
    margin-bottom: 24px;
}

.testimonial-modal-rating .star {
    font-size: 18px;
    color: #d1d5db;
    transition: color 0.2s ease;
}

.testimonial-modal-rating .star.filled {
    color: #fbbf24;
}

/* Description — <pre> keeps line breaks from stored testimonial text */
.testimonial-modal-description {
    font-family: inherit;
    font-size: 15px;
    line-height: 1.65;
    color: #374151;
    margin: 0 0 24px 0;
    padding: 0;
    white-space: pre-wrap;
    word-wrap: break-word;
    overflow-wrap: break-word;
    background: transparent;
    border: none;
    max-width: 100%;
}

/* Date */
.testimonial-modal-date {
    font-size: 13px;
    color: #9ca3af;
    font-style: italic;
}

/* Add cursor pointer to clickable testimonials */
.testimonial-image-slide {
    cursor: pointer;
    transition: transform 0.3s ease;
}

.testimonial-image-slide:hover {
    transform: scale(1.02);
}

.testimonial-content-panel {
    cursor: pointer;
    transition: transform 0.3s ease;
}

.testimonial-content-panel:hover {
    transform: scale(1.01);
}

/* Scrollbar Styling for Modal */
.testimonial-modal-body::-webkit-scrollbar {
    width: 8px;
}

.testimonial-modal-body::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.testimonial-modal-body::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

.testimonial-modal-body::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* Force modal above header - Override any stacking context issues */
.testimonial-modal {
    /* Ensure modal is in document root stacking context */
    isolation: isolate;
    /* Fix display - ensure flex is used when shown */
    display: flex !important;
}

/* Don't apply position:relative to all children - it breaks layout */
.testimonial-modal-overlay {
    position: absolute;
}

/* Responsive Design */
@media (max-width: 768px) {
    .testimonial-modal {
        padding: 10px;
        z-index: 9999999 !important; /* Even higher for mobile */
    }

    .testimonial-modal-content {
        max-width: 100%;
        max-height: 85vh;
        border-radius: 12px;
        position: relative;
        z-index: 2 !important;
    }

    .testimonial-modal-close {
        top: 10px;
        right: 10px;
        width: 36px;
        height: 36px;
    }

    .testimonial-modal-info {
        padding: 20px;
    }

    .testimonial-modal-customer-name {
        font-size: 20px;
    }

    .testimonial-modal-description {
        font-size: 14px;
    }

    .testimonial-modal-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .testimonial-modal-media-wrapper {
        padding: 15px;
    }

    .testimonial-modal-media-wrapper img,
    .testimonial-modal-media-wrapper video {
        max-height: 60vh;
    }
}

@media (max-width: 480px) {
    .testimonial-modal {
        padding: 0;
        z-index: 9999999 !important; /* Ensure highest priority on small mobile */
    }

    .testimonial-modal-content {
        border-radius: 0;
        max-height: 85vh;
    }

    .testimonial-modal-info {
        padding: 20px;
    }

    .testimonial-modal-customer-name {
        font-size: 18px;
    }

    .testimonial-modal-description {
        font-size: 13px;
        line-height: 1.6;
    }

    .testimonial-modal-rating .star {
        font-size: 16px;
    }

    .testimonial-modal-media-wrapper {
        padding: 10px;
    }

    .testimonial-modal-media-wrapper img,
    .testimonial-modal-media-wrapper video {
        max-height: 50vh;
    }
}

/* Animation for modal entrance */
@keyframes modalFadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes modalSlideUp {
    from {
        transform: translateY(50px) scale(0.9);
    }
    to {
        transform: translateY(0) scale(1);
    }
}

/* Prevent body scroll when modal is open */
body.testimonial-modal-open {
    overflow: hidden;
}

/* Lower header z-index when modal is open - Comprehensive fix for all header variations */
/* This ensures header is ALWAYS behind the modal when modal is open */
/* Using multiple selectors with highest specificity */
body.testimonial-modal-open #header,
html body.testimonial-modal-open #header,
body.testimonial-modal-open #header[data-sticky*='yes'],
body.testimonial-modal-open #header[data-sticky*='fixed'],
body.testimonial-modal-open #header[data-sticky],
body.testimonial-modal-open header#header,
html body.testimonial-modal-open header#header,
body.testimonial-modal-open .site-header,
body.testimonial-modal-open header[role="banner"],
body.testimonial-modal-open header,
body.testimonial-modal-open .ct-header,
html body.testimonial-modal-open .ct-header,
body.testimonial-modal-open #header.ct-header,
html body.testimonial-modal-open #header.ct-header,
body.testimonial-modal-open [data-header],
body.testimonial-modal-open #main-container > header,
body.testimonial-modal-open #main-container > #header {
    z-index: 1 !important; /* Force header below modal when modal is open */
    position: relative !important; /* Ensure z-index applies */
}

/* Fix for sticky header elements specifically - Blocksy theme */
/* Keep position: fixed to maintain sticky behavior, but lower z-index */
body.testimonial-modal-open [data-sticky*='yes'],
body.testimonial-modal-open [data-sticky*='fixed'],
body.testimonial-modal-open [data-sticky] {
    z-index: 1 !important;
}

/* Fix for Blocksy sticky container and all nested elements */
body.testimonial-modal-open .ct-sticky-container,
body.testimonial-modal-open .ct-sticky-container > [data-sticky],
body.testimonial-modal-open .ct-sticky-container [data-sticky],
body.testimonial-modal-open .ct-sticky-container > *,
body.testimonial-modal-open .ct-sticky-container * {
    z-index: 1 !important;
}

/* Target header rows that might have their own z-index */
body.testimonial-modal-open #header [data-row],
body.testimonial-modal-open #header [data-row*='top'],
body.testimonial-modal-open #header [data-row*='middle'],
body.testimonial-modal-open #header [data-row*='bottom'] {
    z-index: 1 !important;
}

/* Ensure all header wrapper elements are below modal */
body.testimonial-modal-open [data-header*='sticky'],
body.testimonial-modal-open [data-header*='sticky'] * {
    z-index: 1 !important;
}

/* Desktop and Mobile - ensure all header variations are covered */
@media (min-width: 769px) {
    body.testimonial-modal-open #header,
    body.testimonial-modal-open #header[data-sticky],
    body.testimonial-modal-open .site-header,
    body.testimonial-modal-open header[role="banner"],
    body.testimonial-modal-open [data-sticky],
    body.testimonial-modal-open .ct-sticky-container,
    body.testimonial-modal-open .ct-header,
    body.testimonial-modal-open [data-header] {
        z-index: 1 !important;
    }
}

@media (max-width: 768px) {
    body.testimonial-modal-open #header,
    body.testimonial-modal-open #header[data-sticky],
    body.testimonial-modal-open .site-header,
    body.testimonial-modal-open header[role="banner"],
    body.testimonial-modal-open [data-sticky],
    body.testimonial-modal-open .ct-sticky-container,
    body.testimonial-modal-open .ct-header,
    body.testimonial-modal-open [data-header] {
        z-index: 1 !important;
    }
}

