/* IPTV Portal - Dark Theme */

:root {
    --bg-body: #0a0a0f;
    --bg-sidebar: #0f0f1a;
    --bg-card: #141425;
    --bg-card-hover: #1a1a35;
    --bg-input: #1a1a2e;
    --border-color: #2d2d44;
    --accent: #7b2cbf;
    --accent-hover: #9d4edd;
    --accent-glow: rgba(123, 44, 191, 0.3);
    --text-primary: #e8e8f0;
    --text-secondary: #8888aa;
    --text-muted: #555577;
    --success: #00c853;
    --danger: #ff3d57;
    --warning: #ffc107;
    --sidebar-width: 260px;
}

* { box-sizing: border-box; }

body {
    background: var(--bg-body);
    color: var(--text-primary);
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    margin: 0;
    min-height: 100vh;
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-body); }
::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent); }

/* ===== SIDEBAR ===== */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    z-index: 1050;
    transition: transform 0.3s ease;
}

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

.sidebar-brand {
    color: var(--text-primary);
    text-decoration: none;
    font-size: 1.25rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.sidebar-brand i {
    color: var(--accent);
    font-size: 1.5rem;
}

.sidebar-brand:hover { color: var(--accent); }

.sidebar-toggle {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.25rem;
    cursor: pointer;
}

.sidebar-nav {
    list-style: none;
    padding: 0.75rem 0;
    margin: 0;
    flex: 1;
    overflow-y: auto;
}

.sidebar-nav li a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.7rem 1.25rem;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.9rem;
    transition: all 0.2s;
    border-left: 3px solid transparent;
}

.sidebar-nav li a:hover {
    color: var(--text-primary);
    background: rgba(123, 44, 191, 0.08);
}

.sidebar-nav li.active a {
    color: var(--accent);
    background: rgba(123, 44, 191, 0.12);
    border-left-color: var(--accent);
    font-weight: 600;
}

.sidebar-nav li a i { font-size: 1.15rem; width: 20px; text-align: center; }

.nav-divider {
    height: 1px;
    background: var(--border-color);
    margin: 0.5rem 1.25rem;
}

.sidebar-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--border-color);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.user-info i { font-size: 1.25rem; }

/* ===== MAIN CONTENT ===== */
.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
}

.content-wrapper { padding: 1.5rem; }

.topbar {
    display: flex;
    align-items: center;
    padding: 0.5rem 1rem;
    background: var(--bg-sidebar);
    border-bottom: 1px solid var(--border-color);
}

.topbar-title {
    font-weight: 600;
    font-size: 1.1rem;
    margin-left: 0.5rem;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 1040;
}

/* ===== PAGE HEADER ===== */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.page-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0;
}

/* ===== CARDS ===== */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
}

.card:hover { border-color: rgba(123, 44, 191, 0.3); }

.card-header {
    background: transparent;
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 1.25rem;
    font-weight: 600;
}

.card-body { padding: 1.25rem; }

/* Stat Cards */
.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1.25rem;
    transition: all 0.3s;
}

.stat-card:hover {
    border-color: var(--accent);
    box-shadow: 0 0 20px var(--accent-glow);
    transform: translateY(-2px);
}

.stat-card .stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    margin-bottom: 0.75rem;
}

.stat-card .stat-icon.purple { background: rgba(123, 44, 191, 0.15); color: var(--accent); }
.stat-card .stat-icon.blue { background: rgba(59, 130, 246, 0.15); color: #3b82f6; }
.stat-card .stat-icon.green { background: rgba(0, 200, 83, 0.15); color: var(--success); }
.stat-card .stat-icon.orange { background: rgba(255, 193, 7, 0.15); color: var(--warning); }

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

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

/* ===== TABLES ===== */
.table {
    --bs-table-bg: transparent;
    --bs-table-color: var(--text-primary);
    --bs-table-border-color: var(--border-color);
    --bs-table-hover-bg: rgba(123, 44, 191, 0.06);
    --bs-table-striped-bg: rgba(255, 255, 255, 0.02);
}

.table thead th {
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom-width: 1px;
    padding: 0.75rem 1rem;
}

.table td { padding: 0.75rem 1rem; vertical-align: middle; }

/* ===== BUTTONS ===== */
.btn-primary {
    background: var(--accent);
    border-color: var(--accent);
}

.btn-primary:hover, .btn-primary:focus {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
    box-shadow: 0 0 15px var(--accent-glow);
}

.btn-outline-primary {
    color: var(--accent);
    border-color: var(--accent);
}

.btn-outline-primary:hover {
    background: var(--accent);
    border-color: var(--accent);
}

/* ===== FORMS ===== */
.form-control, .form-select {
    background: var(--bg-input);
    border-color: var(--border-color);
    color: var(--text-primary);
}

.form-control:focus, .form-select:focus {
    background: var(--bg-input);
    border-color: var(--accent);
    color: var(--text-primary);
    box-shadow: 0 0 0 0.25rem var(--accent-glow);
}

.form-control::placeholder { color: var(--text-muted); }

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

/* ===== BADGES ===== */
.badge-status {
    padding: 0.35em 0.7em;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-active { background: rgba(0, 200, 83, 0.15); color: var(--success); }
.badge-error { background: rgba(255, 61, 87, 0.15); color: var(--danger); }
.badge-syncing, .badge-parsing, .badge-updating { background: rgba(255, 193, 7, 0.15); color: var(--warning); }

/* ===== CHANNEL GRID ===== */
.channel-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 1rem;
}

.channel-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 1rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    color: var(--text-primary);
    display: block;
}

.channel-card:hover {
    border-color: var(--accent);
    box-shadow: 0 4px 20px var(--accent-glow);
    transform: translateY(-3px);
    color: var(--text-primary);
}

.channel-card img {
    width: 64px;
    height: 64px;
    object-fit: contain;
    border-radius: 8px;
    margin-bottom: 0.5rem;
    background: rgba(255, 255, 255, 0.05);
    padding: 4px;
}

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

.channel-card .channel-category {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

.channel-card .fav-star {
    position: absolute;
    top: 8px;
    right: 8px;
    color: var(--warning);
    font-size: 0.9rem;
}

/* ===== CATEGORY SIDEBAR ===== */
.category-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.category-list li a {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0.75rem;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: 6px;
    font-size: 0.85rem;
    transition: all 0.2s;
}

.category-list li a:hover { background: rgba(123, 44, 191, 0.08); color: var(--text-primary); }
.category-list li a.active { background: var(--accent); color: #fff; }

.category-list .cat-count {
    background: rgba(255, 255, 255, 0.1);
    padding: 0.1em 0.5em;
    border-radius: 10px;
    font-size: 0.75rem;
}

/* ===== PLAYER ===== */
.player-container {
    background: #000;
    border-radius: 12px;
    overflow: hidden;
    position: relative;
}

.player-container video {
    width: 100%;
    max-height: 70vh;
    display: block;
}

.player-info {
    padding: 1.25rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    margin-top: 1rem;
}

.player-info h3 { margin: 0 0 0.5rem; font-size: 1.1rem; }

.epg-timeline {
    display: flex;
    gap: 0.5rem;
    overflow-x: auto;
    padding: 0.75rem 0;
}

.epg-item {
    flex: 0 0 auto;
    min-width: 200px;
    padding: 0.5rem 0.75rem;
    background: var(--bg-input);
    border-radius: 8px;
    border: 1px solid var(--border-color);
    font-size: 0.8rem;
}

.epg-item.now {
    border-color: var(--accent);
    background: rgba(123, 44, 191, 0.1);
}

.epg-item .epg-time { color: var(--accent); font-weight: 600; }
.epg-item .epg-title { color: var(--text-primary); margin-top: 0.2rem; }

/* ===== SEARCH ===== */
.search-box {
    position: relative;
}

.search-box i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.search-box input {
    padding-left: 2.5rem;
}

/* ===== TABS ===== */
.nav-tabs {
    border-bottom-color: var(--border-color);
}

.nav-tabs .nav-link {
    color: var(--text-secondary);
    border: none;
    border-bottom: 2px solid transparent;
    padding: 0.75rem 1.25rem;
    font-weight: 600;
    transition: all 0.2s;
}

.nav-tabs .nav-link:hover { color: var(--text-primary); border-bottom-color: var(--text-muted); }
.nav-tabs .nav-link.active { color: var(--accent); border-bottom-color: var(--accent); background: transparent; }

/* ===== MODAL ===== */
.modal-content {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
}

.modal-header { border-bottom-color: var(--border-color); }
.modal-footer { border-top-color: var(--border-color); }

/* ===== LOADING ===== */
.spinner-accent { color: var(--accent); }

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(10, 10, 15, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

/* ===== EMPTY STATE ===== */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-muted);
}

.empty-state i { font-size: 3rem; margin-bottom: 1rem; display: block; }
.empty-state h5 { color: var(--text-secondary); margin-bottom: 0.5rem; }

/* ===== RESPONSIVE ===== */
@media (max-width: 991.98px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.show { transform: translateX(0); }
    .sidebar-overlay.show { display: block; }
    .main-content { margin-left: 0; }
    .channel-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
}

@media (max-width: 575.98px) {
    .content-wrapper { padding: 1rem; }
    .page-header h1 { font-size: 1.25rem; }
    .channel-grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 0.5rem; }
}

/* ===== LOGIN / REGISTER ===== */
.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-body);
}

.auth-card {
    width: 100%;
    max-width: 420px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 2.5rem;
}

.auth-card h2 {
    text-align: center;
    margin-bottom: 0.5rem;
    font-weight: 700;
}

.auth-card .auth-subtitle {
    text-align: center;
    color: var(--text-secondary);
    margin-bottom: 2rem;
    font-size: 0.9rem;
}

.auth-logo {
    text-align: center;
    margin-bottom: 1.5rem;
}

.auth-logo i { font-size: 3rem; color: var(--accent); }

/* ===== ALERTS ===== */
.alert {
    border-radius: 10px;
    border: none;
}

/* ===== MISC ===== */
.text-accent { color: var(--accent) !important; }
.bg-accent { background-color: var(--accent) !important; }

.position-relative { position: relative; }

a { color: var(--accent); }
a:hover { color: var(--accent-hover); }
