/* =========================================================
   templates.css — صفحهٔ قالب‌ها (لیست + جزئیات)
   شهبازیون | SuFramework v3.0
   ========================================================= */

/* ─────────────────────────────────────────────────────────
   ۱. Filter Bar (بالای لیست)
   ───────────────────────────────────────────────────────── */
.templates-filter {
    padding: 2rem 0 1.5rem;
    background: var(--c-bg);
    border-bottom: 1px solid var(--c-border);
    position: sticky;
    top: 64px;
    z-index: 50;
}

body.dark-mode .templates-filter {
    background: #0f172a;
}

.filter-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    justify-content: space-between;
}

.filter-search {
    flex: 1;
    min-width: 220px;
    max-width: 380px;
}

.filter-chips-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    flex: 2;
    justify-content: center;
    overflow-x: auto;
    scrollbar-width: none;
}

.filter-chips-row::-webkit-scrollbar {
    display: none;
}

.filter-count {
    font-size: 0.85rem;
    color: var(--c-text-muted);
    font-weight: 600;
    white-space: nowrap;
}

/* ─────────────────────────────────────────────────────────
   ۲. Templates Grid
   ───────────────────────────────────────────────────────── */
.templates-section {
    padding: 3rem 0 4rem;
    background: var(--c-bg-alt);
    min-height: 60vh;
}

body.dark-mode .templates-section {
    background: #0a1020;
}

.templates-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
}

/* ─────────────────────────────────────────────────────────
   ۳. Template Card
   ───────────────────────────────────────────────────────── */
.tpl-card {
    position: relative;
    display: flex;
    flex-direction: column;
    background: var(--c-bg);
    border: 1px solid var(--c-border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    text-decoration: none;
    color: inherit;
    transition: var(--transition);
}

.tpl-card:hover {
    border-color: var(--c-primary-light);
    box-shadow: 0 16px 40px rgba(109, 40, 217, 0.12);
    transform: translateY(-5px);
}

.tpl-cover {
    position: relative;
    aspect-ratio: 16 / 10;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--c-primary) 0%, var(--c-primary-light) 100%);
    overflow: hidden;
}

.tpl-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease;
}

.tpl-card:hover .tpl-cover img {
    transform: scale(1.05);
}

.tpl-emoji {
    font-size: 3.5rem;
    line-height: 1;
    filter: drop-shadow(0 6px 16px rgba(0, 0, 0, 0.2));
    transition: var(--transition);
}

.tpl-card:hover .tpl-emoji {
    transform: scale(1.12) rotate(-4deg);
}

.tpl-badges {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    display: flex;
    gap: 0.35rem;
    flex-wrap: wrap;
}

.tpl-badge {
    padding: 0.22rem 0.65rem;
    font-size: 0.7rem;
    font-weight: 800;
    border-radius: var(--radius-full);
    color: #fff;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    letter-spacing: 0.01em;
}

.tpl-badge.is-featured { background: var(--c-accent); }
.tpl-badge.is-free     { background: var(--c-success); }
.tpl-badge.is-new      { background: var(--c-info); }

.tpl-body {
    padding: 1.35rem 1.35rem 1.5rem;
    display: flex;
    flex-direction: column;
    flex: 1;
    gap: 0.65rem;
}

.tpl-industry {
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--c-primary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.tpl-title {
    font-size: 1.05rem;
    color: var(--c-text);
    margin: 0;
    line-height: 1.45;
    font-weight: 800;
    transition: color var(--transition-fast);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.tpl-card:hover .tpl-title {
    color: var(--c-primary);
}

.tpl-desc {
    font-size: 0.88rem;
    color: var(--c-text-soft);
    line-height: 1.75;
    margin: 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.tpl-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-top: auto;
    padding-top: 0.85rem;
    border-top: 1px solid var(--c-border-soft);
    font-size: 0.82rem;
}

.tpl-price {
    font-weight: 800;
    color: var(--c-primary);
}

.tpl-price.is-free {
    color: var(--c-success);
}

.tpl-stats {
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--c-text-muted);
}

/* ─────────────────────────────────────────────────────────
   ۴. Empty State (اگر قالب نیست)
   ───────────────────────────────────────────────────────── */
.templates-empty {
    grid-column: 1 / -1;
    text-align: center;
    padding: 4rem 1.5rem;
    background: var(--c-bg);
    border-radius: var(--radius-lg);
    border: 1px dashed var(--c-border);
}

/* ─────────────────────────────────────────────────────────
   ۵. Pagination
   ───────────────────────────────────────────────────────── */
.templates-pagination {
    margin-top: 3rem;
    display: flex;
    justify-content: center;
}

/* ─────────────────────────────────────────────────────────
   ۶. Template Detail Page
   ───────────────────────────────────────────────────────── */
.tpl-detail-page {
    padding-bottom: 4rem;
}

.tpl-detail-hero {
    padding: 3rem 0 2rem;
    background: var(--c-bg-alt);
    border-bottom: 1px solid var(--c-border);
}

body.dark-mode .tpl-detail-hero {
    background: #0f172a;
}

.tpl-detail-layout {
    display: grid;
    grid-template-columns: 1fr 380px;
    gap: 3rem;
    align-items: start;
    margin-top: 2.5rem;
}

.tpl-detail-main {
    min-width: 0;
}

.tpl-detail-title {
    font-size: clamp(1.5rem, 3vw, 2.25rem);
    font-weight: 900;
    color: var(--c-text);
    margin: 0 0 1rem;
    line-height: 1.3;
    letter-spacing: -0.01em;
}

.tpl-detail-industry {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.4rem 0.85rem;
    background: var(--c-primary-soft);
    color: var(--c-primary);
    border-radius: var(--radius-full);
    font-size: 0.82rem;
    font-weight: 700;
    margin-bottom: 1.15rem;
}

.tpl-detail-lead {
    font-size: 1.05rem;
    color: var(--c-text-soft);
    line-height: 1.9;
    margin: 0 0 2rem;
}

.tpl-preview {
    margin: 2rem 0;
    border-radius: var(--radius-lg);
    border: 1px solid var(--c-border);
    overflow: hidden;
    background: var(--c-bg);
}

.tpl-preview img {
    width: 100%;
    display: block;
}

.tpl-preview-empty {
    aspect-ratio: 16 / 10;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--c-primary) 0%, var(--c-primary-light) 100%);
    font-size: 5rem;
}

.tpl-section {
    margin: 2.5rem 0;
}

.tpl-section h2 {
    font-size: 1.15rem;
    color: var(--c-text);
    margin: 0 0 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 2px solid var(--c-border);
    font-weight: 800;
}

.tpl-features-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 0.75rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

.tpl-feature-item {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0.75rem 0.9rem;
    background: var(--c-bg-alt);
    border-radius: var(--radius);
    font-size: 0.88rem;
    color: var(--c-text-soft);
    line-height: 1.6;
}

.tpl-feature-item::before {
    content: '✓';
    width: 20px;
    height: 20px;
    border-radius: var(--radius-full);
    background: var(--c-primary-soft);
    color: var(--c-primary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.72rem;
    font-weight: 900;
    flex-shrink: 0;
}

/* ─────────────────────────────────────────────────────────
   ۷. Sidebar (Purchase Card)
   ───────────────────────────────────────────────────────── */
.tpl-detail-sidebar {
    position: sticky;
    top: 90px;
}

.tpl-purchase-card {
    background: var(--c-bg);
    border: 2px solid var(--c-border);
    border-radius: var(--radius-lg);
    padding: 1.75rem 1.5rem;
    box-shadow: var(--shadow-md);
}

.tpl-purchase-card.is-highlight {
    border-color: var(--c-primary);
}

.tpl-purchase-price {
    text-align: center;
    padding-bottom: 1.25rem;
    margin-bottom: 1.25rem;
    border-bottom: 1px solid var(--c-border);
}

.tpl-purchase-amount {
    font-size: 1.85rem;
    font-weight: 900;
    color: var(--c-primary);
    line-height: 1.1;
    letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums;
}

.tpl-purchase-amount.is-free {
    color: var(--c-success);
}

.tpl-purchase-label {
    display: block;
    font-size: 0.82rem;
    color: var(--c-text-muted);
    margin-top: 0.35rem;
}

.tpl-purchase-features {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    margin-bottom: 1.5rem;
}

.tpl-purchase-features li {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: var(--c-text-soft);
}

.tpl-purchase-features li::before {
    content: '✓';
    color: var(--c-primary);
    font-weight: 900;
    font-size: 0.85rem;
}

.tpl-purchase-actions {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.tpl-author-card {
    margin-top: 1.25rem;
    padding: 1rem 1.15rem;
    background: var(--c-bg-alt);
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.tpl-author-avatar {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    background: linear-gradient(135deg, var(--c-primary), var(--c-primary-light));
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 1rem;
    flex-shrink: 0;
}

.tpl-author-info {
    min-width: 0;
}

.tpl-author-name {
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--c-text);
    margin: 0 0 0.15rem;
}

.tpl-author-role {
    font-size: 0.75rem;
    color: var(--c-text-muted);
    margin: 0;
}

/* ─────────────────────────────────────────────────────────
   ۸. Related Templates
   ───────────────────────────────────────────────────────── */
.tpl-related {
    padding: 4rem 0;
    background: var(--c-bg-alt);
    border-top: 1px solid var(--c-border);
}

body.dark-mode .tpl-related {
    background: #0f172a;
}

/* ─────────────────────────────────────────────────────────
   ۹. Responsive
   ───────────────────────────────────────────────────────── */
@media (max-width: 900px) {
    .tpl-detail-layout {
        grid-template-columns: 1fr;
        gap: 2rem;
    }

    .tpl-detail-sidebar {
        position: static;
    }

    .tpl-purchase-card {
        max-width: 100%;
    }
}

@media (max-width: 768px) {
    .templates-filter {
        position: static;
        padding: 1.25rem 0 1rem;
    }

    .filter-row {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
    }

    .filter-search {
        max-width: 100%;
    }

    .filter-chips-row {
        justify-content: flex-start;
        padding-bottom: 0.35rem;
    }

    .templates-section {
        padding: 2rem 0 3rem;
    }

    .templates-grid {
        grid-template-columns: 1fr;
        gap: 1.15rem;
    }
}

@media (max-width: 600px) {
    .tpl-detail-hero {
        padding: 2rem 0 1.5rem;
    }

    .tpl-features-list {
        grid-template-columns: 1fr;
    }

    .tpl-purchase-card {
        padding: 1.5rem 1.25rem;
    }

    .tpl-purchase-amount {
        font-size: 1.55rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    .tpl-card:hover {
        transform: none;
    }

    .tpl-card:hover .tpl-emoji,
    .tpl-card:hover .tpl-cover img {
        transform: none;
    }
}