/* Reset & Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); /* default; overridden by mood themes */
    min-height: 100vh;
    padding: 20px;
    transition: background 1.2s cubic-bezier(0.4, 0, 0.2, 1), color 0.6s ease;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
}

/* Header */
.header {
    text-align: center;
    color: white;
    margin-bottom: 40px;
    animation: fadeInDown 0.8s ease;
}

.header h1 {
    font-size: 3.5em;
    margin-bottom: 10px;
    text-shadow: 2px 2px 8px rgba(0,0,0,0.3);
}

.header p {
    font-size: 1.3em;
    opacity: 0.95;
    margin-bottom: 15px;
}

.tech-badge {
    display: inline-block;
    background: rgba(255,255,255,0.25);
    backdrop-filter: blur(10px);
    padding: 12px 24px;
    border-radius: 50px;
    font-size: 0.9em;
    font-weight: 500;
}

/* Main Card */
.main-card {
    background: rgba(255, 255, 255, 0.88);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-radius: 24px;
    padding: 40px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.25);
    border: 1px solid rgba(255,255,255,0.6);
    animation: fadeInUp 0.8s ease;
}

/* Mood Section */
.mood-section h2 {
    color: #667eea;
    font-size: 1.8em;
    margin-bottom: 20px;
}

#moodInput {
    width: 100%;
    padding: 20px;
    font-size: 1.1em;
    border: 3px solid #e0e0e0;
    border-radius: 15px;
    font-family: inherit;
    resize: vertical;
    transition: all 0.3s ease;
}

#moodInput:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.1);
}

.quick-moods {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 20px 0;
}

.mood-chip {
    padding: 10px 20px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    border: none;
    border-radius: 25px;
    cursor: pointer;
    font-size: 0.95em;
    font-weight: 500;
    transition: all 0.3s ease;
}

.mood-chip:hover {
    transform: translateY(-3px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.primary-btn {
    width: 100%;
    padding: 20px;
    font-size: 1.2em;
    font-weight: bold;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    border: none;
    border-radius: 15px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: all 0.3s ease;
}

.primary-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px rgba(102, 126, 234, 0.4);
}

.primary-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Loading */
.loading {
    text-align: center;
    padding: 40px;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Analysis Section */
.analysis-section {
    margin: 30px 0;
    animation: slideInLeft 0.5s ease;
}

.analysis-card {
    background: rgba(255, 255, 255, 0.75);
    backdrop-filter: blur(8px);
    border-left: 5px solid #667eea;
    padding: 25px;
    border-radius: 15px;
}

.analysis-card h3 { color: #4a3f8f; }

.analysis-card h3 {
    color: #667eea;
    font-size: 1.5em;
    margin-bottom: 15px;
}

.analysis-detail {
    background: rgba(255, 255, 255, 0.92);
    padding: 20px;
    border-radius: 10px;
    margin-top: 15px;
    color: #222;
}

.emotion-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 10px;
    margin-top: 15px;
}

.emotion-item {
    background: #f5f5f5;
    padding: 10px;
    border-radius: 8px;
    text-align: center;
    font-size: 0.9em;
}

/* Playlist */
.playlist-section {
    margin-top: 40px;
    animation: fadeIn 0.8s ease;
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 15px;
    flex-wrap: wrap;
    gap: 10px;
}

.section-header h2 {
    color: #667eea;
    font-size: 1.8em;
}

.ml-badge {
    background: #667eea;
    color: white;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.8em;
    font-weight: 500;
}

.playlist-count {
    color: #999;
    margin-bottom: 20px;
}

.playlist-container {
    display: grid;
    gap: 15px;
}

.song-card {
    background: rgba(255, 255, 255, 0.82);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(255,255,255,0.7);
    padding: 20px;
    border-radius: 15px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: all 0.3s ease;
    animation: slideInRight 0.5s ease;
}

.song-card:hover {
    transform: translateX(10px);
    box-shadow: 0 5px 20px rgba(0,0,0,0.15);
}

.song-info {
    flex: 1;
}

.song-name {
    font-size: 1.2em;
    font-weight: bold;
    color: #333;
    margin-bottom: 8px;
}

.song-score {
    display: inline-block;
    background: #667eea;
    color: white;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 0.7em;
    margin-left: 10px;
    font-weight: 600;
}

.song-artist {
    color: #666;
    margin-bottom: 10px;
}

.song-stats {
    display: flex;
    gap: 15px;
    font-size: 0.9em;
    color: #667eea;
    font-weight: 500;
}

.song-actions {
    display: flex;
    gap: 8px;
}

.action-btn {
    padding: 12px 16px;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.action-btn:hover {
    transform: scale(1.1);
}

.like-btn {
    background: #4caf50;
    color: white;
}

.spotify-btn {
    background: #1db954;
    color: white;
}

.dislike-btn {
    background: #f44336;
    color: white;
}

/* Stats Section */
.stats-section {
    margin-top: 40px;
    padding: 30px;
    background: rgba(102, 126, 234, 0.55);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255,255,255,0.3);
    border-radius: 20px;
    color: white;
}

.stats-section h3 {
    font-size: 1.5em;
    margin-bottom: 20px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
}

.stat-card {
    background: rgba(255,255,255,0.2);
    backdrop-filter: blur(10px);
    padding: 25px;
    border-radius: 15px;
    text-align: center;
}

.stat-value {
    font-size: 3em;
    font-weight: bold;
    margin-bottom: 8px;
}

.stat-label {
    font-size: 0.95em;
    opacity: 0.9;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: white;
    padding: 35px;
    border-radius: 24px;
    max-width: 450px;
    width: 90%;
    text-align: center;
    box-shadow: 0 10px 50px rgba(0,0,0,0.5);
    animation: slideInUp 0.3s ease;
}

.modal-content h3 {
    color: #667eea;
    font-size: 1.6em;
    margin-bottom: 15px;
}

.modal-content p {
    color: #666;
    margin-bottom: 25px;
    font-size: 1.1em;
}

.modal-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.modal-btn {
    padding: 15px 20px;
    border: none;
    border-radius: 12px;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.app-btn {
    background: #1db954;
    color: white;
}

.web-btn {
    background: #667eea;
    color: white;
}

.cancel-btn {
    background: #f0f0f0;
    color: #333;
}

.modal-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
}

/* Utility Classes */
.hidden {
    display: none !important;
}

/* Animations */
@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Responsive */
@media (max-width: 768px) {
    .header h1 {
        font-size: 2.5em;
    }
    
    .main-card {
        padding: 25px;
    }
    
    .song-card {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }
    
    .song-actions {
        width: 100%;
        justify-content: space-between;
    }
}
/* ════════════════════════════════════════════════
   MOOD THEME BACKGROUNDS
   Pastel & emotionally-tuned gradients
   ════════════════════════════════════════════════ */

body.mood-happy {
    background: linear-gradient(135deg, #FFE500 0%, #FF6B6B 50%, #FF3CAC 100%);
}

body.mood-sad {
    background: linear-gradient(135deg, #1a1a4e 0%, #16213e 50%, #0f3460 100%);
    color: #c8d8ff;
}

body.mood-energetic {
    background: linear-gradient(135deg, #FF6500 0%, #FF0000 45%, #CC00FF 100%);
}

body.mood-calm {
    background: linear-gradient(135deg, #00C9B1 0%, #00B4D8 50%, #48CAE4 100%);
}

body.mood-romantic {
    background: linear-gradient(135deg, #FF3CAC 0%, #784BA0 50%, #2B86C5 100%);
}

body.mood-angry {
    background: linear-gradient(135deg, #FF0000 0%, #8B0000 50%, #2d0000 100%);
    color: #ffcccc;
}

body.mood-nostalgic {
    background: linear-gradient(135deg, #F7971E 0%, #FFD200 45%, #F7971E 100%);
}

body.mood-focus {
    background: linear-gradient(135deg, #4776E6 0%, #8E54E9 50%, #4776E6 100%);
}

/* ── All mood backgrounds are vivid/dark — white text always ── */
body[class*="mood-"] .header {
    color: white;
}

body[class*="mood-"] .header h1,
body[class*="mood-"] .header p {
    color: white;
    text-shadow: 0 2px 12px rgba(0,0,0,0.3);
}

/* Tech badge on mood backgrounds */
body[class*="mood-"] .tech-badge {
    background: rgba(255,255,255,0.2);
    color: white;
    border: 1px solid rgba(255,255,255,0.3);
}

/* ════════════════════════════════════════════════
   MOOD INDICATOR PILL (bottom-left)
   ════════════════════════════════════════════════ */

#moodIndicator {
    position: fixed;
    bottom: 24px;
    left: 24px;
    padding: 8px 18px;
    border-radius: 999px;
    font-size: 0.82em;
    font-weight: 600;
    background: rgba(255, 255, 255, 0.65);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.85);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.4s ease, transform 0.4s ease;
    pointer-events: none;
    z-index: 9000;
    text-transform: capitalize;
    letter-spacing: 0.03em;
    color: #444;
}

#moodIndicator.visible {
    opacity: 1;
    transform: translateY(0);
}

/* ════════════════════════════════════════════════
   DASHBOARD PANEL
   ════════════════════════════════════════════════ */

#dashboardToggleBtn {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 8000;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.9);
    border-radius: 999px;
    padding: 10px 20px;
    font-size: 0.88em;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    color: #444;
    font-family: inherit;
}

#dashboardToggleBtn:hover {
    transform: scale(1.04);
    box-shadow: 0 6px 22px rgba(0, 0, 0, 0.18);
}

#dashboardPanel {
    position: fixed;
    top: 0;
    right: -420px;
    width: 400px;
    height: 100vh;
    background: rgba(255, 255, 255, 0.97);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-left: 1px solid rgba(0, 0, 0, 0.07);
    box-shadow: -8px 0 40px rgba(0, 0, 0, 0.12);
    z-index: 9000;
    overflow-y: auto;
    transition: right 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

#dashboardBackdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.18);
    z-index: 8999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}

/* Scrollbar inside dashboard panel */
#dashboardPanel::-webkit-scrollbar {
    width: 4px;
}
#dashboardPanel::-webkit-scrollbar-track {
    background: transparent;
}
#dashboardPanel::-webkit-scrollbar-thumb {
    background: #ddd;
    border-radius: 4px;
}

/* YouTube badge in song cards */
.yt-btn {
    background: linear-gradient(135deg, #ff7043, #ff8a65);
    color: white;
    border: none;
    border-radius: 20px;
    padding: 7px 14px;
    cursor: pointer;
    font-size: 0.78em;
    font-weight: 700;
    transition: all 0.2s ease;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    box-shadow: 0 3px 10px rgba(255, 112, 67, 0.35);
    letter-spacing: 0.02em;
}

.yt-btn::before {
    content: "▶";
    font-size: 0.85em;
}

.yt-btn:hover {
    transform: translateY(-2px) scale(1.04);
    box-shadow: 0 6px 16px rgba(255, 112, 67, 0.45);
}

/* Responsive: hide dashboard toggle on very small screens, make panel full-width */
@media (max-width: 480px) {
    #dashboardPanel {
        width: 100vw;
        right: -100vw;
    }

    #dashboardToggleBtn {
        padding: 8px 14px;
        font-size: 0.8em;
        top: 12px;
        right: 12px;
    }
}

/* ════════════════════════════════════════════════
   MOOD CHIP — always legible on any background
   ════════════════════════════════════════════════ */

/* Default (no mood active) */
.mood-chip {
    background: white !important;
    color: #444 !important;
    border: 1.5px solid rgba(0, 0, 0, 0.1) !important;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
    font-weight: 600 !important;
    white-space: nowrap;
}

.mood-chip:hover {
    background: #f0f0ff !important;
    color: #333 !important;
    transform: translateY(-3px);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.12) !important;
    border-color: rgba(102, 126, 234, 0.4) !important;
}

/* Light/medium mood backgrounds — white chip, dark text */
body.mood-happy .mood-chip,
body.mood-nostalgic .mood-chip,
body.mood-energetic .mood-chip,
body.mood-calm .mood-chip {
    background: rgba(255, 255, 255, 0.92) !important;
    color: #333 !important;
    border-color: rgba(255, 255, 255, 0.9) !important;
    box-shadow: 0 2px 12px rgba(0,0,0,0.12) !important;
}

body.mood-happy .mood-chip:hover,
body.mood-nostalgic .mood-chip:hover,
body.mood-energetic .mood-chip:hover,
body.mood-calm .mood-chip:hover {
    background: white !important;
    color: #222 !important;
}

/* Dark mood backgrounds — white text on semi-transparent chip */
body.mood-sad .mood-chip,
body.mood-angry .mood-chip,
body.mood-romantic .mood-chip,
body.mood-focus .mood-chip {
    background: rgba(255, 255, 255, 0.18) !important;
    color: white !important;
    border-color: rgba(255, 255, 255, 0.45) !important;
    text-shadow: 0 1px 4px rgba(0,0,0,0.4);
    box-shadow: 0 2px 10px rgba(0,0,0,0.2) !important;
}

body.mood-sad .mood-chip:hover,
body.mood-angry .mood-chip:hover,
body.mood-romantic .mood-chip:hover,
body.mood-focus .mood-chip:hover {
    background: rgba(255, 255, 255, 0.32) !important;
    color: white !important;
    border-color: rgba(255, 255, 255, 0.7) !important;
}

/* ── Primary button adapts too ── */
body.mood-happy .primary-btn,
body.mood-nostalgic .primary-btn,
body.mood-calm .primary-btn,
body.mood-romantic .primary-btn,
body.mood-sad .primary-btn,
body.mood-energetic .primary-btn,
body.mood-focus .primary-btn {
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
}

/* ── Main card: keep white/readable on all backgrounds ── */
.main-card {
    background: rgba(255, 255, 255, 0.92) !important;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

/* ── Stats section stays vibrant ── */
.stats-section {
    background: rgba(0, 0, 0, 0.12) !important;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    color: inherit;
}

body.mood-angry .stats-section {
    background: rgba(255, 255, 255, 0.1) !important;
    color: #f5e6e6;
}

/* ── Header text stays readable ── */
/* All mood screens have vivid backgrounds — always white header */
body[class*="mood-"] .header h1,
body[class*="mood-"] .header p {
    color: white;
    text-shadow: 0 2px 12px rgba(0,0,0,0.3);
}

/* Default (no mood class applied yet) — original white header */
body:not([class*="mood-"]) .header h1,
body:not([class*="mood-"]) .header p {
    color: white;
    text-shadow: 2px 2px 8px rgba(0,0,0,0.3);
}

body:not([class*="mood-"]) .tech-badge {
    background: rgba(255,255,255,0.25);
    color: white;
}

body[class*="mood-"] .main-card,
body[class*="mood-"] .analysis-card,
body[class*="mood-"] .song-card,
body[class*="mood-"] .stats-section { color: #1a1a2e; }
body[class*="mood-"] .main-card h2,
body[class*="mood-"] .mood-section h2,
body[class*="mood-"] .playlist-section h2,
body[class*="mood-"] .stats-section h3 { color: #2d2d5a !important; }
body.mood-nostalgic .header h1,
body.mood-nostalgic .header p { color: #2a1a00 !important; text-shadow: 0 1px 4px rgba(255,255,255,0.4) !important; }
body.mood-nostalgic .tech-badge { background: rgba(0,0,0,0.15); color: #2a1a00 !important; }