/* Modal Styles */
.mts-modal {
    display: none;
    position: fixed;
    z-index: 999999;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    overflow: hidden;
}

.mts-modal-content {
    position: relative;
    background-color: #fefefe;
    width: 100%;
    height: 100%;
    padding: 20px;
    border-radius: 0; 
    box-shadow: none; 
    display: flex; 
    flex-direction: column; 
}

/* Fixed Button Container */
.mts-fixed-container {
    position: fixed;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    z-index: 99999;
    display: flex;
    align-items: center;
}

/* Button Styles */
.mts-modal-trigger {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    padding: 14px 10px;
    background: #fff;
    color: #1a202c;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    min-width: 70px;
    min-height: 85px;
    gap: 0;
    writing-mode: initial;
    transform: translateZ(0);
    backface-visibility: hidden;
    position: relative;
    overflow: hidden;
    will-change: transform, opacity;
}

.mts-modal-trigger::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(45deg, rgba(34,113,177,0.1), rgba(34,113,177,0.05));
    opacity: 0;
    transition: opacity 0.3s ease;
}

.mts-modal-trigger::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 120%;
    height: 120%;
    background: rgba(34,113,177,0.1);
    border-radius: 50%;
    transform: translate(-50%, -50%) scale(0);
    transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 0;
}

.mts-modal-trigger-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    z-index: 1;
    transition: transform 0.3s ease;
}

.mts-modal-trigger i {
    font-size: 24px;
    margin-bottom: 8px;
    color: #2271b1;
    transition: transform 0.3s ease, color 0.3s ease;
}

.mts-modal-trigger-text {
    font-size: 13px;
    font-weight: 500;
    color: #1a202c;
    transition: color 0.3s ease;
}

/* Hover Effects */
.mts-modal-trigger:hover {
    background: #f5f7fa;
    color: #135e96;
    box-shadow: 0 4px 16px rgba(34,113,177,0.12);
    transform: translateY(-2px);
}

.mts-modal-trigger:hover::before {
    opacity: 1;
}

.mts-modal-trigger:hover i {
    transform: scale(1.1);
    color: #135e96;
}

.mts-modal-trigger:hover .mts-modal-trigger-text {
    color: #135e96;
}

/* Active/Click Effects */
.mts-modal-trigger:active {
    transform: translateY(1px);
    box-shadow: 0 2px 4px rgba(34,113,177,0.08);
}

.mts-modal-trigger:active::after {
    transform: translate(-50%, -50%) scale(1);
    opacity: 0;
}

/* Focus Effects */
.mts-modal-trigger:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(34,113,177,0.2);
}

/* Animation for Modal Open */
.mts-modal-open .mts-modal-trigger {
    transform: translateX(100%);
    opacity: 0;
    pointer-events: none;
}

/* Search Styles */
.mts-modal-header {
    padding-bottom: 20px;
    border-bottom: 1px solid #eee;
}

.mts-modal-header h2 {
    margin: 0;
    font-size: 24px;
    color: #333;
}

.mts-search-container {
    margin-bottom: 20px;
    padding-bottom: 20px;
    border-bottom: 1px solid #eee;
    position: relative;
}

#mts-search {
    width: 100%;
    padding: 10px 15px 10px 40px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 16px;
    transition: all 0.3s ease;
}

#mts-search:focus {
    outline: none;
    border-color: var(--mts-buy-button-hover-bg-color, #135e96);
    box-shadow: 0 2px 8px rgba(34, 113, 177, 0.1);
}

.mts-search-container::before {
    content: '\f002';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    position: absolute;
    left: 15px;
    top: 35%;
    transform: translateY(-50%);
    color: #666;
    font-size: 14px;
    pointer-events: none;
    transition: color 0.3s ease;
}

.mts-search-container:focus-within::before {
    color: var(--mts-buy-button-hover-bg-color, #135e96);
}

/* Add a subtle shadow when header is sticky */
.mts-modal-header::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 10px;
    background: linear-gradient(to bottom, rgba(0, 0, 0, 0.05), transparent);
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.mts-modal-header.is-sticky::after {
    opacity: 1;
}

/* Demos Grid Styles */
.mts-modal-body {
    display: flex;
    margin-top: 20px;
    position: relative;
    min-height: 0; /* Allow body to shrink if needed */
    flex-grow: 1; /* Allow body to take up remaining space */
    overflow-y: auto; /* Add scrollbar to body if content overflows */
    padding-right: 30px; /* Maintain space for sidebar if needed */
}

.mts-sidebar {
    width: 275px;
    flex-shrink: 0;
    background: #fff;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    position: sticky;
    top: 20px;
    height: fit-content;
    max-height: calc(100vh - 40px - 20px - 30px); /* Adjust max-height based on full screen */
    overflow-y: auto;
    margin-right: 30px;
}

.mts-sidebar h3 {
    margin: 0 0 15px;
    font-size: 18px;
    color: #333;
    padding: 0;
    background: none;
    z-index: auto;
}

.mts-theme-filters {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    margin-bottom: 20px;
    gap: 8px;
}

.mts-theme-filters li {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.mts-theme-filters label {
    display: flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    color: #666;
    transition: all 0.3s ease;
    padding: 6px 12px;
    border: 1px solid #ddd;
    border-radius: 16px;
    position: relative;
    text-transform: capitalize;
    background-color: #f9f9f9;
    font-size: 13px;
}

.mts-theme-filters label:hover {
    color: #333;
    background-color: #eee;
    border-color: #ccc;
}

.mts-theme-filters input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    cursor: pointer;
    height: 0;
    width: 0;
}

.mts-theme-filters input[type="checkbox"]:checked + label {
    color: #fff;
    background-color: var(--mts-buy-button-bg-color, #2271b1);
    border-color: var(--mts-buy-button-bg-color, #2271b1);
}

/* Specific colors for Builder labels with specific classes in initial state */
.mts-theme-filters label.mts-filter-elementor {
    background-color: #950841;
    border-color: #950841;
    color: #fff; /* Ensure text color is white */
}

.mts-theme-filters label.mts-filter-wpbakery {
    background-color: #0973CB;
    border-color: #0973CB;
    color: #fff; /* Ensure text color is white */
}

.mts-theme-filters label.active {
    color: #fff;
    background-color: var(--mts-buy-button-bg-color, #2271b1);
    border-color: var(--mts-buy-button-bg-color, #2271b1);
}

.mts-theme-filters label.selected {
    background-color: #fff;
    color: var(--mts-buy-button-bg-color, #2271b1);
    border-color: var(--mts-buy-button-bg-color, #2271b1);
    font-weight: bold;
}

.mts-theme-filters label.selected::after {
    content: none;
    /* The rest of the style remains for spacing, but no icon will show */
}

.mts-selected-count {
    font-size: 14px;
    color: #666;
    margin-left: 5px;
}

.mts-demos-grid {
    display: grid;
    grid-template-columns: repeat(var(--mts-columns, 3), 1fr);
    gap: 30px;
    padding: 0;
    min-width: 0;
}

/* Adjust height for 2 columns */
.mts-demos-grid[style*="--mts-columns: 2"] .mts-demo-item,
.mts-demos-grid[style*="--mts-columns: 2"] .mts-demo-image {
    max-height: 400px;
}

.mts-demo-item {
    position: relative;
    width: 100%;
    min-height: 400px;
    display: flex;
    flex-direction: column;
    background: #fff;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease, opacity 0.3s ease;
    opacity: 1;
    visibility: visible;
    transform: translateZ(0);
    backface-visibility: hidden;
    will-change: transform, opacity;
}

.mts-demo-item.filtering-out {
    display: none;
    /* Ensure no residual layout impact */
    width: 0 !important;
    height: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
    border: none !important;
    opacity: 0 !important;
    visibility: hidden !important;
    transform: none !important;
    transition: none !important;
}

.mts-demo-item.filtering-in {
    /* Remove animation and will-change to prevent layout issues */
    animation: none !important;
    will-change: auto !important;
    transform: none !important;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translate3d(0, 20px, 0);
    }
    to {
        opacity: 1;
        transform: translate3d(0, 0, 0);
    }
}

.mts-demo-item:hover {
    transform: scale3d(0.98, 0.98, 1);
    will-change: transform;
}

.mts-demo-link {
    display: block;
    width: 100%;
    height: 100%;
    text-decoration: none;
    color: inherit;
}

.mts-demo-count-display {
    text-align: right;
    margin-bottom: 10px;
}

.mts-demo-image {
    position: relative;
    width: 100%;
    height: 350px;
    background-size: cover;
    background-position: top;
    display: flex;
    flex-direction: column-reverse;
    background-color: #f5f5f5;
}

.mts-demo-info {
    padding: 20px;
    background: #fff;
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.mts-demo-info h3 {
    margin: 0 0 10px;
    font-size: 1.2em;
    line-height: 1.2;
    color: #333;
}

.mts-demo-info p {
    margin: 0;
    font-size: 0.9em;
    color: #666;
    line-height: 1.4;
}

.mts-demo-content,
.mts-demo-actions,
.mts-demo-preview-button {
    display: none !important;
}

.mts-demos-grid .mts-demo-item:only-child:not(.filtering-out) {
    grid-column: span var(--mts-columns, 3);
    min-height: 400px;
}

.mts-demos-grid .mts-demo-item:only-child:not(.filtering-out) .mts-demo-image {
    min-height: 400px;
}

.mts-buy-theme-container {
    margin-bottom: 20px;
    padding-bottom: 20px;
    border-bottom: 1px solid #eee;
}

.mts-buy-theme-button {
    display: block;
    width: 100%;
    padding: 12px 20px;
    background: var(--mts-buy-button-bg-color, #2271b1);
    color: #fff !important;
    text-align: center;
    text-decoration: none;
    border-radius: 6px;
    font-weight: 500;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.mts-buy-theme-button:hover {
    background: var(--mts-buy-button-hover-bg-color, #135e96);
    color: #fff;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(34, 113, 177, 0.2);
}

/* Animation Keyframes */
@keyframes slideInRight {
    from {
        transform: translateX(100%);
    }
    to {
        transform: translateX(0);
    }
}

@keyframes slideOutRight {
    from {
        transform: translateX(0);
    }
    to {
        transform: translateX(100%);
    }
}

/* Animation Classes */
.mts-modal.slide-in .mts-modal-content {
    animation: slideInRight 0.5s ease-out forwards;
}

.mts-modal.slide-out .mts-modal-content {
    animation: slideOutRight 0.5s ease-in forwards;
}

/* Hide modal content initially when animating out */
.mts-modal.slide-out {
    display: block; /* Keep the backdrop visible during animation */
}

/* Ensure content is visible during slide-in */
.mts-modal.slide-in {
    display: block;
}

/* Media query adjustments for small screens */
@media screen and (max-width: 768px) {
    .mts-modal-content {
        padding: 10px;
    }

    .mts-modal-body {
        flex-direction: column;
        padding-right: 0;
    }

    .mts-sidebar {
        width: 100%;
        position: static;
        margin-right: 0;
        margin-bottom: 20px;
        max-height: none;
        overflow-y: visible;
    }

    /* Hide Keywords category on mobile */
    .mts-sidebar h3:contains('Keywords') {
        display: none;
    }

    .mts-sidebar h3:contains('Keywords') + ul.mts-theme-filters {
        display: none;
    }

    .mts-demos-grid {
        grid-template-columns: 1fr 1fr;
    }

    .mts-modal-trigger {
        min-height: 80px;
        padding: 10px 20px;
    }

    .mts-modal-trigger i {
        font-size: 28px;
    }

    .mts-modal-trigger-text {
        font-size: 14px;
    }

    .mts-theme-filters {
        margin-bottom: 0;
    }
    .mts-theme-filters-wrapper {
        margin-top: 20px;
    }

    .mts-filter-accordion-toggle {
        justify-content: flex-start;
        gap: 0;
    }
    .mts-filter-accordion-toggle .mts-selected-count {
        margin-left: auto;
        margin-right: 4px;
        font-size: 15px;
    }
    .mts-filter-accordion-toggle::after {
        margin-left: 0;
    }
}

.mts-demo-grid-wrapper {
    flex: 1;
    min-width: 0;
}

/* Close button styles */
.mts-close {
    position: absolute;
    top: 10x; 
    right: 10px; 
    background: none;
    border: none;
    font-size: 24px; 
    cursor: pointer;
    color: #666; 
    z-index: 1000000; 
    transition: color 0.3s ease;
}

.mts-close:hover {
    color: #ffffff; /* Darker color on hover */
    background-color: #2271B1;
}

.mts-close:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(34,113,177,0.2); /* Focus indicator */
}

/* Badge on demo card */
.mts-demo-badges {
    position: absolute;
    top: 16px;
    right: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 2;
    align-items: flex-end;
}

.mts-demo-badge {
    --color-ribbon: #2ecc40;
    position: relative;
    background: var(--color-ribbon);
    color: #fff;
    font-weight: bold;
    font-size: 15px;
    padding: 6px 32px 6px 28px;
    border-radius: 0;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    text-transform: uppercase;
    letter-spacing: 1px;
    overflow: visible;
    display: inline-block;
    margin-right: 0;
    right: 0;
}

.mts-demo-badge::before {
    content: "";
    z-index: 2;
    height: 100%;
    border-top: 16px solid var(--color-ribbon);
    border-left: 8px solid transparent;
    border-bottom: 16px solid var(--color-ribbon);
    left: -7px;
    top: 0;
    position: absolute;
}

.mts-demo-item {
    position: relative;
}

.mts-demo-builders-row {
    margin-bottom: 8px;
    display: flex;
    gap: 8px;
}

.mts-demo-builder {
    display: inline-block;
    padding: 2px 7px;
    border-radius: 3px;
    font-size: 11px;
    font-weight: 600;
    color: #fff;
    background: #888;
    margin-right: 0;
    text-transform: capitalize;
    letter-spacing: 0.5px;
}
.mts-demo-builder.mts-builder-elementor {
    background: #950841;
}
.mts-demo-builder.mts-builder-wpbakery {
    background: #0973CB;
}

.mts-demo-badge.badge-unique {
    --color-ribbon: #c0392b;
    background: #c0392b;
}
.mts-demo-badge.badge-new {
    --color-ribbon: #866DEC;
    background: #866DEC;
}
.mts-demo-badge.badge-most-wanted {
    --color-ribbon: #39B86B;
    background: #39B86B;
}
.mts-filter-accordion-group {
    margin-bottom: 20px;
}

.mts-filter-accordion-toggle {
    width: 100%;
    background: #f5f5f5;
    border: none;
    outline: none;
    padding: 12px 16px;
    text-align: left;
    font-size: 16px;
    font-weight: 600;
    color: #333;
    cursor: pointer;
    border-radius: 6px;
    margin-bottom: 0;
    transition: background 0.2s;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.mts-filter-accordion-toggle.active,
.mts-filter-accordion-toggle:focus {
    background: #e0e7ef;
}
.mts-filter-accordion-toggle::after {
    content: '\25BC';
    font-size: 14px;
    margin-left: 8px;
    transition: transform 0.2s;
}
.mts-filter-accordion-toggle.active::after {
    transform: rotate(-180deg);
}
@media screen and (min-width: 769px) {
    .mts-filter-accordion-toggle {
        display: none;
    }
    .mts-theme-filters-wrapper {
        display: block !important;
    }
}

@media screen and (max-width: 768px) {
    .mts-theme-filters {
        margin-top: 15px;
    }
    .mts-demo-item {
        min-height: 200px;
    }
    .mts-demo-image {
        height: 200px;
    }
    .mts-search-container {
        display: none;
    }
    .mts-demo-info {
        padding: 10px;
    }
    .mts-demo-badge {
        font-size: 10px;
    }
    .mts-sidebar {
        box-shadow: none;
    }
    .mts-demo-badge::before {
        content: "";
        z-index: 2;
        height: 100%;
        border-top: 11px solid var(--color-ribbon);
        border-left: 8px solid transparent;
        border-bottom: 11px solid var(--color-ribbon);
        left: -7px;
        top: 0;
        position: absolute;
    }
    .mts-modal-body {
        margin-top: 10px;
    }
}

.mts-theme-filters-wrapper {
    padding: 0 0 0 0;
    background: none;
    border-radius: 0 0 8px 8px;
}
.mts-filter-section {
    margin-bottom: 18px;
}
.mts-filter-section-title {
    font-size: 15px;
    font-weight: 600;
    color: #666;
    margin-bottom: 8px;
    margin-top: 8px;
}
@media screen and (max-width: 768px) {
    .mts-filter-section {
        margin-bottom: 10px;
    }
    .mts-theme-filters-wrapper {
        padding: 0;
    }
}

@media screen and (min-width: 769px) {
    .mts-modal-body {
        flex-direction: row;
    }
    .mts-sidebar {
        width: 275px;
        flex-shrink: 0;
        margin-right: 30px;
        position: sticky;
        top: 20px;
        height: fit-content;
        max-height: calc(100vh - 40px - 20px - 30px);
        overflow-y: auto;
    }
    .mts-demo-grid-wrapper {
        flex: 1;
        min-width: 0;
    }
}