/* 🎨 GLOBAL STYLES & VARIABLES — REDESIGNED */
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;600;700;900&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Audiowide&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Funnel+Sans:ital,wght@0,300..800;1,300..800&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Fugaz+One&display=swap');

:root {
    --bg-color: #0f0f1a;
    --primary-text: #e0e0e0;
    --secondary-text: #a0a0b0;
    --card-bg: #1a1a2e;
    --border-color: #2a2a4a;
    --accent-gradient: linear-gradient(135deg, #f957ff, #3c1053, #00d4ff);
    --accent-color-1: #f957ff;
    --accent-color-2: #00d4ff;

    /* Existing homepage.html specific variables, adjusted or kept if not conflicting */
    --bg-primary: var(--bg-color);
    --bg-secondary: var(--card-bg);
    --bg-tertiary: #2a2a2a; /* Kept from original style.css, might need adjustment */
    --accent: var(--accent-color-2); /* Using index.html accent */
    --accent-hover: #0056b3; /* Kept from original style.css */
    --error: #e53e3e;
    --success: #38a169;
    --yellowbro: #cbce21; /* Kept from original style.css */
    --shadow: 0 4px 12px rgba(0, 0, 0, 0.4); /* Kept from original style.css */
    --transition: all 0.25s ease-in-out; /* Kept from original style.css */
    --font-family: 'Poppins', sans-serif; /* Using index.html font */
    --newfont1: "Audiowide", sans-serif; /* Kept from original style.css */
    --newfont2: "Funnel Sans", sans-serif; /* Kept from original style.css */
    --newfont3: "Fugaz One", sans-serif; /* Kept from original style.css */
}

.light-theme {
    --bg-primary: #f8f9fa;
    --bg-secondary: #ffffff;
    --bg-tertiary: #e9ecef;
    --text-primary: #212529;
    --text-secondary: #6c757d;
    --border-color: rgba(0, 0, 0, 0.1);
}

/* CSS Reset & Global Styles (from index.html) */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-family);
    background-color: var(--bg-color);
    color: var(--primary-text);
    line-height: 1.6;
    overflow-x: hidden;
    padding-top: 80px; /* Add padding to account for fixed header height */
}

/* Utility Classes (from index.html) */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

.section {
    padding: 100px 0;
}

.section-title {
    font-size: 2.5rem;
    font-weight: 700;
    text-align: center;
    margin-bottom: 50px;
    position: relative;
}

.section-title::after {
    content: '';
    position: absolute;
    bottom: -10px;
    left: 50%;
    transform: translateX(-50%);
    width: 80px;
    height: 4px;
    background: var(--accent-gradient);
    border-radius: 2px;
}

.btn {
    display: inline-block;
    padding: 12px 30px;
    font-size: 1rem;
    font-weight: 600;
    text-decoration: none;
    border-radius: 50px;
    transition: all 0.3s ease;
    cursor: pointer;
    border: none;
}

.btn-primary {
    background: var(--accent-gradient);
    background-size: 200% auto;
    color: white;
}

.btn-primary:hover {
    background-position: right center;
    transform: scale(1.05);
    box-shadow: 0 10px 20px rgba(0, 212, 255, 0.2);
}

/* Header & Navigation (from index.html, merged with homepage.html needs) */
.header { /* Renamed from .app-header to .header for consistency */
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    padding: 20px 0;
    z-index: 1000;
    transition: all 0.3s ease;
    background-color: var(--bg-color); /* Ensure header has a default background */
}

.header.scrolled {
    background-color: rgba(15, 15, 26, 0.7);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.navbar { /* Renamed from .header-container to .navbar for consistency */
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    display: flex;
    align-items: center;
    text-decoration: none;
    color: var(--primary-text);
    font-size: 1.5rem;
    font-weight: 700;
}

.logo img {
    width: 40px; /* Adjusted from 50px for consistency with index.html */
    height: 40px; /* Adjusted from auto for consistency with index.html */
    margin-right: 10px;
}

.nav-links {
    list-style: none;
    display: flex;
}

.nav-links li {
    margin-left: 30px;
}

.nav-links a {
    color: var(--primary-text);
    text-decoration: none;
    font-weight: 400;
    position: relative;
    transition: color 0.3s ease;
}

.nav-links a::after {
    content: '';
    position: absolute;
    bottom: -5px;
    left: 0;
    width: 0;
    height: 2px;
    background: var(--accent-gradient);
    transition: width 0.3s ease;
}

.nav-links a:hover {
    color: white;
}

.nav-links a:hover::after {
    width: 100%;
}

.speed-meter {
    display: flex;
    gap: 15px;
    align-items: center;
    font-size: 0.9rem;
    color: var(--secondary-text);
}

.speed-meter span {
    background-color: var(--card-bg);
    padding: 5px 10px;
    border-radius: 5px;
    border: 1px solid var(--border-color);
}

/* Hero Section (from index.html) */
.hero {
    height: 100vh;
    display: flex;
    align-items: center;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.hero::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle, rgba(15,15,26,0.6) 0%, rgba(15,15,26,1) 70%);
    z-index: 1;
}

.hero-background-shapes {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
}

.shape {
    position: absolute;
    border-radius: 50%;
    opacity: 0.1;
    filter: blur(80px);
}

.shape1 {
    width: 400px; height: 400px;
    background-color: var(--accent-color-1);
    top: 10%; left: 10%;
    animation: moveShape 20s infinite alternate;
}

.shape2 {
    width: 300px; height: 300px;
    background-color: var(--accent-color-2);
    bottom: 15%; right: 15%;
    animation: moveShape 25s infinite alternate-reverse;
}

@keyframes moveShape {
    from { transform: translate(0, 0) rotate(0deg); }
    to { transform: translate(100px, 50px) rotate(180deg); }
}

.hero-content {
    position: relative;
    z-index: 2;
}

.hero-headline {
    font-size: 3rem;
    font-weight: 900;
    margin-bottom: 20px;
    line-height: 1.2;
    color: #fff;
}

/* For Anime.js character animation */
.hero-headline .letter {
    display: inline-block;
    line-height: 1em;
}

.hero-subheadline {
    font-size: 1.2rem;
    max-width: 700px;
    margin: 0 auto 30px;
    color: var(--secondary-text);
}

/* Features Section (from index.html) */
.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 30px;
}

.feature-card {
    background: var(--card-bg);
    padding: 40px 30px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    text-align: center;
    transition: all 0.3s ease;
}

.feature-card:hover {
    transform: translateY(-10px);
    box-shadow: 0 15px 30px rgba(0,0,0,0.3);
    border-color: var(--accent-color-2);
}

.feature-icon {
    font-size: 3rem;
    margin-bottom: 20px;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.feature-title {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 10px;
}

.feature-description {
    color: var(--secondary-text);
}

#channel-count {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 0;
    color: #fff;
}

/* Channels Showcase (from index.html) */
.channels-showcase {
    text-align: center;
}

.channels-grid {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 20px;
    margin-top: 50px;
}

.channel-logo-homepage {
    height: 60px;
    width: 120px;
    background-color: var(--card-bg);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px;
    filter: grayscale(80%);
    opacity: 0.7;
    transition: all 0.3s ease;
    cursor: pointer;
}

.channel-logo-homepage:hover {
    filter: grayscale(0%);
    opacity: 1;
    transform: scale(1.1);
}

.channel-logo-homepage img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

/* M3U Player Section (from index.html) */
#m3u-player {
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 15px;
    padding: 60px;
    text-align: center;
}

.m3u-form {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-top: 20px;
}

.m3u-input {
    width: 100%;
    max-width: 500px;
    padding: 15px 20px;
    background-color: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 50px;
    color: var(--primary-text);
    font-size: 1rem;
    outline: none;
    transition: border-color 0.3s ease;
}

.m3u-input:focus {
    border-color: var(--accent-color-2);
    box-shadow: 0 0 15px rgba(0, 212, 255, 0.2);
}

/* Footer (from index.html) */
.footer {
    background-color: #0a0a14;
    padding: 40px 0;
    text-align: center;
    border-top: 1px solid var(--border-color);
}

.footer p {
    color: var(--secondary-text);
}

/* Scroll Animation Classes (from index.html) */
.scroll-animate {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.8s ease, transform 0.8s ease;
}

.scroll-animate.is-visible {
    opacity: 1;
    transform: translateY(0);
}

/* Existing homepage.html specific styles, merged and adjusted */
.app-main {
    display: grid;
    grid-template-columns: 1fr 380px; /* Revert to original fixed width for sidebar */
    gap: 2rem;
    padding: 2rem;
    align-items: start;
    min-height: calc(100vh - 80px); /* Adjust for header height */
    width: 100%; /* Ensure app-main takes full width */
    max-width: 100%; /* Prevent overflow */
}
.player-container {
    position: sticky;
    top: 80px; /* Position below the header */
}

.player-section, .iframe-player-section {
    position: relative;
    background-color: #000;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: var(--shadow);
}
.video-js, .iframe-player-section iframe {
    width: 100%;
    aspect-ratio: 16 / 9;
    height: 100%;
    display: block;
}
.iframe-player-section {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 300px;
}

.current-channel-info {
    margin: 1rem 0 0.75rem 0;
    text-align: center;
}
#currentChannelName {
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--accent);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding: 0 1rem;
    font-family: var(--newfont1);
}
#currentChannelName:empty {
    content: 'Select a channel to begin';
    font-weight: 400;
}

.player-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sidebar {
    background: var(--bg-secondary);
    border-radius: 12px;
    height: calc(100vh - 100px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid var(--border-color);
    /* Removed temporary background */
}
.sidebar-header {
    padding: 1rem;
    margin-bottom: 15px;
    border-bottom: 5px solid var(--border-color);
}
.sidebar-content {
    flex-grow: 1;
    overflow-y: auto;
    padding: 0.5rem 1rem;
}
.sidebar-content::-webkit-scrollbar {
    width: 6px;
}
.sidebar-content::-webkit-scrollbar-track {
    background: transparent;
}
.sidebar-content::-webkit-scrollbar-thumb {
    background: #444;
    border-radius: 3px;
}
.sidebar-content::-webkit-scrollbar-thumb:hover {
    background: #555;
}

.sidebar-top {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
}
#sidebarTitle {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--yellowbro);
    flex-grow: 1;
    font-family: var(--newfont3);
}
.back-btn {
    padding: 0.5rem;
    line-height: 1;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    justify-content: center;
}

.search-container {
    position: relative;
}
.search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
    pointer-events: none;
}
#searchInput {
    width: 100%;
    padding: 0.75rem 1rem 0.75rem 2.5rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-size: 1rem;
    transition: var(--transition);
}
#searchInput:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.25);
}

.category-menu-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.85rem;
    border-radius: 8px;
    cursor: pointer;
    transition: var(--transition);
}
.category-menu-item:hover {
    background-color: var(--bg-tertiary);
}
.category-menu-item .icon {
    font-size: 1.2rem;
    width: 24px;
    text-align: center;
    color: var(--text-secondary);
}
.category-menu-item .name {
    font-weight: 500;
    font-size: 1rem;
    flex-grow: 1;
}
.category-menu-item .count {
    font-size: 0.85rem;
    color: var(--text-secondary);
    background-color: var(--bg-tertiary);
    padding: 2px 8px;
    border-radius: 12px;
}
.category-menu-item:hover .count {
    background-color: var(--accent);
    color: white;
}

.channel-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.channel-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem;
    border-radius: 8px;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    background-color: transparent;
    border: 1px solid transparent;
}
.channel-card:hover {
    background: var(--bg-tertiary);
}
.channel-card.playing {
    background: rgba(0, 123, 255, 0.1);
    border-color: var(--accent);
}
.channel-logo {
    width: 40px;
    height: 40px;
    object-fit: contain;
    border-radius: 6px;
    flex-shrink: 0;
    background: rgba(255, 255, 255, 0.05);
}
.channel-info {
    flex-grow: 1;
    overflow: hidden;
}
.channel-name {
    font-weight: 500;
    font-size: 0.95rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text-primary);
    font-family: var(--newfont2);
}
.favorite-btn {
    background: transparent;
    border: none;
    font-size: 1.3rem;
    cursor: pointer;
    color: var(--text-secondary);
    transition: var(--transition);
    padding: 0.25rem;
    line-height: 1;
}
.favorite-btn:hover {
    color: #ffc107;
}
.favorite-btn.active {
    color: #ffc107;
    transform: scale(1.1);
}

.hidden {
    display: none !important;
}

.custom-m3u-loader {
    display: flex;
    gap: 0.5rem;
    padding: 0 1rem 1rem;
    border-bottom: 1px solid var(--border-color);
}
#m3uUrlInput {
    flex-grow: 1;
    padding: 0.6rem 0.8rem;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-size: 0.9rem;
}
#loadM3uBtn {
    cursor: pointer;
    padding: 0.6rem 1rem;
    border: none;
    border-radius: 1rem;
}

#nextChannelErrorBtn{
    cursor: pointer;
    padding: 0.6rem 1rem;
    border: none;
    border-radius: 1rem;
}

.btn-icon {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    cursor: pointer;
    padding: 0.6rem 1rem;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: var(--transition);
    font-family: var(--newfont3);
}
.dark-theme .icon-sun, .light-theme .icon-moon {
    display: none;
}

.error-overlay, .resolving-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: rgba(0, 0, 0, 0.85);
    color: white;
    z-index: 10;
    border-radius: 12px;
    backdrop-filter: blur(5px);
}
.loading-message {
    text-align: center;
    padding: 2rem 1rem;
    font-size: 1.1rem;
    color: var(--text-secondary);
    background: var(--bg-secondary);
    border-radius: 12px;
}

.app-footer { /* Renamed to .footer for consistency */
    text-align: center;
    color: var(--secondary-text); /* Changed to index.html secondary-text */
    font-size: 0.9rem;
    padding: 40px 0; /* Changed to index.html padding */
    margin-top: 0; /* Removed margin-top */
    border-top: 1px solid var(--border-color);
    background-color: #0a0a14; /* Added from index.html */
}

.video-js .vjs-big-play-button {
    background-color: rgba(0, 123, 255, 0.8);
    border-color: var(--accent);
}
.video-js .vjs-control-bar {
    background-color: rgba(30, 30, 30, 0.7);
    backdrop-filter: blur(5px);
}
.resolving-overlay .spinner {
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top: 4px solid #fff;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Channel Loading Animation */
.channel-loading-animation {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: rgba(0, 0, 0, 0.9);
    color: white;
    z-index: 10;
    border-radius: 12px;
    backdrop-filter: blur(5px);
    text-align: center;
    padding: 2rem;
}

.channel-loading-animation .spinner {
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top: 4px solid var(--accent);
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
    margin-bottom: 1.5rem;
}

.progress-bar-container {
    width: 80%;
    max-width: 300px;
    background-color: rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    height: 10px;
    margin-top: 1rem;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    width: 0%;
    background: var(--accent);
    border-radius: 10px;
    transition: width 0.3s ease-out;
}

.channel-loading-animation p {
    margin-top: 1rem;
    font-size: 1.1rem;
    font-weight: 500;
}

/* Responsive Design (merged and prioritized index.html media queries) */
@media (max-width: 1024px) {
    .app-main {
        grid-template-columns: 1fr;
        padding: 1rem;
        gap: 1rem;
        min-height: auto; /* Remove min-height on smaller screens */
    }
    .player-container {
        position: static;
        top: auto;
    }
    .sidebar {
        height: auto;
        max-height: 80vh;
        width: 100%;
        border-radius: 8px;
    }
    .sidebar-header {
        margin-bottom: 10px;
    }
    .custom-m3u-loader {
        flex-direction: column;
        gap: 0.75rem;
        padding: 0 1rem 1rem;
    }
    #m3uUrlInput {
        width: 100%;
    }
    #loadM3uBtn {
        width: 100%;
    }
}

@media (max-width: 768px) {
    .nav-links {
        display: none; /* Simple hiding for demo, can be replaced with a hamburger menu */
    }

    .speed-meter {
        display: none; /* Hide speed meter on smaller screens if it causes layout issues */
    }

    .hero-headline {
        font-size: 2.3rem;
    }

    .hero-subheadline {
        font-size: 1rem;
    }

    .section-title {
        font-size: 2rem;
    }

    .m3u-form {
        flex-direction: column;
        align-items: center;
    }

    .m3u-input {
        width: 90%;
    }

    .header { /* Adjusted from .app-header */
        padding: 0.5rem 0;
    }
    .logo {
        height: 40px;
    }
    .navbar { /* Adjusted from .header-container */
        padding: 0 1rem;
    }
    .player-controls {
        flex-direction: column;
        gap: 0.75rem;
        padding: 0 1rem;
    }
    .btn-icon, .btn-primary {
        width: 100%;
        text-align: center;
        justify-content: center;
    }

    .themeToggle, #backToMenuBtn{
        width: 20%;
    }

    .player-controls{
        display: flex;
        flex-direction: row;
    }
    #currentChannelName {
        font-size: 1.1rem;
        padding: 0 0.5rem;
    }
    .sidebar-top {
        margin-bottom: 0.75rem;
    }
    #sidebarTitle {
        font-size: 1.3rem;
    }
    .search-container {
        margin-top: 0.75rem;
    }
}

@media (max-width: 480px) {
    .app-main {
        padding: 0.5rem;
    }
    .sidebar-header {
        padding: 0.75rem;
    }
    .sidebar-content {
        padding: 0.5rem 0.75rem;
    }
    .category-menu-item, .channel-card {
        padding: 0.6rem;
    }
    .channel-logo {
        width: 32px;
        height: 32px;
    }
    .channel-name {
        font-size: 0.9rem;
    }
    .favorite-btn {
        font-size: 1.1rem;
    }
    .custom-m3u-loader {
        padding: 0 0.75rem 0.75rem;
    }
}
