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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #f0f2f5;
    color: #333;
    line-height: 1.6;
    min-height: 100vh;
}

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

header {
    text-align: center;
    padding: 30px 0;
    margin-bottom: 30px;
}

header h1 {
    color: #7b2cbf;
    font-size: 2.5rem;
    margin-bottom: 10px;
}

header p {
    color: #666;
    font-size: 1.1rem;
}

.step {
    background: white;
    padding: 30px;
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.08);
    margin-bottom: 30px;
}

.step h2 {
    color: #333;
    margin-bottom: 25px;
    padding-bottom: 15px;
    border-bottom: 2px solid #f0f2f5;
}

/* Buttons */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 15px;
    font-weight: 500;
    transition: all 0.2s ease;
    text-decoration: none;
    display: inline-block;
}

.btn-primary {
    background: linear-gradient(135deg, #7b2cbf 0%, #9d4edd 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(123, 44, 191, 0.4);
}

.btn-secondary {
    background: #e9ecef;
    color: #495057;
}

.btn-secondary:hover {
    background: #dee2e6;
}

/* Template Grid */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 25px;
}

.template-card {
    background: white;
    border: 2px solid #e9ecef;
    border-radius: 12px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.3s ease;
}

.template-card:hover {
    transform: translateY(-5px);
    border-color: #7b2cbf;
    box-shadow: 0 10px 30px rgba(123, 44, 191, 0.15);
}

.template-card img {
    width: 100%;
    height: 180px;
    object-fit: cover;
    background: #f8f9fa;
}

.template-info {
    padding: 15px;
}

.template-info h3 {
    font-size: 16px;
    color: #333;
    margin-bottom: 5px;
}

.template-info span {
    font-size: 13px;
    color: #888;
}

/* Editor Layout */
.editor-layout {
    display: grid;
    grid-template-columns: 1fr 400px;
    gap: 30px;
}

@media (max-width: 900px) {
    .editor-layout {
        grid-template-columns: 1fr;
    }
}

.preview-container {
    background: #f8f9fa;
    border-radius: 12px;
    padding: 20px;
}

.preview-container h3 {
    margin-bottom: 15px;
    color: #666;
}

#preview-canvas-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    background: #e9ecef;
    border-radius: 8px;
    overflow: hidden;
}

#preview-canvas {
    max-width: 100%;
    max-height: 600px;
    display: block;
}

.form-container {
    background: #f8f9fa;
    border-radius: 12px;
    padding: 25px;
}

#selected-template-info {
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid #dee2e6;
}

#selected-template-info h3 {
    color: #333;
    margin-bottom: 5px;
}

/* Form Fields */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: #495057;
}

.form-group input[type="text"],
.form-group textarea {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    font-size: 15px;
    transition: border-color 0.2s;
}

.form-group input[type="text"]:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #7b2cbf;
}

.form-group input[type="file"] {
    width: 100%;
    padding: 10px;
    border: 2px dashed #dee2e6;
    border-radius: 8px;
    background: white;
    cursor: pointer;
}

.form-group input[type="file"]:hover {
    border-color: #7b2cbf;
}

.image-preview {
    max-width: 100%;
    max-height: 150px;
    margin-top: 10px;
    border-radius: 8px;
    display: none;
}

.video-preview {
    width: 100%;
    max-height: 180px;
    margin-top: 10px;
    border-radius: 8px;
    display: none;
    background: #000000;
}

.form-actions {
    display: flex;
    gap: 15px;
    margin-top: 25px;
}

/* Download Section */
#result-container {
    text-align: center;
    margin-bottom: 25px;
}

#result-image {
    max-width: 100%;
    max-height: 500px;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
}

#result-video {
    width: 100%;
    max-height: 500px;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    background: #000000;
}

.download-actions {
    display: flex;
    justify-content: center;
    gap: 15px;
}

/* Loading */
.loading {
    text-align: center;
    color: #888;
    padding: 40px;
}

#loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255,255,255,0.95);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #7b2cbf;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: 20px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

#loading-message {
    color: #666;
    font-size: 16px;
}

/* Template Actions */
.template-actions {
    margin-top: 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.btn-small {
    display: inline-block;
    padding: 5px 12px;
    background: #7b2cbf;
    color: white;
    text-decoration: none;
    border-radius: 4px;
    font-size: 12px;
    transition: background 0.2s;
}

.btn-small:hover {
    background: #5a189a;
}

.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border: 1px solid #e9ecef;
    background: #f8f9fa;
    color: #b91c1c;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s, color 0.2s;
}

.btn-icon:hover {
    background: #ffe3e3;
    border-color: #f1aeb5;
    color: #8b1010;
}

/* Responsive */
@media (max-width: 600px) {
    .container {
        padding: 15px;
    }

    header h1 {
        font-size: 1.8rem;
    }

    .step {
        padding: 20px;
    }

    .grid {
        grid-template-columns: 1fr;
    }

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

    .btn {
        width: 100%;
        text-align: center;
    }
}
