/* ═══════════════════════════════════════════════════════════════
   YT-Downloader — Premium Dark Glassmorphism Theme
   ═══════════════════════════════════════════════════════════════ */

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

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

:root {
    --bg-primary: #06060b;
    --bg-secondary: #0d0d16;
    --bg-card: rgba(15, 15, 25, 0.65);
    --bg-card-hover: rgba(20, 20, 35, 0.75);
    --bg-input: rgba(18, 18, 30, 0.8);
    --border-color: rgba(255, 255, 255, 0.06);
    --border-glow: rgba(139, 92, 246, 0.3);
    --text-primary: #f0f0f5;
    --text-secondary: #8888a0;
    --text-muted: #55556a;
    --accent-purple: #8b5cf6;
    --accent-purple-light: #a78bfa;
    --accent-cyan: #06d6a0;
    --accent-pink: #ec4899;
    --accent-red: #ef4444;
    --gradient-primary: linear-gradient(135deg, #8b5cf6, #06d6a0);
    --gradient-glow: linear-gradient(135deg, rgba(139, 92, 246, 0.15), rgba(6, 214, 160, 0.15));
    --gradient-bg: radial-gradient(ellipse at 20% 50%, rgba(139, 92, 246, 0.08) 0%, transparent 50%),
                   radial-gradient(ellipse at 80% 20%, rgba(6, 214, 160, 0.06) 0%, transparent 50%),
                   radial-gradient(ellipse at 50% 80%, rgba(236, 72, 153, 0.04) 0%, transparent 50%);
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 8px 32px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 16px 64px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 40px rgba(139, 92, 246, 0.15);
    --radius-sm: 10px;
    --radius-md: 16px;
    --radius-lg: 24px;
    --radius-xl: 32px;
    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-base: 250ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 400ms cubic-bezier(0.4, 0, 0.2, 1);
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.6;
}

/* ── Animated Background ──────────────────────────────────────── */
.bg-effects {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    background: var(--gradient-bg);
}

.bg-effects::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background:
        radial-gradient(circle at 30% 40%, rgba(139, 92, 246, 0.05) 0%, transparent 40%),
        radial-gradient(circle at 70% 60%, rgba(6, 214, 160, 0.04) 0%, transparent 40%);
    animation: bgDrift 25s ease-in-out infinite alternate;
}

@keyframes bgDrift {
    0% { transform: translate(0, 0) rotate(0deg); }
    33% { transform: translate(2%, -1%) rotate(1deg); }
    66% { transform: translate(-1%, 2%) rotate(-1deg); }
    100% { transform: translate(1%, -2%) rotate(0.5deg); }
}

/* ── Noise Overlay ────────────────────────────────────────────── */
.bg-effects::after {
    content: '';
    position: absolute;
    inset: 0;
    opacity: 0.015;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
    background-repeat: repeat;
    background-size: 256px;
}

/* ── Main Layout ──────────────────────────────────────────────── */
.app-container {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100vh;
    padding: 2rem 1.5rem;
}

/* ── Header / Brand ───────────────────────────────────────────── */
.header {
    text-align: center;
    margin-bottom: 2.5rem;
    padding-top: 2rem;
}

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

.logo-icon {
    width: 52px;
    height: 52px;
    border-radius: var(--radius-md);
    background: var(--gradient-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6rem;
    box-shadow: var(--shadow-glow);
    animation: logoPulse 3s ease-in-out infinite;
}

@keyframes logoPulse {
    0%, 100% { box-shadow: 0 0 20px rgba(139, 92, 246, 0.2); }
    50% { box-shadow: 0 0 40px rgba(139, 92, 246, 0.35); }
}

.logo-text {
    font-size: 2rem;
    font-weight: 800;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.03em;
}

.header-subtitle {
    color: var(--text-secondary);
    font-size: 1rem;
    font-weight: 400;
    letter-spacing: 0.02em;
}

/* ── Glass Card ───────────────────────────────────────────────── */
.glass-card {
    background: var(--bg-card);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 2rem;
    box-shadow: var(--shadow-md);
    transition: border-color var(--transition-base), box-shadow var(--transition-base);
    width: 100%;
    max-width: 640px;
}

.glass-card:hover {
    border-color: rgba(255, 255, 255, 0.09);
}

/* ── URL Input Section ────────────────────────────────────────── */
.input-section {
    margin-bottom: 1.5rem;
}

.input-label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 0.75rem;
}

.input-wrapper {
    position: relative;
    display: flex;
    gap: 0.5rem;
}

.url-input {
    flex: 1;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0.95rem 1.25rem;
    font-family: inherit;
    font-size: 0.95rem;
    color: var(--text-primary);
    outline: none;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

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

.url-input:focus {
    border-color: var(--accent-purple);
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.15);
}

.btn-paste {
    flex-shrink: 0;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0 1rem;
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-family: inherit;
}

.btn-paste:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary);
    border-color: var(--accent-purple);
}

/* ── Fetch Button ─────────────────────────────────────────────── */
.btn-fetch {
    width: 100%;
    padding: 1rem;
    border: none;
    border-radius: var(--radius-md);
    background: var(--gradient-primary);
    color: #fff;
    font-family: inherit;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-base);
    position: relative;
    overflow: hidden;
    letter-spacing: 0.02em;
}

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

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

.btn-fetch:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 30px rgba(139, 92, 246, 0.3);
}

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

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

/* ── Loading Spinner ──────────────────────────────────────────── */
.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2.5px solid rgba(255,255,255,0.25);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    vertical-align: middle;
    margin-right: 0.5rem;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ── Video Preview Card ───────────────────────────────────────── */
.preview-section {
    margin-top: 1.5rem;
    display: none;
    animation: fadeSlideIn 0.4s var(--transition-slow) both;
}

.preview-section.visible {
    display: block;
}

@keyframes fadeSlideIn {
    from {
        opacity: 0;
        transform: translateY(16px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.preview-card {
    background: rgba(12, 12, 20, 0.7);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.preview-thumb-wrap {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    background: var(--bg-secondary);
}

.preview-thumb {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform var(--transition-slow);
}

.preview-card:hover .preview-thumb {
    transform: scale(1.03);
}

.preview-duration {
    position: absolute;
    bottom: 10px;
    right: 10px;
    background: rgba(0,0,0,0.8);
    color: #fff;
    font-size: 0.78rem;
    font-weight: 600;
    padding: 0.2rem 0.55rem;
    border-radius: 6px;
    letter-spacing: 0.03em;
    backdrop-filter: blur(8px);
}

.preview-info {
    padding: 1.25rem;
}

.preview-title {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.preview-meta {
    display: flex;
    align-items: center;
    gap: 1rem;
    font-size: 0.82rem;
    color: var(--text-secondary);
}

.preview-meta span {
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

/* ── Format / Quality Selector ────────────────────────────────── */
.options-section {
    margin-top: 1.5rem;
    display: none;
    animation: fadeSlideIn 0.4s ease both;
}

.options-section.visible {
    display: block;
}

.options-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
}

.option-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.option-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.select-wrap {
    position: relative;
}

.select-wrap select {
    width: 100%;
    appearance: none;
    -webkit-appearance: none;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 0.75rem 2.5rem 0.75rem 1rem;
    font-family: inherit;
    font-size: 0.9rem;
    color: var(--text-primary);
    cursor: pointer;
    outline: none;
    transition: border-color var(--transition-fast);
}

.select-wrap select:focus {
    border-color: var(--accent-purple);
}

.select-wrap::after {
    content: '▾';
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
    font-size: 0.85rem;
}

select option {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

/* ── Download Button ──────────────────────────────────────────── */
.btn-download {
    width: 100%;
    padding: 1rem;
    border: none;
    border-radius: var(--radius-md);
    background: linear-gradient(135deg, #06d6a0, #059669);
    color: #fff;
    font-family: inherit;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all var(--transition-base);
    position: relative;
    overflow: hidden;
    letter-spacing: 0.02em;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn-download:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 30px rgba(6, 214, 160, 0.3);
}

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

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

/* ── Progress Bar ─────────────────────────────────────────────── */
.progress-section {
    margin-top: 1rem;
    display: none;
}

.progress-section.visible {
    display: block;
    animation: fadeSlideIn 0.3s ease both;
}

.progress-bar-wrap {
    width: 100%;
    height: 6px;
    background: rgba(255,255,255,0.06);
    border-radius: 3px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: var(--gradient-primary);
    border-radius: 3px;
    width: 0%;
    transition: width 0.3s ease;
}

.progress-bar.indeterminate {
    width: 40%;
    animation: progressIndeterminate 1.5s ease-in-out infinite;
}

@keyframes progressIndeterminate {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(350%); }
}

.progress-text {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 0.5rem;
    text-align: center;
}

/* ── Status Messages ──────────────────────────────────────────── */
.status-msg {
    margin-top: 1rem;
    padding: 0.85rem 1.1rem;
    border-radius: var(--radius-sm);
    font-size: 0.88rem;
    display: none;
    animation: fadeSlideIn 0.3s ease both;
}

.status-msg.visible {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
}

.status-msg.error {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.2);
    color: #fca5a5;
}

.status-msg.success {
    background: rgba(6, 214, 160, 0.1);
    border: 1px solid rgba(6, 214, 160, 0.2);
    color: #6ee7b7;
}

.status-msg.info {
    background: rgba(139, 92, 246, 0.1);
    border: 1px solid rgba(139, 92, 246, 0.2);
    color: var(--accent-purple-light);
}

/* ── Settings Panel ───────────────────────────────────────────── */
.settings-toggle {
    margin-top: 1.5rem;
    text-align: center;
}

.btn-settings {
    background: none;
    border: none;
    color: var(--text-muted);
    font-family: inherit;
    font-size: 0.82rem;
    cursor: pointer;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-sm);
    transition: color var(--transition-fast);
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

.btn-settings:hover {
    color: var(--text-secondary);
}

.settings-panel {
    margin-top: 1rem;
    display: none;
    animation: fadeSlideIn 0.3s ease both;
}

.settings-panel.visible {
    display: block;
}

.settings-panel .option-group {
    margin-bottom: 1rem;
}

.settings-panel .url-input {
    font-size: 0.85rem;
}

.settings-note {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.35rem;
    line-height: 1.5;
}

/* ── Footer ───────────────────────────────────────────────────── */
.footer {
    margin-top: auto;
    padding-top: 3rem;
    padding-bottom: 1.5rem;
    text-align: center;
}

.footer-privacy {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1.2rem;
    background: rgba(6, 214, 160, 0.06);
    border: 1px solid rgba(6, 214, 160, 0.12);
    border-radius: 100px;
    font-size: 0.78rem;
    color: var(--accent-cyan);
    font-weight: 500;
    margin-bottom: 1rem;
}

.footer-text {
    font-size: 0.75rem;
    color: var(--text-muted);
    line-height: 1.7;
}

.footer-text a {
    color: var(--accent-purple-light);
    text-decoration: none;
    transition: color var(--transition-fast);
}

.footer-text a:hover {
    color: var(--accent-purple);
}

/* ── Responsive ───────────────────────────────────────────────── */
@media (max-width: 640px) {
    .app-container {
        padding: 1.5rem 1rem;
    }

    .glass-card {
        padding: 1.5rem;
        border-radius: var(--radius-md);
    }

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

    .logo-icon {
        width: 44px;
        height: 44px;
        font-size: 1.4rem;
    }

    .options-grid {
        grid-template-columns: 1fr;
    }

    .preview-meta {
        flex-wrap: wrap;
        gap: 0.5rem;
    }
}

/* ── Utility Animations ───────────────────────────────────────── */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-6px); }
    40% { transform: translateX(6px); }
    60% { transform: translateX(-4px); }
    80% { transform: translateX(4px); }
}

.shake {
    animation: shake 0.4s ease;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.08);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255,255,255,0.12);
}
