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

/* Reset and 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 {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.header {
    text-align: center;
    padding: 2rem 1rem;
    background: linear-gradient(135deg, var(--gradient-start), var(--gradient-end));
    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 {
    font-size: 2.5rem;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

.header 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;
    padding: 2rem 1rem;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
}

/* Form Card */
.form-card, .playlist-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
}

.form-card h2, .playlist-card h2 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
    color: var(--text-primary);
}

/* Form Groups */
.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

/* Select Wrapper */
.select-wrapper {
    position: relative;
}

.select-wrapper::after {
    content: '▼';
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.75rem;
    color: var(--text-muted);
    pointer-events: none;
}

select {
    width: 100%;
    padding: 0.875rem 1rem;
    background: var(--surface-light);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 1rem;
    font-family: inherit;
    appearance: none;
    cursor: pointer;
    transition: var(--transition);
}

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

/* Mood Grid */
.mood-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
}

.mood-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    padding: 0.75rem 0.5rem;
    background: var(--surface-light);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
}

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

.mood-btn.active {
    background: var(--primary-light);
    border-color: var(--primary-color);
    color: var(--primary-color);
}

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

.mood-text {
    font-size: 0.75rem;
    font-weight: 500;
}

/* Duration Slider */
.duration-slider {
    padding: 0.5rem 0;
}

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

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

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

input[type="range"]::-moz-range-thumb {
    width: 24px;
    height: 24px;
    background: var(--primary-color);
    border-radius: 50%;
    cursor: pointer;
    border: none;
    box-shadow: var(--shadow-md);
}

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

#durationValue {
    font-weight: 600;
    color: var(--primary-color);
    font-size: 0.875rem;
}

/* Customization Options */
.customization-options {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
}

.checkbox-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.checkbox-item input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary-color);
    cursor: pointer;
}

.checkbox-item label {
    font-size: 0.875rem;
    color: var(--text-secondary);
    cursor: pointer;
    margin-bottom: 0;
}

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

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

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

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

/* Playlist Section */
.playlist-section {
    display: none;
    margin-top: 2rem;
}

.playlist-section.visible {
    display: block;
    animation: fadeIn 0.5s ease;
}

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

.playlist-header {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.playlist-info h2 {
    margin-bottom: 0.25rem;
}

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

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

.action-btn {
    width: 40px;
    height: 40px;
    background: var(--surface-light);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.125rem;
    transition: var(--transition);
}

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

.spotify-btn {
    flex: 1;
    min-width: 150px;
    padding: 0.75rem 1rem;
    background: var(--spotify-green);
    border: none;
    border-radius: var(--radius-sm);
    color: white;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: var(--transition);
}

.spotify-btn:hover {
    background: #1ed760;
    transform: translateY(-1px);
}

/* Playlist Stats */
.playlist-stats {
    display: flex;
    justify-content: space-around;
    padding: 1rem;
    background: var(--surface-light);
    border-radius: var(--radius-md);
    margin-bottom: 1.5rem;
}

.stat {
    text-align: center;
}

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

.stat-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

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

.playlist-tracks::-webkit-scrollbar {
    width: 6px;
}

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

.playlist-tracks::-webkit-scrollbar-thumb {
    background: var(--text-muted);
    border-radius: 3px;
}

.track-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

.track-item:hover {
    background: var(--surface-light);
}

.track-number {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 500;
}

.track-artwork {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-sm);
    background: var(--surface-light);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    flex-shrink: 0;
}

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

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

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

.track-duration {
    font-size: 0.875rem;
    color: var(--text-muted);
    flex-shrink: 0;
}

.track-actions {
    display: flex;
    gap: 0.25rem;
}

.track-action-btn {
    width: 32px;
    height: 32px;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    transition: var(--transition);
}

.track-action-btn:hover {
    background: var(--surface-light);
    color: var(--text-primary);
}

.track-action-btn.remove:hover {
    color: var(--error);
}

/* Regenerate Button */
.regenerate-btn {
    width: 100%;
    padding: 0.875rem;
    background: transparent;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: var(--transition);
}

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

/* Saved Playlists Section */
.saved-playlists-section {
    margin-top: 2rem;
    display: none;
}

.saved-playlists-section.visible {
    display: block;
}

.saved-playlists-section h2 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.saved-playlists-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
}

.saved-playlist-card {
    background: var(--surface);
    border-radius: var(--radius-md);
    padding: 1rem;
    border: 1px solid var(--border-color);
    cursor: pointer;
    transition: var(--transition);
}

.saved-playlist-card:hover {
    border-color: var(--primary-color);
    transform: translateY(-2px);
}

.saved-playlist-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.5rem;
}

.saved-playlist-title {
    font-weight: 600;
    color: var(--text-primary);
}

.saved-playlist-delete {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1rem;
    padding: 0.25rem;
    transition: var(--transition);
}

.saved-playlist-delete:hover {
    color: var(--error);
}

.saved-playlist-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
}

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

.footer-content {
    max-width: 1200px;
    margin: 0 auto;
    text-align: center;
}

.powered-by {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

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

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

.copyright {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* 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-md);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
    z-index: 1000;
    opacity: 0;
    transition: all 0.3s ease;
}

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

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

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

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1001;
    padding: 1rem;
}

.modal.show {
    display: flex;
}

.modal-content {
    background: var(--surface);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 400px;
    border: 1px solid var(--border-color);
    animation: modalIn 0.3s ease;
}

@keyframes modalIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
    font-size: 1.125rem;
    font-weight: 600;
}

.modal-close {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    line-height: 1;
    transition: var(--transition);
}

.modal-close:hover {
    color: var(--text-primary);
}

.modal-body {
    padding: 1.5rem;
}

.modal-body p {
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

.share-options {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.share-option-btn {
    width: 100%;
    padding: 0.875rem;
    background: var(--surface-light);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: var(--transition);
}

.share-option-btn:hover {
    background: var(--primary-color);
    border-color: var(--primary-color);
}

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

    .main-content {
        padding: 3rem 2rem;
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 2rem;
        align-items: start;
    }

    .generator-section {
        position: sticky;
        top: 2rem;
    }

    .playlist-section {
        margin-top: 0;
    }

    .saved-playlists-section {
        grid-column: span 2;
    }

    .form-card, .playlist-card {
        padding: 2rem;
    }

    .playlist-header {
        flex-direction: row;
        justify-content: space-between;
        align-items: flex-start;
    }

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

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

@media (min-width: 1024px) {
    .mood-grid {
        grid-template-columns: repeat(6, 1fr);
    }

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

@media (max-width: 480px) {
    .header h1 {
        font-size: 1.25rem;
    }

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

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

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

    .action-btn {
        width: 100%;
    }

    .spotify-btn {
        width: 100%;
    }

    .playlist-stats {
        flex-direction: column;
        gap: 1rem;
    }
}

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

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

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

/* Dark Mode Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--surface);
}

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

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}
