/* CSS Reset & Base Styles */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --primary-color: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #818cf8;
    --secondary-color: #10b981;
    --accent-color: #f59e0b;
    --background: #0f172a;
    --surface: #1e293b;
    --surface-light: #334155;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --border-color: #334155;
    --success: #10b981;
    --warning: #f59e0b;
    --error: #ef4444;
    --gradient-1: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    --gradient-2: linear-gradient(135deg, #10b981 0%, #06b6d4 100%);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.4);
    --radius-sm: 6px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --transition: all 0.3s ease;
}

html {
    scroll-behavior: smooth;
}

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

/* App Container */
.app-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.header {
    text-align: center;
    padding: 2rem 1rem;
    background: var(--gradient-1);
    position: relative;
    overflow: hidden;
}

.header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.05'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
    opacity: 0.5;
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    position: relative;
    z-index: 1;
}

.logo-icon {
    width: 48px;
    height: 48px;
    color: white;
}

.logo h1 {
    font-size: 1.75rem;
    font-weight: 700;
    color: white;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.tagline {
    color: rgba(255, 255, 255, 0.9);
    font-size: 1rem;
    margin-top: 0.5rem;
    position: relative;
    z-index: 1;
}

/* Main Content */
.main-content {
    flex: 1;
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 1rem;
    width: 100%;
}

/* Sections */
.section {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    border: 1px solid var(--border-color);
}

.section h2 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.section-number {
    width: 28px;
    height: 28px;
    background: var(--gradient-1);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
    font-weight: 600;
}

/* Import Section */
.import-options {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
}

.import-card {
    background: var(--surface-light);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    border: 1px solid var(--border-color);
}

.import-card h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.import-card p {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-bottom: 1rem;
}

textarea {
    width: 100%;
    min-height: 150px;
    background: var(--background);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 0.75rem;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.875rem;
    resize: vertical;
    margin-bottom: 1rem;
    transition: var(--transition);
}

textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

textarea::placeholder {
    color: var(--text-muted);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: var(--radius-sm);
    border: none;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
}

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

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

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

.btn-secondary:hover {
    background: var(--border-color);
}

.btn-outline {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.btn-outline:hover {
    border-color: var(--text-secondary);
    color: var(--text-primary);
}

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

.btn-icon {
    font-size: 1.1em;
}

/* Playlist Section */
.playlist-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat {
    background: var(--surface-light);
    border-radius: var(--radius-md);
    padding: 1rem;
    text-align: center;
}

.stat-value {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-light);
}

.stat-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.playlist-container {
    max-height: 400px;
    overflow-y: auto;
}

.song-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 1rem;
    background: var(--surface-light);
    border-radius: var(--radius-sm);
    margin-bottom: 0.5rem;
    border: 1px solid transparent;
    transition: var(--transition);
}

.song-item:hover {
    border-color: var(--primary-color);
}

.song-number {
    width: 28px;
    height: 28px;
    background: var(--background);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    flex-shrink: 0;
}

.song-info {
    flex: 1;
    min-width: 0;
}

.song-title {
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.song-artist {
    font-size: 0.875rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.song-badges {
    display: flex;
    gap: 0.5rem;
    flex-shrink: 0;
}

.badge {
    padding: 0.25rem 0.5rem;
    font-size: 0.7rem;
    font-weight: 500;
    border-radius: 9999px;
    text-transform: uppercase;
}

.badge-mood {
    background: rgba(139, 92, 246, 0.2);
    color: #a78bfa;
}

.badge-energy {
    background: rgba(16, 185, 129, 0.2);
    color: #34d399;
}

/* Analysis Section */
.analysis-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
}

.analysis-card {
    background: var(--surface-light);
    border-radius: var(--radius-md);
    padding: 1.25rem;
}

.analysis-card.full-width {
    grid-column: 1 / -1;
}

.analysis-card h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

/* Mood Chart */
.mood-chart {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    height: 120px;
    align-items: flex-end;
}

.mood-bar {
    flex: 1;
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    transition: var(--transition);
    min-height: 10px;
    position: relative;
}

.mood-bar:hover {
    opacity: 0.8;
}

.mood-bar::after {
    content: attr(data-label);
    position: absolute;
    bottom: -24px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.65rem;
    color: var(--text-secondary);
    white-space: nowrap;
}

.mood-breakdown {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.mood-tag {
    padding: 0.25rem 0.75rem;
    background: var(--background);
    border-radius: 9999px;
    font-size: 0.75rem;
}

/* Energy Chart */
.energy-chart {
    height: 80px;
    display: flex;
    align-items: flex-end;
    gap: 2px;
    margin-bottom: 1rem;
    padding: 0.5rem;
    background: var(--background);
    border-radius: var(--radius-sm);
}

.energy-bar {
    flex: 1;
    border-radius: 2px 2px 0 0;
    min-height: 4px;
    transition: var(--transition);
}

.analysis-insight {
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-style: italic;
}

/* Recommendations */
.recommendations {
    display: grid;
    gap: 0.75rem;
}

.recommendation-item {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.75rem;
    background: var(--background);
    border-radius: var(--radius-sm);
}

.recommendation-icon {
    width: 32px;
    height: 32px;
    background: var(--gradient-2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    flex-shrink: 0;
}

.recommendation-text {
    flex: 1;
}

.recommendation-text strong {
    display: block;
    margin-bottom: 0.25rem;
}

.recommendation-text p {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* Optimization Section */
.optimization-controls {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    align-items: center;
}

.optimization-mode {
    width: 100%;
}

.optimization-mode label {
    display: block;
    margin-bottom: 0.75rem;
    font-weight: 500;
}

.mode-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.mode-btn {
    padding: 0.5rem 1rem;
    background: var(--surface-light);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.875rem;
    cursor: pointer;
    transition: var(--transition);
}

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

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

.slider-control {
    width: 100%;
    max-width: 400px;
}

.slider-control label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

input[type="range"] {
    width: 100%;
    height: 8px;
    border-radius: 4px;
    background: var(--surface-light);
    appearance: none;
    cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
    transition: var(--transition);
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.1);
}

/* Result Section */
.result-comparison {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1.5rem;
}

.comparison-stat {
    flex: 1;
    min-width: 200px;
    background: var(--surface-light);
    border-radius: var(--radius-md);
    padding: 1rem;
    text-align: center;
}

.comparison-label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    margin-bottom: 0.5rem;
}

.comparison-value {
    font-size: 1.5rem;
    font-weight: 700;
}

.comparison-value.positive {
    color: var(--success);
}

.optimized-playlist {
    max-height: 400px;
    overflow-y: auto;
    margin-bottom: 1.5rem;
}

.optimized-song {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 1rem;
    background: var(--surface-light);
    border-radius: var(--radius-sm);
    margin-bottom: 0.5rem;
    border-left: 3px solid var(--primary-color);
}

.optimized-song .song-number {
    background: var(--gradient-1);
    color: white;
}

.position-change {
    font-size: 0.75rem;
    padding: 0.125rem 0.5rem;
    border-radius: 9999px;
    margin-left: auto;
}

.position-change.up {
    background: rgba(16, 185, 129, 0.2);
    color: #34d399;
}

.position-change.down {
    background: rgba(239, 68, 68, 0.2);
    color: #f87171;
}

.position-change.same {
    background: rgba(148, 163, 184, 0.2);
    color: var(--text-secondary);
}

.export-options {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    justify-content: center;
}

/* Footer */
.footer {
    background: var(--surface);
    border-top: 1px solid var(--border-color);
    padding: 1.5rem;
    text-align: center;
}

.footer p {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.footer a {
    color: var(--primary-light);
    text-decoration: none;
    font-weight: 500;
    transition: var(--transition);
}

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

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--background);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: var(--surface-light);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--border-color);
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.section {
    animation: fadeIn 0.4s ease-out;
}

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

.loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.8);
    border-radius: inherit;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    .logo h1 {
        font-size: 1.25rem;
    }

    .logo-icon {
        width: 36px;
        height: 36px;
    }

    .section {
        padding: 1rem;
    }

    .section h2 {
        font-size: 1.1rem;
    }

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

    .mode-buttons {
        justify-content: center;
    }

    .mode-btn {
        flex: 1 0 calc(50% - 0.5rem);
        text-align: center;
    }

    .playlist-stats {
        grid-template-columns: repeat(2, 1fr);
    }

    .song-badges {
        flex-direction: column;
        gap: 0.25rem;
    }

    .export-options {
        flex-direction: column;
    }

    .export-options .btn {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .header {
        padding: 1.5rem 1rem;
    }

    .logo {
        flex-direction: column;
        gap: 0.5rem;
    }

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

    .stat-value {
        font-size: 1.25rem;
    }

    .result-comparison {
        flex-direction: column;
    }
}
