/* =====================================================
   Instagantt Template Gallery - Custom Styles
   A beautiful, modern gallery experience
   ===================================================== */

/* CSS Variables */
:root {
    --primary-gradient: linear-gradient(119.51deg, #F16F8A 18.75%, #7813FB 100%);
    --primary-purple: #7813FB;
    --primary-pink: #F16F8A;
    --dark-bg: #0c1258;
    --text-primary: #1f1e33;
    --text-secondary: #5e6577;
    --text-muted: #8b93a7;
    --border-color: #e6e8ec;
    --card-shadow: 0 4px 24px rgba(120, 19, 251, 0.08);
    --card-shadow-hover: 0 12px 40px rgba(120, 19, 251, 0.15);
    --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --border-radius: 16px;
    --border-radius-sm: 8px;
    --font-family: 'Open Sans', 'Lato', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-family);
    color: var(--text-primary);
    line-height: 1.6;
    background: #fafbfc;
}

/* =====================================================
   Hero Section
   ===================================================== */
.gallery-hero {
    position: relative;
    min-height: 520px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    padding: 120px 24px 60px;
}

.gallery-hero-bg {
    position: absolute;
    inset: 0;
    z-index: 0;
}

.gallery-hero-gradient {
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, 
        #ffffff 0%, 
        #f8f4ff 30%,
        #f0e8ff 60%,
        #e8deff 100%
    );
}

.gallery-hero-pattern {
    position: absolute;
    inset: 0;
    opacity: 0.4;
    background-image: 
        radial-gradient(circle at 20% 80%, rgba(241, 111, 138, 0.15) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(120, 19, 251, 0.15) 0%, transparent 50%),
        radial-gradient(circle at 40% 40%, rgba(120, 19, 251, 0.08) 0%, transparent 30%);
}

.gallery-hero-content {
    position: relative;
    z-index: 1;
    max-width: 900px;
    width: 100%;
    text-align: center;
}

.gallery-hero-title {
    font-family: var(--font-family) !important;
    font-style: normal !important;
    font-size: clamp(2.5rem, 6vw, 4rem);
    font-weight: 800;
    line-height: 1.15;
    margin-bottom: 24px;
    letter-spacing: -0.02em;
}

.gallery-hero-title .gradient-color {
    display: inline-block;
    font-style: normal !important;
}

.gallery-hero-subtitle {
    font-size: 1.125rem;
    color: var(--text-secondary);
    max-width: 650px;
    margin: 0 auto 40px;
    line-height: 1.75;
}

/* =====================================================
   Search Bar
   ===================================================== */
.search-container {
    max-width: 640px;
    margin: 0 auto 32px;
}

.search-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    background: #ffffff;
    border: 2px solid transparent;
    border-radius: 100px;
    padding: 4px 8px 4px 24px;
    box-shadow: 
        0 4px 24px rgba(0, 0, 0, 0.06),
        0 0 0 1px rgba(0, 0, 0, 0.04);
    transition: var(--transition-smooth);
}

.search-wrapper:focus-within {
    border-color: var(--primary-purple);
    box-shadow: 
        0 4px 32px rgba(120, 19, 251, 0.12),
        0 0 0 1px var(--primary-purple);
}

.search-icon {
    color: var(--text-muted);
    flex-shrink: 0;
    transition: var(--transition-smooth);
}

.search-wrapper:focus-within .search-icon {
    color: var(--primary-purple);
}

.search-input {
    flex: 1;
    border: none;
    outline: none;
    padding: 16px;
    font-size: 1rem;
    font-family: var(--font-family);
    color: var(--text-primary);
    background: transparent;
}

.search-input:focus-visible {
    outline: none;
}

.search-input::placeholder {
    color: var(--text-muted);
}

.search-clear {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: none;
    background: #f0f2f5;
    border-radius: 50%;
    cursor: pointer;
    color: var(--text-muted);
    transition: var(--transition-smooth);
    margin-right: 8px;
}

.search-clear:hover {
    background: #e4e6ea;
    color: var(--text-primary);
}

/* =====================================================
   Category Filters
   ===================================================== */
.category-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: center;
}

.category-btn {
    padding: 10px 20px;
    border: 2px solid var(--border-color);
    border-radius: 100px;
    background: #ffffff;
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 600;
    font-family: var(--font-family);
    cursor: pointer;
    transition: var(--transition-smooth);
}

.category-btn:hover:not(.active) {
    border-color: var(--primary-purple);
    color: var(--primary-purple);
}

.category-btn.active {
    background: linear-gradient(119.51deg, #F16F8A 18.75%, #7813FB 100%);
    border-color: #F16F8A;
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(120, 19, 251, 0.25);
}

.category-btn.active:hover {
    box-shadow: 0 6px 16px rgba(120, 19, 251, 0.35);
}

/* =====================================================
   Templates Section
   ===================================================== */
.templates-section {
    padding: 40px 24px 80px;
    background: #ffffff;
    min-height: 600px;
}

.templates-container {
    max-width: 1280px;
    margin: 0 auto;
}

.results-info {
    margin-bottom: 32px;
    color: var(--text-muted);
    font-size: 0.875rem;
}

.results-info span {
    font-weight: 600;
    color: var(--text-primary);
}

/* =====================================================
   Templates Grid
   ===================================================== */
.templates-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 28px;
    margin-bottom: 48px;
}

/* Template Card */
.template-card {
    position: relative;
    background: #ffffff;
    border-radius: var(--border-radius);
    overflow: hidden;
    border: 1px solid var(--border-color);
    transition: var(--transition-smooth);
    cursor: pointer;
}

.template-card:hover {
    transform: translateY(-8px);
    box-shadow: var(--card-shadow-hover);
    border-color: transparent;
}

.template-card-image {
    position: relative;
    aspect-ratio: 4/3;
    overflow: hidden;
    background: #f5f5f5;
}

.template-card-image img,
.template-card-image iframe {
    min-width: 100%;
    min-height: 100%;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    transition: var(--transition-smooth);
    border: none;
    pointer-events: none;
    display: block;
}

.template-card:hover .template-card-image img {
    transform: scale(1.05);
}

.template-card-badge {
    position: absolute;
    top: 12px;
    left: 12px;
    padding: 6px 12px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(8px);
    border-radius: 100px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--primary-purple);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.template-card-content {
    padding: 20px 24px 24px;
}

.template-card-title {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-top: 0;
    margin-bottom: 8px;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.template-card-description {
    font-size: 0.875rem;
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 16px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.template-card-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
}

.template-card-author {
    display: flex;
    align-items: center;
    gap: 10px;
}

.template-card-author-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--primary-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    font-size: 0.75rem;
    font-weight: 700;
}

.template-card-author-name {
    font-size: 0.8125rem;
    color: var(--text-secondary);
}

.template-card-cta {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--primary-purple);
    transition: var(--transition-smooth);
}

.template-card:hover .template-card-cta {
    gap: 10px;
}

/* Template Card Placeholder (for loading) */
.template-card-placeholder {
    background: #ffffff;
    border-radius: var(--border-radius);
    overflow: hidden;
    border: 1px solid var(--border-color);
}

.template-card-placeholder .image-placeholder {
    aspect-ratio: 16/10;
    background: linear-gradient(90deg, #f0f2f5 0%, #e4e6ea 50%, #f0f2f5 100%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

.template-card-placeholder .content-placeholder {
    padding: 20px 24px 24px;
}

.template-card-placeholder .line {
    height: 16px;
    border-radius: 4px;
    background: linear-gradient(90deg, #f0f2f5 0%, #e4e6ea 50%, #f0f2f5 100%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    margin-bottom: 12px;
}

.template-card-placeholder .line.short {
    width: 60%;
}

.template-card-placeholder .line.medium {
    width: 80%;
}

@keyframes shimmer {
    0% {
        background-position: -200% 0;
    }
    100% {
        background-position: 200% 0;
    }
}

/* =====================================================
   Loading State
   ===================================================== */
.loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 80px 24px;
    color: var(--text-muted);
}

.loading-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--border-color);
    border-top-color: var(--primary-purple);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 16px;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* =====================================================
   No Results State
   ===================================================== */
.no-results {
    text-align: center;
    padding: 80px 24px;
    color: var(--text-muted);
}

.no-results svg {
    margin-bottom: 24px;
    opacity: 0.5;
}

.no-results h3 {
    font-size: 1.5rem;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.no-results p {
    margin-bottom: 24px;
}

.btn-reset {
    padding: 12px 24px;
    background: var(--primary-gradient);
    border: none;
    border-radius: 100px;
    color: #ffffff;
    font-size: 0.875rem;
    font-weight: 600;
    font-family: var(--font-family);
    cursor: pointer;
    transition: var(--transition-smooth);
}

.btn-reset:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(120, 19, 251, 0.3);
}

/* =====================================================
   Pagination
   ===================================================== */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 48px;
}

.pagination-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    background: #ffffff;
    border: 2px solid var(--border-color);
    border-radius: 100px;
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 600;
    font-family: var(--font-family);
    cursor: pointer;
    transition: var(--transition-smooth);
}

.pagination-btn:hover:not(:disabled) {
    border-color: var(--primary-purple);
    color: var(--primary-purple);
}

.pagination-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.pagination-numbers {
    display: flex;
    align-items: center;
    gap: 4px;
}

.pagination-number {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    height: 40px;
    padding: 0 12px;
    background: transparent;
    border: none;
    border-radius: 8px;
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 600;
    font-family: var(--font-family);
    cursor: pointer;
    transition: var(--transition-smooth);
}

.pagination-number:hover {
    background: #f0f2f5;
    color: var(--text-primary);
}

.pagination-number.active {
    background: var(--primary-gradient);
    color: #ffffff;
}

.pagination-ellipsis {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    color: var(--text-muted);
}

/* =====================================================
   Responsive Design
   ===================================================== */
@media (max-width: 991px) {
    .gallery-hero {
        min-height: 460px;
        padding: 100px 20px 50px;
    }
    
    .templates-grid {
        grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
        gap: 24px;
    }
}

@media (max-width: 767px) {
    .gallery-hero {
        min-height: auto;
        padding: 90px 16px 40px;
    }
    
    .gallery-hero-title {
        font-size: 2rem;
    }
    
    .gallery-hero-subtitle {
        font-size: 1rem;
    }
    
    .search-wrapper {
        padding: 2px 4px 2px 16px;
    }
    
    .search-input {
        padding: 12px;
        font-size: 0.9375rem;
    }
    
    .category-filters {
        gap: 8px;
    }
    
    .category-btn {
        padding: 8px 16px;
        font-size: 0.8125rem;
    }
    
    .templates-section {
        padding: 32px 16px 60px;
    }
    
    .templates-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .pagination {
        flex-wrap: wrap;
        gap: 12px;
    }
    
    .pagination-numbers {
        order: 2;
        width: 100%;
        justify-content: center;
    }
    
    .pagination-prev {
        order: 1;
    }
    
    .pagination-next {
        order: 3;
    }
}

/* =====================================================
   Modal Styles Override
   ===================================================== */
.modal-backdrop,
.modal-backdrop-signup {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-backdrop.active,
.modal-backdrop-signup.active {
    display: flex;
}

/* =====================================================
   Additional Utility Classes
   ===================================================== */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Focus visible styles for accessibility */
:focus-visible {
    outline: 2px solid var(--primary-purple);
    outline-offset: 2px;
}

/* Smooth scroll behavior */
html {
    scroll-behavior: smooth;
}

/* =====================================================
   Search Highlighting
   ===================================================== */
.template-card-title em,
.template-card-description em {
    font-style: normal;
    background: linear-gradient(119.51deg, rgba(241, 111, 138, 0.2) 18.75%, rgba(120, 19, 251, 0.2) 100%);
    padding: 0 4px;
    border-radius: 4px;
    color: var(--primary-purple);
    font-weight: 600;
}

/* =====================================================
   Image Fallback
   ===================================================== */
.image-fallback {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #f8f4ff 0%, #e8deff 100%);
    color: var(--primary-purple);
    font-size: 3rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    opacity: 0.7;
}

