/* Apple Music Web Downloader - Production Stylesheet */
:root {
    --bg-main: #07070b;
    --bg-secondary: #0f0f17;
    --bg-card: #14141f;
    --bg-card-hover: #1c1c2b;
    --apple-red: #fa243c;
    --apple-red-hover: #e01b32;
    --apple-pink: #ff3b56;
    --accent-glow: rgba(250, 36, 60, 0.25);
    --border-glass: rgba(255, 255, 255, 0.08);
    --text-primary: #f8fafc;
    --text-muted: #94a3b8;
    --text-sub: #64748b;
    --radius-lg: 20px;
    --radius-md: 12px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--bg-main);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-main);
}

::-webkit-scrollbar-thumb {
    background: #262636;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--apple-red);
}

/* Navbar */
.app-navbar {
    background: rgba(15, 15, 23, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-glass);
    padding: 1rem 0;
    position: sticky;
    top: 0;
    z-index: 1000;
}

.brand-title {
    font-size: 1.35rem;
    font-weight: 800;
    color: #fff;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.brand-icon {
    width: 38px;
    height: 38px;
    background: linear-gradient(135deg, var(--apple-red), var(--apple-pink));
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 1.2rem;
    box-shadow: 0 4px 15px var(--accent-glow);
}

/* Main Container (Increased App Width: max-width 1400px) */
.hero-wrapper {
    flex: 1;
    padding: 3rem 1rem;
    background: radial-gradient(circle at 50% 0%, #1e1b2e 0%, var(--bg-main) 70%);
    display: flex;
    align-items: center;
    justify-content: center;
}

.glass-box {
    background: var(--bg-card);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-lg);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.6);
    padding: 2.5rem;
    width: 100%;
    max-width: 1400px;
    position: relative;
    overflow: hidden;
}

.glass-box::before {
    content: '';
    position: absolute;
    top: -60px;
    right: -60px;
    width: 180px;
    height: 180px;
    background: radial-gradient(circle, var(--apple-red) 0%, transparent 70%);
    opacity: 0.15;
    border-radius: 50%;
    pointer-events: none;
}

/* Header Section */
.app-header {
    text-align: center;
    margin-bottom: 2rem;
}

.app-header h1 {
    font-size: 2.3rem;
    font-weight: 800;
    margin-bottom: 0.5rem;
    background: linear-gradient(135deg, #ffffff 30%, var(--apple-pink) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.app-header p {
    color: var(--text-muted);
    font-size: 1.05rem;
}

/* Search Controls */
.search-form {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 2rem;
}

.search-input {
    flex: 1;
    padding: 1.1rem 1.4rem;
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-md);
    color: #fff;
    font-size: 1.05rem;
    transition: all 0.3s ease;
}

.search-input:focus {
    outline: none;
    border-color: var(--apple-red);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.btn-apple {
    background: linear-gradient(135deg, var(--apple-red), var(--apple-pink));
    color: #fff;
    border: none;
    padding: 1.1rem 2rem;
    border-radius: var(--radius-md);
    font-size: 1.05rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    box-shadow: 0 4px 20px var(--accent-glow);
}

.btn-apple:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(250, 36, 60, 0.4);
}

.btn-apple:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Loader & Status */
.loader-box {
    display: none;
    text-align: center;
    padding: 2.5rem 1rem;
}

.spinner-apple {
    width: 50px;
    height: 50px;
    border: 3px solid rgba(250, 36, 60, 0.15);
    border-top-color: var(--apple-red);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 1rem;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Error Banner */
.alert-error {
    background: rgba(239, 68, 68, 0.12);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #f87171;
    padding: 1.1rem 1.4rem;
    border-radius: var(--radius-md);
    margin-bottom: 1.5rem;
    display: none;
    font-size: 0.95rem;
    line-height: 1.5;
}

/* Results Container & Grid */
#resultsContainer {
    width: 100% !important;
    max-width: 100% !important;
}

.results-grid {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-top: 1.5rem;
    width: 100% !important;
    max-width: 100% !important;
}

/* Track Card Base Styles */
.track-card {
    background: linear-gradient(145deg, rgba(22, 22, 34, 0.95), rgba(15, 15, 23, 0.98));
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 18px;
    padding: 24px;
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box;
    transition: all 0.3s ease;
}

.track-card:hover {
    border-color: rgba(250, 36, 60, 0.45);
    box-shadow: 0 10px 35px rgba(250, 36, 60, 0.2);
    transform: translateY(-2px);
}

/* Album Cover Artwork */
.track-cover {
    width: 110px !important;
    height: 110px !important;
    border-radius: 14px;
    object-fit: cover;
    background: #000;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.6);
    flex-shrink: 0;
}

/* Middle Section Metadata */
.track-meta {
    min-width: 0;
    width: 100%;
}

.track-title {
    font-size: 24px !important;
    font-weight: 800 !important;
    color: #ffffff !important;
    margin-bottom: 6px !important;
    line-height: 1.35 !important;
    word-break: break-word !important;
    overflow-wrap: break-word !important;
    white-space: normal !important;
}

.track-details {
    font-size: 15px;
    color: var(--text-muted);
    line-height: 1.5;
    margin-bottom: 10px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
}

.artist-name {
    font-size: 17px !important;
    font-weight: 600 !important;
    color: var(--apple-pink) !important;
}

.album-name {
    font-size: 15px !important;
    color: var(--text-muted) !important;
}

.release-year, .track-duration {
    font-size: 15px !important;
    color: var(--text-sub) !important;
}

.meta-dot {
    color: rgba(255, 255, 255, 0.3);
    font-size: 14px;
}

.badge-quality {
    display: inline-block;
    background: rgba(250, 36, 60, 0.15);
    color: var(--apple-pink);
    font-size: 13px;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 8px;
    border: 1px solid rgba(250, 36, 60, 0.3);
}

/* Download Button Container & Button */
.track-action {
    width: 220px;
    flex-shrink: 0;
}

.btn-download-item {
    background: linear-gradient(135deg, var(--apple-red), var(--apple-pink));
    color: #ffffff;
    border: none;
    padding: 14px 20px;
    border-radius: 12px;
    font-weight: 800;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-shadow: 0 4px 20px var(--accent-glow);
    white-space: nowrap !important;
    width: 100%;
}

.btn-download-item:hover {
    transform: scale(1.03);
    box-shadow: 0 8px 30px rgba(250, 36, 60, 0.5);
}

/* Modal Download Result Card */
.download-success-box {
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.3);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    margin-top: 1.5rem;
    text-align: center;
    display: none;
    animation: fadeIn 0.4s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Footer Styling */
.app-footer {
    background: #0d0d14;
    border-top: 1px solid var(--border-glass);
    padding: 1.5rem 0;
    color: #cbd5e1;
    font-size: 0.92rem;
    font-weight: 500;
}

.app-footer span {
    color: var(--apple-pink);
    font-weight: 700;
}

/* Desktop CSS Grid Layout (min-width: 769px) */
@media (min-width: 769px) {
    .track-card {
        display: grid !important;
        grid-template-columns: 110px 1fr 220px !important;
        align-items: center !important;
        gap: 24px !important;
        padding: 24px !important;
        width: 100% !important;
    }

    .track-action {
        justify-self: end !important;
        align-self: center !important;
        width: 220px !important;
    }
}

/* Mobile Stacked Layout (max-width: 768px) */
@media (max-width: 768px) {
    .glass-box {
        padding: 1.5rem 1.1rem;
    }

    .search-form {
        flex-direction: column;
    }

    .btn-apple {
        width: 100%;
    }

    .track-card {
        display: flex !important;
        flex-direction: column !important;
        text-align: center !important;
        align-items: center !important;
        gap: 16px !important;
        padding: 20px !important;
    }

    .track-details {
        justify-content: center;
    }

    .track-action {
        width: 100% !important;
    }

    .btn-download-item {
        width: 100% !important;
        justify-content: center !important;
    }
}