/* ========================================
   SparkSheets Marketplace - Shared Styles
   Created: 2025-12-02
   Purpose: Consolidated styles for template marketplace
   Dependencies: variables.css (CSS variables)
   ======================================== */

/* ========== Base Styles ========== */
body.marketplace-page {
    background: var(--bg-secondary, #f5f7fa);
}

/* ========== Hero / Search Section ========== */
.search-section,
.author-header {
    background: var(--gradient-hero, linear-gradient(135deg, #667eea 0%, #764ba2 100%));
    padding: var(--spacing-3xl, 60px) 0;
    color: white;
}

.search-box {
    max-width: 600px;
    margin: 0 auto;
}

.search-input {
    border-radius: var(--radius-full, 50px);
    padding: var(--spacing-sm, 16px) var(--spacing-md, 24px);
    font-size: var(--font-size-lg, 1.1rem);
    border: none;
}

/* ========== Template Cards ========== */
.template-card {
    background: var(--bg-primary, white);
    border-radius: var(--radius-lg, 12px);
    overflow: hidden;
    box-shadow: var(--shadow-sm, 0 2px 8px rgba(0,0,0,0.08));
    transition: transform var(--transition-base, 0.2s), box-shadow var(--transition-base, 0.2s);
    height: 100%;
}

.template-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg, 0 8px 24px rgba(0,0,0,0.12));
}

.template-card-body {
    padding: var(--spacing-md, 20px);
}

.template-title {
    font-weight: var(--font-weight-semibold, 600);
    margin-bottom: var(--spacing-xs, 8px);
    color: var(--text-primary, #1a1a1a);
}

.template-description {
    color: var(--text-secondary, #666);
    font-size: var(--font-size-sm, 0.9rem);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.template-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: var(--spacing-sm, 12px);
    border-top: 1px solid var(--border-light, #f0f0f0);
    margin-top: var(--spacing-sm, 12px);
}

/* ========== Badges ========== */
.badge-category {
    background: var(--primary-light, #f0f4ff);
    color: var(--gray-600, #4a5568);
    font-weight: var(--font-weight-medium, 500);
    padding: 6px 12px;
}

/* Product Type Badges */
.badge-product-type {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 12px;
    border-radius: 16px;
    font-size: 0.75rem;
    font-weight: var(--font-weight-semibold, 600);
    transition: all 0.2s ease;
}

.badge-product-spark {
    background: linear-gradient(135deg, #FFD700 0%, #FFC700 100%);
    color: #333;
    box-shadow: 0 2px 8px rgba(255, 215, 0, 0.3);
}

.badge-product-spark:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(255, 215, 0, 0.4);
}

.badge-product-template {
    background: linear-gradient(135deg, #4A90E2 0%, #357ABD 100%);
    color: white;
    box-shadow: 0 2px 8px rgba(74, 144, 226, 0.3);
}

.badge-product-template:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(74, 144, 226, 0.4);
}

.badge-product-agent {
    background: linear-gradient(135deg, #7B68EE 0%, #6A5ACD 100%);
    color: white;
    box-shadow: 0 2px 8px rgba(123, 104, 238, 0.3);
}

.badge-product-agent:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(123, 104, 238, 0.4);
}

/* ========== Filter Sidebar ========== */
.filter-sidebar {
    background: var(--bg-primary, white);
    border-radius: var(--radius-lg, 12px);
    padding: var(--spacing-md, 20px);
    box-shadow: var(--shadow-xs, 0 2px 8px rgba(0,0,0,0.05));
    position: sticky;
    top: 20px;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
}

.filter-title,
.section-title {
    font-weight: var(--font-weight-semibold, 600);
    margin-bottom: var(--spacing-sm, 16px);
    padding-bottom: var(--spacing-sm, 12px);
    border-bottom: 2px solid var(--border-light, #f0f0f0);
}

.sort-select {
    border-radius: var(--radius-md, 8px);
}

/* ========== Loading & Empty States ========== */
.loading-spinner {
    display: none;
    text-align: center;
    padding: var(--spacing-2xl, 40px);
}

.no-results,
.no-templates,
.error-message {
    text-align: center;
    padding: var(--spacing-3xl, 60px) var(--spacing-md, 20px);
    color: var(--text-secondary, #666);
}

/* ========== Detail Page Specific ========== */
.template-header {
    background: var(--bg-primary, white);
    border-bottom: 1px solid var(--border-primary, #e0e0e0);
    padding: var(--spacing-lg, 32px) 0;
}

.template-header .template-title {
    font-size: var(--font-size-2xl, 2rem);
    font-weight: var(--font-weight-bold, 700);
    margin-bottom: var(--spacing-xs, 8px);
}

.template-header .template-meta {
    display: flex;
    gap: var(--spacing-sm, 16px);
    align-items: center;
    color: var(--text-secondary, #666);
    border-top: none;
    padding-top: 0;
    margin-top: 0;
}

.content-section {
    background: var(--bg-primary, white);
    border-radius: var(--radius-lg, 12px);
    padding: var(--spacing-md, 24px);
    margin-bottom: var(--spacing-md, 24px);
    box-shadow: var(--shadow-xs, 0 2px 8px rgba(0,0,0,0.05));
}

.template-preview {
    background: var(--bg-tertiary, #fafafa);
    border: 1px solid var(--border-primary, #e0e0e0);
    border-radius: var(--radius-md, 8px);
    padding: var(--spacing-md, 24px);
    min-height: 200px;
    max-height: 400px;
    overflow-y: auto;
}

.sidebar-card {
    background: var(--bg-primary, white);
    border-radius: var(--radius-lg, 12px);
    padding: var(--spacing-md, 24px);
    box-shadow: var(--shadow-xs, 0 2px 8px rgba(0,0,0,0.05));
    position: sticky;
    top: var(--spacing-md, 24px);
}

.price-display {
    font-size: var(--font-size-xl, 1.5rem);
    font-weight: var(--font-weight-bold, 700);
    color: var(--info, #2563eb);
    margin-bottom: var(--spacing-sm, 16px);
}

.btn-use-template {
    width: 100%;
    padding: var(--spacing-sm, 12px);
    font-weight: var(--font-weight-semibold, 600);
    border-radius: var(--radius-md, 8px);
}

/* ========== Reviews ========== */
.review-item {
    padding: var(--spacing-sm, 16px) 0;
    border-bottom: 1px solid var(--border-light, #f0f0f0);
}

.review-item:last-child {
    border-bottom: none;
}

.review-rating {
    color: var(--warning, #f59e0b);
}

.review-form {
    background: var(--bg-tertiary, #f8f9fa);
    padding: var(--spacing-md, 20px);
    border-radius: var(--radius-md, 8px);
}

/* Star Rating Input */
.star-rating {
    display: flex;
    flex-direction: row-reverse;
    justify-content: flex-end;
}

.star-rating input {
    display: none;
}

.star-rating label {
    cursor: pointer;
    font-size: var(--font-size-xl, 1.5rem);
    color: var(--gray-300, #ddd);
    padding: 0 2px;
}

.star-rating label:hover,
.star-rating label:hover ~ label,
.star-rating input:checked ~ label {
    color: var(--warning, #f59e0b);
}

/* ========== Related Templates ========== */
.related-card {
    background: var(--bg-tertiary, #f8f9fa);
    border-radius: var(--radius-md, 8px);
    padding: var(--spacing-sm, 12px);
    cursor: pointer;
    transition: background var(--transition-base, 0.2s);
}

.related-card:hover {
    background: var(--gray-200, #e9ecef);
}

/* ========== Author Page ========== */
.author-avatar {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: var(--bg-primary, white);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
    color: var(--text-muted, #6c757d);
    margin: 0 auto var(--spacing-sm, 16px);
    overflow: hidden;
    box-shadow: var(--shadow-lg, 0 4px 20px rgba(0,0,0,0.2));
}

.author-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Small author avatar (detail page sidebar) */
.sidebar-card .author-avatar,
.content-section .author-avatar {
    width: 40px;
    height: 40px;
    font-size: 1.2rem;
    margin: 0;
}

.author-name {
    font-size: var(--font-size-2xl, 2rem);
    font-weight: var(--font-weight-bold, 700);
    margin-bottom: var(--spacing-xs, 8px);
}

.author-bio {
    opacity: 0.9;
    max-width: 600px;
    margin: 0 auto var(--spacing-sm, 16px);
}

.author-stats {
    display: flex;
    justify-content: center;
    gap: var(--spacing-lg, 32px);
    margin-top: var(--spacing-md, 24px);
}

.stat-item {
    text-align: center;
}

.stat-value {
    font-size: var(--font-size-xl, 1.5rem);
    font-weight: var(--font-weight-bold, 700);
}

.stat-label {
    font-size: var(--font-size-sm, 0.875rem);
    opacity: 0.8;
}

.social-links {
    margin-top: var(--spacing-sm, 16px);
}

.social-links a {
    color: white;
    font-size: var(--font-size-xl, 1.5rem);
    margin: 0 var(--spacing-xs, 8px);
    opacity: 0.8;
    transition: opacity var(--transition-base, 0.2s);
}

.social-links a:hover {
    opacity: 1;
}

.author-info a {
    color: var(--text-primary, #333);
}

.author-info a:hover {
    color: var(--info, #2563eb);
}

/* ========== Templates Section (Author Page) ========== */
.templates-section {
    padding: var(--spacing-2xl, 40px) 0;
}

/* Author page template cards with padding */
.templates-section .template-card {
    padding: var(--spacing-md, 20px);
    margin-bottom: var(--spacing-md, 20px);
}

.templates-section .template-meta {
    gap: var(--spacing-sm, 16px);
    font-size: var(--font-size-sm, 0.85rem);
    color: var(--text-muted, #888);
    border-top: none;
    padding-top: 0;
    margin-top: 0;
}

.templates-section .template-meta .material-icons {
    font-size: 1rem;
    vertical-align: middle;
    margin-right: 4px;
}

/* ========== Modal Overlay Styles (for App Integration) ========== */
.marketplace-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: var(--z-modal);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--spacing-md, 20px);
    animation: fadeIn 0.2s ease-out;
}

.marketplace-modal-content {
    background: var(--bg-primary, white);
    border-radius: var(--radius-xl, 16px);
    max-width: 1200px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-2xl, 0 24px 48px rgba(0,0,0,0.2));
    animation: slideUp 0.3s ease-out;
}

.marketplace-modal-container {
    padding: var(--spacing-lg, 32px);
}

.marketplace-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-md, 24px);
    padding-bottom: var(--spacing-sm, 16px);
    border-bottom: 2px solid var(--border-light, #f0f0f0);
}

.marketplace-modal-header h3 {
    margin: 0;
    font-size: var(--font-size-xl, 1.5rem);
    font-weight: var(--font-weight-bold, 700);
}

.btn-close-modal {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-secondary, #666);
    cursor: pointer;
    padding: var(--spacing-xs, 8px);
    border-radius: var(--radius-md, 8px);
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
}

.btn-close-modal:hover {
    background: var(--bg-tertiary, #f5f5f5);
    color: var(--text-primary, #333);
}

.search-box-compact {
    max-width: 100%;
}

.search-box-compact .form-control {
    border-radius: var(--radius-md, 8px);
    padding: var(--spacing-sm, 12px);
}

/* Detail Modal (nested modal for template details) */
.marketplace-detail-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    z-index: calc(var(--z-modal) + 1);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--spacing-md, 20px);
    animation: fadeIn 0.2s ease-out;
}

.detail-modal-content {
    background: var(--bg-primary, white);
    border-radius: var(--radius-xl, 16px);
    max-width: 800px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    padding: var(--spacing-xl, 40px);
    box-shadow: var(--shadow-2xl, 0 24px 48px rgba(0,0,0,0.3));
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .marketplace-modal-content {
        width: 100vw;
        height: 100vh;
        max-width: 100vw;
        max-height: 100vh;
        border-radius: 0;
        margin: 0;
    }
    
    .marketplace-modal-container {
        padding: var(--spacing-md, 20px);
    }
    
    .detail-modal-content {
        width: 100vw;
        height: 100vh;
        max-width: 100vw;
        max-height: 100vh;
        border-radius: 0;
        padding: var(--spacing-md, 20px);
    }
}

/* Compact filter sidebar for modal */
.marketplace-modal-content .filter-sidebar {
    max-height: 60vh;
    overflow-y: auto;
}

/* Price badge on cards */
.price-badge {
    position: absolute;
    top: var(--spacing-sm, 12px);
    right: var(--spacing-sm, 12px);
    background: linear-gradient(135deg, #FFD700 0%, #FFC700 100%);
    color: #333;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: var(--font-weight-semibold, 600);
    box-shadow: 0 2px 8px rgba(255, 215, 0, 0.3);
}

.template-card {
    position: relative;
}

.template-card.is-paid {
    border: 2px solid rgba(255, 215, 0, 0.3);
}

.template-stats {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs, 8px);
}

