@import url(../theme.css);
@import url(../responsive.css);
@import url(../overrides.css);
@import url(../components/headerTopBanner.css);
@import url(../components/final-cta.css);
@import url(../components/terms-content.css);

/* =========================
   Template page design tokens
   ========================= */
:root {
    --sp-tmpl-bg: var(--bg-light-blue);
    --sp-tmpl-surface: var(--white);
    --sp-tmpl-surface-soft: var(--borderlight);
    --sp-tmpl-border: var(--bordercolor);
    --sp-tmpl-border-soft: var(--bordercolor);
    --sp-tmpl-text-main: var(--black);
    --sp-tmpl-text-subtle: var(--muted);
    --sp-tmpl-primary: var(--black);
    --sp-tmpl-primary-contrast: var(--white);
    --sp-tmpl-chip-bg: var(--white);
    --sp-tmpl-chip-border: var(--bordercolor);
    --sp-tmpl-chip-bg-active: var(--sp-tmpl-primary);
    --sp-tmpl-chip-text-active: var(--sp-tmpl-primary-contrast);
    --sp-tmpl-backdrop: var(--black_6);
}

/* =========================
   Typography helpers
   ========================= */

.heroSectionTitle {
    font-size: 3.25vw;
    font-weight: 400;
    color: var(--black);
    text-transform: uppercase;
}

.heroSectionSubTitle {
    font-size: 20px;
    font-weight: 400;
    color: var(--black_7);
}

/* =========================
   Page layout
   ========================= */

.templates-page {
    background: var(--sp-tmpl-bg);
    min-height: calc(100vh - 80px);
    font-family: "Inter", system-ui, -apple-system, BlinkMacSystemFont,
        "Segoe UI", sans-serif;
}

/* TOP BAR */

.templates-topbar {
    border-bottom: 1px solid var(--sp-tmpl-border);
    background: var(--sp-tmpl-surface);
    position: sticky;
    top: 0;
    z-index: 10;
}

.templates-topbar-inner {
    margin: 0 auto;
    padding: 0.75rem 1.25rem;
    display: flex;
    gap: 1rem;
    align-items: center;
}

.orientation-filters {
    display: flex;
    gap: 0.5rem;
    flex-shrink: 0;
}

.chip {
    border-radius: 999px;
    padding: 0.65rem 0.9rem;
    border: 1px solid var(--sp-tmpl-chip-border);
    background: var(--sp-tmpl-chip-bg);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
}

.chip:hover {
    border-color: var(--blue-color);
}

.chip-active {
    background: var(--blue-color);
    color: var(--white);
    border-color: var(--blue-color);
}

.templates-search-wrap {
    flex: 1 1 auto;
}

.templates-search-input {
    width: 100%;
    max-width: 300px;
    border-radius: 999px;
    border: 1px solid var(--sp-tmpl-chip-border);
    padding: 0.55rem 1rem;
    font-size: 0.95rem;
    outline: none;
    background: var(--sp-tmpl-surface);
}

.templates-search-input:focus {
    border-color: var(--blue-color);
}

/* LAYOUT */

.templates-layout {
    margin: 0 auto;
    padding: 1.5rem 1.25rem 2.5rem;
    display: flex;
    flex-wrap: wrap;
    /* grid-template-columns: 1fr; */
    /* grid-template-columns: 240px minmax(0, 1fr); */
    gap: 1.5rem;
    z-index: 9;
    position: relative;
    background: var(--white);
}

/* SIDEBAR */

.templates-sidebar {
    align-self: start;
    position: sticky;
    top: 75px;
    display: none;
}

.templates-sidebar-inner {
    background: var(--sp-tmpl-surface);
    border-radius: 1rem;
    border: 1px solid var(--sp-tmpl-border);
    padding: 1rem;
}

.sidebar-title {
    font-size: 0.9rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 0.75rem;
    color: var(--sp-tmpl-text-subtle);
}

.sidebar-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.sidebar-link {
    width: 100%;
    text-align: left;
    border-radius: 0.5rem;
    border: 0;
    background: transparent;
    padding: 0.4rem 0.5rem;
    font-size: 0.9rem;
    color: var(--sp-tmpl-text-main);
    cursor: pointer;
}

.sidebar-link:hover {
    background: var(--blue-color);
    color: var(--white);
}

.sidebar-link-active {
    background: var(--blue-color);
    color: var(--white);
}

/* MAIN GRID WRAPPER */

.templates-main-inner {
    background: var(--sp-tmpl-surface);
    border-radius: 1rem;
    border: 1px solid var(--sp-tmpl-border);
    padding: 1rem 1rem 1.5rem;
    min-height: 300px;
}

/* =========================
   MAIN GALLERY – MASONRY GRID
   ========================= */

.templates-grid {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 1.25rem;
    /* column-count: 5;
    column-gap: 1.25rem; */
    width: 100%;
}

/* @media (max-width: 1400px) {
    .templates-grid {
        column-count: 4;
    }
}

@media (max-width: 992px) {
    .templates-grid {
        column-count: 3;
    }
}

@media (max-width: 668px) {
    .templates-grid {
        column-count: 2;
    }
}

@media (max-width: 420px) {
    .templates-grid {
        column-count: 1;
    }
} */

.template-card {
    break-inside: avoid;
    margin-bottom: 1.25rem;
    width: calc(20% - 1.25rem);
    display: block;
    border-radius: 0.75rem;
    background: var(--sp-tmpl-surface);
    border: 1px solid var(--sp-tmpl-border-soft);
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

@media screen and (max-width: 1200px) {
    .template-card {
        width: calc(25% - 1.25rem);
    }
}

@media screen and (max-width: 992px) {
    .template-card {
        width: calc(33% - 1.25rem);
        margin: 0 !important;
    }
}

@media screen and (max-width: 668px) {
    .template-card {
        width: calc(50% - 1.25rem);
    }

    .templates-search-input{
        max-width: 100%;
    }
}

@media screen and (max-width: 460px) {
    .template-card {
        width: calc(100% - 1.25rem);
    }
}

.template-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 18px var(--box-shadow-blogs);
}

.template-card.loaded {
    opacity: 1;
    transform: translateY(0);
}

.template-thumb-wrap {
    width: 100%;
    background: var(--sp-tmpl-surface);
}

.template-thumb-wrap img {
    width: 100%;
    height: auto;
    display: block;
    border-bottom: 1px solid var(--bordercolor);
    object-fit: cover;
}

.template-meta {
    padding: 0.6rem 0.7rem 0.7rem;
}

.template-name {
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 0.15rem;
    text-align: center;
}

/* Empty state */

.templates-empty {
    text-align: center;
    padding: 2rem 1rem;
    color: var(--sp-tmpl-text-subtle);
}

.d-none {
    display: none !important;
}

/* =========================
   PREVIEW MODAL (LIGHT)
   ========================= */

.template-preview-overlay {
    position: fixed;
    inset: 0;
    z-index: 1050;
}

.template-preview-backdrop {
    position: absolute;
    inset: 0;
    background: var(--sp-tmpl-backdrop);
}

.template-preview-dialog {
    position: relative;
    max-width: 1040px;
    max-height: 90vh;
    height: auto;
    margin: 3vh auto;
    background: var(--sp-tmpl-surface);
    border-radius: 1.25rem;
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    color: var(--sp-tmpl-text-main);
    box-shadow: 0 18px 40px var(--box-shadow-blogs);
}

/* Close / navigation */

.preview-close-btn {
    position: sticky;
    top: 0.9rem;
    align-self: flex-end;
    margin-right: 1rem;
    border: 1px solid var(--sp-tmpl-border-soft);
    background: var(--sp-tmpl-surface);
    color: var(--sp-tmpl-text-main);
    border-radius: 999px;
    width: 32px;
    height: 32px;
    min-width: 32px;
    min-height: 32px;
    cursor: pointer;
    z-index: 2;
}

.preview-nav-btn {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    border: 1px solid var(--sp-tmpl-border-soft);
    background: var(--sp-tmpl-surface);
    color: var(--sp-tmpl-text-main);
    border-radius: 999px;
    width: 36px;
    height: 36px;
    cursor: pointer;
    z-index: 2;
}

.preview-nav-btn.prev {
    left: calc(50% - 520px);
    /* approximate left edge of dialog */
}

.preview-nav-btn.next {
    right: calc(50% - 520px);
}

/* MAIN preview top block (image + meta) */

.template-preview-content {
    /* display: grid;
    grid-template-columns: minmax(0, 3fr) minmax(0, 1.4fr); */
    gap: 1rem;
    padding: 2.25rem 1.25rem 1.75rem;
    align-items: flex-start;
}

.template-preview-image-wrap {
    background: var(--borderlight);
    border-radius: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    height: 420px;
}

.template-preview-image-wrap img {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
}

/* Right: meta */

.template-preview-meta {
    padding: 0.75rem 0.5rem;
}

.preview-title {
    font-size: 1.1rem;
    margin-bottom: 0.75rem;
}

.preview-detail-line {
    font-size: 0.85rem;
    color: var(--sp-tmpl-text-subtle);
    margin-bottom: 0.25rem;
}

.preview-tagline {
    font-size: 0.9rem;
    margin-top: 0.75rem;
}

/* =========================
   PREVIEW – EXTRA SECTIONS
   ========================= */

.template-preview-extra {
    padding: 0 1.25rem 1.75rem;
    border-top: 1px solid var(--sp-tmpl-border);
}

.preview-section-title {
    font-size: 0.95rem;
    font-weight: 600;
    margin: 1rem 0 0.75rem;
}

/* Similar templates → single row, horizontal scroll */
.preview-similar-row {
    display: flex;
    gap: 0.75rem;
    overflow-x: auto;
    padding-bottom: 0.25rem;
    margin-bottom: 1rem;
}

.preview-similar-row::-webkit-scrollbar {
    height: 6px;
}

.preview-similar-row::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 999px;
}

.preview-mini-card {
    /* flex: 0 0 auto; */
    width: 200px;
    min-width: 200px;
    border-radius: 0.75rem;
    border: 1px solid var(--sp-tmpl-border-soft);
    overflow: hidden;
    background: var(--sp-tmpl-surface);
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.preview-mini-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 18px var(--box-shadow-blogs);
}

.preview-mini-thumb img {
    width: 100%;
    height: auto;
    display: block;
    object-fit: cover;
}

.preview-mini-meta {
    padding: 0.35rem 0.45rem 0.5rem;
}

.preview-mini-title {
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1.3;
}

.preview-reco-grid {
    column-count: 5;
    column-gap: 0.75rem;
    width: 100%;
}

@media (max-width: 1400px) {
    .preview-reco-grid {
        column-count: 4;
    }
}

@media (max-width: 992px) {
    .preview-reco-grid {
        column-count: 3;
    }
}

@media (max-width: 768px) {
    .preview-reco-grid {
        column-count: 2;
    }
}

.preview-recommendations .preview-mini-card {
    width: 100%;
    margin-bottom: 0.75rem;
    break-inside: avoid;
}

/* =========================
   RESPONSIVE
   ========================= */

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

    .templates-sidebar {
        position: static;
    }

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

    .preview-nav-btn.prev {
        left: 0.75rem;
    }

    .preview-nav-btn.next {
        right: 0.75rem;
    }
}

@media (max-width: 575.98px) {
    .templates-topbar-inner {
        flex-direction: column;
        align-items: stretch;
    }

    .orientation-filters {
        justify-content: center;
    }

    .template-preview-dialog {
        height: 95vh;
        margin: 2.5vh auto;
    }
}