/**
 * MyMirror Testimonials - Front-end Styles
 */

.mymirror-testimonials-wrapper {
    width: 100%;
    margin: 0 auto;
}

.mmt-testimonials-grid {
    display: grid;
    gap: 20px;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
}

/* Regular Grid Layout - override default auto-fill */
[data-mmt-layout="grid"] .mmt-testimonials-grid,
[data-mmt-masonry="grid"] .mmt-testimonials-grid {
    /* JavaScript will set grid-template-columns dynamically */
    grid-auto-rows: auto;
}

/* Masonry.js Layout - remove CSS Grid */
[data-mmt-layout="masonry_js"] .mmt-testimonials-grid,
[data-mmt-masonry="masonry_js"] .mmt-testimonials-grid {
    display: block !important;
    grid-template-columns: none !important;
}

/* Masonry CSS Grid Layout */
[data-mmt-layout="css_grid"] .mmt-testimonials-grid,
[data-mmt-masonry="css_grid"] .mmt-testimonials-grid {
    display: grid !important;
    grid-auto-rows: 1px;
    align-items: start;
    /* JavaScript will set grid-template-columns dynamically */
}

/* CSS Grid cards need proper height handling */
[data-mmt-layout="css_grid"] .mmt-testimonial-card,
[data-mmt-masonry="css_grid"] .mmt-testimonial-card {
    height: auto;
    overflow: visible;
}

/* -------------------------------------------------
   GRID EQUAL HEIGHT LAYOUT
   ------------------------------------------------- */
[data-mmt-layout="grid_equal_height"] .mmt-testimonials-grid {
    display: grid !important;
    grid-auto-rows: auto;
    align-items: stretch;
    /* JavaScript will set grid-template-columns dynamically */
}

/* Equal height cards stretch to fill row */
[data-mmt-layout="grid_equal_height"] .mmt-testimonial-card {
    height: 100%;
    display: flex;
    flex-direction: column;
}

/* Per-row mode: each row has independent height */
[data-mmt-layout="grid_equal_height"][data-mmt-grid-height-mode="per_row"] .mmt-testimonials-grid {
    /* Grid auto-rows handles per-row height automatically */
    grid-auto-rows: auto;
}

/* Tallest card mode: all cards match tallest one - set by JavaScript */
[data-mmt-layout="grid_equal_height"][data-mmt-grid-height-mode="tallest_card"] .mmt-testimonials-grid {
    /* grid-auto-rows will be set by JavaScript to fixed pixel value */
}

/* Equal height card content distribution */
[data-mmt-layout="grid_equal_height"] .mmt-testimonial-card .mmt-testimonial-text {
    flex: 1;
}

/* Push author info to bottom in equal height mode */
[data-mmt-layout="grid_equal_height"] .mmt-testimonial-card .mmt-author-info,
[data-mmt-layout="grid_equal_height"] .mmt-testimonial-card .mmt-author-name,
[data-mmt-layout="grid_equal_height"] .mmt-testimonial-card .mmt-author-title,
[data-mmt-layout="grid_equal_height"] .mmt-testimonial-card .mmt-source-link {
    margin-top: auto;
}

/* Testimonial Card */
.mmt-testimonial-card {
    background: #ffffff;
    padding: 24px;
    border-radius: 8px;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    gap: 16px;
    cursor: pointer;
    box-sizing: border-box; /* Include padding in width calculation */
    overflow: hidden; /* Prevent content overflow */
    min-width: 0; /* Allow flex/grid children to shrink below content size */
}

/* Masonry.js - cards need width set by JavaScript */
[data-mmt-masonry="masonry_js"] .mmt-testimonial-card {
    width: auto; /* Will be set by JavaScript */
}

/* Grid layouts - cards fill their grid cell */
[data-mmt-masonry="grid"] .mmt-testimonial-card,
[data-mmt-masonry="css_grid"] .mmt-testimonial-card {
    width: 100%;
}

/* Card Presets */
.mmt-card-basic {
    border: 1px solid #e0e0e0;
}

.mmt-card-shadow {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.mmt-card-shadow:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
    transform: translateY(-2px);
}

.mmt-card-minimal {
    background: transparent;
    border-left: 3px solid #2271b1;
    padding-left: 20px;
}

/* Rating Stars */
.mmt-rating {
    display: flex;
    align-items: center;
    gap: 4px;
}

.mmt-stars {
    display: flex;
    gap: 2px;
}

.mmt-star {
    font-size: 18px;
    line-height: 1;
}

.mmt-star-full {
    color: #ffa500;
}

.mmt-star-half {
    color: #ffa500;
    opacity: 0.5;
}

.mmt-star-empty {
    color: #d0d0d0;
}

/* Testimonial Title */
.mmt-testimonial-title {
    font-size: 18px;
    font-weight: 600;
    line-height: 1.3;
    color: #333333;
    margin: 0 0 8px 0;
    word-break: break-word;
    overflow-wrap: break-word;
}

/* Testimonial Text */
.mmt-testimonial-text {
    font-size: 16px;
    line-height: 1.6;
    color: #333333;
    word-break: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
}

.mmt-testimonial-text p:first-child {
    margin-top: 0;
}

.mmt-testimonial-text p:last-child {
    margin-bottom: 0;
}

.mmt-testimonial-text strong {
    font-weight: 700;
}

.mmt-testimonial-text em {
    font-style: italic;
}

.mmt-testimonial-text a {
    color: #2271b1;
    text-decoration: underline;
}

.mmt-testimonial-text a:hover {
    color: #135e96;
}

/* Read More Link */
.mmt-read-more {
    color: #2271b1;
    cursor: pointer;
    font-style: italic;
    white-space: nowrap;
}

.mmt-read-more:hover {
    color: #135e96;
    text-decoration: underline;
}

/* Text Truncation */
.mmt-testimonial-text.mmt-truncated {
    position: relative;
}

.mmt-read-more {
    color: #2271b1;
    font-weight: 500;
    margin-top: 8px;
    display: inline-block;
}

/* Lightbox */
.mmt-lightbox {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 999999;
    align-items: center;
    justify-content: center;
}

.mmt-lightbox.mmt-active {
    display: flex;
}

.mmt-lightbox-content {
    background: #ffffff;
    width: 90%;
    max-width: 800px;
    max-height: 90vh;
    border-radius: 12px;
    position: relative;
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.mmt-lightbox-card {
    padding: 60px 100px 40px 100px; /* Extra horizontal padding for nav arrows */
}

.mmt-lightbox-close {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 40px;
    height: 40px;
    background: #f0f0f0;
    border: none;
    border-radius: 50%;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    transition: all 0.2s;
    z-index: 10;
}

.mmt-lightbox-close:hover {
    background: #e0e0e0;
    transform: rotate(90deg);
}

.mmt-lightbox-nav {
    position: fixed !important; /* Fixed to viewport, not relative to content */
    top: 50% !important;
    transform: translateY(-50%) !important;
    width: 50px !important;
    height: 50px !important;
    background: rgba(255, 255, 255, 0.9) !important;
    border: none !important;
    border-radius: 50% !important;
    font-size: 24px !important;
    cursor: pointer;
    transition: all 0.2s;
    z-index: 1000000 !important; /* Above lightbox content */
    /* Force visibility - prevent theme/plugin conflicts */
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    pointer-events: auto !important;
}

.mmt-lightbox-nav:hover {
    background: #ffffff;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.mmt-lightbox-prev {
    left: 20px;
}

.mmt-lightbox-next {
    right: 20px;
}

.mmt-lightbox-nav:disabled {
    opacity: 0.3 !important;
    cursor: not-allowed !important;
}

/* Lightbox responsive */
@media (max-width: 768px) {
    .mmt-lightbox-content {
        width: 95%;
        max-height: 95vh;
    }

    .mmt-lightbox-card {
        padding: 24px 20px; /* Arrows are position:fixed, no need for large side padding */
    }

    .mmt-lightbox-nav {
        width: 40px;
        height: 40px;
        font-size: 20px;
        /* Keep fixed positioning on mobile too */
    }

    .mmt-lightbox-prev {
        left: 10px;
    }

    .mmt-lightbox-next {
        right: 10px;
    }
}

/* Author Info */
.mmt-author-info {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: auto;
}

.mmt-author-avatar {
    flex-shrink: 0;
}

.mmt-author-avatar img {
    display: block;
    object-fit: cover;
    /* width and height are set via HTML attributes from Avatar Size setting */
}

.mmt-author-avatar-rounded img {
    border-radius: 50%;
}

.mmt-author-details {
    flex: 1;
    min-width: 0;
}

.mmt-author-name {
    font-weight: 600;
    font-size: 16px;
    color: #000000;
    margin-bottom: 4px;
}

.mmt-author-title {
    font-size: 14px;
    color: #666666;
    margin-bottom: 2px;
}

.mmt-author-location {
    font-size: 13px;
    color: #999999;
}

.mmt-testimonial-date {
    font-size: 13px;
    color: #999999;
    margin-top: 2px;
}

/* Verified Badge */
.mmt-verified-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 13px;
    color: #0a8f3e;
    font-weight: 500;
}

.mmt-verified-badge .dashicons {
    width: 16px;
    height: 16px;
    font-size: 16px;
}

/* Source Link */
.mmt-source-link {
    font-size: 14px;
}

.mmt-source-link a {
    color: #2271b1;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: color 0.2s ease;
}

.mmt-source-link a::after {
    content: '→';
    display: inline-block;
    transition: transform 0.3s ease;
}

.mmt-source-link a:hover {
    text-decoration: underline;
}

.mmt-source-link a:hover::after {
    transform: translateX(4px);
}

/* Cards with source URL — clickable with visual hint */
.mmt-testimonial-card.mmt-has-link {
    cursor: pointer;
    position: relative;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

/* Link icon in top-right corner */
.mmt-link-icon {
    position: absolute;
    top: 10px;
    right: 10px;
    font-size: 14px;
    opacity: 0.4;
    transition: opacity 0.2s ease;
    z-index: 5;
}

/* Desktop hover effects */
.mmt-testimonial-card.mmt-has-link:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12);
}

.mmt-testimonial-card.mmt-has-link:hover .mmt-link-icon {
    opacity: 0.8;
}

/* Mobile — icon always slightly visible as hint */
@media (max-width: 768px) {
    .mmt-link-icon {
        opacity: 0.5;
    }
}

/* Responsive Breakpoints */
@media (max-width: 1199px) {
    /* Desktop Mid */
}

@media (max-width: 899px) {
    /* Tablet */
    .mmt-testimonials-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .mmt-testimonial-card {
        padding: 20px;
    }
}

@media (max-width: 599px) {
    /* Mobile */
    .mmt-testimonials-grid {
        grid-template-columns: 1fr;
    }

    .mmt-testimonial-card {
        padding: 16px;
    }

    .mmt-testimonial-text {
        font-size: 15px;
    }
}

/* Animation Classes */
.mmt-testimonial-card.mmt-animate-fade {
    animation: mmtFadeIn 0.3s ease-in;
}

@keyframes mmtFadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.mmt-testimonial-card.mmt-animate-slide {
    animation: mmtSlideUp 0.3s ease-out;
}

@keyframes mmtSlideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Loading State */
.mmt-testimonials-grid.mmt-loading {
    opacity: 0.6;
    pointer-events: none;
}

/* -------------------------------------------------
   ELEMENTOR COMPATIBILITY
   Fix Elementor container conflicts
   ------------------------------------------------- */

/* Reset Elementor container styles that may conflict with grid */
.elementor-widget-container .mymirror-testimonials-wrapper,
.elementor-element .mymirror-testimonials-wrapper {
    width: 100% !important;
    max-width: 100% !important;
}

/* Elementor Pro containers - ensure proper sizing */
.e-con .mymirror-testimonials-wrapper,
.e-con-inner .mymirror-testimonials-wrapper {
    width: 100% !important;
    max-width: 100% !important;
}

/* Elementor v4 flex container fixes */
.e-con > .elementor-widget-container .mymirror-testimonials-wrapper {
    flex: 1 1 auto;
    min-width: 0;
}

/* Fix for Elementor tabs, accordion, toggle widgets */
.elementor-tab-content .mymirror-testimonials-wrapper,
.elementor-accordion-content .mymirror-testimonials-wrapper,
.elementor-toggle-content .mymirror-testimonials-wrapper {
    width: 100% !important;
}

/* Ensure cards don't overflow in Elementor containers */
.elementor-widget-container .mmt-testimonial-card,
.e-con .mmt-testimonial-card {
    max-width: 100%;
    box-sizing: border-box;
}

/* Elementor editor preview fix - ensure visibility */
.elementor-editor-active .mymirror-testimonials-wrapper {
    min-height: 100px;
}

/* Fix potential button style conflicts from Elementor themes */
.mmt-lightbox button,
.mmt-lightbox-close,
.mmt-lightbox-nav {
    padding: 0 !important;
    border: none !important;
    background-color: transparent;
    line-height: 1 !important;
}

.mmt-lightbox-close {
    background: #f0f0f0 !important;
}

.mmt-lightbox-nav {
    background: rgba(255, 255, 255, 0.9) !important;
}

/* Prevent Elementor global font overrides */
.mymirror-testimonials-wrapper .mmt-testimonial-card {
    font-family: inherit;
}

/* -------------------------------------------------
   AVATAR STANDALONE STYLES
   ------------------------------------------------- */
.mmt-author-avatar {
    flex-shrink: 0;
    display: flex; /* Default to flex for alignment support */
    justify-content: flex-start; /* Default left alignment */
}

.mmt-author-avatar img {
    display: block;
    object-fit: cover;
    /* width and height are set via HTML attributes from Avatar Size setting */
}

/* Avatar alignment classes */
/* Use flexbox for reliable alignment */
.mmt-author-avatar.mmt-avatar-left {
    display: flex;
    justify-content: flex-start;
}

.mmt-author-avatar.mmt-avatar-center {
    display: flex;
    justify-content: center;
}

.mmt-author-avatar.mmt-avatar-right {
    display: flex;
    justify-content: flex-end;
}
