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

:root {
    --primary-purple: #9333ea;
    --secondary-purple: #a855f7;
    --accent-purple: #c084fc;
    --dark-purple: #6b21a8;
    --black-bg: #000000;
    --dark-gray: #0a0a0a;
    --darker-gray: #111111;
    --text-primary: #ffffff;
    --text-secondary: #d4d4d8;
    --gradient-purple: linear-gradient(135deg, #9333ea 0%, #a855f7 50%, #c084fc 100%);
    --gradient-purple-dark: linear-gradient(135deg, #6b21a8 0%, #9333ea 100%);
    --shadow-purple: 0 0 30px rgba(147, 51, 234, 0.3);
    --shadow-purple-strong: 0 0 50px rgba(147, 51, 234, 0.5);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--black-bg);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
}

/* Animated Background */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: 
        radial-gradient(circle at 20% 30%, rgba(147, 51, 234, 0.15) 0%, transparent 50%),
        radial-gradient(circle at 80% 70%, rgba(168, 85, 247, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 50% 50%, rgba(192, 132, 252, 0.05) 0%, transparent 50%);
    pointer-events: none;
    z-index: 0;
    animation: backgroundPulse 8s ease-in-out infinite;
}

@keyframes backgroundPulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.8;
    }
}

.app-container {
    position: relative;
    z-index: 1;
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

/* Header */
.header {
    text-align: center;
    padding: 40px 20px;
    margin-bottom: 40px;
}

.header-content {
    position: relative;
}

.logo {
    display: inline-flex;
    align-items: center;
    gap: 15px;
    font-size: 2.5rem;
    font-weight: 800;
    background: var(--gradient-purple);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 10px;
    text-shadow: 0 0 30px rgba(147, 51, 234, 0.5);
}

.logo i {
    font-size: 2.8rem;
    background: var(--gradient-purple);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    filter: drop-shadow(0 0 20px rgba(147, 51, 234, 0.6));
    animation: logoGlow 3s ease-in-out infinite;
}

@keyframes logoGlow {
    0%, 100% {
        filter: drop-shadow(0 0 20px rgba(147, 51, 234, 0.6));
    }
    50% {
        filter: drop-shadow(0 0 30px rgba(168, 85, 247, 0.8));
    }
}

.tagline {
    color: var(--text-secondary);
    font-size: 1.1rem;
    font-weight: 400;
}

/* Main Content */
.main-content {
    display: flex;
    flex-direction: column;
    gap: 30px;
}

/* Section Cards */
.section-card {
    background: var(--darker-gray);
    border: 1px solid rgba(147, 51, 234, 0.2);
    border-radius: 20px;
    padding: 30px;
    box-shadow: var(--shadow-purple);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.section-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--gradient-purple);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.section-card:hover {
    border-color: rgba(147, 51, 234, 0.4);
    box-shadow: var(--shadow-purple-strong);
    transform: translateY(-2px);
}

.section-card:hover::before {
    opacity: 1;
}

.section-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 25px;
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--text-primary);
}

.section-title i {
    color: var(--primary-purple);
    font-size: 1.3rem;
}

/* Upload Section */
.upload-area {
    border: 2px dashed rgba(147, 51, 234, 0.4);
    border-radius: 15px;
    padding: 60px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: var(--dark-gray);
    position: relative;
    overflow: hidden;
}

.upload-area:hover {
    border-color: var(--primary-purple);
    background: rgba(147, 51, 234, 0.05);
    box-shadow: 0 0 30px rgba(147, 51, 234, 0.2);
}

.upload-area.dragover {
    border-color: var(--primary-purple);
    background: rgba(147, 51, 234, 0.1);
    box-shadow: var(--shadow-purple);
}

.upload-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

.upload-icon {
    font-size: 4rem;
    color: var(--primary-purple);
    filter: drop-shadow(0 0 15px rgba(147, 51, 234, 0.5));
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-10px);
    }
}

.upload-text {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-primary);
}

.upload-hint {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.preview-container {
    position: relative;
    max-width: 100%;
    margin-top: 20px;
}

.preview-container img {
    max-width: 100%;
    max-height: 400px;
    border-radius: 15px;
    box-shadow: var(--shadow-purple);
    object-fit: contain;
}

.remove-image {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(0, 0, 0, 0.8);
    border: 2px solid var(--primary-purple);
    color: var(--text-primary);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.remove-image:hover {
    background: var(--primary-purple);
    transform: scale(1.1);
    box-shadow: var(--shadow-purple);
}

/* Form Controls */
.form-group {
    margin-bottom: 25px;
}

.form-group label {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    margin-bottom: 10px;
    color: var(--text-primary);
    font-size: 1rem;
}

.form-group label i {
    color: var(--primary-purple);
}

.form-control {
    width: 100%;
    padding: 15px 20px;
    background: var(--dark-gray);
    border: 2px solid rgba(147, 51, 234, 0.3);
    border-radius: 12px;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 1rem;
    transition: all 0.3s ease;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-purple);
    box-shadow: 0 0 20px rgba(147, 51, 234, 0.3);
    background: rgba(147, 51, 234, 0.05);
}

.form-control::placeholder {
    color: var(--text-secondary);
}

select.form-control {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%239333ea' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 15px center;
    padding-right: 45px;
}

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

/* Email Input */
.email-group {
    background: rgba(147, 51, 234, 0.1);
    border: 2px solid rgba(147, 51, 234, 0.3);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 25px;
}

.email-notice {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    background: rgba(147, 51, 234, 0.15);
    border-left: 4px solid var(--primary-purple);
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 15px;
}

.email-notice i {
    color: var(--primary-purple);
    font-size: 1.2rem;
    margin-top: 2px;
}

.email-notice p {
    color: var(--text-secondary);
    font-size: 0.95rem;
    line-height: 1.6;
}

/* Generate Button */
.generate-btn {
    width: 100%;
    padding: 18px 30px;
    background: var(--gradient-purple);
    border: none;
    border-radius: 12px;
    color: var(--text-primary);
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    transition: all 0.3s ease;
    box-shadow: var(--shadow-purple);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.generate-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: var(--shadow-purple-strong);
    background: var(--gradient-purple-dark);
}

.generate-btn:active:not(:disabled) {
    transform: translateY(0);
}

.generate-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    box-shadow: none;
}

.generate-btn i {
    font-size: 1.2rem;
    animation: sparkle 2s ease-in-out infinite;
}

@keyframes sparkle {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.2) rotate(10deg);
    }
}

/* Result Section */
.result-container {
    position: relative;
    min-height: 300px;
}

.loading-spinner {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    gap: 20px;
}

.spinner {
    width: 60px;
    height: 60px;
    border: 4px solid rgba(147, 51, 234, 0.2);
    border-top-color: var(--primary-purple);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.loading-spinner p {
    color: var(--text-secondary);
    font-size: 1.1rem;
}

.result-image-container {
    text-align: center;
}

.result-image-container img {
    max-width: 100%;
    max-height: 600px;
    border-radius: 15px;
    box-shadow: var(--shadow-purple-strong);
    margin-bottom: 25px;
    border: 2px solid rgba(147, 51, 234, 0.3);
}

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

.download-btn {
    padding: 15px 35px;
    background: var(--gradient-purple);
    border: none;
    border-radius: 12px;
    color: var(--text-primary);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: all 0.3s ease;
    box-shadow: var(--shadow-purple);
}

.download-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-purple-strong);
}

.download-btn i {
    font-size: 1.1rem;
}

/* Error Message */
.error-message {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    padding: 40px 20px;
    background: rgba(220, 38, 38, 0.1);
    border: 2px solid rgba(220, 38, 38, 0.3);
    border-radius: 15px;
    color: #fca5a5;
}

.error-message i {
    font-size: 3rem;
    color: #ef4444;
}

.error-message p {
    font-size: 1.1rem;
    text-align: center;
}

/* Success Message */
.success-message {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 20px;
    background: rgba(34, 197, 94, 0.1);
    border: 2px solid rgba(34, 197, 94, 0.3);
    border-radius: 12px;
    margin-bottom: 20px;
    color: #86efac;
}

.success-message i {
    font-size: 1.5rem;
    color: #22c55e;
}

/* History Section */
.history-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.empty-history {
    grid-column: 1 / -1;
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
}

.empty-history i {
    font-size: 4rem;
    color: rgba(147, 51, 234, 0.3);
    margin-bottom: 20px;
}

.empty-history p {
    font-size: 1.1rem;
}

.history-item {
    position: relative;
    border-radius: 15px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 2px solid rgba(147, 51, 234, 0.2);
    background: var(--dark-gray);
}

.history-item:hover {
    transform: translateY(-5px);
    border-color: var(--primary-purple);
    box-shadow: var(--shadow-purple);
}

.history-item img {
    width: 100%;
    height: 200px;
    object-fit: cover;
    display: block;
}

.history-item-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.9), transparent);
    padding: 15px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.history-item:hover .history-item-overlay {
    opacity: 1;
}

.history-item-info {
    color: var(--text-primary);
    font-size: 0.9rem;
}

.history-item-style {
    color: var(--primary-purple);
    font-weight: 600;
    font-size: 0.85rem;
}

/* Footer */
.footer {
    text-align: center;
    padding: 40px 20px;
    margin-top: 60px;
    color: var(--text-secondary);
    font-size: 0.9rem;
    border-top: 1px solid rgba(147, 51, 234, 0.2);
}

/* Responsive Design */
@media (max-width: 768px) {
    .logo {
        font-size: 2rem;
    }

    .logo i {
        font-size: 2.2rem;
    }

    .section-card {
        padding: 20px;
    }

    .upload-area {
        padding: 40px 15px;
    }

    .upload-icon {
        font-size: 3rem;
    }

    .history-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 15px;
    }
}

@media (max-width: 480px) {
    .app-container {
        padding: 15px;
    }

    .header {
        padding: 30px 15px;
    }

    .logo {
        font-size: 1.8rem;
    }

    .section-title {
        font-size: 1.3rem;
    }
}
