/* CSS Variables */
:root {
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --primary-light: #a5b4fc;
    --secondary: #10b981;
    --secondary-hover: #059669;
    --background: #0f172a;
    --surface: #1e293b;
    --surface-light: #334155;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --border: #334155;
    --success: #22c55e;
    --warning: #f59e0b;
    --error: #ef4444;
    --gradient-start: #6366f1;
    --gradient-end: #8b5cf6;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -2px rgba(0, 0, 0, 0.2);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.3), 0 4px 6px -4px rgba(0, 0, 0, 0.2);
    --radius: 12px;
    --radius-sm: 8px;
    --transition: all 0.2s ease;
}

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

html {
    font-size: 16px;
    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 {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    max-width: 1200px;
    margin: 0 auto;
    padding: 1.5rem;
}

/* Header */
.header {
    text-align: center;
    margin-bottom: 2.5rem;
    padding: 1.5rem 0;
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 0.75rem;
}

.logo-img {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-sm);
}

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

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

/* Main Content */
.main-content {
    flex: 1;
    display: grid;
    gap: 2rem;
}

@media (min-width: 768px) {
    .main-content {
        grid-template-columns: 1fr 1fr;
        align-items: start;
    }
}

/* Controls Section */
.controls-section {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
}

.control-group {
    margin-bottom: 1.75rem;
}

.control-group:last-of-type {
    margin-bottom: 1.5rem;
}

.label-text {
    display: block;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.75rem;
    font-size: 0.95rem;
}

/* BPM Slider */
.control-group label {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.bpm-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
}

.slider {
    width: 100%;
    height: 8px;
    border-radius: 4px;
    background: var(--surface-light);
    outline: none;
    -webkit-appearance: none;
    appearance: none;
    cursor: pointer;
}

.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--gradient-start), var(--gradient-end));
    cursor: pointer;
    box-shadow: var(--shadow);
    transition: var(--transition);
}

.slider::-webkit-slider-thumb:hover {
    transform: scale(1.1);
}

.slider::-moz-range-thumb {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--gradient-start), var(--gradient-end));
    cursor: pointer;
    border: none;
    box-shadow: var(--shadow);
}

.bpm-labels {
    display: flex;
    justify-content: space-between;
    margin-top: 0.5rem;
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Genre Buttons */
.genre-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
}

.genre-btn {
    padding: 0.75rem 1rem;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

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

.genre-btn.active {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.15);
    color: var(--primary-light);
}

/* Duration Select */
.select-input {
    width: 100%;
    padding: 0.875rem 1rem;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text-primary);
    font-size: 1rem;
    cursor: pointer;
    transition: var(--transition);
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2394a3b8'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    background-size: 1.25rem;
}

.select-input:hover,
.select-input:focus {
    border-color: var(--primary);
    outline: none;
}

.select-input option {
    background: var(--surface);
    color: var(--text-primary);
}

/* Platform Buttons */
.platform-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
}

.platform-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.875rem;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

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

.platform-btn.active {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.15);
    color: var(--primary-light);
}

.platform-icon {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

/* Generate Button */
.generate-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 1rem 2rem;
    border: none;
    border-radius: var(--radius);
    background: linear-gradient(135deg, var(--gradient-start), var(--gradient-end));
    color: white;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: var(--shadow);
}

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

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

.btn-icon {
    width: 24px;
    height: 24px;
    fill: currentColor;
}

/* Playlist Section */
.playlist-section {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    display: none;
}

.playlist-section.visible {
    display: block;
    animation: slideIn 0.3s ease;
}

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

.playlist-header {
    margin-bottom: 1rem;
}

.playlist-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
}

.playlist-info {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.info-badge {
    display: inline-block;
    padding: 0.375rem 0.75rem;
    background: var(--surface-light);
    border-radius: 20px;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* Playlist Actions */
.playlist-actions {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.action-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 1rem;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.action-btn:hover {
    border-color: var(--primary);
    color: var(--primary-light);
    background: rgba(99, 102, 241, 0.1);
}

.btn-icon-small {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

/* Playlist Container */
.playlist-container {
    max-height: 400px;
    overflow-y: auto;
    margin-bottom: 1rem;
}

.playlist-container::-webkit-scrollbar {
    width: 8px;
}

.playlist-container::-webkit-scrollbar-track {
    background: var(--surface-light);
    border-radius: 4px;
}

.playlist-container::-webkit-scrollbar-thumb {
    background: var(--primary);
    border-radius: 4px;
}

/* Track Item */
.track-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.875rem;
    background: var(--surface-light);
    border-radius: var(--radius-sm);
    margin-bottom: 0.5rem;
    transition: var(--transition);
}

.track-item:hover {
    background: rgba(99, 102, 241, 0.1);
}

.track-number {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-muted);
    min-width: 24px;
}

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

.track-title {
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

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

.track-meta {
    display: flex;
    gap: 1rem;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.track-bpm {
    color: var(--primary-light);
    font-weight: 500;
}

.track-duration {
    color: var(--text-muted);
}

/* Platform Links */
.platform-links {
    border-top: 1px solid var(--border);
    padding-top: 1rem;
    margin-top: 0.5rem;
}

.platform-links p {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
}

.platform-link-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.platform-link {
    display: inline-flex;
    align-items: center;
    padding: 0.625rem 1rem;
    background: var(--surface-light);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 500;
    transition: var(--transition);
}

.platform-link:hover {
    background: var(--primary);
    color: white;
}

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

.footer p {
    color: var(--text-muted);
    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);
    text-decoration: underline;
}

/* Toast Notification */
.toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--surface);
    color: var(--text-primary);
    padding: 1rem 1.5rem;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    font-size: 0.9rem;
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 1000;
    border: 1px solid var(--border);
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.toast.success {
    border-color: var(--success);
}

.toast.error {
    border-color: var(--error);
}

/* Loading State */
.generate-btn.loading {
    pointer-events: none;
    opacity: 0.7;
}

.generate-btn.loading::after {
    content: '';
    width: 20px;
    height: 20px;
    border: 2px solid white;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-left: 0.5rem;
}

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

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

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

    .tagline {
        font-size: 0.95rem;
    }

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

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

    .playlist-actions {
        justify-content: center;
    }

    .track-meta {
        flex-direction: column;
        gap: 0.25rem;
        align-items: flex-end;
    }

    .platform-link-buttons {
        flex-direction: column;
    }

    .platform-link {
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .genre-grid {
        grid-template-columns: 1fr;
    }

    .bpm-labels {
        flex-direction: column;
        align-items: center;
        gap: 0.25rem;
    }

    .playlist-info {
        justify-content: center;
    }
}

/* Dark mode is default, but add light mode support */
@media (prefers-color-scheme: light) {
    :root {
        --background: #f1f5f9;
        --surface: #ffffff;
        --surface-light: #e2e8f0;
        --text-primary: #0f172a;
        --text-secondary: #475569;
        --text-muted: #64748b;
        --border: #cbd5e1;
        --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
        --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
    }
}
