/* ==========================================================================
   Base
   ========================================================================== */

.woolentor-ready-templates,
.woolentor-ready-templates *,
.template-modal,
.template-modal * {
    box-sizing: border-box;
}

.woolentor-ready-templates {
    margin: 0;
    min-height: 100vh;
    color: #18233f;
    background: #f9f9f9;
    isolation: isolate;
}

body.modal-open {
    overflow: hidden;
}

.woolentor-ready-templates button,
.woolentor-ready-templates input,
.woolentor-ready-templates select,
.template-modal button,
.template-modal input,
.template-modal select {
    font: inherit;
}

.woolentor-ready-templates button,
.template-modal button {
    cursor: pointer;
}

.woolentor-ready-templates .sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ==========================================================================
   Layout Shell
   ========================================================================== */

   .woolentor-ready-templates .explorer-shell {
    display: grid;
    grid-template-columns: 300px minmax(0, 1fr);
    gap: 0;
    background: #fff;
    align-content: start;
    align-items: start;
}

.sidebar-panel,
.content-panel {
    min-width: 0;
}

.sidebar-panel {
    position: sticky;
    top: calc(var(--wp-admin--admin-bar--height, 0px) + 67px);
    align-self: start;
    display: flex;
    flex-direction: column;
    gap: 32px;
    max-height: calc(100vh - var(--wp-admin--admin-bar--height, 0px) - 40px);
    overflow-y: auto;
    justify-content: flex-start;
    background: #fff;
    border-right: 1px solid #d8d8d8;
    border-radius: 16px 0 16px 16px;
    box-shadow: 0 4px 50px 0 #0000000d;
    scrollbar-width: thin;
    scrollbar-color: #c5cbd5 transparent;
}

.sidebar-panel::-webkit-scrollbar {
    width: 6px;
}

.sidebar-panel::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar-panel::-webkit-scrollbar-thumb {
    background: #c5cbd5;
    border-radius: 999px;
}

.content-panel {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.templates-anchor {
    position: absolute;
    top: 0;
    left: 0;
    width: 1px;
    height: 1px;
    overflow: hidden;
    scroll-margin-top: var(--woolentor-ready-templates-sticky-top, calc(var(--wp-admin--admin-bar--height, 0px) + 67px));
    pointer-events: none;
}

/* ==========================================================================
   Sidebar
   ========================================================================== */

.sidebar-header-top {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 20px 20px 0;
}

.sidebar-title {
    margin: 0;
    color: #1c1c1d;
    font-size: clamp(14px, 0.875rem + ((1vw - 3.2px) * 0.412), 18px);
    line-height: 1.66;
}

.sidebar-border {
    border-top: 1px solid #d8d8d8;
}

.sidebar-controls {
    display: flex;
    flex-direction: column;
    gap: 20px;
    padding: 0 20px;
}

.category-nav {
    display: grid;
    gap: 18px;
    padding: 0 20px 20px 20px;
}

#category-list {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.category-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    width: 100%;
    padding: 8px 12px;
    background: transparent;
    border: 0.5px solid transparent;
    border-radius: 6px;
    text-align: left;
    font-weight: 700;
}

.category-item span {
    color: #1c1c1d;
    font-size: 16px;
    line-height: 1.63;
}

.category-item strong {
    padding: 3px 7px;
    border-radius: 999px;
    background: #e8f3ff;
    color: #3489fe;
    font-size: 12px;
    font-weight: 500;
    text-align: center;
    line-height: 1;
}

.category-item.is-active {
    background: #e8f3ff;
    border-color: #d1e6ff;
    box-shadow: 0 0 0 1px #e1efff;
}

.category-item.is-active span {
    color: #3489fe;
}

.category-item.is-active strong {
    background: #3489fe;
    color: #fff;
}

/* ==========================================================================
   Filters And Form Controls
   ========================================================================== */

.field select, 
.search-field input {
    width: 100%;
    min-height: 41px;
    padding: 0 16px;
    color: rgba(115, 115, 115, 1);
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid rgba(27, 46, 89, 0.12);
    border-radius: 6px;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
    font-size: 14px;
}

.field select,
#builder-filter {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg width='14' height='14' viewBox='0 0 14 14' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M13.5875 3.87098C13.3597 3.64321 12.9904 3.64321 12.7627 3.87098L7.41233 9.22131C7.30142 9.32776 7.15365 9.3872 6.99992 9.3872C6.84619 9.3872 6.69841 9.32776 6.5875 9.22131L1.24067 3.87393C1.0129 3.64614 0.643593 3.64613 0.415814 3.87391C0.18805 4.10167 0.188041 4.47095 0.415793 4.69872L5.76267 10.0461C6.09625 10.3641 6.53939 10.5414 7.00021 10.5414C7.46103 10.5414 7.90417 10.3641 8.23775 10.0461L13.5875 4.69582C13.8153 4.46804 13.8153 4.09875 13.5875 3.87098Z' fill='%23737373'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 16px center;
    background-size: 14px 14px;
}

.field select:focus,
.search-field input:focus {
    border-color: rgba(79, 124, 255, 0.35);
    box-shadow: 0 0 0 4px rgba(79, 124, 255, 0.12);
}

#builder-filter {
    padding: 0 44px 0 12px;
    font-size: 16px;
    border-radius: 6px;
    border: 1px solid #d8d8d8;
}

#builder-filter:focus {
    border: 1px solid #d8d8d8 !important;
    box-shadow: none !important;
}

.type-tabs {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
    padding: 4px;
    background: #e8f3ff;
    border-radius: 6px;
    box-shadow: 0 0 4px 0 #00000012 inset;
}

.type-tabs button {
    min-height: 36px;
    padding: 0;
    color: #1c1c1d;
    background: transparent;
    border: 0;
    border-radius: 4px;
    font-size: 16px;
    line-height: 1.63;
    font-weight: 300;
}

.type-tabs button.is-active {
    color: #3489fe;
    background: #fff;
    box-shadow: 0 0 2px 0 #0000001a;
}

.search-field {
    position: relative;
    display: block;
    min-width: min(100%, 224px);
}

.search-field svg {
    position: absolute;
    top: 50%;
    left: 16px;
    width: 18px;
    height: 18px;
    fill: none;
    stroke: #97a1bf;
    stroke-width: 2;
    transform: translateY(-50%);
    pointer-events: none;
}

.search-field input {
    padding-left: 44px;
}

.field-compact {
    min-width: 149px;
}

/* ==========================================================================
   Toolbar
   ========================================================================== */

.toolbar-title-text {
    margin: 0;
    color: #110f21;
    font-size: clamp(18px, 1.05rem + 0.5vw, 22px);
    font-weight: 500;
}

.toolbar-title p:last-child {
    display: none;
    margin: 10px 0 0;
    color: #7480a3;
}

.content-toolbar {
    position: sticky;
    top: var(--woolentor-ready-templates-sticky-top, calc(var(--wp-admin--admin-bar--height, 0px) + 67px));
    z-index: 30;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 15px 20px;
    background: #fff;
    border-radius: 0 16px 16px 0;
    box-shadow: 0px 4px 50px 0px #0000000D;
}

.toolbar-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    flex-wrap: wrap;
}

#refresh-data {
    width: 34px;
    height: 34px;
    padding: 0 !important;
    background: transparent;
    border: none;
}

#status-panel {
    padding-left: 30px;
}

.status-card {
    width: 100%;
    padding: 16px 18px;
    color: #7480a3;
    background: rgba(255, 255, 255, 0.72);
    border: 1px solid rgba(27, 46, 89, 0.12);
    border-radius: 10px;
    font-weight: 500;
}

.status-card.is-loading {
    background: linear-gradient(
        90deg,
        rgba(233, 241, 255, 0.9),
        rgba(255, 255, 255, 0.95),
        rgba(233, 241, 255, 0.9)
    );
    background-size: 200% 100%;
    animation: shimmer 1.2s linear infinite;
}

.status-card.is-error {
    color: #a03d14;
    background: #fff3eb;
    border-color: rgba(204, 94, 37, 0.18);
}

/* ==========================================================================
   Cards Grid
   ========================================================================== */

.templates-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 22px;
    padding-left: 30px;
}
.quick-link span {
    font-size: 14px;
    font-weight: normal;
}
.template-card {
    display: flex;
    flex-direction: column;
    min-width: 0;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 12px 50px 0 #00000012;
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.template-card:hover {
    border-color: rgba(79, 124, 255, 0.24);
    box-shadow: 0 24px 48px rgba(62, 93, 158, 0.14);
}

.card-media {
    position: relative;
    aspect-ratio: 300 / 188;
    overflow: hidden;
    background: transparent;
}

.card-media img {
    position: absolute;
    width: 100%;
    box-shadow: 0 20px 35px rgba(6, 18, 55, 0.3);
}

.template-status-badge {
    position: absolute;
    top: 15px;
    left: 15px;
    z-index: 2;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px 9px;
    color: #fff;
    background: #3489fe;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 500;
    line-height: 1;
}

.card-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    background: rgba(0, 0, 0, 0.6);
    transition: opacity 0.24s ease;
}

.template-card:hover .card-overlay {
    opacity: 1;
}

.quick-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 44px;
    padding: 0 32px;
    color: #1c1c1d;
    background: #fff;
    border: none;
    border-radius: 6px;
    box-shadow: 0 20px 35px rgba(18, 29, 59, 0.14);
    font-size: 14px;
    line-height: 1;
}

.quick-link svg {
    width: 16px;
    height: 16px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
}

.card-body {
    display: grid;
    gap: 17px;
    padding: 14px 14px 13px;
}
.meta-title-area {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.meta-row {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 12px;
    flex-wrap: wrap;
}

.builder-badge {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    min-height: 22px;
    padding: 0 6px;
    border: 1px solid transparent;
    border-radius: 999px;
    font-size: 10px;
    line-height: 1;
}

.builder-badge img {
    width: 11px;
    height: 11px;
}

.builder-badge--elementor {
    color: #3489fe;
    background: #fff;
    border-color: #3489fe;
}

.builder-badge--gutenberg {
    color: #2563eb;
    background: #fff;
    border-color: #2563eb;
}

.builder-badge--default {
    color: #4b5563;
    background: #fff;
    border-color: #d1d5db;
}

.title-row {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 6px;
    flex-wrap: wrap;
}

.title-row h3 {
    margin: 0;
    color: #110f21;
    font-size: 16px;
    line-height: 1.62;
}

.plan-chip {
    padding: 3.63px 9.07px;
    color: #ff8c29;
    background: transparent;
    border: 0.91px solid #ff8400;
    border-radius: 999px;
    font-size: 10px;
    font-weight: 500;
    line-height: 1;
}

.card-footer {
    display: flex;
    gap: 12px;
}

.demo-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    width: 100%;
    min-height: 40px;
    color: #3489fe;
    background: #e8f3ff;
    border: 0.45px solid #d1e6ff;
    border-radius: 7px;
    box-shadow: 0 0 0 0.91px #e1efff;
    text-decoration: none;
    font-size: 14px;
    font-weight: 400;
}

.demo-link svg {
    width: 10px;
    height: 10px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
}

/* ==========================================================================
   Empty State
   ========================================================================== */

    .empty-state {
        grid-column: 1 / -1;
        padding: 56px 24px;
        color: #7480a3;
        background: rgba(255, 255, 255, 0.65);
        border: 1px dashed rgba(116, 128, 163, 0.34);
        border-radius: 24px;
        text-align: center;
        display: flex;
        flex-direction: column;
        justify-content: center;
        gap: 15px;
    }
    .empty-state h3, 
    .empty-state p {
        margin: 0;
    }

/* ==========================================================================
   Modal Preview
   ========================================================================== */

.template-modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: none;
}

.template-modal.is-open {
    display: block;
}

.template-modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(17, 15, 33, 0.45);
    backdrop-filter: blur(2px);
}

.template-modal__dialog {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    gap: 20px;
    width: min(700px, calc(100% - 32px));
    margin: 40px auto;
    background: #fff;
    border-radius: 20px;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.18);
    overflow: hidden;
}

.popup-border {
    border: 1px solid #d8d8d8;
}

.template-modal__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 20px 20px 0;
}

.template-modal__header h3 {
    margin: 0;
    color: #1c1c1d;
    font-size: clamp(18px, 1rem + 0.5vw, 20px);
    line-height: 1.2;
}

.template-modal__close {
    padding: 0;
    color: rgba(90, 90, 91, 1);
    background: transparent;
    border: none;
    font-size: 28px !important;
    line-height: 1 !important;
}

.template-modal__image-wrap {
    height: min(68vh, 760px);
    padding: 0 20px;
    overflow: auto;
    background: #fff;
}

.template-modal__image {
    display: block;
    width: 100%;
    height: auto;
}

.template-modal__footer {
    display: flex;
    justify-content: center;
    padding-bottom: 20px;
}

.template-modal__live {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 51px;
    padding: 0 32px;
    color: #ff6f3d;
    background: rgba(246, 247, 251, 1);
    border: 0.5px solid rgba(232, 234, 240, 1);
    border-radius: 6px;
    box-shadow: 0px 0px 0px 1px rgba(225, 239, 255, 1);
    text-decoration: none;
    font-size: 16px;
    font-weight: 500;
}

.template-modal__live svg {
    width: 16px;
    height: 16px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
}

/* ==========================================================================
   Animation
   ========================================================================== */

@keyframes shimmer {
    0% {
        background-position: 200% 0;
    }

    100% {
        background-position: -200% 0;
    }
}

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 1180px) {
    .explorer-shell {
        grid-template-columns: 260px minmax(0, 1fr);
    }

    .templates-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}
@media (max-width: 1213px) and (min-width: 884px) {
	.sidebar-panel , 
	.content-toolbar {
	    top: calc(var(--woolentor-ready-templates-sticky-top, 0px) + 16px) !important;
	}
}
@media (max-width: 1141px) {
    .content-toolbar {
        flex-direction: column;
        top: var(--wp-admin--admin-bar--height);
    }

    .toolbar-actions {
        justify-content: center;
    }
}

@media (max-width: 900px) {
    .sidebar-panel {
        border-right: 0;
        border-bottom: 1px solid rgba(27, 46, 89, 0.12);
        top: var(--wp-admin--admin-bar--height);
    }
}

@media (max-width: 871px) {
    .templates-grid {
        grid-template-columns: repeat(1, minmax(0, 1fr));
    }
}

@media (max-width: 720px) {
    .woolentor-ready-templates {
        padding-bottom: 24px;
    }

    .sidebar-panel {
        position: static;
        max-height: none;
        overflow-y: visible;
    }

    .explorer-shell {
        width: 100%;
        grid-template-columns: minmax(0, 1fr) !important;
        gap: 30px !important;
    }
    
    #refresh-data {
        display: none;
    }

    .content-toolbar {
        flex-direction: column;
        top: var(--wp-admin--admin-bar--height);
    }

    .toolbar-actions {
        width: 100%;
        justify-content: stretch;
    }

    .search-field,
    .field-compact,
    .refresh-button {
        width: 100%;
    }

    .templates-grid {
        grid-template-columns: minmax(0, 1fr);
        padding: 0;
    }

    .template-modal__dialog {
        width: calc(100% - 16px);
        margin: 16px auto;
    }

    .template-modal__image-wrap {
        height: 58vh;
    }
}

@media (max-width: 580px) {
    .explorer-shell {
        grid-template-columns: minmax(0, 1fr);
    }

    #category-list,
    .category-nav,
    .sidebar-header-top {
        gap: 10px;
    }

    .sidebar-panel {
        gap: 16px;
    }

    #refresh-data {
        display: none;
    }
}
