/* Import Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
    --primary: #000000;
    --primary-hover: #1a1a1a;
    --accent: #5b5bf7;
    --accent-light: rgba(91, 91, 247, 0.1);
    
    /* Light Mode (Default) */
    --bg-color: #fafafa;
    --surface-color: #ffffff;
    --surface-border: #e5e5e5;
    --text-primary: #0a0a0a;
    --text-secondary: #737373;
    --text-muted: #a3a3a3;
    --glass-shadow: 0 1px 3px rgba(0, 0, 0, 0.05), 0 20px 40px rgba(0, 0, 0, 0.05);
    --glass-blur: 20px;
    --nav-bg: rgba(250, 250, 250, 0.8);
    --nav-border: #e5e5e5;
    --card-bg: #ffffff;
    --input-bg: #f5f5f5;
    --input-text: #0a0a0a;
    --input-border: #e5e5e5;
    --input-placeholder: #a3a3a3;
    --hover-bg: #f5f5f5;
    --toggle-bg: #f5f5f5;
    --toggle-icon: #525252;
}

body.dark-mode {
    --bg-color: #0a0a0a;
    --surface-color: #171717;
    --surface-border: #262626;
    --text-primary: #fafafa;
    --text-secondary: #a3a3a3;
    --text-muted: #525252;
    --glass-shadow: 0 1px 3px rgba(0, 0, 0, 0.3), 0 20px 40px rgba(0, 0, 0, 0.3);
    --nav-bg: rgba(10, 10, 10, 0.9);
    --nav-border: #262626;
    --card-bg: #171717;
    --input-bg: #262626;
    --input-text: #fafafa;
    --input-border: #404040;
    --input-placeholder: #525252;
    --hover-bg: #262626;
    --toggle-bg: #262626;
    --toggle-icon: #fafafa;
    --accent: #818cf8;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Visually hidden but accessible */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    line-height: 1.6;
    color: var(--text-primary);
    background-color: var(--bg-color);
    overflow-x: hidden;
    min-height: 100vh;
    transition: background-color 0.3s ease, color 0.3s ease;
    -webkit-overflow-scrolling: touch;
}

/* Minimal Background */
.background-shapes {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    overflow: hidden;
    opacity: 0.5;
}

.shape {
    position: absolute;
    border-radius: 50%;
    filter: blur(120px);
    opacity: 0.3;
}

.shape-1 {
    top: -20%;
    right: -10%;
    width: 600px;
    height: 600px;
    background: var(--accent);
}

.shape-2 {
    bottom: -20%;
    left: -10%;
    width: 500px;
    height: 500px;
    background: var(--accent);
}

.shape-3 {
    display: none;
}

@keyframes float {
    0%, 100% { transform: translate(0, 0) rotate(0deg); }
    33% { transform: translate(30px, -50px) rotate(10deg); }
    66% { transform: translate(-20px, 20px) rotate(-5deg); }
}

/* Layout */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Navigation */
.navbar {
    background: var(--nav-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--nav-border);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    height: 64px;
}

.nav-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 64px;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px;
}

.nav-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    text-decoration: none;
    letter-spacing: -0.02em;
}

.nav-logo i {
    color: var(--accent);
    font-size: 1.5rem;
}

.nav-menu {
    display: flex;
    gap: 40px;
    list-style: none;
}

.nav-menu a {
    text-decoration: none;
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 1rem;
    transition: all 0.3s ease;
    position: relative;
}

.nav-menu a:hover {
    color: #6366f1;
}

.nav-menu a::after {
    content: '';
    position: absolute;
    bottom: -5px;
    left: 0;
    width: 0;
    height: 2px;
    background: var(--primary-gradient);
    transition: width 0.3s ease;
}

.nav-menu a:hover::after {
    width: 100%;
}

.nav-toggle {
    display: none;
    flex-direction: column;
    gap: 6px;
    cursor: pointer;
}

.nav-toggle span {
    width: 30px;
    height: 3px;
    background: var(--text-primary);
    border-radius: 3px;
}

.theme-toggle {
    background: var(--toggle-bg);
    border: 1px solid var(--surface-border);
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--toggle-icon);
    font-size: 1rem;
    transition: all 0.2s ease;
}

.theme-toggle:hover {
    background: var(--hover-bg);
    border-color: var(--text-muted);
}

/* Main Section - Single Page Layout */
.main-section {
    min-height: calc(100vh - 64px);
    min-height: calc(100dvh - 64px); /* Dynamic viewport height for mobile browsers */
    margin-top: 64px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
    overflow-y: auto;
    overflow-x: hidden;
}

.main-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 80px;
    max-width: 1100px;
    width: 100%;
}

/* Hero Content - Left Side */
.hero-content {
    flex: 1;
    max-width: 440px;
}

.hero-title {
    font-size: 3.2rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 16px;
    line-height: 1.1;
    letter-spacing: -0.03em;
}

.hero-title span {
    color: var(--accent);
}

.hero-subtitle {
    font-size: 1.05rem;
    color: var(--text-secondary);
    font-weight: 400;
    line-height: 1.6;
}

/* Download Card - Right Side */
.download-card {
    flex: 1;
    max-width: 400px;
    background: var(--surface-color);
    border: 1px solid var(--surface-border);
    border-radius: 16px;
    padding: 28px;
    box-shadow: var(--glass-shadow);
    position: relative;
    overflow: visible;
}

.download-card::before {
    display: none;
}

.card-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 20px;
    color: var(--text-primary);
    text-align: left;
    letter-spacing: -0.01em;
}

/* Form Elements */
.form-group {
    margin-bottom: 12px;
    position: relative;
}

.form-input {
    width: 100%;
    padding: 14px 16px;
    border: 1px solid var(--input-border);
    border-radius: 10px;
    font-size: 0.95rem;
    font-family: 'Inter', sans-serif;
    background: var(--input-bg);
    color: var(--input-text);
    transition: all 0.2s ease;
}

.form-input:focus {
    outline: none;
    border-color: var(--accent);
    background: var(--surface-color);
    box-shadow: 0 0 0 3px var(--accent-light);
}

.form-input::placeholder {
    color: var(--input-placeholder);
}

/* Suggestions List */
.suggestions-list {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--surface-color);
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    list-style: none;
    margin-top: 4px;
    max-height: 240px;
    overflow-y: auto;
    z-index: 1000;
    display: none;
    border: 1px solid var(--surface-border);
}

.suggestions-list.show {
    display: block;
    animation: fadeIn 0.15s ease-out;
}

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

.suggestion-item {
    padding: 12px 16px;
    cursor: pointer;
    transition: background 0.15s ease;
    border-bottom: 1px solid var(--surface-border);
}

.suggestion-item:last-child {
    border-bottom: none;
}

.suggestion-item:hover {
    background: var(--hover-bg);
}

.suggestion-title {
    font-weight: 500;
    color: var(--text-primary);
    font-size: 0.9rem;
    line-height: 1.3;
}

.suggestion-artist {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 2px;
}

.button-group {
    display: flex;
    gap: 12px;
    margin-top: 20px;
}

.download-button {
    flex: 2;
    background: var(--primary);
    color: white;
    border: none;
    padding: 14px;
    border-radius: 10px;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s ease;
}

.download-button:hover {
    background: var(--primary-hover);
}

body.dark-mode .download-button {
    background: #fafafa;
    color: #0a0a0a;
}

body.dark-mode .download-button:hover {
    background: #e5e5e5;
}

.clear-button {
    flex: 1;
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--surface-border);
    padding: 14px;
    border-radius: 10px;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.clear-button:hover {
    background: var(--hover-bg);
    border-color: var(--text-muted);
    color: var(--text-primary);
}

/* Status Panel */
.status-panel {
    margin-top: 20px;
    padding: 16px;
    background: var(--hover-bg);
    border-radius: 12px;
    border: 1px solid var(--surface-border);
    display: none;
}

.status-panel.show {
    display: block;
    animation: fadeIn 0.3s ease-out;
}

/* Audio Player */
.audio-player-container {
    margin-top: 12px;
    background: var(--surface-color);
    border-radius: 10px;
    padding: 12px;
    border: 1px solid var(--surface-border);
}

.close-player-btn {
    background: var(--hover-bg);
    border: 1px solid var(--surface-border);
    width: 32px;
    height: 32px;
    border-radius: 8px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close-player-btn:hover {
    background: var(--surface-border);
    color: var(--text-primary);
}

.status-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.status-icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    color: white;
}

.status-icon.searching { background: var(--accent); }
.status-icon.downloading { background: #f59e0b; }
.status-icon.completed { background: #22c55e; }
.status-icon.failed { background: #ef4444; }

.status-text {
    font-weight: 500;
    font-size: 0.9rem;
    color: var(--text-primary);
}

.progress-container {
    margin-bottom: 8px;
}

.progress-bar {
    width: 100%;
    height: 6px;
    background: var(--surface-border);
    border-radius: 3px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--accent);
    width: 0%;
    border-radius: 3px;
    transition: width 0.4s ease;
}

.progress-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 8px;
}

.download-indicator {
    display: none;
    align-items: center;
    gap: 8px;
}

.download-indicator.active {
    display: flex;
}

.buffer-bar {
    width: 20px;
    height: 4px;
    background: var(--surface-border);
    border-radius: 2px;
    overflow: hidden;
    position: relative;
}

.buffer-bar::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, var(--accent), transparent);
    animation: bufferMove 1.2s ease-in-out infinite;
}

@keyframes bufferMove {
    0% { left: -100%; }
    100% { left: 100%; }
}

.indicator-text {
    font-size: 0.75rem;
    color: var(--accent);
    font-weight: 500;
}

.progress-text {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 500;
}

/* Audio Player */
.audio-player-container {
    margin-top: 10px;
    background: var(--surface-color);
    border-radius: 8px;
    padding: 10px;
    border: 1px solid var(--surface-border);
}

.audio-player-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 8px;
}

.song-info h3 {
    font-size: 0.85rem;
    font-weight: 500;
    margin-bottom: 2px;
}

.song-info p {
    color: var(--text-secondary);
    font-size: 0.75rem;
}

.close-player-btn {
    background: var(--hover-bg);
    border: 1px solid var(--surface-border);
    width: 28px;
    height: 28px;
    border-radius: 6px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
}

.close-player-btn:hover {
    background: var(--surface-border);
    color: var(--text-primary);
}

audio {
    width: 100%;
    height: 36px;
}

/* Success/Error States */
.success-card {
    background: rgba(34, 197, 94, 0.1);
    border: 1px solid rgba(34, 197, 94, 0.2);
    border-radius: 10px;
    padding: 16px;
    text-align: center;
    color: #16a34a;
}

.error-card {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.2);
    border-radius: 10px;
    padding: 16px;
    text-align: center;
    color: #dc2626;
}

body.dark-mode .success-card {
    background: rgba(34, 197, 94, 0.15);
    border-color: rgba(34, 197, 94, 0.3);
    color: #4ade80;
}

body.dark-mode .error-card {
    background: rgba(239, 68, 68, 0.15);
    border-color: rgba(239, 68, 68, 0.3);
    color: #f87171;
}

.download-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #22c55e;
    color: white;
    padding: 10px 20px;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 500;
    font-size: 0.85rem;
    margin-top: 12px;
    transition: all 0.2s ease;
}

.download-link:hover {
    background: #16a34a;
}

.download-another-button, .retry-button {
    width: 100%;
    padding: 10px;
    margin-top: 10px;
    border: 1px solid var(--surface-border);
    background: transparent;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
    font-size: 0.9rem;
    color: var(--text-secondary);
    transition: all 0.2s ease;
}

.download-another-button:hover, .retry-button:hover {
    background: var(--hover-bg);
    border-color: var(--text-muted);
    color: var(--text-primary);
}

/* Animations */
@keyframes slideUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Tablet Responsive */
@media (max-width: 900px) {
    .main-container {
        flex-direction: column;
        gap: 40px;
        padding: 20px;
    }
    
    .main-section {
        height: auto;
        min-height: calc(100vh - 64px);
        overflow-y: auto;
        overflow-x: hidden;
        padding: 30px 20px;
        -webkit-overflow-scrolling: touch;
    }
    
    .hero-content {
        text-align: center;
        max-width: 100%;
    }
    
    .hero-title {
        font-size: 2.2rem;
    }
    
    .download-card {
        max-width: 100%;
        padding: 24px;
    }
    
    .button-group {
        flex-direction: column;
    }
    
    .shape {
        opacity: 0.2;
    }
}

/* Mobile Responsive */
@media (max-width: 600px) {
    body {
        overflow-y: auto;
        overflow-x: hidden;
    }
    
    .navbar {
        height: 56px;
    }
    
    .nav-container {
        height: 56px;
        padding: 0 16px;
    }
    
    .nav-logo {
        font-size: 1.1rem;
        gap: 8px;
    }
    
    .nav-logo i {
        font-size: 1.25rem;
    }
    
    .main-section {
        margin-top: 56px;
        min-height: calc(100vh - 56px);
        padding: 20px 16px;
        display: block;
        overflow-y: auto;
        overflow-x: hidden;
    }
    
    .main-container {
        flex-direction: column;
        gap: 24px;
        padding: 0;
        align-items: stretch;
    }
    
    .hero-content {
        text-align: center;
        padding: 0;
        margin-bottom: 8px;
    }
    
    .hero-title {
        font-size: 1.75rem;
        margin-bottom: 12px;
    }
    
    .hero-subtitle {
        font-size: 0.95rem;
        line-height: 1.5;
    }
    
    .download-card {
        padding: 20px;
        border-radius: 14px;
        margin-bottom: 20px;
    }
    
    .card-title {
        font-size: 1rem;
        margin-bottom: 16px;
    }
    
    .form-input {
        padding: 12px 14px;
        font-size: 16px; /* Prevents iOS zoom on focus */
        border-radius: 8px;
    }
    
    .form-group {
        margin-bottom: 10px;
    }
    
    .button-group {
        flex-direction: column;
        gap: 10px;
        margin-top: 16px;
    }
    
    .download-button,
    .clear-button {
        padding: 14px;
        font-size: 0.95rem;
        border-radius: 8px;
        width: 100%;
    }
    
    .status-panel {
        padding: 14px;
        margin-top: 16px;
    }
    
    .status-header {
        gap: 10px;
        margin-bottom: 10px;
    }
    
    .status-icon {
        width: 32px;
        height: 32px;
        font-size: 0.85rem;
    }
    
    .status-text {
        font-size: 0.85rem;
    }
    
    .audio-player-container {
        padding: 10px;
        margin-top: 10px;
    }
    
    .song-info h3 {
        font-size: 0.8rem;
    }
    
    .song-info p {
        font-size: 0.7rem;
    }
    
    audio {
        height: 40px;
    }
    
    .suggestions-list {
        max-height: 200px;
        border-radius: 10px;
    }
    
    .suggestion-item {
        padding: 10px 14px;
    }
    
    .suggestion-title {
        font-size: 0.85rem;
    }
    
    .suggestion-artist {
        font-size: 0.75rem;
    }
    
    .success-card,
    .error-card {
        padding: 14px;
    }
    
    .download-link {
        padding: 10px 16px;
        font-size: 0.8rem;
    }
    
    .download-another-button,
    .retry-button {
        padding: 10px;
        font-size: 0.85rem;
    }
    
    .shape-1,
    .shape-2 {
        opacity: 0.15;
        filter: blur(80px);
    }
    
    .shape-1 {
        width: 300px;
        height: 300px;
    }
    
    .shape-2 {
        width: 250px;
        height: 250px;
    }
    
    .background-shapes {
        opacity: 0.3;
    }
}

/* Extra small devices */
@media (max-width: 375px) {
    .hero-title {
        font-size: 1.5rem;
    }
    
    .hero-subtitle {
        font-size: 0.9rem;
    }
    
    .download-card {
        padding: 16px;
    }
    
    .form-input {
        padding: 11px 12px;
    }
}

/* Landscape mobile */
@media (max-height: 500px) and (orientation: landscape) {
    .main-section {
        padding: 16px;
    }
    
    .main-container {
        flex-direction: row;
        gap: 20px;
    }
    
    .hero-content {
        text-align: left;
    }
    
    .hero-title {
        font-size: 1.5rem;
    }
    
    .hero-subtitle {
        font-size: 0.85rem;
    }
}