.template-page {
    min-height: calc(100vh - 80px);
    background: #f7f9fc;
    padding: 50px 20px 80px;
}

.template-container {
    width: min(1180px, 100%);
    margin: auto;
}

.template-header {
    text-align: center;
    margin-bottom: 35px;
}

.template-header .step-number {
    color: #4f46e5;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 1.5px;
}

.template-header h1 {
    margin: 10px 0;
    font-size: 40px;
    color: #172033;
}

.template-header p {
    color: #667085;
    font-size: 16px;
}

.template-filters {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 35px;
}

.template-filter {
    border: 1px solid #d0d5dd;
    background: #fff;
    color: #475467;
    padding: 10px 18px;
    border-radius: 30px;
    cursor: pointer;
    font-weight: 600;
}

.template-filter:hover,
.template-filter.active {
    background: #4f46e5;
    border-color: #4f46e5;
    color: #fff;
}

.template-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 25px;
}

.template-card {
    background: #fff;
    border: 1px solid #eaecf0;
    border-radius: 16px;
    overflow: hidden;
    transition: .2s ease;
}

.template-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 15px 40px rgba(16, 24, 40, .10);
}

.template-card.hidden {
    display: none;
}

.template-preview {
    position: relative;
    height: 400px;
    padding: 20px;
    background: #eef1f6;
}

.template-placeholder {
    width: 100%;
    height: 100%;
    background: #fff;
    box-shadow: 0 5px 20px rgba(16,24,40,.10);
    overflow: hidden;
}

.mock-header {
    height: 65px;
    background: #293044;
}

.mock-layout {
    display: grid;
    grid-template-columns: 28% 72%;
    height: calc(100% - 65px);
}

.mock-sidebar {
    padding: 20px 12px;
    background: #eef0f5;
}

.mock-sidebar div {
    height: 7px;
    background: #c7ccd6;
    border-radius: 5px;
    margin-bottom: 15px;
}

.mock-content {
    padding: 25px 18px;
}

.mock-name {
    width: 55%;
    height: 13px;
    background: #333b50;
    border-radius: 4px;
    margin-bottom: 8px;
}

.mock-line {
    width: 80%;
    height: 5px;
    background: #e1e4e9;
    margin-bottom: 25px;
}

.mock-heading {
    width: 35%;
    height: 8px;
    background: #4f46e5;
    border-radius: 4px;
    margin: 18px 0 10px;
}

.mock-text {
    width: 90%;
    height: 5px;
    background: #e3e5e9;
    border-radius: 4px;
    margin: 7px 0;
}

.mock-text.short {
    width: 65%;
}

.template-badge {
    position: absolute;
    top: 30px;
    left: 30px;
    background: #4f46e5;
    color: #fff;
    padding: 6px 10px;
    font-size: 11px;
    font-weight: 700;
    border-radius: 5px;
}

.template-badge.new {
    background: #12b76a;
}

.preview-template-btn {
    position: absolute;
    left: 50%;
    bottom: 30px;
    transform: translateX(-50%);
    padding: 10px 20px;
    border: 0;
    border-radius: 8px;
    background: #fff;
    color: #172033;
    font-weight: 700;
    cursor: pointer;
    opacity: 0;
    transition: .2s ease;
}

.template-preview:hover .preview-template-btn {
    opacity: 1;
}

.template-card-info {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
    padding: 18px;
}

.template-card-info h3 {
    margin: 0;
    color: #172033;
}

.template-card-info p {
    margin: 5px 0 0;
    font-size: 13px;
    color: #667085;
}

.use-template-btn {
    flex-shrink: 0;
    padding: 9px 15px;
    border: 1px solid #4f46e5;
    background: #fff;
    color: #4f46e5;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 700;
}

.use-template-btn:hover {
    background: #4f46e5;
    color: #fff;
}

/* MODAL */

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

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

.template-modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, .75);
}

.template-modal-content {
    position: relative;
    width: min(650px, 90%);
    height: 90vh;
    margin: 5vh auto;
    background: #fff;
    border-radius: 16px;
    padding: 30px;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.modal-close {
    position: absolute;
    right: 20px;
    top: 15px;
    width: 35px;
    height: 35px;
    border: 0;
    background: #f2f4f7;
    border-radius: 50%;
    font-size: 24px;
    cursor: pointer;
    z-index: 5;
}

.modal-preview {
    width: 430px;
    max-width: 80%;
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.modal-preview #modalTemplatePreview {
    width: 100%;
    height: 100%;
    max-height: 650px;
}

.modal-preview .template-placeholder {
    height: 100%;
}

.modal-template-name {
    font-size: 20px;
    font-weight: 700;
    margin: 15px 0;
    color: #172033;
}

.template-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 45px;
    height: 45px;
    border-radius: 50%;
    border: 0;
    background: #fff;
    box-shadow: 0 5px 20px rgba(0,0,0,.15);
    font-size: 30px;
    cursor: pointer;
    z-index: 5;
}

.template-nav.prev {
    left: 20px;
}

.template-nav.next {
    right: 20px;
}

.modal-use-template {
    width: 100%;
    max-width: 430px;
    padding: 14px;
    border: 0;
    border-radius: 10px;
    background: #4f46e5;
    color: #fff;
    font-weight: 700;
    font-size: 15px;
    cursor: pointer;
}

.no-templates {
    text-align: center;
    padding: 50px;
    color: #667085;
}

@media (max-width: 950px) {

    .template-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 650px) {

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

    .template-header h1 {
        font-size: 30px;
    }

    .template-preview {
        height: 450px;
    }

    .modal-preview {
        width: 85%;
    }

    .template-nav.prev {
        left: 8px;
    }

    .template-nav.next {
        right: 8px;
    }
}