/* New css */
/* Basic Reset and Font Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
    /* Switched to Inter for better readability */
    -webkit-tap-highlight-color: transparent;
    /* Removes blue highlight on mobile tap */
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
    /* Smooth Theme Transition */
}

:root {
    /* Brand Colors */
    --primary-color: #e93636;
    --primary-shadow: rgba(233, 54, 54, 0.3);
    --btn-green: #5cb85c;

    /* Light Mode (Default) Variables */
    --body-bg: #f2f4f8;
    --container-bg: #ffffff;
    --header-gradient-start: #ffffff;
    --header-gradient-end: #fafafa;
    --text-dark: #1e272e;
    --text-light: #808e9b;
    --tabs-container-bg: #f1f3f6;
    --tab-content-bg: #f9fbfc;
    --list-item-bg: #f0f2f5;
    --list-item-hover: #f5f5f5;
    --divider-color: #f0f0f0;
    --skeleton-base: #e0e0e0;
    --skeleton-highlight: #f5f5f5;
    --container-shadow: rgba(0, 0, 0, 0.06);
    --modal-bg: #ffffff;
}

/* Dark Mode Override Variables */
.mp3-widget-plus.dark-mode {
    --body-bg: #121212;
    --container-bg: #1e1e1e;
    --header-gradient-start: #1e1e1e;
    --header-gradient-end: #2d2d2d;
    /* Slightly lighter for contrast */
    --text-dark: #ffffff;
    --text-light: #a0a0a0;
    --tabs-container-bg: #0d0d0d;
    /* Much darker (almost black) to separate from header */
    --tab-content-bg: #181818;
    --list-item-bg: #0d0d0d;
    --list-item-hover: #2a2a2a;
    --divider-color: #333333;
    --skeleton-base: #2c2c2c;
    --skeleton-highlight: #3a3a3a;
    --container-shadow: rgba(0, 0, 0, 0.5);
    --modal-bg: #252525;
}

.mp3-widget-plus {
    display: flex;
    justify-content: center;
    background-color: var(--body-bg);
    min-height: 100vh;
    padding: 20px 0;
}

/* FIX 1: Force scrollbar to prevent horizontal layout shift */
html {
    overflow-y: scroll;
}

body {
    background-color: var(--body-bg);
    /* padding: 20px; */
}

.mp3-container {
    width: 100%;
    max-width: 500px;
    background: var(--container-bg);
    padding: 0;
    border-radius: 8px;
    height: fit-content;
    position: relative;
    overflow: hidden;
    margin: 0 auto;
}

.mp3-widget-plus.dark-mode .mp3-popup-card {
    background-color: var(--tab-content-bg);
    /* box-shadow: 0 15px 35px rgba(255, 255, 255, .25); */
}

.mp3-widget-plus.dark-mode .mp3-popup-title,
.mp3-widget-plus.dark-mode .mp3-popup-description {
    color: #fff;
}

.mp3-tab-content {
    background: var(--tab-content-bg);
    padding: 20px 0;
}

.mp3-download-list {
    display: flex;
    flex-direction: column;
    padding: 0 25px;
    gap: 12px;
}

.mp3-download-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: var(--list-item-bg);
    border-radius: 12px;
    border: 1px solid var(--divider-color);
}

.mp3-item-left {
    display: flex;
    align-items: center;
}

.mp3-item-details {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.mp3-item-res {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-dark);
}

.mp3-item-meta {
    font-size: 13px;
    color: var(--text-light);
}

.mp3-download-action-btn {
    width: 100%;
    padding: 10px 24px;
    border-radius: 6px;
    background: var(--primary-color);
    border: none;
    color: white;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    text-transform: uppercase;
}

/* Modal Overlay */
.mp3-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(2px);
    opacity: 1;
    transition: opacity 0.3s ease;
}

/* The Card Container */
.mp3-popup-card {
    background-color: #ffffff;
    width: 100%;
    max-width: 800px;
    border-radius: 12px;
    padding: 50px 40px;
    text-align: center;
    position: relative;
    /* box-shadow: 0 15px 35px rgba(0, 0, 0, 0.25); */
    transform: scale(1);
    animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    min-height: 350px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

/* Close Button */
.mp3-close-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    background: none;
    border: none;
    cursor: pointer;
    color: #999;
    transition: color 0.2s;
    padding: 5px;
    display: none;
    /* Hidden by default */
}

.mp3-close-btn:hover {
    color: #555;
    background: unset;
}

/* Typography */
.mp3-popup-title {
    color: #444444;
    font-size: 36px;
    font-weight: 700;
    margin-bottom: 20px;
    line-height: 1.2;
    width: 100%;
    white-space: normal;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mp3-overlay.error .mp3-popup-title {
    color: var(--primary-color);
    font-size: 36px;
    font-weight: 700;
    margin-bottom: 20px;
    line-height: 1.2;
    transition: color 0.3s ease;
}

.mp3-overlay.error #mp3-badgeIcon,
.mp3-overlay.error #mp3-badgeText {
    color: var(--primary-color);
}

.mp3-overlay.error .mp3-progress-container {
    display: none;
}

.mp3-overlay.error .mp3-download-btn {
    display: none;
}

.mp3-overlay.error .mp3-popup-description {
    color: #555555;
    font-size: 18px;
    font-weight: 400;
    margin-bottom: 30px;
    line-height: 1.5;
    max-width: 90%;
    min-height: 27px;
    /* Reserves space for 1 line of text */
    display: block;
}

/* Quality Indicator */
.mp3-quality-badge {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 30px;
    color: #89d843;
}

.mp3-quality-text {
    font-size: 20px;
    font-weight: 500;
}

/* --- Action Wrapper (Prevents Layout Shift) --- */
.mp3-action-area {
    width: 100%;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* --- Progress Bar Styles (Updated for Infinite) --- */
.mp3-progress-container {
    width: 100%;
    max-width: 100%;
    margin: 0 auto;
    text-align: left;
    display: block;
}

.mp3-progress-track {
    width: 100%;
    height: 14px;
    background-color: #e0e0e0;
    border-radius: 10px;
    overflow: hidden;
    position: relative;
}

.mp3-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #89d843, #7ac43b);
    border-radius: 10px;
    position: absolute;
    left: -40%;
    width: 40%;
    /* Shorter bar for the moving effect */
    box-shadow: 0 0 10px rgba(137, 216, 67, 0.4);
    animation: indeterminateSlide 1.5s infinite ease-in-out;
}

@keyframes indeterminateSlide {
    0% {
        left: -40%;
        width: 40%;
    }

    50% {
        width: 60%;
    }

    /* Stretches slightly in middle */
    100% {
        left: 100%;
        width: 40%;
    }
}

.mp3-close-btn-custom {
    position: unset;
    background: #fe0000;
    color: white;
    border: none;
    padding: 20px 60px;
    font-size: 24px;
    font-weight: 700;
    border-radius: 12px;
    cursor: pointer;
    width: auto;
    min-width: 280px;
    display: none;
    margin: 0;
    justify-content: center;
    align-items: center;
    box-shadow: none;
    text-decoration: none;
}

.mp3-close-btn-custom:hover,
.mp3-close-btn-custom:active,
.mp3-close-btn-custom:focus,
.mp3-download-btn:hover,
.mp3-download-btn:active,
.mp3-download-btn:focus {
    text-decoration: none;
    color: white;
}

.mp3-quality-badge-error {
    display: none;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 30px;
}

/* --- Download Button Styles --- */
.mp3-download-btn {
    margin: 0 auto;
    padding: 10px 24px;
    border-radius: 6px;
    background: var(--primary-color);
    border: none;
    color: white;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    text-transform: uppercase;
    display: none;
    justify-content: center;
    align-items: center;
    position: relative;
}

.mp-header {
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    /* ... other styles ... */
}

.mp3-spinner {
    display: none;
    width: 28px;
    height: 28px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.mp3-download-btn.loading .btn-text {
    visibility: hidden;
    /* Hide text but keep space to maintain button size */
}

.mp3-download-btn.loading .mp3-spinner {
    display: block;
    position: absolute;
    /* Center without using 'transform' to avoid conflict with 'spin' animation */
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    margin: auto;
}

.mp3-download-btn.loading {
    pointer-events: none;
    opacity: 1;
}

#mp3-downloadBtn:hover {
    text-decoration: none;
}

.mp3-download-form {
    background-color: #ffffff;
    max-width: 568px;
    border-top: 3px #f4114a solid;
    border-radius: 12px;
    box-shadow: 0 2px 2px rgba(0, 0, 0, 0.1);
    margin: 0 auto;
    padding: 16px;
}

#progressMessages {
    color: #666666;
    background-color: #fcfcfc;
    font-size: 16px;
    height: 48px;
    border: 1px #e5e8eb solid;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    gap: 8px;
}

#progressSpinner {
    width: 16px;
    height: 16px;
    border: 2px transparent solid;
    border-top: 2px #f4114a solid;
    border-bottom: 2px #f4114a solid;
    border-radius: 50%;
    animation: spin 2s linear infinite;
}

.progress-error {
    color: #f4114a;
    background-color: #fcfcfc;
    font-size: 16px;
    padding: 12px;
    border: 1px #e5e8eb solid;
    border-radius: 8px;
    text-align: center;
}