/* ═══════════════════════════════════════════════════════════
   YouTube Downloader — Premium Dark Theme
   ═══════════════════════════════════════════════════════════ */

/* ── Design Tokens ────────────────────────────────────────── */
:root {
    --bg-body: #07070d;
    --bg-card: rgba(255, 255, 255, 0.035);
    --bg-card-hover: rgba(255, 255, 255, 0.06);
    --bg-input: rgba(255, 255, 255, 0.05);
    --border: rgba(255, 255, 255, 0.08);
    --border-hover: rgba(255, 255, 255, 0.15);
    --text-1: #ececf1;
    --text-2: #9a9aab;
    --text-3: #5a5a6e;
    --cyan: #00d4ff;
    --cyan-dim: rgba(0, 212, 255, 0.15);
    --magenta: #ff006e;
    --purple: #8338ec;
    --purple-dim: rgba(131, 56, 236, 0.15);
    --success: #00e676;
    --success-dim: rgba(0, 230, 118, 0.12);
    --error: #ff3d57;
    --error-dim: rgba(255, 61, 87, 0.12);
    --warning: #ffb300;
    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --radius-xl: 24px;
    --shadow-glow: 0 0 40px rgba(0, 212, 255, 0.08);
    --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-body);
    color: var(--text-1);
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
    display: flex;
    flex-direction: column;
}

/* ── Background Blobs ─────────────────────────────────────── */
.bg-blobs {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    overflow: hidden;
}

.blob {
    position: absolute;
    border-radius: 50%;
    filter: blur(120px);
    opacity: 0.4;
    animation: blobFloat 20s ease-in-out infinite;
}

.blob-1 {
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, var(--cyan) 0%, transparent 70%);
    top: -150px;
    right: -100px;
    animation-delay: 0s;
}

.blob-2 {
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, var(--purple) 0%, transparent 70%);
    bottom: -100px;
    left: -100px;
    animation-delay: -7s;
}

.blob-3 {
    width: 300px;
    height: 300px;
    background: radial-gradient(circle, var(--magenta) 0%, transparent 70%);
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    animation-delay: -14s;
    opacity: 0.2;
}

@keyframes blobFloat {
    0%, 100% { transform: translate(0, 0) scale(1); }
    25% { transform: translate(30px, -40px) scale(1.05); }
    50% { transform: translate(-20px, 20px) scale(0.95); }
    75% { transform: translate(15px, 30px) scale(1.02); }
}

/* ── Container ────────────────────────────────────────────── */
.container {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 720px;
    margin: auto;
    padding: 40px 20px 60px;
}

/* ── Glass Card ───────────────────────────────────────────── */
.glass-card {
    background: var(--bg-card);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 16px;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.glass-card:hover {
    border-color: var(--border-hover);
}

/* ── Header ───────────────────────────────────────────────── */
.header {
    text-align: center;
    margin-bottom: 32px;
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
}

.logo-icon {
    width: 52px;
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--cyan-dim);
    border-radius: var(--radius-md);
    border: 1px solid rgba(0, 212, 255, 0.2);
}

.header h1 {
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.2;
}

.gradient-text {
    background: linear-gradient(135deg, var(--cyan), var(--purple));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.subtitle {
    color: var(--text-2);
    font-size: 0.875rem;
    margin-top: 2px;
}

/* ── Search Section ───────────────────────────────────────── */
.search-section {
    box-shadow: var(--shadow-glow);
}

.input-wrapper {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 6px 6px 6px 16px;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.input-wrapper:focus-within {
    border-color: var(--cyan);
    box-shadow: 0 0 0 3px var(--cyan-dim);
}

.input-icon {
    color: var(--text-3);
    flex-shrink: 0;
    display: flex;
}

#url-input {
    flex: 1;
    background: none;
    border: none;
    outline: none;
    color: var(--text-1);
    font-size: 0.95rem;
    font-family: inherit;
    padding: 10px 0;
}

#url-input::placeholder {
    color: var(--text-3);
}

/* ── Buttons ──────────────────────────────────────────────── */
.btn-primary {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 28px;
    background: linear-gradient(135deg, var(--cyan), var(--purple));
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: opacity var(--transition), transform var(--transition);
    white-space: nowrap;
    position: relative;
    overflow: hidden;
}

.btn-primary:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

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

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.btn-ghost {
    background: transparent;
    color: var(--text-2);
    border: 1px solid var(--border);
    padding: 10px 24px;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
}

.btn-ghost:hover {
    color: var(--text-1);
    border-color: var(--border-hover);
    background: rgba(255, 255, 255, 0.03);
}

.btn-download {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 14px 32px;
    background: linear-gradient(135deg, var(--success), #00c853);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: all var(--transition);
}

.btn-download:hover {
    opacity: 0.9;
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0, 230, 118, 0.25);
}

/* ── Spinner ──────────────────────────────────────────────── */
.spinner {
    display: inline-block;
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

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

/* ── Error Section ────────────────────────────────────────── */
.error-section {
    border-color: rgba(255, 61, 87, 0.3);
    background: var(--error-dim);
}

.error-content {
    text-align: center;
}

.error-icon {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 61, 87, 0.15);
    color: var(--error);
    font-size: 1.25rem;
    font-weight: 700;
    border-radius: 50%;
    margin: 0 auto 16px;
}

.error-content p {
    color: var(--text-2);
    font-size: 0.9rem;
    margin-bottom: 20px;
    line-height: 1.5;
    word-break: break-word;
}

/* ── Video Info Section ───────────────────────────────────── */
.video-info {
    display: flex;
    gap: 20px;
    align-items: flex-start;
}

.thumbnail-wrapper {
    position: relative;
    flex-shrink: 0;
    width: 200px;
    border-radius: var(--radius-md);
    overflow: hidden;
}

.thumbnail-wrapper img {
    width: 100%;
    aspect-ratio: 16 / 9;
    object-fit: cover;
    display: block;
}

.duration-badge {
    position: absolute;
    bottom: 6px;
    right: 6px;
    background: rgba(0, 0, 0, 0.8);
    color: #fff;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 4px;
}

.video-details {
    flex: 1;
    min-width: 0;
}

.video-details h2 {
    font-size: 1.1rem;
    font-weight: 600;
    line-height: 1.4;
    margin-bottom: 8px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.video-channel {
    color: var(--text-2);
    font-size: 0.85rem;
}

/* ── Tabs ─────────────────────────────────────────────────── */
.tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 16px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: var(--radius-sm);
    padding: 4px;
}

.tab {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 16px;
    background: transparent;
    color: var(--text-2);
    border: none;
    border-radius: 6px;
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
}

.tab:hover {
    color: var(--text-1);
    background: rgba(255, 255, 255, 0.04);
}

.tab.active {
    color: #fff;
    background: linear-gradient(135deg, var(--cyan), var(--purple));
    box-shadow: 0 2px 12px rgba(0, 212, 255, 0.2);
}

/* ── Format List ──────────────────────────────────────────── */
.format-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 360px;
    overflow-y: auto;
    padding-right: 4px;
}

.format-list::-webkit-scrollbar {
    width: 4px;
}

.format-list::-webkit-scrollbar-track {
    background: transparent;
}

.format-list::-webkit-scrollbar-thumb {
    background: var(--text-3);
    border-radius: 4px;
}

.format-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition);
}

.format-item:hover {
    background: var(--bg-card-hover);
    border-color: var(--border);
}

.format-item.mp4-item {
    border-left: 3px solid var(--cyan);
}

.format-item.other-item {
    border-left: 3px solid var(--text-3);
}

.format-item.audio-item {
    border-left: 3px solid var(--purple);
}

.format-separator {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 0;
    color: var(--text-3);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.format-separator::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
}

.format-res {
    font-weight: 600;
    font-size: 0.9rem;
    min-width: 70px;
    color: var(--text-1);
}

.format-ext {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    padding: 2px 8px;
    border-radius: 4px;
    background: var(--cyan-dim);
    color: var(--cyan);
}

.format-ext.other {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-2);
}

.format-ext.audio {
    background: var(--purple-dim);
    color: var(--purple);
}

.format-meta {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.8rem;
    color: var(--text-2);
}

.format-codec,
.format-fps {
    font-size: 0.75rem;
    color: var(--text-3);
}

.format-size {
    font-size: 0.8rem;
    color: var(--text-2);
    text-align: right;
    min-width: 60px;
}

.format-audio-badge {
    font-size: 0.7rem;
    padding: 2px 8px;
    border-radius: 4px;
    white-space: nowrap;
}

.format-audio-badge.has-audio {
    background: var(--success-dim);
    color: var(--success);
}

.format-audio-badge.no-audio {
    background: rgba(255, 179, 0, 0.1);
    color: var(--warning);
}

.format-download-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--cyan), var(--purple));
    border: none;
    cursor: pointer;
    flex-shrink: 0;
    transition: all var(--transition);
    opacity: 0;
}

.format-item:hover .format-download-btn {
    opacity: 1;
}

.format-download-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 16px rgba(0, 212, 255, 0.3);
}

.format-download-btn svg {
    color: #fff;
}

/* ── Codec Disclaimer ─────────────────────────────────────── */
.codec-disclaimer {
    margin-top: 16px;
    padding: 14px 16px;
    background: rgba(255, 255, 255, 0.02);
    border-radius: var(--radius-sm);
    border-left: 3px solid var(--purple);
    font-size: 0.8rem;
    color: var(--text-2);
    line-height: 1.5;
}

.codec-disclaimer p {
    margin-bottom: 8px;
}

.codec-disclaimer p:last-child {
    margin-bottom: 0;
}

.codec-disclaimer strong {
    color: var(--text-1);
    font-weight: 600;
}

/* ── Progress Section ─────────────────────────────────────── */
.progress-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.progress-label {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-2);
}

.progress-percent {
    font-size: 1.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--cyan), var(--purple));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.progress-track {
    width: 100%;
    height: 8px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 100px;
    overflow: hidden;
    margin-bottom: 12px;
}

.progress-bar {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--cyan), var(--purple), var(--magenta));
    background-size: 200% 100%;
    border-radius: 100px;
    transition: width 0.4s ease;
    animation: progressShimmer 2s linear infinite;
    position: relative;
}

.progress-bar::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    animation: progressShine 1.5s ease infinite;
}

@keyframes progressShimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

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

.progress-details {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    color: var(--text-3);
}

.progress-filename {
    margin-top: 12px;
    font-size: 0.8rem;
    color: var(--text-3);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ── Complete Section ─────────────────────────────────────── */
.complete-section {
    border-color: rgba(0, 230, 118, 0.2);
}

.complete-content {
    text-align: center;
    padding: 16px 0;
}

.checkmark-circle {
    width: 72px;
    height: 72px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--success-dim);
    border-radius: 50%;
    margin: 0 auto 20px;
    animation: scaleIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes scaleIn {
    from { transform: scale(0); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.complete-content h3 {
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 8px;
}

.complete-filename {
    color: var(--text-2);
    font-size: 0.85rem;
    margin-bottom: 24px;
    word-break: break-all;
}

.complete-content .btn-download {
    margin-bottom: 12px;
}

.complete-content .btn-ghost {
    margin-top: 8px;
}

/* ── Footer ───────────────────────────────────────────────── */
.footer {
    text-align: center;
    margin-top: 40px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
    color: var(--text-3);
    font-size: 0.8rem;
}

.footer strong {
    color: var(--text-2);
}

.footer a {
    color: inherit;
    text-decoration: none;
    transition: color var(--transition);
}

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

/* ── Utility ──────────────────────────────────────────────── */
.hidden {
    display: none !important;
}

/* Section entrance animation */
.glass-card {
    animation: fadeUp 0.4s ease;
}

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

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 640px) {
    .container {
        padding: 24px 16px 40px;
    }

    .header h1 {
        font-size: 1.35rem;
    }

    .glass-card {
        padding: 18px;
        border-radius: var(--radius-md);
    }

    .video-info {
        flex-direction: column;
    }

    .thumbnail-wrapper {
        width: 100%;
    }

    .input-wrapper {
        flex-direction: column;
        padding: 12px;
        gap: 10px;
    }

    .input-icon {
        display: none;
    }

    #url-input {
        width: 100%;
        text-align: center;
    }

    .btn-primary {
        width: 100%;
    }

    .format-item {
        flex-wrap: wrap;
        gap: 8px;
    }

    .format-meta {
        flex-wrap: wrap;
        gap: 6px;
    }

    .format-download-btn {
        opacity: 1;
    }

    .blob-1 { width: 300px; height: 300px; }
    .blob-2 { width: 250px; height: 250px; }
    .blob-3 { width: 200px; height: 200px; }
}
