/* =====================================================
   1️⃣ THEME VARIABLES
   ===================================================== */

:root {
    /* Backgrounds */
    --bg: #0f0f0f;
    --card: #181818;
    --hover: #222;

    /* Text */
    --text: #ffffff;
    --muted: #aaaaaa;

    /* Accent */
    --accent: #ff0000; /* YouTube Red */

    /* Buttons */
    --btn-bg: #222;
    --btn-hover: #333;

    /* Borders */
    --border: #2a2a2a;

    /* Radius */
    --radius: 12px;
}

/* LIGHT MODE */
[data-theme="light"] {
    --bg: #ffffff;
    --card: #f8f9fa;
    --hover: #f1f1f1;

    --text: #000000;
    --muted: #555555;

    --accent: #cc0000;

    --btn-bg: #eeeeee;
    --btn-hover: #dddddd;

    --border: #dddddd;
}


/* =====================================================
   2️⃣ BASE / GLOBAL
   ===================================================== */

body {
    background: var(--bg);
    color: var(--text);
    font-family: Inter, Roboto, Arial, sans-serif;
}


.text-muted {
    color: var(--muted) !important;
    font-size: 0.85rem;
    line-height: 1.3;
}

.card {
    background: var(--card);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

a {
    color: inherit;
    text-decoration: none;
}


/* =====================================================
   3️⃣ NAVBAR & SEARCH
   ===================================================== */

.navbar {
    background: var(--bg);
    border-bottom: 1px solid var(--border);
}

.search-input {
    background: var(--card);
    border: none;
    color: var(--text);
}

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

.search-input:focus {
    background: var(--card);
    color: var(--text);
    box-shadow: none;
}


/* =====================================================
   4️⃣ CHANNEL HEADER
   ===================================================== */

.channel-header img {
    border: 2px solid var(--border);
}

.channel-header h4 {
    font-weight: 600;
}

.desc-clamp {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

@media (min-width: 768px) {
    .desc-clamp {
        -webkit-line-clamp: unset;
    }
}


/* =====================================================
   5️⃣ TABS (BOOTSTRAP OVERRIDE – IMPORTANT)
   ===================================================== */

.nav-tabs {
    border-bottom: 1px solid var(--border);
}

.nav-tabs .nav-link {
    background: transparent !important;
    color: var(--muted) !important;
    border: none !important;
    padding: 12px 16px;
    font-weight: 500;
}

.nav-tabs .nav-link:hover {
    color: var(--text) !important;
}

/* ACTIVE TAB */
.nav-tabs .nav-link.active,
.nav-tabs .nav-item.show .nav-link {
    color: var(--text) !important;
    background: transparent !important;
    border-bottom: 3px solid var(--accent) !important;
}


/* =====================================================
   6️⃣ FILTERS & SORT
   ===================================================== */
.btn-group {
    display: flex;
    gap: 8px;
}

.filter-btn {
    background: var(--card);            /* ⬅ key fix */
    color: var(--text);
    border: 1px solid var(--border);
    padding: 6px 14px;
    border-radius: 999px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all .2s ease;
}

.filter-btn {
    box-shadow: inset 0 0 0 1px rgba(255,255,255,0.04);
}


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

.filter-btn.active {
    background: var(--accent); /* YouTube red */
    color: #fff;
    border-color: var(--accent);
}



/* ================= SORT SELECT (ARROW FIX) ================= */

.form-select {
    background-color: var(--btn-bg);
    color: var(--text);
    border: 1px solid var(--border);

    /* remove default */
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;

    /* custom arrow */
    background-image:
        linear-gradient(45deg, transparent 50%, var(--muted) 50%),
        linear-gradient(135deg, var(--muted) 50%, transparent 50%);
    background-position:
        calc(100% - 18px) 50%,
        calc(100% - 12px) 50%;
    background-size: 6px 6px, 6px 6px;
    background-repeat: no-repeat;

    padding-right: 32px;
}

.form-select:focus {
    border-color: var(--accent);
    box-shadow: none;
}

/* =====================================================
   7️⃣ VIDEO GRID & CARDS
   ===================================================== */

.video-item a {
    color: var(--text);
}

.video-card img,
.video-item img {
    border-radius: var(--radius);
    transition: transform 0.25s ease, filter 0.25s ease;
}

.video-item:hover img {
    transform: scale(1.04);
    filter: brightness(1.1);
}

.video-title {
    font-size: 0.9rem;
    font-weight: 600;
    line-height: 1.3;
    max-height: 38px;
    overflow: hidden;
}

.video-item .small,
.channel {
    font-size: 12px;
    color: var(--muted);
}
.channel-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* =====================================================
   8️⃣ SHORTS (9:16)
   ===================================================== */

.ratio-9x16 {
    position: relative;
    width: 100%;
    padding-top: 177.78%;
}

.ratio-9x16 img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}


/* =====================================================
   9️⃣ DURATION BADGE
   ===================================================== */

.duration {
    position: absolute;
    bottom: 8px;
    right: 8px;
    background: var(--bg);
    color: var(--text);
    font-size: 12px;
    padding: 2px 6px;
    border-radius: 4px;
}


/* =====================================================
   🔟 SKELETON LOADER
   ===================================================== */

@keyframes shimmer {
    0% { background-position: -1000px 0; }
    100% { background-position: 1000px 0; }
}

.skeleton {
    background: linear-gradient(
        90deg,
        #e0e0e0 25%,
        #f5f5f5 37%,
        #e0e0e0 63%
    );
    background-size: 1000px 100%;
    animation: shimmer 1.4s infinite;
    border-radius: 6px;
}

.skeleton-thumb {
    width: 100%;
    aspect-ratio: 16 / 9;
}

.skeleton-text {
    height: 12px;
    margin-top: 8px;
}

.skeleton-text.short { width: 60%; }
.skeleton-text.long  { width: 90%; }


/* =====================================================
   1️⃣1️⃣ SPINNER & MESSAGES
   ===================================================== */

#loadingSpinner {
    color: var(--muted);
}

#noMoreVideos {
    font-size: 0.9rem;
    color: var(--muted);
}


/* =====================================================
   1️⃣2️⃣ SCROLLBAR
   ===================================================== */

::-webkit-scrollbar {
    width: 8px;
}

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

::-webkit-scrollbar-thumb:hover {
    background: var(--muted);
}
/* =========================
   THEME TOGGLE BUTTON
   ========================= */

.theme-btn {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--card);
    color: var(--text);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;

    font-size: 18px;
    line-height: 1;

    transition:
        background 0.25s ease,
        color 0.25s ease,
        border-color 0.25s ease,
        transform 0.15s ease,
        box-shadow 0.25s ease;
}

/* Hover */
.theme-btn:hover {
    background: var(--hover);
    box-shadow: 0 4px 10px rgba(0,0,0,.25);
    transform: translateY(-1px);
}

/* Active (click) */
.theme-btn:active {
    transform: scale(0.92);
    box-shadow: none;
}

/* Focus (keyboard) */
.theme-btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(255,0,0,.35);
}

/* Icon animation */
.theme-btn span {
    transition: transform 0.3s ease, opacity 0.3s ease;
}

/* Slight rotate on hover */
.theme-btn:hover span {
    transform: rotate(-12deg) scale(1.05);
}

/* =========================
   LIGHT MODE TUNING
   ========================= */
[data-theme="light"] .theme-btn {
    background: #ffffff;
    color: #111;
    border-color: var(--border);
}

[data-theme="light"] .theme-btn:hover {
    background: #f1f1f1;
    box-shadow: 0 4px 12px rgba(0,0,0,.15);
}

/* =========================
   DARK MODE TUNING
   ========================= */
.theme-btn {
    box-shadow: inset 0 0 0 rgba(255,255,255,0);
}
/* Icon buttons */
.btn-icon {
    background: transparent;
    border: none;
    color: var(--text);
    font-size: 20px;
}

/* ================= MOBILE SEARCH OVERLAY ================= */
.mobile-search-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1055; /* Above navbar */
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    display: none;
}

/* Visible state */
.mobile-search-overlay.show {
    display: block;
}

/* Header style */
.mobile-search-header {
    display: flex;
    align-items: center;
    padding: 10px;
}

/* Icon button */
.btn-icon {
    background: transparent;
    border: none;
    color: var(--text);
    font-size: 20px;
}

/* Prevent body scroll when search open */
body.search-open {
    overflow: hidden;
}
/* Search form */
.mobile-search-form {
    position: relative;
}

/* Search button inside input */
.search-btn {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    color: var(--muted);
    font-size: 18px;
    cursor: pointer;
}

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

/* Input fix */
.search-input {
    padding-right: 44px;
}
/* ================= MOBILE MENU ================= */

.mobile-menu {
    background: var(--bg);
    color: var(--text);
    width: 260px;
}

/* Header */
.mobile-menu .offcanvas-header {
    border-bottom: 1px solid var(--border);
}

/* Close button adapts to theme */
.mobile-menu .btn-close {
    filter: var(--close-filter, invert(1));
}

/* Menu items */
.menu-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 10px 12px;
    border-radius: 10px;
    color: var(--text);
    text-decoration: none;
    font-size: 0.95rem;
    transition: background 0.2s ease;
}

.menu-item span {
    flex: 1;
}

/* Hover */
.menu-item:hover {
    background: var(--hover);
}

/* Active (YouTube style) */
.menu-item.active {
    background: var(--hover);
    font-weight: 600;
}

/* Divider */
.menu-divider {
    border-color: var(--border);
    margin: 12px 0;
}
/* Default = DARK MODE */
.mobile-menu .btn-close {
    filter: invert(1);
    opacity: 1;
}

/* LIGHT MODE */
[data-theme="light"] .mobile-menu .btn-close {
    filter: invert(0);
}
/* Search result link */
.search-result-link {
    display: block;
    color: var(--text);
    text-decoration: none;
}

.search-result-link:hover {
    color: var(--text);
}

/* Row hover */
.video-row {
    padding: 8px;
    border-radius: var(--radius);
}

.video-row:hover {
    background: var(--hover);
}




/* Thumbnails */
.video-row img {
    transition: transform .25s ease;
}

.video-row:hover img {
    transform: scale(1.02);
}
/* =========================
   CATEGORY BAR
========================= */
.yt-cat-bar {
    position: sticky;
    top: 56px; /* below header */
    z-index: 50;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
}

/* =========================
   SCROLL CONTAINER
========================= */
.yt-cat-scroll {
    display: flex;
    gap: 10px;
    padding: 10px 12px;
    overflow-x: auto;
    white-space: nowrap;
    scrollbar-width: none;
}

.yt-cat-scroll::-webkit-scrollbar {
    display: none;
}

/* =========================
   CATEGORY CHIP
========================= */
.yt-cat {
    flex: 0 0 auto;
    padding: 6px 12px;
    border-radius: 16px;
    font-size: 14px;
    font-family: Roboto, Arial, sans-serif;
    background: var(--card);
    color: var(--text);
    text-decoration: none;
    transition: background .2s ease, color .2s ease;
}

.yt-cat:hover {
    background: var(--hover);
}

/* =========================
   ACTIVE CHIP (YouTube style)
========================= */
.yt-cat.active {
    background: var(--text);
    color: var(--bg);
}

/* =========================
   EXPLORE CHIP
========================= */

.yt-cat.explore {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-weight: 500;
    padding: 6px 12px;
}

.yt-cat.explore .yt-icon {
    width: 20px;          /* YouTube size */
    height: 20px;
    flex-shrink: 0;
    display: block;
}

.yt-cat.explore svg {
    opacity: .9;
    fill: currentColor;
}
/* ===============================
   SHORTS SHELF (YT STYLE)
================================ */

.yt-shorts-shelf {
    margin: 24px 0 32px;
}

/* Header */
.yt-shorts-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 5px;
    margin-left:10px;
    font-family: Roboto, Arial, sans-serif;
}

.yt-shorts-header svg {
    width: 22px;
    height: 22px;
    color: var(--accent);
}

.yt-shorts-title {
    font-size: 20px;
    font-weight: 500;
    color: var(--text);
}

/* Scroll Row */
.yt-shorts-row {
    display: flex;
    gap: 12px;
    padding-left: 10px;
    padding-right: 16px;
    overflow-x: auto;
    scrollbar-width: none;
}

.yt-shorts-row::-webkit-scrollbar {
    display: none;
}

/* Card */
.yt-short-card {
    flex: 0 0 160px;
    height: 284px;
    position: relative;
    border-radius: 12px;
    overflow: hidden;
    background: var(--card);
    cursor: pointer;
    transition: transform .2s ease, box-shadow .2s ease;
}

.yt-short-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 18px rgba(0,0,0,.35);
}

/* Thumbnail */
.yt-short-thumb {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Gradient Overlay */
.yt-short-gradient {
    position: absolute;
    inset: 0;
    background: linear-gradient(
        to top,
        rgba(0,0,0,.85),
        rgba(0,0,0,.2) 45%,
        transparent 70%
    );
}

/* Info */
.yt-short-info {
    position: absolute;
    bottom: 10px;
    left: 10px;
    right: 10px;
    z-index: 2;
}

/* Title */
.yt-short-title {
    font-size: 14px;
    font-weight: 500;
    line-height: 1.25;
    color: #fff;
    max-height: 36px;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

/* Views */
.yt-short-views {
    margin-top: 4px;
    font-size: 12px;
    color: rgba(255,255,255,.85);
}

/* Play Icon */
.yt-short-play {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 28px;
    height: 28px;
    background: rgba(0,0,0,.6);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.yt-short-play svg {
    width: 14px;
    height: 14px;
    fill: #fff;
}

/* ===============================
   DARK / LIGHT MODE
================================ */

[data-theme="light"] .yt-short-card {
    box-shadow: none;
}

[data-theme="light"] .yt-short-card:hover {
    box-shadow: 0 6px 18px rgba(0,0,0,.15);
}
/* Overlay */
.yt-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 999;
    display: none;
}

/* Drawer */
.yt-drawer {
    position: fixed;
    top: 0;
    left: 0;
    width: 260px;
    height: 100%;
    background: var(--bg);
    border-right: 1px solid var(--border);
    transform: translateX(-100%);
    transition: transform .25s ease;
    z-index: 1000;
    display: flex;
    flex-direction: column;
}

/* Open state */
.yt-drawer.open {
    transform: translateX(0);
}

.yt-overlay.show {
    display: block;
}

/* Header */
.yt-drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    border-bottom: 1px solid var(--border);
    font-size: 16px;
}

/* Close button */
.yt-close {
    background: none;
    border: none;
    font-size: 18px;
    color: var(--text);
    cursor: pointer;
}

/* Menu */
.yt-drawer-menu a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: var(--text);
    text-decoration: none;
    font-size: 14px;
}

.yt-drawer-menu a:hover {
    background: var(--hover);
}