@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Outfit:wght@300;400;500;600;700;800&display=swap');

:root {
    /* Color Palette */
    --bg-primary: #ffffff;
    --bg-secondary: #f8fafc;
    --bg-card: rgba(255, 255, 255, 0.8);
    --bg-glass: rgba(255, 255, 255, 0.9);
    --border-light: rgba(0, 0, 0, 0.1);
    --border-hover: rgba(139, 92, 246, 0.4);
    
    --accent-purple: #7c3aed;
    --accent-blue: #2563eb;
    --accent-cyan: #0891b2;
    --accent-gradient: linear-gradient(135deg, #7c3aed 0%, #2563eb 100%);
    --accent-gradient-hover: linear-gradient(135deg, #8b5cf6 0%, #3b82f6 100%);
    
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    
    --success: #059669;
    --danger: #dc2626;
    --warning: #d97706;
    
    /* Glows */
    --glow-purple: 0 0 15px rgba(124, 58, 237, 0.2);
    --glow-cyan: 0 0 15px rgba(8, 145, 178, 0.2);
    --shadow-card: 0 4px 16px 0 rgba(0, 0, 0, 0.08);
    
    /* Layout Variables */
    --sidebar-width: 280px;
    --header-height: 70px;
}

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

body {
    background-color: var(--bg-primary);
    background-image: 
        radial-gradient(at 0% 0%, rgba(124, 58, 237, 0.04) 0, transparent 50%),
        radial-gradient(at 100% 100%, rgba(37, 99, 235, 0.04) 0, transparent 50%);
    background-attachment: fixed;
    color: var(--text-primary);
    font-family: 'Inter', sans-serif;
    min-height: 100vh;
    overflow-x: hidden;
}

h1, h2, h3, h4, h5, h6 {
    font-family: 'Outfit', sans-serif;
    font-weight: 600;
    letter-spacing: -0.02em;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}
::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--accent-purple);
}

/* Glassmorphism Class */
.glass-panel {
    background: var(--bg-card);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-light);
    border-radius: 12px;
}

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

/* Header Styling */
.app-header {
    height: var(--header-height);
    background: var(--bg-glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.logo-area {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
    color: var(--text-primary);
}

.logo-icon {
    font-size: 1.8rem;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    font-weight: 800;
    font-family: 'Outfit', sans-serif;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border-radius: 10px;
    border: 1px solid var(--accent-purple);
    box-shadow: var(--glow-purple);
}

.logo-text {
    font-size: 1.25rem;
    font-weight: 700;
    background: linear-gradient(to right, #0f172a, #475569);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

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

/* Main Layout: Sidebar + Content */
.main-wrapper {
    display: flex;
    flex: 1;
    position: relative;
}

/* Category Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: rgba(248, 250, 252, 0.6);
    border-right: 1px solid var(--border-light);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    height: calc(100vh - var(--header-height));
    position: sticky;
    top: var(--header-height);
    overflow-y: auto;
}

.sidebar-title {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.category-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.category-item a {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.category-item a:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    padding-left: 1.25rem;
}

.category-item.active a {
    background: var(--accent-gradient);
    color: #fff;
    box-shadow: var(--glow-purple);
}

.category-count {
    font-size: 0.75rem;
    background: rgba(255, 255, 255, 0.1);
    padding: 2px 8px;
    border-radius: 9999px;
    color: var(--text-secondary);
}

.category-item.active .category-count {
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
}

/* Content Area */
.content-area {
    flex: 1;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 2rem;
    overflow-x: hidden;
}

/* Search Area */
.search-container {
    display: flex;
    align-items: center;
    max-width: 500px;
    width: 100%;
    position: relative;
}

.search-input {
    width: 100%;
    padding: 0.75rem 1.25rem 0.75rem 2.75rem;
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: 9999px;
    color: var(--text-primary);
    font-size: 0.95rem;
    transition: all 0.3s ease;
}

.search-input:focus {
    outline: none;
    border-color: var(--accent-purple);
    box-shadow: var(--glow-purple);
    background: rgba(30, 41, 59, 0.6);
}

.search-icon {
    position: absolute;
    left: 1rem;
    color: var(--text-secondary);
    pointer-events: none;
}

/* Channels Grid */
.channels-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1.5rem;
}

/* Channel Card */
.channel-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 1.5rem;
    text-decoration: none;
    color: var(--text-primary);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
    height: 100%;
}

.channel-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: var(--accent-gradient);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.channel-card:hover {
    transform: translateY(-5px);
    border-color: var(--border-hover);
    box-shadow: var(--glow-purple), var(--shadow-card);
}

.channel-card:hover::before {
    opacity: 1;
}

.channel-logo-wrapper {
    width: 80px;
    height: 80px;
    border-radius: 16px;
    background: rgba(15, 23, 42, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1.25rem;
    border: 1px solid var(--border-light);
    overflow: hidden;
    padding: 8px;
    transition: transform 0.3s ease;
}

.channel-card:hover .channel-logo-wrapper {
    transform: scale(1.05);
    border-color: rgba(255, 255, 255, 0.2);
}

.channel-logo {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.channel-logo-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.5rem;
    color: var(--text-secondary);
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.channel-name {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.channel-category {
    font-size: 0.75rem;
    color: var(--accent-cyan);
    font-weight: 600;
    text-transform: uppercase;
    background: rgba(6, 182, 212, 0.1);
    padding: 2px 8px;
    border-radius: 9999px;
}

/* Watch Page Layout */
.watch-container {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 2rem;
}

@media (max-width: 1024px) {
    .watch-container {
        grid-template-columns: 1fr;
    }
}

.player-section {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.player-wrapper {
    position: relative;
    border-radius: 16px;
    overflow: hidden;
    border: 1px solid var(--border-light);
    background: #000;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    aspect-ratio: 16 / 9;
}

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

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

.player-channel-logo {
    width: 60px;
    height: 60px;
    border-radius: 12px;
    border: 1px solid var(--border-light);
    padding: 4px;
    background: rgba(15, 23, 42, 0.5);
    object-fit: contain;
}

.player-channel-name {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

/* Playlist Sidebar (Watch Page) */
.playlist-sidebar {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    max-height: 700px;
}

.playlist-header {
    font-size: 1.1rem;
    font-weight: 700;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-light);
}

.playlist-items {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    overflow-y: auto;
    flex: 1;
    padding-right: 4px;
}

.playlist-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem;
    border-radius: 8px;
    text-decoration: none;
    color: var(--text-secondary);
    border: 1px solid transparent;
    transition: all 0.2s ease;
}

.playlist-item:hover {
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-primary);
    border-color: var(--border-light);
}

.playlist-item.active {
    background: rgba(139, 92, 246, 0.1);
    color: var(--accent-purple);
    border-color: rgba(139, 92, 246, 0.2);
}

.playlist-item-logo {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    object-fit: contain;
    background: rgba(15, 23, 42, 0.5);
    padding: 2px;
    border: 1px solid var(--border-light);
}

.playlist-item-name {
    font-size: 0.85rem;
    font-weight: 600;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1.2rem;
    font-size: 0.9rem;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s ease;
    border: 1px solid transparent;
    font-family: 'Inter', sans-serif;
}

.btn-primary {
    background: var(--accent-gradient);
    color: #fff;
    box-shadow: var(--glow-purple);
}

.btn-primary:hover {
    background: var(--accent-gradient-hover);
    transform: translateY(-1px);
    box-shadow: 0 0 20px rgba(139, 92, 246, 0.5);
}

.btn-secondary {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.2);
}

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

.btn-danger:hover {
    background: #dc2626;
    transform: translateY(-1px);
}

/* Ad Containers */
.ad-container {
    width: 100%;
    margin: 1.5rem 0;
    display: flex;
    justify-content: center;
    align-items: center;
}

.ad-sidebar-wrapper {
    margin-top: 1rem;
    width: 100%;
}

/* Player Overlay Ad */
.player-ad-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(12px);
    z-index: 10;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    transition: opacity 0.5s ease;
}

.player-ad-timer {
    position: absolute;
    top: 1.5rem;
    right: 1.5rem;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 0.5rem 1rem;
    border-radius: 9999px;
    font-size: 0.8rem;
    font-weight: 600;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.player-ad-close {
    cursor: pointer;
    background: var(--accent-gradient);
    border: none;
    color: #fff;
    padding: 0.6rem 1.5rem;
    border-radius: 9999px;
    font-size: 0.9rem;
    font-weight: 700;
    display: none;
    box-shadow: var(--glow-purple);
    transition: all 0.2s;
}

.player-ad-close:hover {
    transform: scale(1.05);
}

/* Admin Styles */
.admin-grid {
    display: grid;
    grid-template-columns: var(--sidebar-width) 1fr;
    min-height: 100vh;
}

.admin-sidebar {
    background: #f1f5f9;
    border-right: 1px solid var(--border-light);
    padding: 2rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.admin-nav {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    list-style: none;
}

.admin-nav-item a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.8rem 1rem;
    border-radius: 8px;
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.95rem;
    transition: all 0.2s;
}

.admin-nav-item a:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
}

.admin-nav-item.active a {
    background: var(--accent-gradient);
    color: #fff;
    box-shadow: var(--glow-purple);
}

.admin-content {
    padding: 2.5rem;
    display: flex;
    flex-direction: column;
    gap: 2.5rem;
    overflow-y: auto;
    height: 100vh;
    background: var(--bg-primary);
}

.admin-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-light);
}

.admin-title {
    font-size: 1.75rem;
    font-weight: 800;
    background: linear-gradient(to right, #0f172a, #475569);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Admin Dashboard Stats */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
}

.stat-card {
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.stat-icon {
    width: 54px;
    height: 54px;
    border-radius: 12px;
    background: rgba(139, 92, 246, 0.15);
    border: 1px solid rgba(139, 92, 246, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: var(--accent-purple);
}

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

.stat-value {
    font-size: 1.75rem;
    font-weight: 800;
    line-height: 1.2;
}

.stat-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* Tables */
.table-responsive {
    overflow-x: auto;
    width: 100%;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

.admin-table th {
    padding: 1rem;
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-muted);
    border-bottom: 2px solid var(--border-light);
}

.admin-table td {
    padding: 1rem;
    border-bottom: 1px solid var(--border-light);
    font-size: 0.9rem;
    vertical-align: middle;
}

.admin-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.02);
}

.admin-table-logo {
    width: 44px;
    height: 44px;
    border-radius: 8px;
    object-fit: contain;
    border: 1px solid var(--border-light);
    background: rgba(0,0,0,0.2);
    padding: 2px;
}

/* Badges */
.badge {
    display: inline-flex;
    padding: 2px 8px;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 9999px;
}

.badge-success {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
}

.badge-danger {
    background: rgba(239, 68, 110, 0.1);
    color: var(--danger);
}

/* Forms */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1.25rem;
}

.form-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.form-control {
    width: 100%;
    padding: 0.75rem 1rem;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--border-light);
    border-radius: 8px;
    color: var(--text-primary);
    font-family: 'Inter', sans-serif;
    font-size: 0.95rem;
    transition: all 0.2s;
}

.form-control:focus {
    outline: none;
    border-color: var(--accent-purple);
    background: rgba(15, 23, 42, 0.8);
    box-shadow: var(--glow-purple);
}

textarea.form-control {
    resize: vertical;
    min-height: 120px;
}

.switch-container {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
}

.switch {
    position: relative;
    display: inline-block;
    width: 46px;
    height: 24px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.15);
    transition: .4s;
    border-radius: 34px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked + .slider {
    background: var(--accent-gradient);
}

input:checked + .slider:before {
    transform: translateX(22px);
}

/* Modals */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(8px);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    padding: 1rem;
}

.modal-content {
    width: 100%;
    max-width: 500px;
    padding: 2rem;
    position: relative;
    animation: modalFadeIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalFadeIn {
    from {
        opacity: 0;
        transform: translateY(10px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
    transition: color 0.2s;
}

.modal-close:hover {
    color: var(--text-primary);
}

/* Login Card styling */
.login-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 1.5rem;
}

.login-card {
    max-width: 400px;
    width: 100%;
    padding: 2.5rem;
}

.login-header {
    text-align: center;
    margin-bottom: 2rem;
}

.login-title {
    font-size: 1.5rem;
    font-weight: 800;
    margin-bottom: 0.5rem;
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    margin-top: 2rem;
}

.pagination-item {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 38px;
    height: 38px;
    padding: 0 6px;
    border-radius: 8px;
    border: 1px solid var(--border-light);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    background: var(--bg-card);
    transition: all 0.2s;
}

.pagination-item:hover:not(.disabled) {
    border-color: var(--border-hover);
    color: var(--text-primary);
}

.pagination-item.active {
    background: var(--accent-gradient);
    color: #fff;
    border-color: transparent;
    box-shadow: var(--glow-purple);
}

.pagination-item.disabled {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
}

/* Grid & Cards Responsive adjustments */
@media (max-width: 640px) {
    .app-header {
        padding: 0 1rem;
    }
    
    .sidebar {
        display: none; /* Hide on mobile: we can create a simple category banner or search-based navigation */
    }
    
    .content-area {
        padding: 1.5rem 1rem;
    }
    
    .channels-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: 1rem;
    }
    
    .channel-card {
        padding: 1rem;
    }
    
    .channel-logo-wrapper {
        width: 60px;
        height: 60px;
        border-radius: 12px;
        margin-bottom: 0.75rem;
    }
    
    .channel-name {
        font-size: 0.9rem;
    }
    
    .admin-grid {
        grid-template-columns: 1fr;
    }
    
    .admin-sidebar {
        display: none; /* Simple drawer or header navigation can be added for admin on mobile */
    }
    
    .admin-content {
        padding: 1.5rem 1rem;
    }
}

/* Category Slider for Mobile */
.mobile-categories-slider {
    display: none;
    overflow-x: auto;
    gap: 0.5rem;
    padding-bottom: 0.5rem;
    margin-bottom: 1rem;
    scrollbar-width: none;
}

.mobile-categories-slider::-webkit-scrollbar {
    display: none;
}

.mobile-category-chip {
    white-space: nowrap;
    padding: 0.5rem 1rem;
    border-radius: 9999px;
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 500;
}

.mobile-category-chip.active {
    background: var(--accent-gradient);
    color: #fff;
    border-color: transparent;
}

@media (max-width: 640px) {
    .mobile-categories-slider {
        display: flex;
    }
}

/* Alert styles */
.alert {
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1.5rem;
    font-size: 0.9rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    border: 1px solid transparent;
}

.alert-success {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
    border-color: rgba(16, 185, 129, 0.2);
}

.alert-danger {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
    border-color: rgba(239, 68, 68, 0.2);
}
