/* mobile.css */

@media (max-width: 767px) {

    /* Layout stack vertically on mobile */
    .content {
        display: flex !important;
        flex-direction: column !important;
        flex: 1 1 0% !important;
        min-height: 0 !important;
        overflow-y: auto;
        overflow-x: hidden;
        background: #000 !important;
        /* 🔥 GAPS SHOW AS BLACK */
    }

    .desktop-only {
        display: none !important;
    }

    .mobile-only {
        display: inline-flex;
    }

    /* Player on top */
    .player-section {
        width: 100%;
        display: flex !important;
        flex-direction: column !important;
        flex: 1 1 auto !important;
        min-height: 200px;
        padding: 0;
        order: 1;
        overflow: hidden !important;
        background: #000;
        position: relative;
        contain: paint;
        /* 🔥 CLIP STRICTLY */
        transform: translateZ(0);
        /* 🔥 HARDWARE LAYER for clipping */
    }

    .video-container {
        position: relative;
        width: 100%;
        aspect-ratio: 16/9;
        min-height: 200px;
        /* Safety minimum */
        max-height: 40vh;
        border-radius: 0;
        overflow: hidden !important;
        background: #000;
        flex: 0 0 auto;
        z-index: 10;
        display: block;
        contain: paint;
    }

    video {
        width: 100%;
        height: 100%;
        object-fit: contain;
        display: block;
    }

    /* ---- FAVORITES UNDER PLAYER ---- */
    .favorites-container {
        display: flex;
        flex-direction: column;
        background: var(--bg);
        padding: 0.75rem 0.75rem 1rem;
        margin-top: -1px;
        /* 🔥 OVERLAP PLAYER TO HIDE LINE */
        border-radius: 24px 24px 0 0;
        order: 2;
        position: relative;
        z-index: 15;
        /* Below video */

        width: 100%;
        box-sizing: border-box;
        flex: 1 1 auto;
        min-height: 100px;
        /* Ensure at least some visibility */
    }

    .favorites-header {
        display: flex !important;
        align-items: center;
        justify-content: space-between;
        margin-bottom: 0.75rem;
        padding-bottom: 0.65rem;
        border-bottom: 1px solid var(--border);
        width: 100%;
        flex-shrink: 0;
    }

    .favorites-header h3 {
        font-size: 0.95rem;
        font-weight: 700;
        display: flex;
        align-items: center;
        gap: 0.5rem;
        margin: 0;
    }

    /* HIDE heart icon - REMOVED for cleaner look */
    .favorites-header h3 svg {
        display: none !important;
    }

    .favorites-header .favorites-title {
        font-size: 0.95rem;
    }

    .favorites-header .fav-count {
        font-size: 0.8rem;
        color: var(--text-dim);
        font-weight: 500;
    }

    /* 2-column favorites grid */
    .favorites-grid {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 0.6rem;
        width: 100%;
        box-sizing: border-box;

        /* PERFECT: Show ~5 rows, scroll for rest */
        max-height: 500px;
        /* Fixed pixel height - shows ~5 rows */
        overflow-y: auto;
        /* Scroll when more than 5 rows */
        overflow-x: hidden;

        /* Smooth scrolling */
        -webkit-overflow-scrolling: touch;
        scroll-behavior: smooth;

        /* Grid fits content */
        grid-auto-rows: min-content;
    }

    /* Custom scrollbar for favorites grid */
    .favorites-grid::-webkit-scrollbar {
        width: 4px;
    }

    .favorites-grid::-webkit-scrollbar-track {
        background: transparent;
    }

    .favorites-grid::-webkit-scrollbar-thumb {
        background: var(--border-hover);
        border-radius: 2px;
    }

    .favorites-grid::-webkit-scrollbar-thumb:hover {
        background: var(--highlight);
    }

    .favorite-card {
        display: flex;
        align-items: center;
        gap: 0.45rem;
        padding: 0.55rem 0.6rem;
        background: var(--card-bg);
        border-radius: 12px;
        border: 1px solid var(--border);
        cursor: pointer;
        transition: var(--transition);
    }

    .favorite-card:active {
        transform: scale(0.97);
    }

    .favorite-card.active {
        border-color: var(--highlight);
        background: linear-gradient(135deg, rgba(244, 63, 94, 0.1), rgba(236, 72, 153, 0.05));
        box-shadow: 0 4px 12px rgba(244, 63, 94, 0.2);
    }

    .favorite-card .channel-logo {
        width: 32px;
        height: 32px;
        border-radius: 8px;
        overflow: hidden;
        flex-shrink: 0;
        background: var(--accent);
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .favorite-card .channel-logo img {
        width: 100%;
        height: 100%;
        object-fit: contain;
        display: block;
    }

    .favorite-card .channel-info {
        flex: 1;
        min-width: 0;
        display: flex;
        flex-direction: column;
        gap: 0.15rem;
    }

    .favorite-card .channel-title {
        font-size: 0.82rem;
        font-weight: 600;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .favorite-card .channel-meta {
        font-size: 0.7rem;
        color: var(--text-dim);
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .favorite-card .channel-fav {
        width: 24px;
        height: 24px;
        min-width: 24px;
        border-radius: 999px;
        border: 1px solid rgba(148, 163, 184, 0.35);
        background: rgba(15, 23, 42, 0.96);
        display: inline-flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        padding: 0;
        transition: all 0.18s ease;
    }

    .favorite-card .channel-fav .fav-icon {
        width: 13px;
        height: 13px;
        fill: transparent;
        stroke: rgba(148, 163, 184, 0.8);
        stroke-width: 2;
        transition: transform 0.18s ease, fill 0.18s ease;
    }

    .favorite-card .channel-fav.fav-active {
        background: var(--glass);
        border-color: var(--highlight);
        box-shadow: 0 0 0 2px var(--highlight-soft);
    }

    .favorite-card .channel-fav.fav-active .fav-icon {
        fill: #f43f5e;
        stroke: #f43f5e;
        transform: scale(1.1);
    }

    .favorites-empty {
        text-align: center;
        padding: 2rem 1rem;
        color: var(--text-dim);
    }

    .favorites-empty svg {
        width: 48px;
        height: 48px;
        margin: 0 auto 1rem;
        opacity: 0.5;
    }

    .channel-grid {
        display: none !important;
    }

    /* ---- SIDEBAR CHANNEL CARDS (hamburger menu) ---- */
    .sidebar-channel {
        display: flex;
        align-items: center;
        gap: 0.6rem;
        padding: 0.7rem 0.8rem;
        border-radius: 12px;
        background: var(--card-bg);
        border: 1px solid var(--border);
        margin-bottom: 0.65rem;
        cursor: pointer;
        transition: all 0.2s ease;
    }

    .sidebar-channel:hover {
        border-color: var(--highlight);
    }

    .sidebar-channel.active {
        border-color: var(--highlight);
        background: var(--highlight-soft);
    }

    .sidebar-channel .channel-icon {
        width: 38px;
        height: 38px;
        border-radius: 10px;
        overflow: hidden;
        flex-shrink: 0;
        background: var(--accent);
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .sidebar-channel .channel-icon img {
        width: 100%;
        height: 100%;
        object-fit: contain;
        display: block;
    }

    .sidebar-channel .channel-text {
        flex: 1;
        min-width: 0;
        /* CRITICAL for ellipsis */
        overflow: hidden;
        display: flex;
        flex-direction: column;
    }

    .sidebar-channel .channel-name {
        font-size: 0.9rem;
        font-weight: 600;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        /* Guaranteed heart visibility */
        position: relative;
    }

    .sidebar-channel .channel-name.scrolling .channel-name-inner {
        display: inline-block;
        animation: scroll-text 12s linear infinite;
        padding-right: 30px;
    }

    @keyframes scroll-text {
        0% {
            transform: translateX(0);
        }

        100% {
            transform: translateX(-50%);
        }
    }

    .sidebar-channel .channel-meta {
        font-size: 0.75rem;
        color: var(--text-dim);
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        display: block;
    }

    .sidebar-channel .quality {
        font-size: 0.72rem;
        padding: 0.2rem 0.5rem;
        border-radius: 999px;
        background: var(--highlight-soft);
        color: var(--highlight);
        font-weight: 700;
        flex-shrink: 0;
    }

    body.light .sidebar-channel .quality {
        color: #e11d48;
    }

    .sidebar-channel .channel-fav,
    .channel-card .channel-fav {
        width: 28px;
        height: 28px;
        min-width: 28px;
        border-radius: 999px;
        border: 1px solid rgba(148, 163, 184, 0.35);
        background: rgba(15, 23, 42, 0.96);
        display: inline-flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        padding: 0;
        transition: all 0.18s ease;
        margin-left: auto;
    }

    .sidebar-channel .channel-fav .fav-icon,
    .channel-card .channel-fav .fav-icon {
        width: 15px;
        height: 15px;
        fill: transparent;
        stroke: rgba(148, 163, 184, 0.8);
        stroke-width: 2;
        transition: transform 0.18s ease, fill 0.18s ease;
    }

    .sidebar-channel .channel-fav.fav-active,
    .channel-card .channel-fav.fav-active {
        background: rgba(24, 24, 27, 0.96);
        border-color: rgba(248, 113, 113, 0.9);
        box-shadow: 0 0 0 2px rgba(248, 113, 113, 0.3);
    }

    .sidebar-channel .channel-fav.fav-active .fav-icon,
    .channel-card .channel-fav.fav-active .fav-icon {
        fill: #f43f5e;
        stroke: #f43f5e;
        transform: scale(1.1);
    }

    /* ---- Filter Panel ---- */
    .filter-panel {
        position: fixed;
        right: 0;
        top: 0;
        width: 90%;
        max-width: 340px;
        height: 100vh;
        background: var(--secondary);
        transform: translateX(100%);
        transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
        z-index: 999;
        display: flex;
        flex-direction: column;
        box-shadow: -5px 0 30px rgba(0, 0, 0, 0.3);
    }

    .filter-panel.open {
        transform: translateX(0);
    }

    .filter-panel-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 0.75rem 1rem;
        border-bottom: 1px solid var(--border);
        background: var(--primary);
        flex-shrink: 0;
    }

    .filter-panel-header h3 {
        font-size: 1rem;
        font-weight: 700;
    }

    .filter-content-modern {
        flex: 1;
        overflow: hidden;
        display: flex;
        flex-direction: column;
    }

    .modern-filters {
        padding: 0.75rem;
        display: flex;
        flex-direction: column;
        gap: 0.6rem;
        flex: 1;
        overflow-y: auto;
    }

    .filter-input-group {
        position: relative;
    }

    .input-icon {
        position: absolute;
        left: 0.75rem;
        top: 50%;
        transform: translateY(-50%);
        width: 16px;
        height: 16px;
        color: var(--text-dim);
        pointer-events: none;
    }

    .modern-input {
        width: 100%;
        padding: 0.6rem 0.75rem 0.6rem 2.5rem;
        background: var(--card-bg);
        border: 1px solid var(--border);
        border-radius: 8px;
        color: var(--text);
        font-size: 0.85rem;
        transition: all 0.3s ease;
    }

    .modern-input:focus {
        outline: none;
        border-color: var(--highlight);
        box-shadow: 0 0 0 3px rgba(244, 63, 94, 0.1);
    }

    .filter-grid {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 0.5rem;
    }

    .filter-select-group {
        display: flex;
        flex-direction: column;
        gap: 0.35rem;
    }

    .filter-label {
        display: flex;
        align-items: center;
        gap: 0.4rem;
        font-size: 0.7rem;
        font-weight: 600;
        color: var(--text-dim);
        text-transform: uppercase;
        letter-spacing: 0.3px;
    }

    .filter-label svg {
        width: 12px;
        height: 12px;
    }

    .modern-select {
        padding: 0.6rem 0.5rem;
        background: var(--card-bg);
        border: 1px solid var(--border);
        border-radius: 7px;
        color: var(--text);
        font-size: 0.8rem;
        font-weight: 500;
        cursor: pointer;
        transition: all 0.3s ease;
    }

    .modern-select:focus {
        outline: none;
        border-color: var(--highlight);
        box-shadow: 0 0 0 3px rgba(244, 63, 94, 0.1);
    }

    .modern-toggles {
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
    }

    .modern-toggle {
        display: flex;
        align-items: center;
        gap: 0.7rem;
        padding: 0.6rem 0.75rem;
        background: var(--card-bg);
        border-radius: 8px;
        cursor: pointer;
        border: 1px solid transparent;
        transition: all 0.3s ease;
    }

    .modern-toggle:active {
        transform: scale(0.98);
    }

    .modern-toggle input[type="checkbox"] {
        display: none;
    }

    .toggle-track {
        width: 40px;
        height: 22px;
        background: var(--accent);
        border-radius: 11px;
        position: relative;
        transition: all 0.3s ease;
        flex-shrink: 0;
    }

    .toggle-thumb {
        position: absolute;
        width: 18px;
        height: 18px;
        background: white;
        border-radius: 50%;
        top: 2px;
        left: 2px;
        transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    }

    .modern-toggle input:checked+.toggle-track {
        background: linear-gradient(135deg, var(--highlight), #ec4899);
    }

    .modern-toggle input:checked+.toggle-track .toggle-thumb {
        transform: translateX(18px);
    }

    .toggle-content {
        flex: 1;
        display: flex;
        align-items: center;
        gap: 0.6rem;
    }

    .toggle-content svg {
        width: 16px;
        height: 16px;
        color: var(--text-dim);
        flex-shrink: 0;
    }

    .toggle-label {
        font-size: 0.85rem;
        font-weight: 500;
    }

    .modern-stats {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 0.5rem;
    }

    .stat-card {
        display: flex;
        align-items: center;
        gap: 0.6rem;
        padding: 0.7rem;
        background: linear-gradient(135deg, var(--card-bg), var(--accent));
        border-radius: 8px;
        border: 1px solid var(--border);
    }

    .stat-card svg {
        width: 22px;
        height: 22px;
        color: var(--highlight);
        flex-shrink: 0;
    }

    .stat-info {
        display: flex;
        flex-direction: column;
    }

    .stat-value {
        font-size: 1.1rem;
        font-weight: 700;
        line-height: 1;
    }

    .stat-label {
        font-size: 0.7rem;
        color: var(--text-dim);
        font-weight: 500;
        margin-top: 0.2rem;
    }

    /* SIDEBAR FILTERS + SEARCH */
    .sidebar-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 1rem;
        border-bottom: 1px solid var(--border);
    }

    .sidebar-header div {
        flex: 1;
    }

    .sidebar-header h2 {
        font-size: 1.1rem;
        font-weight: 700;
        margin: 0;
    }

    .sidebar-count {
        font-size: 0.75rem;
        color: var(--text-dim);
        display: block;
        margin-top: 0.2rem;
    }

    .sidebar-search-container {
        padding: 0.75rem 1rem;
        border-bottom: 1px solid rgba(255, 255, 255, 0.05);
        background: var(--primary);
    }

    .sidebar-search-wrapper {
        position: relative;
    }

    .sidebar-search-wrapper .search-icon {
        position: absolute;
        left: 12px;
        top: 50%;
        transform: translateY(-50%);
        width: 18px;
        height: 18px;
        opacity: 0.5;
        pointer-events: none;
    }

    .sidebar-search-input {
        width: 100%;
        padding: 0.7rem 0.7rem 0.7rem 40px;
        background: var(--card-bg);
        border: 1px solid var(--border);
        border-radius: 10px;
        color: var(--text);
        font-size: 0.9rem;
        transition: all 0.2s;
    }

    .sidebar-search-input:focus {
        outline: none;
        border-color: var(--highlight);
        box-shadow: 0 0 0 3px rgba(244, 63, 94, 0.1);
    }

    .sidebar-filter-section {
        border-bottom: 1px solid rgba(255, 255, 255, 0.05);
        background: var(--primary);
    }

    .sidebar-filter-toggle {
        width: 100%;
        display: flex;
        align-items: center;
        gap: 10px;
        padding: 0.9rem 1rem;
        background: transparent;
        border: none;
        color: var(--text);
        font-size: 0.95rem;
        font-weight: 600;
        cursor: pointer;
        transition: background 0.2s;
    }

    .sidebar-filter-toggle:active {
        background: rgba(255, 255, 255, 0.03);
    }

    .sidebar-filter-toggle svg:first-child {
        width: 18px;
        height: 18px;
        color: var(--highlight);
    }

    .sidebar-filter-toggle .dropdown-icon {
        width: 16px;
        height: 16px;
        margin-left: auto;
        transition: transform 0.3s;
        opacity: 0.7;
    }

    .sidebar-filters-content {
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.35s cubic-bezier(0.4, 0, 0.2, 1);
        background: var(--accent);
    }

    .sidebar-filters-content.open {
        max-height: 800px;
        overflow-y: auto;
    }

    .sidebar-filter-group {
        padding: 0.6rem 1rem;
    }

    .sidebar-filter-group label {
        display: block;
        font-size: 0.75rem;
        font-weight: 600;
        color: var(--text-dim);
        text-transform: uppercase;
        letter-spacing: 0.5px;
        margin-bottom: 0.4rem;
    }

    .sidebar-filter-select {
        width: 100%;
        padding: 0.65rem;
        background: var(--card-bg);
        border: 1px solid var(--border);
        border-radius: 8px;
        color: var(--text);
        font-size: 0.85rem;
        cursor: pointer;
        transition: all 0.2s;
    }

    .sidebar-filter-select:focus {
        outline: none;
        border-color: var(--highlight);
    }

    .sidebar-filter-toggles {
        padding: 0.6rem 1rem;
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
    }

    .sidebar-toggle-option {
        display: flex;
        align-items: center;
        gap: 0.6rem;
        padding: 0.6rem;
        background: var(--card-bg);
        border-radius: 8px;
        cursor: pointer;
        font-size: 0.85rem;
    }

    .sidebar-toggle-option input[type="checkbox"] {
        width: 18px;
        height: 18px;
        cursor: pointer;
        accent-color: var(--highlight);
    }

    .toggle-text {
        flex: 1;
    }

    .sidebar-filter-stats {
        display: flex;
        gap: 0.5rem;
        padding: 0.75rem 1rem;
        background: rgba(0, 0, 0, 0.2);
    }

    .stat-item {
        flex: 1;
        text-align: center;
        padding: 0.5rem;
        background: var(--card-bg);
        border-radius: 8px;
    }

    .stat-item strong {
        display: block;
        font-size: 1.2rem;
        font-weight: 700;
        color: var(--highlight);
    }

    .stat-item span {
        display: block;
        font-size: 0.7rem;
        color: var(--text-dim);
        margin-top: 0.2rem;
    }

    .sidebar-channels {
        flex: 1;
        overflow-y: auto;
        padding: 1rem;
    }

    #filterBtn {
        display: none !important;
    }
}