/* ============================================
   TEMPLATES PAGE — Premium Compact Grid
   ============================================ */

.templates-page-container {
    padding: 40px 20px 60px;
    max-width: 1400px;
    margin: 0 auto;
}

/* Hero Section */
.templates-header {
    text-align: center;
    margin-bottom: 40px;
}

.templates-header h1 {
    font-size: 2.5rem;
    font-weight: 800;
    background: linear-gradient(135deg, #0f172a 0%, #475569 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 12px;
    letter-spacing: -0.03em;
}

.templates-header p {
    color: #64748b;
    font-size: 1.1rem;
    max-width: 600px;
    margin: 0 auto;
    line-height: 1.6;
}

/* Category Filters — Sticky pill bar */
.template-filters {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 32px;
    padding: 12px 0;
    position: sticky;
    top: 70px;
    z-index: 50;
    background: rgba(248, 250, 252, 0.92);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: 16px;
}

.filter-btn {
    background: white;
    border: 1px solid #e2e8f0;
    padding: 8px 18px;
    border-radius: 9999px;
    font-size: 0.85rem;
    font-weight: 500;
    color: #64748b;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 1px 2px rgba(0,0,0,0.04);
    white-space: nowrap;
}

.filter-btn:hover {
    border-color: #0ea5e9;
    color: #0ea5e9;
    transform: translateY(-1px);
}

.filter-btn.active {
    background: #0ea5e9;
    color: white;
    border-color: #0ea5e9;
    box-shadow: 0 4px 8px rgba(14, 165, 233, 0.25);
}

/* Template Grid — Compact 4-5 columns */
.templates-row {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 40px;
}

/* Category Sections */
.template-category {
    margin-bottom: 48px;
    scroll-margin-top: 140px;
}

.category-title {
    font-size: 1.4rem;
    font-weight: 700;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 2px solid #e2e8f0;
    color: #1e293b;
    display: flex;
    align-items: center;
    gap: 10px;
}

.category-count {
    font-size: 0.8rem;
    background: #eff6ff;
    color: #2563eb;
    padding: 3px 10px;
    border-radius: 99px;
    font-weight: 600;
}

/* Template Card — Compact */
.template-card {
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0,0,0,0.04);
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid #e2e8f0;
    display: flex;
    flex-direction: column;
    position: relative;
    cursor: pointer;
}

.template-card:hover {
    transform: translateY(-6px);
    box-shadow: 0 12px 24px rgba(0,0,0,0.1);
    border-color: #0ea5e9;
}

/* Preview — Smaller height */
.template-preview {
    height: 260px;
    background: #f8fafc;
    overflow: hidden;
    position: relative;
}

.mini-resume-scale {
    transform: scale(0.28);
    transform-origin: top left;
    width: 360%;
    height: 360%;
    pointer-events: none;
    padding: 16px;
    background: white;
    -webkit-font-smoothing: antialiased;
}

/* Hover overlay */
.template-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(to top, rgba(14, 165, 233, 0.15) 0%, transparent 60%);
    opacity: 0;
    transition: opacity 0.3s ease;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding-bottom: 16px;
    pointer-events: none;
}

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

.template-overlay .btn {
    padding: 8px 20px;
    font-size: 0.8rem;
    font-weight: 600;
    border-radius: 8px;
    background: #0ea5e9;
    color: white;
    border: none;
    box-shadow: 0 4px 12px rgba(14, 165, 233, 0.4);
    pointer-events: auto;
}

/* Template Info — Compact */
.template-info {
    padding: 12px 14px;
    text-align: left;
    border-top: 1px solid #f1f5f9;
    background: white;
}

.template-info h3 {
    margin-bottom: 2px;
    color: #1e293b;
    font-weight: 600;
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.template-info p {
    font-size: 0.75rem;
    color: #94a3b8;
    margin-bottom: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.template-btn {
    display: none; /* Hidden — the overlay button is enough */
}

/* Back to Top */
#back-to-top {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: #0ea5e9;
    color: white;
    border: none;
    box-shadow: 0 4px 12px rgba(14, 165, 233, 0.3);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 100;
}

#back-to-top.visible {
    opacity: 1;
    visibility: visible;
}

#back-to-top:hover {
    transform: translateY(-3px);
    background: #0284c7;
}

/* Responsive */
@media (max-width: 1024px) {
    .templates-row {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
        gap: 16px;
    }
    .templates-header h1 {
        font-size: 2rem;
    }
}

@media (max-width: 640px) {
    .templates-page-container {
        padding: 20px 12px 40px;
    }
    .templates-row {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }
    .template-preview {
        height: 200px;
    }
    .mini-resume-scale {
        transform: scale(0.22);
        width: 455%;
        height: 455%;
    }
    .template-filters {
        gap: 6px;
        top: 60px;
    }
    .filter-btn {
        padding: 6px 12px;
        font-size: 0.78rem;
    }
    .templates-header h1 {
        font-size: 1.5rem;
    }
    .templates-header p {
        font-size: 0.9rem;
    }
}
