/* CSS Variables */
:root {
    --primary-color: #6366f1;
    --primary-hover: #4f46e5;
    --secondary-color: #8b5cf6;
    --background-color: #0f0f1a;
    --surface-color: #1a1a2e;
    --surface-light: #252542;
    --text-primary: #ffffff;
    --text-secondary: #a0a0b0;
    --border-color: #2a2a4a;
    --success-color: #10b981;
    --shadow-color: rgba(99, 102, 241, 0.2);
    --gradient-start: #6366f1;
    --gradient-end: #8b5cf6;
}

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--background-color);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

/* App Container */
.app-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Header */
.header {
    text-align: center;
    padding: 40px 20px;
    background: linear-gradient(135deg, var(--surface-color) 0%, var(--surface-light) 100%);
    border-radius: 0 0 30px 30px;
    margin-bottom: 40px;
    border-bottom: 1px solid var(--border-color);
}

.logo-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    margin-bottom: 10px;
}

.logo {
    width: 50px;
    height: 50px;
    border-radius: 10px;
}

.header h1 {
    font-size: 2.5rem;
    background: linear-gradient(135deg, var(--gradient-start), var(--gradient-end));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-weight: 700;
}

.tagline {
    color: var(--text-secondary);
    font-size: 1.1rem;
    margin-top: 10px;
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 40px;
    padding-bottom: 40px;
}

/* Section Styles */
section {
    background: var(--surface-color);
    border-radius: 20px;
    padding: 30px;
    border: 1px solid var(--border-color);
}

section h2 {
    font-size: 1.5rem;
    margin-bottom: 10px;
    color: var(--text-primary);
}

.section-description {
    color: var(--text-secondary);
    margin-bottom: 20px;
}

/* Emotion Grid */
.emotion-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 15px;
}

.emotion-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px 15px;
    background: var(--surface-light);
    border: 2px solid var(--border-color);
    border-radius: 15px;
    cursor: pointer;
    transition: all 0.3s ease;
    gap: 8px;
}

.emotion-btn:hover {
    transform: translateY(-3px);
    border-color: var(--primary-color);
    box-shadow: 0 5px 20px var(--shadow-color);
}

.emotion-btn.selected {
    background: linear-gradient(135deg, var(--gradient-start), var(--gradient-end));
    border-color: transparent;
    transform: scale(1.05);
}

.emotion-icon {
    font-size: 2rem;
}

.emotion-label {
    font-size: 0.9rem;
    color: var(--text-primary);
    font-weight: 500;
}

/* Style Options */
.style-options {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    justify-content: center;
}

.style-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 15px 25px;
    background: var(--surface-light);
    border: 2px solid var(--border-color);
    border-radius: 30px;
    cursor: pointer;
    transition: all 0.3s ease;
    color: var(--text-primary);
}

.style-btn:hover {
    border-color: var(--primary-color);
    box-shadow: 0 3px 15px var(--shadow-color);
}

.style-btn.active {
    background: linear-gradient(135deg, var(--gradient-start), var(--gradient-end));
    border-color: transparent;
}

.style-icon {
    font-size: 1.3rem;
}

.style-label {
    font-size: 1rem;
    font-weight: 500;
}

/* Generate Section */
.generate-section {
    background: transparent;
    border: none;
    padding: 0;
    display: flex;
    justify-content: center;
}

.generate-btn {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 20px 50px;
    font-size: 1.3rem;
    font-weight: 600;
    background: linear-gradient(135deg, var(--gradient-start), var(--gradient-end));
    color: white;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 5px 30px var(--shadow-color);
}

.generate-btn:hover:not(:disabled) {
    transform: translateY(-3px);
    box-shadow: 0 10px 40px var(--shadow-color);
}

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

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

.btn-icon {
    font-size: 1.5rem;
}

/* Artwork Section */
.artwork-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 25px;
}

.artwork-container {
    position: relative;
    width: 100%;
    max-width: 800px;
    border-radius: 15px;
    overflow: hidden;
    background: var(--surface-light);
    border: 2px solid var(--border-color);
}

#artworkCanvas {
    display: block;
    width: 100%;
    height: auto;
    background: #1a1a2e;
}

.artwork-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(26, 26, 46, 0.9);
    color: var(--text-secondary);
    font-size: 1.1rem;
    text-align: center;
    padding: 20px;
}

.artwork-overlay.hidden {
    display: none;
}

/* Palette Section */
.palette-section {
    width: 100%;
    max-width: 500px;
    text-align: center;
    display: none;
}

.palette-section.visible {
    display: block;
}

.palette-section h3 {
    margin-bottom: 15px;
    font-size: 1.2rem;
}

.color-palette {
    display: flex;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
}

.color-swatch {
    width: 60px;
    height: 60px;
    border-radius: 10px;
    cursor: pointer;
    transition: transform 0.3s ease;
    border: 3px solid transparent;
    position: relative;
}

.color-swatch:hover {
    transform: scale(1.1);
    border-color: white;
}

.color-swatch::after {
    content: attr(data-color);
    position: absolute;
    bottom: -25px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.7rem;
    color: var(--text-secondary);
    white-space: nowrap;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.color-swatch:hover::after {
    opacity: 1;
}

/* Download Section */
.download-section {
    display: none;
    gap: 15px;
    flex-wrap: wrap;
    justify-content: center;
}

.download-section.visible {
    display: flex;
}

.download-btn,
.regenerate-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 15px 30px;
    font-size: 1rem;
    font-weight: 600;
    border: none;
    border-radius: 30px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.download-btn {
    background: var(--success-color);
    color: white;
}

.download-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(16, 185, 129, 0.3);
}

.regenerate-btn {
    background: var(--surface-light);
    color: var(--text-primary);
    border: 2px solid var(--border-color);
}

.regenerate-btn:hover {
    border-color: var(--primary-color);
    box-shadow: 0 3px 15px var(--shadow-color);
}

/* Footer */
.footer {
    text-align: center;
    padding: 30px 20px;
    margin-top: auto;
    border-top: 1px solid var(--border-color);
}

.footer a {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.95rem;
    transition: color 0.3s ease;
}

.footer a:hover {
    color: var(--primary-color);
}

/* Animations */
@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

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

.fade-in {
    animation: fadeIn 0.5s ease forwards;
}

/* Loading State */
.generate-btn.loading .btn-text::after {
    content: '...';
    animation: dots 1.5s infinite;
}

@keyframes dots {
    0%, 20% { content: '.'; }
    40% { content: '..'; }
    60%, 100% { content: '...'; }
}

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

    .logo-container {
        flex-direction: column;
    }

    .tagline {
        font-size: 1rem;
    }

    .emotion-grid {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
        gap: 10px;
    }

    .emotion-btn {
        padding: 15px 10px;
    }

    .emotion-icon {
        font-size: 1.5rem;
    }

    .emotion-label {
        font-size: 0.8rem;
    }

    .style-options {
        gap: 10px;
    }

    .style-btn {
        padding: 12px 20px;
    }

    .generate-btn {
        padding: 15px 35px;
        font-size: 1.1rem;
    }

    section {
        padding: 20px;
        border-radius: 15px;
    }

    .color-swatch {
        width: 50px;
        height: 50px;
    }

    .download-btn,
    .regenerate-btn {
        padding: 12px 25px;
        font-size: 0.95rem;
    }
}

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

    .header {
        padding: 30px 15px;
        border-radius: 0 0 20px 20px;
    }

    .header h1 {
        font-size: 1.5rem;
    }

    .emotion-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .style-btn {
        padding: 10px 15px;
        font-size: 0.9rem;
    }

    .style-icon {
        font-size: 1.1rem;
    }

    .generate-btn {
        padding: 12px 25px;
        font-size: 1rem;
    }

    .main-content {
        gap: 25px;
    }

    section h2 {
        font-size: 1.2rem;
    }
}

/* Tooltip for copied color */
.tooltip {
    position: fixed;
    background: var(--primary-color);
    color: white;
    padding: 8px 15px;
    border-radius: 5px;
    font-size: 0.9rem;
    pointer-events: none;
    z-index: 1000;
    animation: fadeIn 0.2s ease;
}

/* Focus States for Accessibility */
button:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 3px;
}

/* Print Styles */
@media print {
    .header,
    .emotion-section,
    .style-section,
    .generate-section,
    .download-section,
    .palette-section,
    .footer {
        display: none;
    }

    .artwork-container {
        max-width: 100%;
        border: none;
    }

    .artwork-overlay {
        display: none;
    }
}
