/* --- Variables & Reset --- */
:root {
    --bg-body: #0b1120;
    /* Deep Blue from image */
    --bg-header: #0f172a;
    --bg-card-top: #ffffff;
    --bg-card-bottom: #1e293b;

    --text-main: #ffffff;
    --text-dark: #1a1a1a;
    /* For inside the white card area if needed */
    --text-muted: #94a3b8;

    --accent: #06b6d4;
    /* Cyan/Blue from image */
    --accent-hover: #0891b2;

    --border: rgba(255, 255, 255, 0.1);

    --font-family: 'Outfit', sans-serif;
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;

    --transition: all 0.2s ease;
}

body.light-mode {
    --bg-body: #f1f5f9;
    --bg-header: #ffffff;
    --bg-card-top: #ffffff;
    --bg-card-bottom: #e2e8f0;

    --text-main: #0f172a;
    --text-muted: #64748b;

    --border: rgba(0, 0, 0, 0.1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: var(--font-family);
}

body {
    background-color: var(--bg-body);
    color: var(--text-main);
    overflow: hidden;
    height: 100vh;
}

/* --- Layout --- */
.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

/* --- Top Header --- */
.top-header {
    height: 70px;
    background-color: var(--bg-header);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    border-bottom: 2px solid var(--accent);
    /* Cyan line at bottom of header as seen in image */
    flex-shrink: 0;
}

.brand {
    font-size: 1.6rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.8rem;
    color: var(--accent);
}

.brand span {
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.icon-btn {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    transition: var(--transition);
}

.icon-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-main);
}

.search-btn-wrapper {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

#search-input {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    color: var(--text-main);
    padding: 0.5rem 1rem;
    border-radius: var(--radius-md);
    outline: none;
    width: 200px;
    transition: var(--transition);
}

#search-input.hidden {
    display: none;
}

/* --- Category Bar --- */
.category-bar-container {
    padding: 1.5rem 2rem 0.5rem 2rem;
    background-color: var(--bg-body);
    flex-shrink: 0;
}

.category-scroll {
    display: flex;
    gap: 1rem;
    overflow-x: auto;
    padding-bottom: 0.5rem;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}

.category-scroll::-webkit-scrollbar {
    height: 4px;
}

.category-scroll::-webkit-scrollbar-thumb {
    background-color: var(--accent);
    border-radius: var(--radius-full);
}

.cat-pill {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    color: var(--text-muted);
    padding: 0.6rem 1.2rem;
    border-radius: var(--radius-sm);
    white-space: nowrap;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: var(--transition);
    text-transform: capitalize;
}

.cat-pill:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-main);
}

.cat-pill.active {
    background-color: var(--accent);
    color: #000;
    /* Black text on cyan as per image style usually, or white */
    color: #fff;
    /* Let's check image. Looks like cyan bg with white/black text. Going with white for contract. */
    border-color: var(--accent);
    font-weight: 600;
}

/* Image shows cyan text on active? No, looks like solid cyan block */
.cat-pill.active {
    background-color: var(--accent);
    color: #ffffff;
}

/* --- Main Content --- */
.main-content {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem 2rem;
}

.channel-grid {
    display: grid;
    /* Reduced min-width to 160px for better fit */
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 1.5rem;
    padding-bottom: 2rem;
}

/* --- Card Design (Updated) --- */
.channel-card {
    background-color: var(--bg-card-bottom);
    border-radius: var(--radius-lg);
    overflow: hidden;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border);
    position: relative;
    height: 100%;
    /* Ensure full height in grid */
}

.channel-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.3);
    border-color: var(--accent);
}

.card-image {
    background-color: var(--bg-card-top);
    /* Fixed height for uniformity */
    height: 140px;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    position: relative;
}

.card-image img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    transition: var(--transition);
}

.channel-card:hover .card-image img {
    transform: scale(1.05);
}

.card-info {
    background-color: var(--bg-card-bottom);
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    border-top: 1px solid var(--border);
}

.card-name {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.card-group {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    background: rgba(255, 255, 255, 0.05);
    padding: 2px 6px;
    border-radius: 4px;
    align-self: flex-start;
}

/* Live Indicator */
/* Removed empty card-image::after ruleset */

/* Custom Live Status in Footer */
.live-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.75rem;
    color: #22c55e;
    /* Green */
    margin-top: 4px;
}

.live-dot {
    width: 8px;
    height: 8px;
    background-color: #22c55e;
    border-radius: 50%;
    box-shadow: 0 0 8px #22c55e;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% {
        opacity: 1;
        transform: scale(1);
    }

    50% {
        opacity: 0.5;
        transform: scale(1.2);
    }

    100% {
        opacity: 1;
        transform: scale(1);
    }
}

/* --- Player & Toast (Keep Existing) --- */
.player-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(10px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: var(--transition);
}

.player-modal.active {
    opacity: 1;
    pointer-events: all;
}

.player-content {
    width: 90%;
    max-width: 1000px;
    background: var(--bg-card-bottom);
    border-radius: var(--radius-lg);
    overflow: hidden;
    position: relative;
    border: 1px solid var(--border);
}

.video-wrapper {
    position: relative;
    padding-bottom: 56.25%;
    height: 0;
    background: #000;
}

.video-wrapper video {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.close-player {
    position: absolute;
    top: 1rem;
    right: 1rem;
    z-index: 1100;
    background: rgba(0, 0, 0, 0.5);
    border: none;
    color: white;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close-player:hover {
    background: var(--accent);
}

.player-info {
    padding: 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.player-header {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.player-header h3 {
    font-size: 1.4rem;
    font-weight: 600;
}

.fav-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1.2rem;
}

.fav-btn.active {
    color: #ff4757;
}

.badge {
    background: var(--accent);
    color: white;
    padding: 4px 10px;
    border-radius: var(--radius-full);
    font-size: 0.8rem;
}

/* Toast */
.toast-container {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.toast {
    background: var(--bg-card-bottom);
    border: 1px solid var(--border);
    padding: 1rem 1.5rem;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    transform: translateX(100%);
    opacity: 0;
    transition: all 0.4s ease;
    color: var(--text-main);
}

.toast.show {
    transform: translateX(0);
    opacity: 1;
}

.toast i {
    color: var(--accent);
}

/* Skeleton */
.skeleton {
    background: linear-gradient(90deg, var(--bg-card-bottom) 25%, #2a3441 50%, var(--bg-card-bottom) 75%);
    background-size: 200% 100%;
    animation: skeleton-load 1.5s infinite;
    border-radius: var(--radius-md);
}

@keyframes skeleton-load {
    0% {
        background-position: 200% 0;
    }

    100% {
        background-position: -200% 0;
    }
}

.skeleton-card {
    aspect-ratio: 16/14;
    border-radius: var(--radius-lg);
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .top-header {
        padding: 0 1rem;
    }

    .category-bar-container {
        padding: 1rem 1rem 0 1rem;
    }

    .channel-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: 1rem;
    }

    .main-content {
        padding: 1rem;
    }

    #search-input {
        width: 140px;
    }

    #search-input.hidden {
        display: none;
    }
}