/**
 * QRFix Templates - Frontend Styles
 */

/* ===== TEMPLATES GALLERY ===== */
.qrfix-templates-gallery {
    max-width: 1400px;
    margin: 0 auto;
    padding: 40px 20px;
}

.templates-header {
    text-align: center;
    margin-bottom: 40px;
}

.templates-header h2 {
    font-size: 36px;
    font-weight: 700;
    color: #1F2937;
    margin-bottom: 16px;
}

.templates-header h2 .highlight {
    color: #8B5CF6;
}

.templates-header p {
    font-size: 16px;
    color: #6B7280;
    max-width: 800px;
    margin: 0 auto;
    line-height: 1.7;
}

/* Category Slider */
.category-slider-wrapper {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 32px;
    position: relative;
}

.category-slider {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    scroll-behavior: smooth;
    padding: 10px 0;
    flex: 1;
    scrollbar-width: none;
}

.category-slider::-webkit-scrollbar {
    display: none;
}

.category-item {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 16px 24px;
    background: #F9FAFB;
    border: 2px solid #E5E7EB;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 100px;
}

.category-item:hover {
    border-color: #D1D5DB;
    background: white;
}

.category-item.active {
    border-color: #8B5CF6;
    background: rgba(139, 92, 246, 0.05);
}

.category-icon {
    font-size: 28px;
    line-height: 1;
}

.category-item span {
    font-size: 13px;
    font-weight: 500;
    color: #374151;
    white-space: nowrap;
}

.slider-nav {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 2px solid #E5E7EB;
    background: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.slider-nav:hover {
    border-color: #8B5CF6;
    color: #8B5CF6;
}

.slider-nav svg {
    width: 20px;
    height: 20px;
}

/* Plan Filter Tabs */
.plan-filter-tabs {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-bottom: 32px;
    flex-wrap: wrap;
}

.plan-tab {
    padding: 10px 20px;
    border: none;
    background: #F3F4F6;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    color: #6B7280;
    cursor: pointer;
    transition: all 0.2s ease;
}

.plan-tab:hover {
    background: #E5E7EB;
}

.plan-tab.active {
    background: #8B5CF6;
    color: white;
}

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

.templates-loading {
    grid-column: 1 / -1;
    text-align: center;
    padding: 60px 20px;
    color: #6B7280;
}

.templates-loading .spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #E5E7EB;
    border-top-color: #8B5CF6;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 16px;
}

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

.no-templates {
    grid-column: 1 / -1;
    text-align: center;
    padding: 60px 20px;
    color: #9CA3AF;
}

/* Template Card */
.template-card {
    background: white;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    transition: all 0.3s ease;
}

.template-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
}

.template-card.locked {
    opacity: 0.85;
}

.template-preview {
    position: relative;
    aspect-ratio: 9/16;
    overflow: hidden;
    background: linear-gradient(135deg, #f5f7fa 0%, #e4e8ed 100%);
    cursor: pointer;
}

.template-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

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

.featured-badge {
    position: absolute;
    top: 12px;
    left: 12px;
    background: linear-gradient(135deg, #F59E0B, #D97706);
    color: white;
    font-size: 11px;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 20px;
}

.plan-badge {
    position: absolute;
    top: 12px;
    right: 12px;
    font-size: 10px;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 20px;
    text-transform: uppercase;
}

.plan-badge.free {
    background: #D1FAE5;
    color: #059669;
}

.plan-badge.premium {
    background: #EDE9FE;
    color: #7C3AED;
}

.plan-badge.enterprise {
    background: #FEF3C7;
    color: #D97706;
}

.lock-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: white;
    gap: 8px;
    opacity: 0;
    transition: opacity 0.2s ease;
}

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

.lock-icon {
    font-size: 32px;
}

.lock-overlay span:last-child {
    font-size: 13px;
    font-weight: 500;
}

.template-info {
    padding: 16px;
}

.template-info h4 {
    font-size: 15px;
    font-weight: 600;
    color: #1F2937;
    margin: 0 0 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.btn-use-template {
    width: 100%;
    padding: 12px 16px;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    background: linear-gradient(135deg, #8B5CF6, #7C3AED);
    color: white;
}

.btn-use-template:hover:not([disabled]) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(139, 92, 246, 0.35);
}

.btn-use-template[disabled] {
    background: #E5E7EB;
    color: #9CA3AF;
    cursor: not-allowed;
}

/* Pagination */
.templates-pagination {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 32px;
}

.page-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #E5E7EB;
    cursor: pointer;
    transition: all 0.2s ease;
}

.page-dot.active {
    width: 30px;
    border-radius: 5px;
    background: #8B5CF6;
}

/* Footer */
.templates-footer {
    text-align: center;
}

.btn-view-all {
    display: inline-block;
    padding: 14px 32px;
    background: linear-gradient(135deg, #10B981, #059669);
    color: white;
    text-decoration: none;
    border-radius: 10px;
    font-weight: 600;
    transition: all 0.2s ease;
}

.btn-view-all:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.35);
    color: white;
}

/* Modal */
.template-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
}

.modal-content {
    position: relative;
    background: white;
    border-radius: 20px;
    max-width: 900px;
    width: 90%;
    max-height: 90vh;
    overflow: auto;
}

.modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 40px;
    height: 40px;
    border: none;
    background: #F3F4F6;
    border-radius: 50%;
    font-size: 24px;
    cursor: pointer;
    z-index: 10;
    transition: all 0.2s ease;
}

.modal-close:hover {
    background: #E5E7EB;
}

.modal-body {
    display: grid;
    grid-template-columns: 1fr 1.2fr;
    min-height: 400px;
}

.modal-loading {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 60px;
}

.modal-preview {
    background: linear-gradient(135deg, #f5f7fa, #e8ecf1);
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-preview img {
    max-width: 100%;
    max-height: 500px;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
}

.modal-details {
    padding: 32px;
}

.modal-details h3 {
    font-size: 24px;
    font-weight: 700;
    color: #1F2937;
    margin: 0 0 12px;
}

.template-desc {
    color: #6B7280;
    line-height: 1.6;
    margin-bottom: 20px;
}

.template-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 24px;
}

.meta-item {
    font-size: 13px;
    color: #6B7280;
}

.meta-item strong {
    color: #374151;
}

.modal-actions {
    margin-top: 24px;
}

.modal-actions .btn-primary {
    display: inline-block;
    padding: 14px 28px;
    background: linear-gradient(135deg, #8B5CF6, #7C3AED);
    color: white;
    text-decoration: none;
    border-radius: 10px;
    font-weight: 600;
    transition: all 0.2s ease;
}

.modal-actions .btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(139, 92, 246, 0.35);
    color: white;
}

/* ===== TEMPLATE CUSTOMIZER ===== */
.qrfix-template-customizer {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

.customizer-header {
    margin-bottom: 32px;
}

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: #6B7280;
    text-decoration: none;
    font-size: 14px;
    margin-bottom: 16px;
    transition: color 0.2s ease;
}

.back-link:hover {
    color: #8B5CF6;
}

.template-title-section h1 {
    font-size: 28px;
    font-weight: 700;
    color: #1F2937;
    margin: 0 0 12px;
}

.template-meta {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.meta-tag {
    font-size: 12px;
    font-weight: 500;
    padding: 4px 12px;
    border-radius: 20px;
    background: #F3F4F6;
    color: #6B7280;
}

.meta-tag.type {
    background: #DBEAFE;
    color: #1D4ED8;
}

.meta-tag.plan-free {
    background: #D1FAE5;
    color: #059669;
}

.meta-tag.plan-premium {
    background: #EDE9FE;
    color: #7C3AED;
}

.meta-tag.plan-enterprise {
    background: #FEF3C7;
    color: #D97706;
}

.customizer-body {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 32px;
}

/* Form Panel */
.customizer-form-panel {
    background: white;
    border-radius: 20px;
    padding: 28px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}

.panel-header {
    margin-bottom: 24px;
}

.panel-header h3 {
    font-size: 18px;
    font-weight: 600;
    color: #1F2937;
    margin: 0 0 4px;
}

.panel-header p {
    font-size: 14px;
    color: #6B7280;
    margin: 0;
}

.customizer-form .form-group {
    margin-bottom: 20px;
}

.customizer-form label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: #374151;
    margin-bottom: 6px;
}

.customizer-form .required {
    color: #EF4444;
}

.customizer-form .form-input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #E5E7EB;
    border-radius: 10px;
    font-size: 14px;
    transition: all 0.2s ease;
}

.customizer-form .form-input:focus {
    outline: none;
    border-color: #8B5CF6;
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.1);
}

.customizer-form textarea.form-input {
    resize: vertical;
    min-height: 100px;
}

.customizer-form .field-help {
    font-size: 12px;
    color: #9CA3AF;
    margin-top: 4px;
}

.customizer-form .color-picker {
    padding: 4px;
    height: 48px;
    cursor: pointer;
}

.qr-destination-group {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.05), rgba(124, 58, 237, 0.08));
    padding: 20px;
    border-radius: 12px;
    margin-top: 24px;
    border: 2px solid rgba(139, 92, 246, 0.2);
}

.form-actions {
    display: flex;
    gap: 12px;
    margin-top: 28px;
}

.form-actions .btn {
    flex: 1;
    padding: 14px 20px;
    border: none;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.form-actions .btn-secondary {
    background: #F3F4F6;
    color: #374151;
}

.form-actions .btn-secondary:hover {
    background: #E5E7EB;
}

.form-actions .btn-primary {
    background: linear-gradient(135deg, #8B5CF6, #7C3AED);
    color: white;
}

.form-actions .btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(139, 92, 246, 0.35);
}

/* Preview Panel */
.customizer-preview-panel {
    background: white;
    border-radius: 20px;
    padding: 28px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}

.preview-device {
    margin-bottom: 20px;
}

.device-frame {
    background: #1F2937;
    border-radius: 32px;
    padding: 12px;
    max-width: 320px;
    margin: 0 auto;
    transition: all 0.3s ease;
}

.device-frame.desktop-mode {
    max-width: 100%;
    border-radius: 12px;
}

.device-screen {
    background: white;
    border-radius: 24px;
    overflow: hidden;
    aspect-ratio: 9/16;
}

.device-frame.desktop-mode .device-screen {
    aspect-ratio: 16/10;
    border-radius: 8px;
}

.device-screen img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.device-screen iframe {
    width: 100%;
    height: 100%;
    border: none;
}

.preview-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #F9FAFB;
    color: #9CA3AF;
    font-size: 14px;
}

.preview-actions {
    display: flex;
    justify-content: center;
    gap: 8px;
}

.preview-mode-btn {
    padding: 8px 16px;
    border: 2px solid #E5E7EB;
    background: white;
    border-radius: 8px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.preview-mode-btn.active {
    border-color: #8B5CF6;
    background: rgba(139, 92, 246, 0.05);
    color: #8B5CF6;
}

/* Processing Modal */
.processing-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.processing-modal .modal-content {
    text-align: center;
    padding: 48px;
    max-width: 400px;
}

.processing-animation .spinner {
    width: 60px;
    height: 60px;
    border: 4px solid #E5E7EB;
    border-top-color: #8B5CF6;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 24px;
}

.processing-modal h3 {
    font-size: 20px;
    font-weight: 600;
    color: #1F2937;
    margin: 0 0 8px;
}

.processing-modal p {
    color: #6B7280;
    margin: 0 0 24px;
}

.processing-modal .progress-bar {
    height: 6px;
    background: #E5E7EB;
    border-radius: 3px;
    overflow: hidden;
}

.processing-modal .progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #8B5CF6, #7C3AED);
    border-radius: 3px;
    transition: width 0.3s ease;
    width: 0%;
}

/* Upgrade Prompt */
.qrfix-upgrade-prompt {
    max-width: 500px;
    margin: 60px auto;
    text-align: center;
    padding: 48px;
    background: white;
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
}

.upgrade-icon {
    font-size: 64px;
    margin-bottom: 20px;
}

.qrfix-upgrade-prompt h2 {
    font-size: 28px;
    font-weight: 700;
    color: #1F2937;
    margin: 0 0 12px;
}

.qrfix-upgrade-prompt p {
    color: #6B7280;
    margin-bottom: 24px;
}

.upgrade-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.upgrade-actions .btn {
    padding: 12px 24px;
    border-radius: 10px;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.2s ease;
}

.upgrade-actions .btn-primary {
    background: linear-gradient(135deg, #8B5CF6, #7C3AED);
    color: white;
}

.upgrade-actions .btn-secondary {
    background: #F3F4F6;
    color: #374151;
}

/* Image Upload Field */
.field-image-upload {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.field-image-upload .image-preview {
    max-width: 200px;
    border-radius: 8px;
    overflow: hidden;
}

.field-image-upload .image-preview img {
    width: 100%;
    height: auto;
}

.field-image-upload .btn {
    align-self: flex-start;
}

/* Responsive */
@media (max-width: 1024px) {
    .customizer-body {
        grid-template-columns: 1fr;
    }
    
    .customizer-preview-panel {
        order: -1;
    }
    
    .modal-body {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .templates-header h2 {
        font-size: 28px;
    }
    
    .templates-grid {
        grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    }
    
    .category-item {
        padding: 12px 16px;
        min-width: 80px;
    }
    
    .category-icon {
        font-size: 24px;
    }
    
    .device-frame {
        max-width: 280px;
    }
}
