/* ===== CSS Variables for Light/Dark Mode ===== */
:root {
    /* Dark Mode (default) */
    --bg-gradient-start: #0f172a;
    --bg-gradient-end: #020617;
    --glass-bg: rgba(15, 23, 42, 0.35);
    --glass-border: rgba(255, 255, 255, 0.1);
    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --logo-gradient: linear-gradient(135deg, #e0f2fe 0%, #bae6fd 70%, #7dd3fc 100%);
    --input-bg: rgba(15, 23, 42, 0.3);
    --button-bg: rgba(255, 255, 255, 0.08);
    --button-hover: rgba(56, 189, 248, 0.2);
    --info-panel-bg: rgba(15, 23, 42, 0.25);
    --progress-bg: rgba(0, 0, 0, 0.3);
    --progress-fill: linear-gradient(90deg, #38bdf8, #818cf8, #c084fc);
    --download-btn-bg: rgba(16, 185, 129, 0.15);
    --download-btn-border: rgba(52, 211, 153, 0.3);
    --shadow-panel: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

/* Light Mode */
[data-theme="light"] {
    --bg-gradient-start: #f8fafc;
    --bg-gradient-end: #e2e8f0;
    --glass-bg: rgba(255, 255, 255, 0.4);
    --glass-border: rgba(0, 0, 0, 0.08);
    --text-primary: #0f172a;
    --text-secondary: #334155;
    --logo-gradient: linear-gradient(135deg, #1e293b 0%, #334155 70%, #475569 100%);
    --input-bg: rgba(255, 255, 255, 0.5);
    --button-bg: rgba(0, 0, 0, 0.04);
    --button-hover: rgba(56, 189, 248, 0.15);
    --info-panel-bg: rgba(255, 255, 255, 0.3);
    --progress-bg: rgba(0, 0, 0, 0.08);
    --progress-fill: linear-gradient(90deg, #0284c7, #4f46e5, #7c3aed);
    --download-btn-bg: rgba(16, 185, 129, 0.1);
    --download-btn-border: rgba(16, 185, 129, 0.4);
    --shadow-panel: 0 25px 50px -12px rgba(0, 0, 0, 0.15);
}

/* ===== Base Styles ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    min-height: 100vh;
    background: radial-gradient(circle at 20% 30%, var(--bg-gradient-start), var(--bg-gradient-end));
    font-family: 'Inter', sans-serif;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.2rem;
    color: var(--text-primary);
    transition: background 0.3s ease, color 0.2s ease;
    position: relative;
}

/* Noise overlay for glass depth */
body::before {
    content: "";
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background-image: url('data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIzMDAiIGhlaWdodD0iMzAwIj48ZmlsdGVyIGlkPSJmIj48ZmVUdXJidWxlbmNlIHR5cGU9ImZyYWN0YWxOb2lzZSIgYmFzZUZyZXF1ZW5jeT0iLjc1IiBudW1PY3RhdmVzPSIzIiAvPjwvZmlsdGVyPjxyZWN0IHdpZHRoPSIxMDAlIiBoZWlnaHQ9IjEwMCUiIGZpbHRlcj0idXJsKCNmKSIgb3BhY2l0eT0iMC4wMjUiIC8+PC9zdmc+');
    opacity: 0.15;
    pointer-events: none;
    z-index: 0;
}

/* Floating orbs */
.orb {
    position: fixed;
    border-radius: 50%;
    filter: blur(80px);
    z-index: 1;
    pointer-events: none;
    transition: opacity 0.3s;
}
.orb1 {
    width: 50vw; height: 50vw;
    top: -10vh; right: -10vw;
    background: radial-gradient(circle, rgba(56, 189, 248, 0.3), transparent);
}
.orb2 {
    width: 70vw; height: 70vw;
    bottom: -20vh; left: -20vw;
    background: radial-gradient(circle, rgba(168, 85, 247, 0.2), transparent);
}
[data-theme="light"] .orb1 { opacity: 0.5; }
[data-theme="light"] .orb2 { opacity: 0.4; }

/* ===== Top Buttons (Home + Theme Toggle) ===== */
.top-buttons {
    position: fixed;
    top: 24px;
    right: 24px;
    display: flex;
    gap: 12px;
    z-index: 100;
}

.home-btn,
.theme-toggle {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 60px;
    padding: 10px 16px;
    color: var(--text-primary);
    font-size: 1.2rem;
    cursor: pointer;
    box-shadow: var(--shadow-panel);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    text-decoration: none;
}

.home-btn:hover,
.theme-toggle:hover {
    transform: scale(1.05);
    border-color: rgba(56, 189, 248, 0.5);
}

.theme-toggle .fa-sun { display: none; }
.theme-toggle .fa-moon { display: inline-block; }

[data-theme="light"] .theme-toggle .fa-sun { display: inline-block; }
[data-theme="light"] .theme-toggle .fa-moon { display: none; }

/* Main Glass Panel */
.glass-panel {
    max-width: 720px;
    width: 100%;
    background: var(--glass-bg);
    backdrop-filter: blur(18px) saturate(180%);
    -webkit-backdrop-filter: blur(18px) saturate(180%);
    border: 1px solid var(--glass-border);
    border-radius: 48px;
    box-shadow: var(--shadow-panel), inset 0 0 0 1px rgba(255, 255, 255, 0.03);
    padding: 2.5rem 2rem 2.8rem;
    transition: background 0.3s, border-color 0.3s;
    z-index: 2;
    position: relative;
}

/* Logo */
.logo-wrapper {
    text-align: center;
    margin-bottom: 2.2rem;
}
.logo {
    font-family: 'Poppins', sans-serif;
    font-weight: 500;
    font-size: clamp(2.6rem, 12vw, 4.4rem);
    letter-spacing: -0.02em;
    background: var(--logo-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    display: inline-block;
    padding: 0 0.2rem;
}
.logo i {
    font-size: 0.85em;
    margin-right: 6px;
    background: linear-gradient(145deg, #ff6b6b, #ff4444);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}
.logo span { font-weight: 300; }

/* Input Section */
.convert-section {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--input-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 120px;
    padding: 8px 8px 8px 24px;
    transition: border 0.2s, box-shadow 0.2s;
}
.convert-section:focus-within {
    border-color: rgba(56, 189, 248, 0.5);
    box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.15);
}
.url-input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    font-size: 1.1rem;
    padding: 0.9rem 0;
    color: var(--text-primary);
    font-family: 'Inter', sans-serif;
}
.url-input::placeholder {
    color: var(--text-secondary);
    opacity: 0.6;
}
.convert-btn {
    background: var(--button-bg);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid var(--glass-border);
    border-radius: 100px;
    padding: 0.9rem 2.1rem;
    font-size: 1.1rem;
    font-weight: 500;
    font-family: 'Poppins', sans-serif;
    color: var(--text-primary);
    box-shadow: 0 6px 14px rgba(0, 0, 0, 0.1);
    cursor: pointer;
    transition: all 0.25s;
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}
.convert-btn:hover {
    background: var(--button-hover);
    border-color: rgba(56, 189, 248, 0.5);
    transform: scale(1.02);
}
.convert-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Info Panel */
.info-panel {
    margin-top: 2.8rem;
    background: var(--info-panel-bg);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 1px solid var(--glass-border);
    border-radius: 36px;
    padding: 1.6rem 2rem;
    transition: background 0.3s;
}
.status-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 1.4rem;
}
.status-header i { font-size: 1.3rem; color: #38bdf8; }
.status-header h3 {
    font-family: 'Poppins', sans-serif;
    font-weight: 400;
    font-size: 1.3rem;
}

/* Video Info (Thumbnail + Title) */
.video-info {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 1.5rem;
    padding: 0.8rem;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 16px;
    border: 1px solid var(--glass-border);
}
.thumbnail {
    width: 80px;
    height: 60px;
    object-fit: cover;
    border-radius: 10px;
    flex-shrink: 0;
}
.title-wrapper {
    flex: 1;
}
.video-title {
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-primary);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Progress Bar */
.progress-visual {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}
.progress-bar-container {
    flex: 2;
    min-width: 180px;
    height: 8px;
    background: var(--progress-bg);
    border-radius: 20px;
    overflow: hidden;
}
.progress-fill {
    width: 0%;
    height: 100%;
    background: var(--progress-fill);
    border-radius: 20px;
    transition: width 0.3s ease;
}
.progress-percent {
    font-weight: 500;
    min-width: 50px;
    color: var(--text-primary);
}
.processing-message {
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 1.2rem 0 0.8rem;
}
.message-text { display: flex; align-items: center; gap: 8px; opacity: 0.9; }

/* Download Button */
.download-btn {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    background: var(--download-btn-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--download-btn-border);
    border-radius: 60px;
    padding: 0.9rem 2rem;
    font-size: 1.1rem;
    font-weight: 500;
    font-family: 'Poppins', sans-serif;
    color: var(--text-primary);
    box-shadow: 0 6px 14px rgba(0, 0, 0, 0.1);
    cursor: pointer;
    transition: all 0.25s;
}
.download-btn:hover:not(.disabled) {
    transform: translateY(-2px);
    background: rgba(16, 185, 129, 0.25);
    border-color: rgba(52, 211, 153, 0.6);
}
.download-btn.disabled {
    opacity: 0.4;
    pointer-events: none;
}
.placeholder-note {
    margin-top: 12px;
    color: var(--text-secondary);
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* ===== Mobile Responsive ===== */
@media (max-width: 580px) {
    body {
        padding: 0.6rem;
        align-items: flex-start;
        padding-top: 1.5rem;
    }
    
    .glass-panel {
        padding: 1.5rem 1rem 1.8rem;
        border-radius: 32px;
    }
    
    /* Smaller logo on mobile */
    .logo-wrapper {
        margin-bottom: 1.5rem;
    }
    
    .logo {
        font-size: 2.2rem;
        line-height: 1.2;
    }
    
    .logo i {
        font-size: 0.8em;
    }
    
    /* Fixed input section for mobile - RECTANGLE input + button below */
    .convert-section {
        flex-direction: column;
        padding: 0;
        gap: 12px;
        background: transparent;
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
        border: none;
        border-radius: 0;
        box-shadow: none;
    }
    
    .convert-section:focus-within {
        border: none;
        box-shadow: none;
    }
    
    .url-input {
        width: 100%;
        padding: 1rem 1.2rem;
        font-size: 1rem;
        text-align: left;
        border-radius: 16px;
        background: var(--input-bg);
        backdrop-filter: blur(12px);
        -webkit-backdrop-filter: blur(12px);
        border: 1px solid var(--glass-border);
        color: var(--text-primary);
    }
    
    .url-input::placeholder {
        color: var(--text-secondary);
        opacity: 0.6;
    }
    
    .url-input:focus {
        outline: none;
        border-color: rgba(56, 189, 248, 0.5);
        box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.1);
    }
    
    .convert-btn {
        width: 100%;
        justify-content: center;
        padding: 1rem;
        font-size: 1.1rem;
        border-radius: 40px;
        background: var(--button-bg);
        backdrop-filter: blur(8px);
        -webkit-backdrop-filter: blur(8px);
        border: 1px solid var(--glass-border);
    }
    
    /* Info panel adjustments */
    .info-panel {
        margin-top: 1.8rem;
        padding: 1.2rem 1rem;
        border-radius: 28px;
    }
    
    .status-header {
        margin-bottom: 1rem;
    }
    
    .status-header i {
        font-size: 1.1rem;
    }
    
    .status-header h3 {
        font-size: 1.1rem;
    }
    
    /* Video info on mobile */
    .video-info {
        flex-direction: row;
        align-items: center;
        gap: 12px;
        padding: 0.6rem;
        margin-bottom: 1.2rem;
    }
    
    .thumbnail {
        width: 60px;
        height: 45px;
        border-radius: 8px;
    }
    
    .video-title {
        font-size: 0.85rem;
        -webkit-line-clamp: 2;
    }
    
    /* Progress bar mobile */
    .progress-visual {
        gap: 10px;
    }
    
    .progress-bar-container {
        min-width: 0;
        flex: 1;
    }
    
    .progress-percent {
        min-width: 45px;
        font-size: 0.9rem;
    }
    
    /* Status message */
    .processing-message {
        margin: 0.8rem 0 0.6rem;
    }
    
    .message-text {
        font-size: 0.9rem;
    }
    
    /* Download button mobile */
    .download-btn {
        width: 100%;
        justify-content: center;
        padding: 0.9rem;
        font-size: 1rem;
    }
    
    .placeholder-note {
        font-size: 0.8rem;
    }
    
    /* Top buttons mobile */
    .top-buttons {
        top: 12px;
        right: 12px;
        gap: 8px;
    }
    
    .home-btn,
    .theme-toggle {
        padding: 6px 10px;
        font-size: 1rem;
    }
    
    /* Footer mobile */
    .footer {
        margin-top: 1.5rem;
    }
    
    .footer-text {
        font-size: 0.75rem;
    }
    
    .footer-icon {
        width: 18px;
        height: 18px;
    }
}

/* Extra small devices */
@media (max-width: 380px) {
    .logo {
        font-size: 1.9rem;
    }
    
    .glass-panel {
        padding: 1.2rem 0.8rem 1.5rem;
    }
    
    .url-input {
        padding: 0.9rem 1rem;
        font-size: 0.95rem;
    }
    
    .convert-btn {
        padding: 0.9rem;
        font-size: 1rem;
    }
    
    .thumbnail {
        width: 50px;
        height: 38px;
    }
    
    .video-title {
        font-size: 0.8rem;
    }
}

/* ===== Footer ===== */
.footer {
    margin-top: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.footer:hover {
    opacity: 1;
}

.footer-link {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-decoration: none;
    color: inherit;
    cursor: pointer;
}

.footer-text {
    font-size: 0.85rem;
    font-weight: 300;
    color: var(--text-secondary);
    letter-spacing: 0.3px;
    transition: color 0.2s;
}

.footer-link:hover .footer-text {
    color: var(--text-primary);
}

.footer-icon {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    object-fit: cover;
    border: 1.5px solid var(--glass-border);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s ease, border-color 0.2s;
}

.footer-link:hover .footer-icon {
    transform: scale(1.05);
    border-color: rgba(56, 189, 248, 0.5);
}

/* Mobile footer adjustment */
@media (max-width: 580px) {
    .footer {
        margin-top: 1.5rem;
    }
    
    .footer-text {
        font-size: 0.75rem;
    }
    
    .footer-icon {
        width: 22px;
        height: 22px;
    }
}