/* ============================================
   FormForge Templates - Shared Styles
   Matches Royal Plugins design system
   ============================================ */

/* --- Template Page Header --- */
.templates-hero {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #1a1a2e 100%);
    padding: 7rem 5% 4rem;
    text-align: center;
    color: #fff;
    position: relative;
    overflow: hidden;
}

.templates-hero::before {
    content: '';
    position: absolute;
    width: 600px;
    height: 600px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(201,162,39,0.05) 0%, transparent 70%);
    top: -200px;
    right: -100px;
}

.templates-hero h1 {
    font-family: 'Cormorant Garamond', serif;
    font-size: clamp(2rem, 4vw, 3rem);
    font-weight: 600;
    line-height: 1.15;
    margin: 0 0 1rem;
    letter-spacing: -0.02em;
}

.templates-hero .highlight {
    color: var(--gold);
}

.templates-hero p {
    font-size: 1.0625rem;
    color: rgba(255,255,255,0.7);
    max-width: 600px;
    margin: 0 auto;
    line-height: 1.7;
    font-weight: 300;
}

.templates-hero .template-count {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(201,162,39,0.15);
    border: 1px solid rgba(201,162,39,0.3);
    padding: 0.5rem 1.25rem;
    border-radius: 50px;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--gold);
    margin-bottom: 1.5rem;
}

/* --- Breadcrumbs --- */
.breadcrumbs {
    padding: 1rem 5%;
    background: var(--cream);
    border-bottom: 1px solid var(--border-light);
}

.breadcrumbs-inner {
    max-width: 1200px;
    margin: 0 auto;
    font-size: 0.8125rem;
    color: var(--charcoal-muted);
}

.breadcrumbs a {
    color: var(--charcoal-muted);
    text-decoration: none;
}

.breadcrumbs a:hover {
    color: var(--gold-dark);
}

.breadcrumbs span.separator {
    margin: 0 0.5rem;
    opacity: 0.5;
}

.breadcrumbs span.current {
    color: var(--charcoal);
    font-weight: 500;
}

/* --- Filter Bar --- */
.filter-bar {
    background: var(--white);
    border-bottom: 1px solid var(--border-light);
    padding: 1.5rem 5%;
    position: sticky;
    top: 70px;
    z-index: 998;
}

.filter-bar-inner {
    max-width: 1200px;
    margin: 0 auto;
}

.filter-search {
    position: relative;
    max-width: 400px;
    margin: 0 auto 1.25rem;
}

.filter-search input {
    width: 100%;
    padding: 0.75rem 1rem 0.75rem 2.75rem;
    font-size: 0.9375rem;
    font-family: 'Inter', sans-serif;
    border: 1px solid var(--border-light);
    border-radius: 8px;
    background: var(--cream);
    color: var(--charcoal);
    outline: none;
    transition: border-color 0.2s;
    box-sizing: border-box;
}

.filter-search input:focus {
    border-color: var(--gold);
}

.filter-search svg {
    position: absolute;
    left: 0.875rem;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    stroke: var(--charcoal-muted);
}

.filter-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: center;
    margin-bottom: 1rem;
}

.filter-tab {
    padding: 0.5rem 1rem;
    font-size: 0.8125rem;
    font-family: 'Inter', sans-serif;
    font-weight: 500;
    color: var(--charcoal-muted);
    background: transparent;
    border: 1px solid var(--border-light);
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.filter-tab:hover {
    color: var(--charcoal);
    border-color: var(--charcoal-muted);
}

.filter-tab.active {
    background: var(--gold);
    color: var(--charcoal);
    border-color: var(--gold);
}

.filter-tiers {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
}

.filter-tier {
    padding: 0.375rem 0.875rem;
    font-size: 0.75rem;
    font-family: 'Inter', sans-serif;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--charcoal-muted);
    background: transparent;
    border: 1px solid var(--border-light);
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
}

.filter-tier:hover {
    border-color: var(--charcoal-muted);
}

.filter-tier.active {
    background: var(--charcoal);
    color: #fff;
    border-color: var(--charcoal);
}

/* --- Template Grid --- */
.templates-grid-section {
    background: var(--cream);
    padding: 3rem 5% 5rem;
}

.templates-grid-inner {
    max-width: 1200px;
    margin: 0 auto;
}

.templates-count-label {
    text-align: center;
    font-size: 0.875rem;
    color: var(--charcoal-muted);
    margin-bottom: 2rem;
}

.templates-count-label strong {
    color: var(--charcoal);
}

.templates-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.75rem;
}

.templates-empty {
    grid-column: 1 / -1;
    text-align: center;
    padding: 4rem 2rem;
    color: var(--charcoal-muted);
    font-size: 1rem;
}

/* --- Template Card --- */
.template-card {
    background: var(--white);
    border-radius: 12px;
    border: 1px solid #d1d5db;
    overflow: hidden;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    text-decoration: none;
    color: inherit;
}

.template-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 40px rgba(0,0,0,0.08);
    border-color: var(--gold);
}

/* Form preview viewport */
.template-preview {
    height: 300px;
    overflow: hidden;
    position: relative;
    background: #f8f9fa;
    border-bottom: 1px solid var(--border-light);
}

.template-preview-inner {
    padding: 1.5rem;
    transition: transform 4s ease-in-out;
}

.template-card:hover .template-preview-inner {
    transform: translateY(var(--scroll-distance, 0px));
}

/* Card body */
.template-card-body {
    padding: 1.25rem 1.5rem 1.5rem;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.template-card-meta {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    margin-bottom: 0.75rem;
}

.template-card h3 {
    font-family: 'Cormorant Garamond', serif;
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--charcoal);
    margin: 0 0 0.5rem;
    line-height: 1.3;
}

.template-card p {
    font-size: 0.875rem;
    color: var(--charcoal-muted);
    line-height: 1.5;
    margin: 0 0 1rem;
    flex: 1;
}

.template-card-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: auto;
}

.template-card-actions .btn-preview {
    flex: 1;
    padding: 0.625rem;
    font-size: 0.8125rem;
    font-family: 'Inter', sans-serif;
    font-weight: 500;
    color: var(--charcoal-muted);
    background: transparent;
    border: 1px solid var(--border-light);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    text-align: center;
}

.template-card-actions .btn-preview:hover {
    color: var(--charcoal);
    border-color: var(--charcoal);
}

.template-card-actions .btn-use {
    flex: 1;
    padding: 0.625rem;
    font-size: 0.8125rem;
    font-family: 'Inter', sans-serif;
    font-weight: 500;
    color: var(--charcoal);
    background: var(--gold);
    border: 1px solid var(--gold);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    text-align: center;
}

.template-card-actions .btn-use:hover {
    background: var(--gold-dark);
    border-color: var(--gold-dark);
}

/* --- Tier Badges --- */
.tier-badge {
    display: inline-block;
    padding: 0.2rem 0.625rem;
    border-radius: 4px;
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    line-height: 1.4;
}

.tier-badge-pro {
    background: rgba(201,162,39,0.12);
    color: #a88620;
}

.tier-badge-business {
    background: rgba(59,130,246,0.1);
    color: #2563eb;
}

.tier-badge-agency {
    background: rgba(147,51,234,0.1);
    color: #7c3aed;
}

.field-count {
    font-size: 0.75rem;
    color: var(--charcoal-muted);
}

/* --- Preview Modal --- */
.template-modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.6);
    z-index: 10000;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.template-modal-overlay.active {
    display: flex;
}

.template-modal {
    background: var(--white);
    border-radius: 12px;
    max-width: 1000px;
    width: 100%;
    max-height: 90vh;
    display: grid;
    grid-template-columns: 1fr 340px;
    overflow: hidden;
    position: relative;
}

.template-modal-preview {
    height: 100%;
    max-height: 90vh;
    overflow: hidden;
    background: #f8f9fa;
    border-right: 1px solid var(--border-light);
    position: relative;
}

.template-modal-preview-inner {
    padding: 2rem;
    transition: transform 4s ease-in-out;
}

.template-modal-preview:hover .template-modal-preview-inner {
    transform: translateY(var(--modal-scroll-distance, 0px));
}

.template-modal-sidebar {
    padding: 2rem;
    overflow-y: auto;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}

.template-modal-sidebar h2 {
    font-family: 'Cormorant Garamond', serif;
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--charcoal);
    margin: 0 0 0.75rem;
}

.template-modal-sidebar p {
    font-size: 0.9375rem;
    color: var(--charcoal-muted);
    line-height: 1.6;
    margin: 0 0 1.25rem;
}

.template-modal-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-light);
}

.template-modal-meta-item {
    font-size: 0.8125rem;
    color: var(--charcoal-muted);
}

.template-modal-meta-item strong {
    color: var(--charcoal);
}

.template-modal-cta {
    margin-top: auto;
}

.template-modal-cta .btn-use-large {
    display: block;
    width: 100%;
    padding: 0.875rem;
    font-size: 0.9375rem;
    font-family: 'Inter', sans-serif;
    font-weight: 600;
    color: var(--charcoal);
    background: var(--gold);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    text-decoration: none;
    text-align: center;
    transition: all 0.2s;
    box-sizing: border-box;
}

.template-modal-cta .btn-use-large:hover {
    background: var(--gold-dark);
}

.template-modal-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: rgba(0,0,0,0.05);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    transition: background 0.2s;
}

.template-modal-close:hover {
    background: rgba(0,0,0,0.1);
}

.template-modal-close svg {
    width: 18px;
    height: 18px;
    stroke: var(--charcoal);
}

.template-modal-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: rgba(255,255,255,0.9);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    transition: all 0.2s;
}

.template-modal-nav:hover {
    background: #fff;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.template-modal-nav svg {
    width: 16px;
    height: 16px;
    stroke: var(--charcoal);
}

.template-modal-prev {
    left: 1rem;
}

.template-modal-next {
    right: calc(340px + 1rem);
}

/* --- Form Preview Rendering --- */
.preview-form {
    font-family: 'Inter', sans-serif;
}

.preview-field {
    margin-bottom: 1.25rem;
}

.preview-field label {
    display: block;
    font-size: 0.8125rem;
    font-weight: 500;
    color: #374151;
    margin-bottom: 0.375rem;
}

.preview-field label .required {
    color: #ef4444;
    margin-left: 2px;
}

.preview-field input[type="text"],
.preview-field input[type="email"],
.preview-field input[type="tel"],
.preview-field input[type="url"],
.preview-field input[type="number"],
.preview-field input[type="date"] {
    width: 100%;
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    font-family: 'Inter', sans-serif;
    border: 1px solid var(--border-light);
    border-radius: 6px;
    background: #fff;
    color: #9ca3af;
    box-sizing: border-box;
}

.preview-field textarea {
    width: 100%;
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    font-family: 'Inter', sans-serif;
    border: 1px solid var(--border-light);
    border-radius: 6px;
    background: #fff;
    color: #9ca3af;
    resize: none;
    box-sizing: border-box;
}

.preview-field select {
    width: 100%;
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    font-family: 'Inter', sans-serif;
    border: 1px solid var(--border-light);
    border-radius: 6px;
    background: #fff;
    color: #9ca3af;
    box-sizing: border-box;
}

.preview-field .radio-group,
.preview-field .checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.preview-field .radio-option,
.preview-field .checkbox-option {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8125rem;
    color: #374151;
}

.preview-field .radio-option input,
.preview-field .checkbox-option input {
    width: 16px;
    height: 16px;
    accent-color: var(--gold);
}

.preview-field .file-upload {
    border: 2px dashed var(--border-light);
    border-radius: 8px;
    padding: 1.25rem;
    text-align: center;
    color: #9ca3af;
    font-size: 0.8125rem;
    background: #fafafa;
}

.preview-field .file-upload svg {
    display: block;
    margin: 0 auto 0.5rem;
    width: 24px;
    height: 24px;
    stroke: #9ca3af;
}

.preview-field h3 {
    font-family: 'Cormorant Garamond', serif;
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--charcoal);
    margin: 0.5rem 0 0;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-light);
}

/* Star rating */
.preview-stars {
    display: flex;
    gap: 4px;
    font-size: 1.25rem;
    color: #d1d5db;
}

.preview-stars .star {
    color: #fbbf24;
}

/* NPS scale */
.preview-nps {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

.preview-nps span {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border-light);
    border-radius: 4px;
    font-size: 0.75rem;
    color: #6b7280;
    background: #fff;
}

/* Likert scale */
.preview-likert {
    display: flex;
    gap: 0.25rem;
    justify-content: space-between;
}

.preview-likert span {
    flex: 1;
    text-align: center;
    padding: 0.375rem 0.25rem;
    border: 1px solid var(--border-light);
    border-radius: 4px;
    font-size: 0.625rem;
    color: #6b7280;
    background: #fff;
}

/* Submit button */
.preview-submit {
    display: inline-block;
    padding: 0.625rem 1.5rem;
    background: var(--gold);
    color: var(--charcoal);
    font-size: 0.875rem;
    font-weight: 600;
    border: none;
    border-radius: 6px;
    cursor: default;
    margin-top: 0.5rem;
}

/* --- Individual Template Page --- */
.template-detail-hero {
    background: var(--cream);
    padding: 3rem 5% 2.5rem;
}

.template-detail-hero-inner {
    max-width: 1200px;
    margin: 0 auto;
}

.template-detail-meta {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.template-detail-hero h1 {
    font-family: 'Cormorant Garamond', serif;
    font-size: clamp(1.75rem, 3.5vw, 2.5rem);
    font-weight: 600;
    color: var(--charcoal);
    margin: 0 0 0.75rem;
    line-height: 1.2;
}

.template-detail-hero p {
    font-size: 1.0625rem;
    color: var(--charcoal-muted);
    line-height: 1.7;
    max-width: 700px;
    margin: 0;
}

/* Full-width preview */
.template-detail-preview {
    background: var(--white);
    padding: 3rem 5%;
}

.template-detail-preview-inner {
    max-width: 700px;
    margin: 0 auto;
    background: #f8f9fa;
    border-radius: 12px;
    border: 1px solid var(--border-light);
    overflow: hidden;
    position: relative;
}

.template-detail-preview-viewport {
    max-height: 500px;
    overflow: hidden;
}

.template-detail-preview-content {
    padding: 2rem;
    transition: transform 4s ease-in-out;
}

.template-detail-preview-inner:hover .template-detail-preview-content {
    transform: translateY(var(--detail-scroll-distance, 0px));
}

/* Fields table */
.template-fields-section {
    background: var(--cream);
    padding: 3rem 5%;
}

.template-fields-inner {
    max-width: 800px;
    margin: 0 auto;
}

.template-fields-inner h2 {
    font-family: 'Cormorant Garamond', serif;
    font-size: 1.75rem;
    font-weight: 600;
    color: var(--charcoal);
    margin: 0 0 1.5rem;
}

.fields-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--white);
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--border-light);
}

.fields-table th {
    background: var(--charcoal);
    color: #fff;
    padding: 0.75rem 1.25rem;
    font-size: 0.8125rem;
    font-weight: 600;
    text-align: left;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.fields-table td {
    padding: 0.75rem 1.25rem;
    font-size: 0.875rem;
    color: var(--charcoal-light);
    border-bottom: 1px solid var(--border-light);
}

.fields-table tr:last-child td {
    border-bottom: none;
}

.fields-table tr:nth-child(even) td {
    background: var(--cream);
}

.fields-table .required-yes {
    color: #059669;
    font-weight: 500;
}

.fields-table .required-no {
    color: var(--charcoal-muted);
}

/* What's Included */
.template-features-section {
    background: var(--white);
    padding: 3rem 5%;
}

.template-features-inner {
    max-width: 800px;
    margin: 0 auto;
}

.template-features-inner h2 {
    font-family: 'Cormorant Garamond', serif;
    font-size: 1.75rem;
    font-weight: 600;
    color: var(--charcoal);
    margin: 0 0 1.5rem;
}

.tier-features-list {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

.tier-feature-item {
    display: flex;
    align-items: flex-start;
    gap: 0.625rem;
    font-size: 0.9375rem;
    color: var(--charcoal-light);
    line-height: 1.5;
}

.tier-feature-item svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    margin-top: 2px;
}

.tier-feature-item svg.check {
    stroke: var(--green);
}

/* Related Templates */
.related-templates-section {
    background: var(--cream);
    padding: 3rem 5%;
}

.related-templates-inner {
    max-width: 1200px;
    margin: 0 auto;
}

.related-templates-inner h2 {
    font-family: 'Cormorant Garamond', serif;
    font-size: 1.75rem;
    font-weight: 600;
    color: var(--charcoal);
    margin: 0 0 1.5rem;
    text-align: center;
}

.related-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
}

/* --- CTA Section --- */
.templates-cta {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #1a1a2e 100%);
    padding: 4rem 5%;
    text-align: center;
    color: #fff;
}

.templates-cta h2 {
    font-family: 'Cormorant Garamond', serif;
    font-size: clamp(1.5rem, 3vw, 2.25rem);
    font-weight: 600;
    margin: 0 0 1rem;
}

.templates-cta p {
    font-size: 1rem;
    color: rgba(255,255,255,0.7);
    max-width: 500px;
    margin: 0 auto 1.5rem;
    line-height: 1.6;
}

.templates-cta .btn-cta {
    display: inline-block;
    padding: 0.875rem 2.5rem;
    background: var(--gold);
    color: var(--charcoal);
    font-size: 0.9375rem;
    font-weight: 600;
    border-radius: 50px;
    text-decoration: none;
    transition: all 0.2s;
}

.templates-cta .btn-cta:hover {
    background: var(--gold-dark);
    transform: translateY(-2px);
}

/* --- Responsive --- */
@media (max-width: 1024px) {
    .template-modal {
        grid-template-columns: 1fr;
        max-height: 90vh;
    }

    .template-modal-preview {
        max-height: 40vh;
        border-right: none;
        border-bottom: 1px solid var(--border-light);
    }

    .template-modal-sidebar {
        max-height: 50vh;
    }

    .template-modal-next {
        right: 1rem;
    }
}

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

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

    .tier-features-list {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .filter-tabs {
        justify-content: flex-start;
        overflow-x: auto;
        flex-wrap: nowrap;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        padding-bottom: 0.5rem;
    }

    .filter-tabs::-webkit-scrollbar {
        display: none;
    }

    .filter-bar {
        top: 0;
    }
}

@media (max-width: 600px) {
    .templates-grid {
        grid-template-columns: 1fr;
    }

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

    .template-modal {
        margin: 1rem;
    }

    .template-card-actions {
        flex-direction: column;
    }
}
