/**
 * Epic Event Invitation Generator - Premium Styles
 * Etsy-quality design with premium themes and features
 */

:root {
    --primary-color: #667eea;
    --primary-dark: #5a67d8;
    --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --success-gradient: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
    --gold-gradient: linear-gradient(135deg, #d4af37 0%, #ffd700 100%);
    --text-dark: #1a1a2e;
    --text-light: #64748b;
    --border-color: #e2e8f0;
    --bg-light: #f8fafc;
    --card-shadow: 0 4px 20px rgba(0,0,0,0.08);
    --card-shadow-hover: 0 8px 30px rgba(0,0,0,0.12);
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: linear-gradient(180deg, #f0f4f8 0%, #d9e2ec 100%);
    min-height: 100vh;
    color: var(--text-dark);
}

/* Tool Container */
.tool-container {
    max-width: 1800px;
    margin: 0 auto;
    padding: 2rem;
}

/* Header */
.tool-header {
    text-align: center;
    margin-bottom: 2rem;
    padding: 2.5rem 2rem;
    background: white;
    border-radius: 20px;
    box-shadow: var(--card-shadow);
}

.tool-header h1 {
    font-size: 2.5rem;
    font-weight: 800;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 0.75rem;
}

.tool-description {
    font-size: 1.1rem;
    color: var(--text-light);
    max-width: 700px;
    margin: 0 auto 1.5rem;
    line-height: 1.6;
}

.header-badges {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

.badge {
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
}

.theme-badge { background: linear-gradient(135deg, #667eea, #764ba2); color: white; }
.typography-badge { background: linear-gradient(135deg, #11998e, #38ef7d); color: white; }
.ornament-badge { background: linear-gradient(135deg, #f093fb, #f5576c); color: white; }
.mockup-badge { background: linear-gradient(135deg, #4facfe, #00f2fe); color: white; }

/* Workspace Layout */
.tool-workspace {
    display: grid;
    grid-template-columns: 520px 1fr;
    gap: 2rem;
    align-items: start;
}

@media (max-width: 1400px) {
    .tool-workspace {
        grid-template-columns: 1fr;
    }
}

/* Control Panel */
.control-panel {
    background: white;
    border-radius: 20px;
    box-shadow: var(--card-shadow);
    overflow: hidden;
}

.panel-section {
    padding: 1.5rem 2rem;
    border-bottom: 1px solid var(--border-color);
}

.panel-section:last-child {
    border-bottom: none;
}

.panel-section h3 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-dark);
    margin-bottom: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Category Grid */
.category-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.75rem;
}

.category-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0.75rem 0.5rem;
    border: 2px solid var(--border-color);
    border-radius: 12px;
    background: white;
    cursor: pointer;
    transition: all 0.2s ease;
}

.category-btn:hover {
    border-color: var(--primary-color);
    transform: translateY(-2px);
}

.category-btn.active {
    border-color: var(--primary-color);
    background: linear-gradient(135deg, rgba(102,126,234,0.1), rgba(118,75,162,0.1));
}

.cat-icon {
    font-size: 1.5rem;
    margin-bottom: 0.25rem;
}

.cat-name {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-light);
    text-align: center;
}

/* Theme Carousel */
.theme-carousel {
    display: flex;
    gap: 1rem;
    overflow-x: auto;
    padding: 0.5rem 0;
    scrollbar-width: thin;
}

.theme-carousel::-webkit-scrollbar {
    height: 6px;
}

.theme-carousel::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

.theme-carousel::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 10px;
}

.theme-card {
    flex: 0 0 120px;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.theme-card:hover {
    transform: translateY(-4px);
}

.theme-card.active .theme-preview {
    box-shadow: 0 0 0 3px var(--primary-color);
}

.theme-preview {
    width: 120px;
    height: 80px;
    border-radius: 10px;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding-bottom: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    transition: box-shadow 0.2s ease;
}

.theme-label {
    font-size: 0.65rem;
    font-weight: 600;
    color: white;
    text-shadow: 0 1px 3px rgba(0,0,0,0.5);
    padding: 3px 8px;
    background: rgba(0,0,0,0.3);
    border-radius: 4px;
}

.theme-category {
    display: block;
    text-align: center;
    font-size: 0.7rem;
    color: var(--text-light);
    margin-top: 0.5rem;
}

/* Typography Options */
.typography-options {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.typography-btn {
    flex: 1;
    min-width: 90px;
    padding: 0.75rem;
    border: 2px solid var(--border-color);
    border-radius: 10px;
    background: white;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.typography-btn:hover {
    border-color: var(--primary-color);
}

.typography-btn.active {
    border-color: var(--primary-color);
    background: linear-gradient(135deg, rgba(102,126,234,0.1), rgba(118,75,162,0.1));
}

.typo-preview {
    font-size: 1.5rem;
    color: var(--text-dark);
}

.typo-name {
    font-size: 0.65rem;
    color: var(--text-light);
    margin-top: 0.25rem;
    font-weight: 500;
}

/* Ornaments Grid */
.ornaments-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
    max-height: 200px;
    overflow-y: auto;
}

.ornament-checkbox {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.ornament-checkbox:hover {
    background: var(--bg-light);
}

.ornament-checkbox input:checked + .ornament-label {
    color: var(--primary-color);
    font-weight: 600;
}

.ornament-checkbox input {
    accent-color: var(--primary-color);
}

.ornament-label {
    font-size: 0.8rem;
    color: var(--text-dark);
}

/* Form Styles */
.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
    color: var(--text-dark);
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 0.8rem 1rem;
    border: 2px solid var(--border-color);
    border-radius: 10px;
    font-size: 0.95rem;
    font-family: 'Inter', sans-serif;
    transition: all 0.2s ease;
    background: white;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.form-group textarea {
    resize: vertical;
    min-height: 80px;
}

.form-row {
    display: flex;
    gap: 1rem;
}

.form-group.half {
    flex: 1;
}

.suggest-btn {
    padding: 0.25rem 0.75rem;
    background: var(--gold-gradient);
    color: #1a1a2e;
    border: none;
    border-radius: 15px;
    font-size: 0.7rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.suggest-btn:hover {
    transform: scale(1.05);
}

/* QR Section */
.qr-section {
    background: var(--bg-light);
    padding: 1rem;
    border-radius: 10px;
    margin-top: 1rem;
}

.toggle-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-weight: 600;
}

.toggle-label input {
    width: 18px;
    height: 18px;
    accent-color: var(--primary-color);
}

.qr-options {
    margin-top: 1rem;
}

.qr-options input {
    margin-bottom: 0.5rem;
}

.qr-options small {
    color: var(--text-light);
    font-size: 0.8rem;
}

.hidden {
    display: none !important;
}

/* Action Buttons */
.actions-section {
    display: flex;
    gap: 1rem;
    padding: 2rem !important;
}

.btn-primary,
.btn-secondary,
.btn-success,
.btn-outline {
    padding: 1rem 1.5rem;
    border: none;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: 'Inter', sans-serif;
}

.btn-large {
    padding: 1.1rem 2rem;
    font-size: 1.05rem;
}

.btn-primary {
    flex: 2;
    background: var(--primary-gradient);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    flex: 1;
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
}

.btn-secondary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(245, 87, 108, 0.4);
}

.btn-success {
    width: 100%;
    background: var(--success-gradient);
    color: white;
}

.btn-success:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(56, 239, 125, 0.4);
}

.btn-outline {
    flex: 1;
    background: white;
    color: var(--text-dark);
    border: 2px solid var(--border-color);
}

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

button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

/* Preview Panel */
.preview-panel {
    background: white;
    border-radius: 20px;
    box-shadow: var(--card-shadow);
    padding: 2rem;
    position: sticky;
    top: 20px;
}

.preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.preview-header h2 {
    font-size: 1.5rem;
    font-weight: 700;
}

.mockup-selector {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.mockup-btn {
    padding: 0.5rem 1rem;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    background: white;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.mockup-btn:hover {
    border-color: var(--primary-color);
}

.mockup-btn.active {
    background: var(--primary-gradient);
    color: white;
    border-color: transparent;
}

/* Canvas Container */
.canvas-wrapper {
    margin-bottom: 1.5rem;
}

.canvas-container,
.mockup-container {
    background: var(--bg-light);
    border: 2px solid var(--border-color);
    border-radius: 16px;
    padding: 2rem;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 500px;
    overflow: auto;
}

#previewCanvas,
#mockupCanvas {
    max-width: 100%;
    height: auto;
    box-shadow: 0 8px 30px rgba(0,0,0,0.15);
    border-radius: 8px;
    background: white;
}

/* Preview Actions */
.preview-actions {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.secondary-actions {
    display: flex;
    gap: 0.75rem;
}

.preview-note {
    text-align: center;
    color: var(--text-light);
    margin-top: 1rem;
    font-size: 0.9rem;
    font-style: italic;
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    z-index: 10000;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(4px);
}

.modal.active {
    display: flex;
}

.modal-content {
    background: white;
    padding: 2rem;
    border-radius: 20px;
    max-width: 500px;
    width: 90%;
    position: relative;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-close {
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 28px;
    cursor: pointer;
    color: var(--text-light);
    transition: color 0.2s ease;
}

.modal-close:hover {
    color: var(--text-dark);
}

.modal h3 {
    margin: 0 0 1.5rem;
    font-size: 1.5rem;
    color: var(--text-dark);
}

/* Suggestion List */
.suggestion-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    max-height: 400px;
    overflow-y: auto;
}

.suggestion-item {
    padding: 1rem;
    border: 2px solid var(--border-color);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.suggestion-item:hover {
    border-color: var(--primary-color);
    background: var(--bg-light);
}

/* Payment Modal */
.payment-modal-content {
    max-width: 420px;
}

.etsy-free-notice {
    background: linear-gradient(135deg, #d1fae5, #a7f3d0);
    border: 2px solid #10b981;
    padding: 1.25rem;
    border-radius: 12px;
    margin-bottom: 1.5rem;
    text-align: center;
    color: #065f46;
}

.price-display {
    text-align: center;
    margin-bottom: 1.5rem;
}

.price-label {
    font-size: 1rem;
    color: var(--text-light);
}

.price-amount {
    font-size: 2.5rem;
    font-weight: 800;
    color: var(--text-dark);
}

#card-element {
    padding: 1rem;
    border: 2px solid var(--border-color);
    border-radius: 10px;
    background: white;
    margin-bottom: 0.5rem;
}

#card-errors {
    color: #ef4444;
    font-size: 0.85rem;
    min-height: 1.25rem;
}

.payment-email {
    margin: 1rem 0 1.5rem;
}

.payment-email label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.payment-email input {
    width: 100%;
    padding: 0.9rem 1rem;
    border: 2px solid var(--border-color);
    border-radius: 10px;
    font-size: 1rem;
}

.payment-footer {
    margin-top: 1rem;
    text-align: center;
    font-size: 0.8rem;
    color: var(--text-light);
}

/* Notifications */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 1rem 1.5rem;
    border-radius: 12px;
    color: white;
    font-weight: 600;
    box-shadow: 0 4px 20px rgba(0,0,0,0.2);
    z-index: 10001;
    animation: slideInRight 0.3s ease;
}

.notification.success {
    background: var(--success-gradient);
}

.notification.error {
    background: linear-gradient(135deg, #ef4444, #dc2626);
}

.notification.info {
    background: var(--primary-gradient);
}

@keyframes slideInRight {
    from {
        transform: translateX(400px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Loading Animation */
.loading {
    position: relative;
    pointer-events: none;
}

.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 24px;
    height: 24px;
    margin: -12px 0 0 -12px;
    border: 3px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

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

/* Responsive */
@media (max-width: 768px) {
    .tool-container {
        padding: 1rem;
    }

    .tool-header h1 {
        font-size: 1.75rem;
    }

    .tool-description {
        font-size: 0.95rem;
    }

    .category-grid {
        grid-template-columns: repeat(4, 1fr);
    }

    .cat-name {
        font-size: 0.6rem;
    }

    .form-row {
        flex-direction: column;
    }

    .actions-section {
        flex-direction: column;
    }

    .secondary-actions {
        flex-direction: column;
    }

    .mockup-selector {
        justify-content: center;
    }

    .preview-header {
        flex-direction: column;
        text-align: center;
    }
}

/* Print Styles */
@media print {
    .control-panel,
    .preview-actions,
    .mockup-selector,
    .preview-note,
    #dp-header,
    #dp-footer,
    #etsy-banner,
    .templates-gallery-section {
        display: none !important;
    }

    .preview-panel {
        box-shadow: none;
        padding: 0;
    }

    .canvas-container {
        border: none;
        padding: 0;
    }
}

/* ==================== PREMADE TEMPLATES GALLERY ==================== */
.templates-gallery-section {
    background: white;
    border-radius: 20px;
    box-shadow: var(--card-shadow);
    padding: 2rem;
    margin-bottom: 2rem;
}

.gallery-header {
    text-align: center;
    margin-bottom: 2rem;
}

.gallery-header h2 {
    font-size: 2rem;
    font-weight: 800;
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 0.5rem;
}

.gallery-header p {
    color: var(--text-light);
    font-size: 1.1rem;
}

/* Category Filter Buttons */
.gallery-categories {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 2px solid var(--border-color);
}

.gallery-cat-btn {
    padding: 0.6rem 1.2rem;
    border: 2px solid var(--border-color);
    border-radius: 30px;
    background: white;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.gallery-cat-btn:hover {
    border-color: var(--primary-color);
    background: var(--bg-light);
}

.gallery-cat-btn.active {
    background: var(--primary-gradient);
    color: white;
    border-color: transparent;
}

.gallery-cat-btn .cat-count {
    background: rgba(0,0,0,0.1);
    padding: 0.15rem 0.5rem;
    border-radius: 20px;
    font-size: 0.75rem;
}

.gallery-cat-btn.active .cat-count {
    background: rgba(255,255,255,0.2);
}

/* Templates Grid */
.templates-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 1.5rem;
    max-height: 700px;
    overflow-y: auto;
    padding: 0.5rem;
}

.templates-grid::-webkit-scrollbar {
    width: 8px;
}

.templates-grid::-webkit-scrollbar-track {
    background: var(--bg-light);
    border-radius: 10px;
}

.templates-grid::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 10px;
}

/* Template Card */
.template-card {
    background: white;
    border: 2px solid var(--border-color);
    border-radius: 16px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.3s ease;
    opacity: 1;
    transform: translateY(0);
}

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

.template-preview {
    height: 180px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.template-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.template-placeholder {
    text-align: center;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
}

.placeholder-title {
    font-size: 1.1rem;
    font-weight: 700;
    line-height: 1.3;
    max-width: 200px;
    margin-bottom: 0.5rem;
}

.placeholder-subtitle {
    font-size: 0.85rem;
    max-width: 220px;
    opacity: 0.9;
}

/* Dark background = light text */
.template-preview.dark-bg .placeholder-title,
.template-preview.dark-bg .placeholder-subtitle {
    color: #ffffff;
    text-shadow: 0 1px 3px rgba(0,0,0,0.5);
}

/* Light background = dark text */
.template-preview.light-bg .placeholder-title,
.template-preview.light-bg .placeholder-subtitle {
    color: #1a1a2e;
    text-shadow: 0 1px 2px rgba(255,255,255,0.5);
}

.template-info {
    padding: 1rem;
}

.template-info h4 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-dark);
    margin-bottom: 0.35rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.template-info p {
    font-size: 0.8rem;
    color: var(--text-light);
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 0.5rem;
}

.template-tag {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.2rem 0.6rem;
    background: var(--bg-light);
    color: var(--primary-color);
    border-radius: 20px;
}

/* Gallery Divider */
.gallery-divider {
    text-align: center;
    position: relative;
    margin-top: 2rem;
}

.gallery-divider::before {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    top: 50%;
    height: 2px;
    background: var(--border-color);
}

.gallery-divider span {
    background: white;
    padding: 0 1.5rem;
    position: relative;
    color: var(--text-light);
    font-size: 0.95rem;
    font-weight: 500;
}

/* Responsive Templates Grid */
@media (max-width: 1200px) {
    .templates-grid {
        grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    }
}

@media (max-width: 768px) {
    .templates-gallery-section {
        padding: 1.5rem;
    }

    .gallery-header h2 {
        font-size: 1.5rem;
    }

    .gallery-categories {
        gap: 0.5rem;
    }

    .gallery-cat-btn {
        padding: 0.5rem 0.9rem;
        font-size: 0.8rem;
    }

    .templates-grid {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
        gap: 1rem;
        max-height: 500px;
    }

    .template-preview {
        height: 130px;
    }

    .template-info {
        padding: 0.75rem;
    }

    .template-info h4 {
        font-size: 0.9rem;
    }

    .template-info p {
        font-size: 0.75rem;
    }
}
