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

:root {
    --spotify-green: #1DB954;
    --spotify-green-light: #1ed760;
    --bg-primary: #0a0a0f;
    --bg-card: rgba(255, 255, 255, 0.04);
    --bg-card-hover: rgba(255, 255, 255, 0.07);
    --bg-input: rgba(255, 255, 255, 0.06);
    --text-primary: #f0f0f5;
    --text-secondary: #8b8b9e;
    --text-muted: #55556a;
    --border-subtle: rgba(255, 255, 255, 0.08);
    --border-focus: rgba(29, 185, 84, 0.5);
    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --shadow-glow: 0 0 60px rgba(29, 185, 84, 0.15);
    --transition-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-smooth: 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-family);
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* Ambient background glow */
.bg-glow {
    position: fixed;
    top: -30%;
    left: 50%;
    translate: -50% 0;
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, rgba(29, 185, 84, 0.12) 0%, transparent 70%);
    pointer-events: none;
    z-index: 0;
    animation: pulse-glow 6s ease-in-out infinite alternate;
}

@keyframes pulse-glow {
    0% {
        opacity: 0.6;
        scale: 1;
    }

    100% {
        opacity: 1;
        scale: 1.15;
    }
}

/* Container */
.container {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 640px;
    padding: 3rem 1.25rem 2rem;
    flex: 1;
}

/* Hero / Header */
.hero {
    text-align: center;
    margin-bottom: 2.5rem;
}

.logo {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    margin-bottom: 0.75rem;
}

.logo h1 {
    font-size: 2rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--spotify-green), var(--spotify-green-light));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.02em;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 0.95rem;
    font-weight: 400;
}

/* Search Bar */
.search-section {
    margin-bottom: 2rem;
}

.search-bar {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.input-wrapper {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--bg-input);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 0.5rem 0.75rem;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.input-wrapper:focus-within {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(29, 185, 84, 0.1);
}

.input-icon {
    flex-shrink: 0;
    color: var(--text-muted);
}

.input-wrapper input {
    flex: 1;
    background: none;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-family: var(--font-family);
    font-size: 0.95rem;
    padding: 0.5rem 0;
}

.input-wrapper input::placeholder {
    color: var(--text-muted);
}

.paste-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-secondary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    padding: 0.4rem 0.7rem;
    font-family: var(--font-family);
    font-size: 0.8rem;
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
}

.paste-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

.submit-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.85rem 1.5rem;
    background: linear-gradient(135deg, var(--spotify-green), var(--spotify-green-light));
    color: #000;
    border: none;
    border-radius: var(--radius-md);
    font-family: var(--font-family);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    position: relative;
    overflow: hidden;
}

.submit-btn::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.15), transparent);
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.submit-btn:hover::before {
    opacity: 1;
}

.submit-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 24px rgba(29, 185, 84, 0.35);
}

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

.submit-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.spinner {
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        rotate: 360deg;
    }
}

/* Error Card */
.error-card {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    background: rgba(239, 68, 68, 0.08);
    border: 1px solid rgba(239, 68, 68, 0.2);
    border-radius: var(--radius-md);
    color: #fca5a5;
    font-size: 0.9rem;
    margin-bottom: 2rem;
    animation: slide-in 0.35s var(--transition-smooth);
}

.error-card svg {
    flex-shrink: 0;
    color: #ef4444;
}

.error-card[hidden] {
    display: none;
}

/* Result Card */
.result-card {
    display: flex;
    gap: 1.5rem;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    backdrop-filter: blur(12px);
    animation: slide-in 0.5s var(--transition-smooth);
    transition: background var(--transition-fast);
}

.result-card[hidden] {
    display: none;
}

.result-card:hover {
    background: var(--bg-card-hover);
}

@keyframes slide-in {
    from {
        opacity: 0;
        translate: 0 12px;
    }

    to {
        opacity: 1;
        translate: 0 0;
    }
}

.result-cover {
    position: relative;
    width: 160px;
    min-width: 160px;
    height: 160px;
    border-radius: var(--radius-md);
    overflow: hidden;
    flex-shrink: 0;
}

.result-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.preview-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 4px;
    background: var(--spotify-green-light);
    width: 0%;
    transition: width 0.1s linear;
    z-index: 2;
    opacity: 0;
}

.result-cover.playing .preview-progress {
    opacity: 1;
}

.cover-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.45);
    opacity: 0;
    transition: opacity var(--transition-fast);
    cursor: pointer;
}

.cover-overlay[hidden] {
    display: none !important;
}

.result-cover:hover .cover-overlay {
    opacity: 1;
}

.result-info {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 0.4rem;
    min-width: 0;
}

.track-title {
    font-size: 1.3rem;
    font-weight: 700;
    line-height: 1.3;
    letter-spacing: -0.01em;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.track-artist {
    color: var(--text-secondary);
    font-size: 0.95rem;
    font-weight: 500;
}

.meta-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.meta-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.3rem 0.65rem;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 100px;
    font-size: 0.78rem;
    color: var(--text-secondary);
    white-space: nowrap;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.spotify-link {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    color: var(--spotify-green);
    text-decoration: none;
    font-size: 0.88rem;
    font-weight: 500;
    transition: color var(--transition-fast);
}

.spotify-link:hover {
    color: var(--spotify-green-light);
}

/* Actions Row */
.actions-row {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    margin-top: 1rem;
}

.download-mp3-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.6rem 1.2rem;
    background: linear-gradient(135deg, var(--spotify-green), var(--spotify-green-light));
    color: #000;
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font-family);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.download-mp3-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(29, 185, 84, 0.3);
}

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

.download-mp3-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}


/* Artist Card */
.artist-card {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    padding: 1.25rem 1.5rem;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-lg);
    margin-top: 1rem;
    animation: fadeUp var(--transition-base) ease-out;
}

.artist-card[hidden] {
    display: none !important;
}

.artist-avatar-wrap {
    flex-shrink: 0;
    width: 72px;
    height: 72px;
    border-radius: 50%;
    overflow: hidden;
    border: 2px solid var(--spotify-green);
    box-shadow: 0 0 12px rgba(29, 185, 84, 0.15);
}

.artist-avatar {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.artist-info {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    min-width: 0;
}

.artist-name {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

.artist-desc {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin: 0;
    line-height: 1.4;
}

/* Footer */
.footer {
    text-align: center;
    padding: 1.5rem 1rem;
    color: var(--text-muted);
    font-size: 0.8rem;
    z-index: 1;
}

/* Responsive */
@media (max-width: 560px) {
    .result-card {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }

    .result-cover {
        width: 200px;
        height: 200px;
    }

    .result-info {
        align-items: center;
    }

    .meta-row {
        justify-content: center;
    }

    .logo h1 {
        font-size: 1.6rem;
    }
}