/* YTDownloader - Modern Dark Theme */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

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

:root {
    --bg: #0a0a0f;
    --bg2: #111118;
    --bg3: #1a1a24;
    --card: #16161f;
    --border: #2a2a3a;
    --accent: #ff0000;
    --accent2: #cc0000;
    --gold: #f4a261;
    --success: #22c55e;
    --warning: #f59e0b;
    --danger: #ef4444;
    --text: #e2e2f0;
    --text-muted: #7878a0;
    --radius: 12px;
    --shadow: 0 8px 32px rgba(0, 0, 0, .4);
}

body {
    font-family: 'Inter', sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.6;
}

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

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

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

/* ── Navbar ── */
.navbar {
    background: rgba(10, 10, 15, .95);
    border-bottom: 1px solid var(--border);
    padding: 0 24px;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(12px);
}

.navbar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.3rem;
    font-weight: 800;
    text-decoration: none;
    color: #fff;
}

.navbar-brand .yt-icon {
    color: var(--accent);
    font-size: 1.5rem;
}

.navbar-brand span {
    color: var(--accent);
}

.nav-badge {
    background: var(--accent);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 20px;
    letter-spacing: .5px;
}

/* ── Hero ── */
.hero {
    text-align: center;
    padding: 80px 24px 60px;
    background: radial-gradient(ellipse at 50% 0%, rgba(255, 0, 0, .15) 0%, transparent 70%);
}

.hero h1 {
    font-size: clamp(2rem, 5vw, 3.5rem);
    font-weight: 800;
    background: linear-gradient(135deg, #fff 40%, var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 16px;
    line-height: 1.1;
}

.hero p {
    color: var(--text-muted);
    font-size: 1.1rem;
    max-width: 560px;
    margin: 0 auto 40px;
}

/* ── Search Bar ── */
.search-wrapper {
    max-width: 720px;
    margin: 0 auto;
    position: relative;
}

.search-bar {
    display: flex;
    gap: 0;
    background: var(--card);
    border: 2px solid var(--border);
    border-radius: 16px;
    overflow: hidden;
    transition: border-color .25s;
}

.search-bar:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 4px rgba(255, 0, 0, .1);
}

.search-icon {
    padding: 0 16px;
    color: var(--text-muted);
    font-size: 20px;
    display: flex;
    align-items: center;
}

.search-input {
    flex: 1;
    background: none;
    border: none;
    outline: none;
    color: var(--text);
    font-size: 16px;
    font-family: inherit;
    padding: 18px 8px;
}

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

.search-btn {
    background: var(--accent);
    border: none;
    color: #fff;
    font-weight: 700;
    font-size: 15px;
    padding: 0 28px;
    cursor: pointer;
    transition: background .2s;
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: inherit;
}

.search-btn:hover {
    background: var(--accent2);
}

.search-btn:disabled {
    background: var(--border);
    cursor: not-allowed;
}

.search-hint {
    margin-top: 12px;
    font-size: 12px;
    color: var(--text-muted);
}

.search-hint code {
    background: var(--bg3);
    padding: 2px 6px;
    border-radius: 4px;
    color: var(--text);
}

/* ── Quality Selector ── */
.quality-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 16px;
    justify-content: center;
    flex-wrap: wrap;
}

.quality-label {
    font-size: 13px;
    color: var(--text-muted);
}

.quality-btn {
    background: var(--bg3);
    border: 1px solid var(--border);
    color: var(--text-muted);
    padding: 6px 14px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: .2s;
    font-family: inherit;
}

.quality-btn.active,
.quality-btn:hover {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

/* ── Container ── */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px;
}

/* ── Alert ── */
.alert {
    border-radius: var(--radius);
    padding: 16px 20px;
    font-size: 14px;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 24px;
}

.alert-error {
    background: rgba(239, 68, 68, .12);
    border: 1px solid rgba(239, 68, 68, .3);
    color: #fca5a5;
}

.alert-success {
    background: rgba(34, 197, 94, .1);
    border: 1px solid rgba(34, 197, 94, .3);
    color: #86efac;
}

.alert-warning {
    background: rgba(245, 158, 11, .1);
    border: 1px solid rgba(245, 158, 11, .3);
    color: #fcd34d;
}

.alert-info {
    background: rgba(99, 102, 241, .1);
    border: 1px solid rgba(99, 102, 241, .3);
    color: #a5b4fc;
}

/* ── Channel Info ── */
.channel-info {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 24px;
}

.channel-meta {
    display: flex;
    align-items: center;
    gap: 16px;
}

.channel-meta h2 {
    font-size: 1.2rem;
    font-weight: 700;
}

.channel-meta .video-count {
    color: var(--text-muted);
    font-size: 14px;
}

.channel-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

/* ── Action Buttons ── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    border-radius: 10px;
    font-weight: 600;
    font-size: 14px;
    border: none;
    cursor: pointer;
    transition: .2s;
    text-decoration: none;
    font-family: inherit;
}

.btn-primary {
    background: var(--accent);
    color: #fff;
}

.btn-primary:hover {
    background: var(--accent2);
}

.btn-success {
    background: var(--success);
    color: #fff;
}

.btn-success:hover {
    filter: brightness(1.1);
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
}

.btn-outline:hover {
    border-color: var(--text-muted);
}

.btn-ghost {
    background: var(--bg3);
    color: var(--text);
}

.btn-ghost:hover {
    background: var(--border);
}

.btn-danger {
    background: var(--danger);
    color: #fff;
}

.btn-danger:hover {
    filter: brightness(1.1);
}

.btn-lg {
    padding: 14px 28px;
    font-size: 16px;
    border-radius: 12px;
}

.btn-sm {
    padding: 6px 14px;
    font-size: 12px;
    border-radius: 8px;
}

.btn:disabled {
    opacity: .5;
    cursor: not-allowed;
}

/* ── Select All Bar ── */
.select-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 20px;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 12px;
}

.select-bar-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.select-info {
    font-size: 14px;
    color: var(--text-muted);
}

.select-info strong {
    color: var(--text);
}

/* ── Video Grid ── */
.video-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 16px;
    margin-bottom: 40px;
}

.video-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    cursor: pointer;
    transition: transform .2s, border-color .2s, box-shadow .2s;
    position: relative;
}

.video-card:hover {
    transform: translateY(-2px);
    border-color: var(--text-muted);
    box-shadow: var(--shadow);
}

.video-card.selected {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(255, 0, 0, .3);
}

.video-check {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 2;
    width: 22px;
    height: 22px;
    border-radius: 6px;
    background: rgba(0, 0, 0, .7);
    border: 2px solid rgba(255, 255, 255, .4);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    color: #fff;
    transition: .2s;
}

.video-card.selected .video-check {
    background: var(--accent);
    border-color: var(--accent);
}

.video-thumb {
    position: relative;
    aspect-ratio: 16/9;
    overflow: hidden;
    background: var(--bg3);
}

.video-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform .3s;
}

.video-card:hover .video-thumb img {
    transform: scale(1.04);
}

.video-duration {
    position: absolute;
    bottom: 8px;
    right: 8px;
    background: rgba(0, 0, 0, .85);
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 4px;
}

.video-body {
    padding: 14px;
}

.video-title {
    font-size: 13px;
    font-weight: 600;
    line-height: 1.4;
    color: var(--text);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 8px;
}

.video-meta {
    display: flex;
    gap: 10px;
    font-size: 11px;
    color: var(--text-muted);
}

/* ── Download Queue ── */
.queue-section {
    margin-top: 40px;
    margin-bottom: 60px;
}

.queue-section h2 {
    font-size: 1.3rem;
    font-weight: 700;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.queue-item {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 20px;
    margin-bottom: 12px;
    transition: .2s;
}

.queue-item-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

.queue-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.queue-status {
    font-size: 12px;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 6px;
}

.queue-status.downloading {
    background: rgba(99, 102, 241, .2);
    color: #a5b4fc;
}

.queue-status.done {
    background: rgba(34, 197, 94, .15);
    color: #86efac;
}

.queue-status.error {
    background: rgba(239, 68, 68, .15);
    color: #fca5a5;
}

.queue-status.pending {
    background: rgba(245, 158, 11, .12);
    color: #fcd34d;
}

/* ── Progress Bar ── */
.progress-wrap {
    background: var(--bg3);
    border-radius: 6px;
    height: 6px;
    overflow: hidden;
    margin-bottom: 8px;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), #ff6b6b);
    border-radius: 6px;
    transition: width .4s;
}

.progress-info {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: var(--text-muted);
}

/* ── File List ── */
.file-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}

.file-item {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg3);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 14px;
    font-size: 13px;
    text-decoration: none;
    color: var(--text);
    transition: .2s;
}

.file-item:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.file-size {
    font-size: 11px;
    color: var(--text-muted);
}

/* ── Setup Warning ── */
.setup-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 48px;
    text-align: center;
    max-width: 600px;
    margin: 60px auto;
}

.setup-icon {
    font-size: 4rem;
    margin-bottom: 20px;
}

.setup-card h2 {
    font-size: 1.5rem;
    margin-bottom: 12px;
}

.setup-card p {
    color: var(--text-muted);
    margin-bottom: 24px;
    font-size: 14px;
    line-height: 1.7;
}

.code-block {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 16px;
    margin: 12px 0;
    font-family: monospace;
    font-size: 13px;
    text-align: left;
    color: var(--success);
    word-break: break-all;
}

/* ── Stats Bar ── */
.stats-bar {
    display: flex;
    gap: 24px;
    flex-wrap: wrap;
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 24px;
    margin-bottom: 24px;
}

.stat-item {
    text-align: center;
}

.stat-num {
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--accent);
}

.stat-label {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 600;
}

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

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

.loading-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(10, 10, 15, .85);
    z-index: 200;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 16px;
    backdrop-filter: blur(4px);
}

.loading-overlay.active {
    display: flex;
}

.loading-text {
    color: var(--text-muted);
    font-size: 14px;
}

/* ── Toast ── */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 300;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 14px 18px;
    font-size: 13px;
    box-shadow: var(--shadow);
    min-width: 240px;
    max-width: 360px;
    animation: toastIn .3s ease;
    display: flex;
    align-items: center;
    gap: 10px;
}

.toast.success {
    border-left: 3px solid var(--success);
}

.toast.error {
    border-left: 3px solid var(--danger);
}

.toast.info {
    border-left: 3px solid #6366f1;
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateX(20px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* ── Footer ── */
footer {
    border-top: 1px solid var(--border);
    padding: 24px;
    text-align: center;
    font-size: 13px;
    color: var(--text-muted);
}

/* ── Responsive ── */
@media (max-width: 640px) {
    .search-bar {
        flex-direction: column;
    }

    .search-btn {
        padding: 14px;
        width: 100%;
        justify-content: center;
    }

    .hero {
        padding: 48px 16px 32px;
    }

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

    .video-grid {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
        gap: 10px;
    }
}