/* =========================================
   StreamBox — Admin Panel Stylesheet
   ========================================= */

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

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

:root {
    --bg-primary: #0a0a0a;
    --bg-secondary: #111;
    --bg-sidebar: #0d0d0d;
    --bg-card: #1a1a1a;
    --bg-card-hover: #222;
    --bg-input: #161616;
    --accent-primary: #e50914;
    --accent-primary-hover: #f40612;
    --accent-secondary: #f5c518;
    --accent-green: #22c55e;
    --accent-blue: #3b82f6;
    --accent-purple: #8b5cf6;
    --accent-orange: #f97316;
    --text-primary: #ffffff;
    --text-secondary: #b3b3b3;
    --text-muted: #737373;
    --border-color: #222;
    --border-light: #333;
    --shadow-sm: 0 2px 8px rgba(0,0,0,0.3);
    --shadow-md: 0 8px 24px rgba(0,0,0,0.4);
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --transition: all 0.3s cubic-bezier(0.4,0,0.2,1);
    --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --sidebar-width: 260px;
}

html { scroll-behavior: smooth; }
body {
    font-family: var(--font);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}
a { color: inherit; text-decoration: none; transition: var(--transition); }
img { max-width: 100%; display: block; }
button { font-family: var(--font); cursor: pointer; border: none; }
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg-primary); }
::-webkit-scrollbar-thumb { background: #333; border-radius: 3px; }

/* ---- Admin Layout ---- */
.admin-layout {
    display: flex;
    min-height: 100vh;
}

/* ---- Sidebar ---- */
.admin-sidebar {
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 100;
    overflow-y: auto;
    transition: transform 0.3s;
}
.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
    font-size: 1.2rem;
    font-weight: 700;
}
.sidebar-logo i { color: var(--accent-primary); font-size: 1.4rem; }
.sidebar-logo span {
    background: linear-gradient(135deg, #e50914, #f5c518);
    -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}
.sidebar-logo small { display: block; font-size: 0.65rem; color: var(--text-muted); font-weight: 400; -webkit-text-fill-color: var(--text-muted); }

.sidebar-menu { padding: 16px 0; }
.sidebar-section { padding: 8px 20px; font-size: 0.7rem; text-transform: uppercase; letter-spacing: 1.5px; color: var(--text-muted); margin-top: 8px; }
.sidebar-link {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 20px; font-size: 0.88rem; font-weight: 500;
    color: var(--text-secondary); transition: var(--transition);
    border-left: 3px solid transparent;
}
.sidebar-link:hover { background: var(--bg-card); color: var(--text-primary); }
.sidebar-link.active {
    background: rgba(229,9,20,0.08); color: var(--accent-primary);
    border-left-color: var(--accent-primary);
}
.sidebar-link i { width: 20px; text-align: center; font-size: 0.9rem; }
.sidebar-link .badge {
    margin-left: auto; background: var(--accent-primary); color: #fff;
    font-size: 0.65rem; padding: 2px 7px; border-radius: 10px; font-weight: 600;
}

.sidebar-user {
    padding: 16px 20px; border-top: 1px solid var(--border-color);
    display: flex; align-items: center; gap: 10px; margin-top: auto;
}
.sidebar-user .avatar {
    width: 36px; height: 36px; border-radius: 50%; background: var(--bg-card);
    display: flex; align-items: center; justify-content: center; color: var(--accent-primary);
}
.sidebar-user .user-info { flex: 1; }
.sidebar-user .user-info .name { font-size: 0.85rem; font-weight: 600; }
.sidebar-user .user-info .role { font-size: 0.7rem; color: var(--text-muted); text-transform: capitalize; }

/* ---- Main Content ---- */
.admin-main {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
}

/* Top Bar */
.admin-topbar {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 30px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    position: sticky; top: 0; z-index: 50;
}
.admin-topbar h1 { font-size: 1.3rem; font-weight: 700; }
.admin-topbar .topbar-actions { display: flex; align-items: center; gap: 12px; }
.topbar-btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 8px 14px; background: var(--bg-card); border: 1px solid var(--border-color);
    border-radius: var(--radius-sm); color: var(--text-secondary);
    font-size: 0.8rem; transition: var(--transition);
}
.topbar-btn:hover { background: var(--bg-card-hover); color: var(--text-primary); }
.mobile-sidebar-toggle {
    display: none; background: none; border: none; color: var(--text-primary);
    font-size: 1.2rem; padding: 8px; cursor: pointer;
}

/* ---- Content Area ---- */
.admin-content { padding: 30px; }

/* ---- Stats Cards ---- */
.stats-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 20px; margin-bottom: 30px;
}
.stat-card {
    background: var(--bg-card); border: 1px solid var(--border-color); border-radius: var(--radius-md);
    padding: 24px; position: relative; overflow: hidden; transition: var(--transition);
}
.stat-card:hover { border-color: var(--border-light); transform: translateY(-2px); box-shadow: var(--shadow-sm); }
.stat-card .stat-icon {
    width: 48px; height: 48px; border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.2rem; margin-bottom: 16px;
}
.stat-card .stat-icon.red { background: rgba(229,9,20,0.15); color: var(--accent-primary); }
.stat-card .stat-icon.blue { background: rgba(59,130,246,0.15); color: var(--accent-blue); }
.stat-card .stat-icon.green { background: rgba(34,197,94,0.15); color: var(--accent-green); }
.stat-card .stat-icon.orange { background: rgba(249,115,22,0.15); color: var(--accent-orange); }
.stat-card .stat-icon.purple { background: rgba(139,92,246,0.15); color: var(--accent-purple); }
.stat-card .stat-value { font-size: 2rem; font-weight: 800; margin-bottom: 4px; }
.stat-card .stat-label { font-size: 0.85rem; color: var(--text-muted); }
.stat-card::after {
    content: ''; position: absolute; top: 0; right: 0; width: 80px; height: 80px;
    border-radius: 50%; opacity: 0.03; transform: translate(20px, -20px);
}
.stat-card:nth-child(1)::after { background: var(--accent-primary); }
.stat-card:nth-child(2)::after { background: var(--accent-blue); }
.stat-card:nth-child(3)::after { background: var(--accent-green); }
.stat-card:nth-child(4)::after { background: var(--accent-orange); }

/* ---- Data Tables ---- */
.data-table-wrapper {
    background: var(--bg-card); border: 1px solid var(--border-color); border-radius: var(--radius-md);
    overflow: hidden; margin-bottom: 24px;
}
.data-table-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 20px; border-bottom: 1px solid var(--border-color); flex-wrap: wrap; gap: 12px;
}
.data-table-header h3 { font-size: 1rem; font-weight: 600; }
.data-table-actions { display: flex; gap: 8px; align-items: center; }
.table-search {
    position: relative;
}
.table-search input {
    padding: 8px 12px 8px 34px; background: var(--bg-input); border: 1px solid var(--border-color);
    border-radius: var(--radius-sm); color: var(--text-primary); font-size: 0.85rem; font-family: var(--font);
    width: 200px; transition: border-color 0.3s;
}
.table-search input:focus { outline: none; border-color: var(--accent-primary); }
.table-search i { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--text-muted); font-size: 0.8rem; }

.data-table {
    width: 100%; border-collapse: collapse;
}
.data-table th {
    padding: 12px 16px; text-align: left; font-size: 0.75rem; text-transform: uppercase;
    letter-spacing: 0.5px; color: var(--text-muted); font-weight: 600;
    border-bottom: 1px solid var(--border-color); background: var(--bg-input);
}
.data-table td {
    padding: 12px 16px; border-bottom: 1px solid var(--border-color);
    font-size: 0.88rem; color: var(--text-secondary); vertical-align: middle;
}
.data-table tr:hover td { background: rgba(255,255,255,0.02); }
.data-table tr:last-child td { border-bottom: none; }
.data-table .poster-thumb {
    width: 40px; height: 56px; border-radius: 4px; object-fit: cover;
}
.data-table .channel-thumb {
    width: 36px; height: 36px; border-radius: 50%; object-fit: cover;
}

/* Status badges */
.badge-active { background: rgba(34,197,94,0.15); color: #22c55e; padding: 3px 10px; border-radius: 20px; font-size: 0.75rem; font-weight: 600; }
.badge-inactive { background: rgba(239,68,68,0.15); color: #ef4444; padding: 3px 10px; border-radius: 20px; font-size: 0.75rem; font-weight: 600; }
.badge-featured { background: rgba(245,197,24,0.15); color: #f5c518; padding: 3px 10px; border-radius: 20px; font-size: 0.75rem; font-weight: 600; }
.badge-role { padding: 3px 10px; border-radius: 20px; font-size: 0.75rem; font-weight: 600; }
.badge-admin { background: rgba(139,92,246,0.15); color: #8b5cf6; }
.badge-manager { background: rgba(59,130,246,0.15); color: #3b82f6; }

/* Action buttons */
.action-btns { display: flex; gap: 6px; }
.action-btn {
    width: 32px; height: 32px; border-radius: var(--radius-sm);
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--bg-input); border: 1px solid var(--border-color);
    color: var(--text-muted); font-size: 0.8rem; transition: var(--transition);
}
.action-btn:hover { color: var(--text-primary); background: var(--bg-card-hover); }
.action-btn.edit:hover { color: var(--accent-blue); border-color: var(--accent-blue); }
.action-btn.delete:hover { color: var(--accent-primary); border-color: var(--accent-primary); }

/* ---- Forms ---- */
.form-card {
    background: var(--bg-card); border: 1px solid var(--border-color); border-radius: var(--radius-md);
    padding: 30px; margin-bottom: 24px;
}
.form-card h3 { font-size: 1.1rem; margin-bottom: 24px; padding-bottom: 12px; border-bottom: 1px solid var(--border-color); }
.form-group { margin-bottom: 20px; }
.form-group label {
    display: block; margin-bottom: 6px; font-weight: 500; font-size: 0.88rem; color: var(--text-secondary);
}
.form-group label .required { color: var(--accent-primary); }
.form-control {
    width: 100%; padding: 10px 14px; background: var(--bg-input); border: 1px solid var(--border-color);
    border-radius: var(--radius-sm); color: var(--text-primary); font-size: 0.9rem; font-family: var(--font);
    transition: border-color 0.3s;
}
.form-control:focus { outline: none; border-color: var(--accent-primary); }
textarea.form-control { min-height: 100px; resize: vertical; }
select.form-control {
    appearance: none; -webkit-appearance: none;
    padding-right: 36px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23b3b3b3' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 12px center;
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.form-hint { font-size: 0.75rem; color: var(--text-muted); margin-top: 4px; }
.form-check {
    display: flex; align-items: center; gap: 10px; padding: 10px 14px;
    background: var(--bg-input); border-radius: var(--radius-sm); margin-bottom: 10px;
}
.form-check input[type="checkbox"] {
    width: 18px; height: 18px; accent-color: var(--accent-primary); cursor: pointer;
}
.form-check label { cursor: pointer; margin: 0; }

/* File upload */
.file-upload {
    border: 2px dashed var(--border-color); border-radius: var(--radius-md);
    padding: 30px; text-align: center; cursor: pointer; transition: var(--transition);
}
.file-upload:hover { border-color: var(--accent-primary); background: rgba(229,9,20,0.03); }
.file-upload i { font-size: 2rem; color: var(--text-muted); margin-bottom: 10px; }
.file-upload p { color: var(--text-muted); font-size: 0.85rem; }
.file-upload input[type="file"] { display: none; }

/* Tab navigation for video input */
.video-tabs { display: flex; gap: 0; margin-bottom: 0; }
.video-tab {
    flex: 1; padding: 10px; text-align: center; background: var(--bg-input);
    border: 1px solid var(--border-color); color: var(--text-muted);
    cursor: pointer; font-size: 0.85rem; font-weight: 500; transition: var(--transition);
}
.video-tab:first-child { border-radius: var(--radius-sm) 0 0 0; }
.video-tab:last-child { border-radius: 0 var(--radius-sm) 0 0; }
.video-tab.active { background: var(--accent-primary); color: #fff; border-color: var(--accent-primary); }
.video-tab-content { display: none; padding: 16px; background: var(--bg-input); border: 1px solid var(--border-color); border-top: none; border-radius: 0 0 var(--radius-sm) var(--radius-sm); }
.video-tab-content.active { display: block; }

/* TMDB Search */
.tmdb-search { position: relative; }
.tmdb-results {
    position: absolute; top: 100%; left: 0; right: 0; z-index: 50;
    background: var(--bg-card); border: 1px solid var(--border-color); border-radius: 0 0 var(--radius-sm) var(--radius-sm);
    max-height: 300px; overflow-y: auto; display: none;
}
.tmdb-results.show { display: block; }
.tmdb-result-item {
    display: flex; align-items: center; gap: 12px; padding: 10px 14px;
    cursor: pointer; transition: background 0.2s; border-bottom: 1px solid var(--border-color);
}
.tmdb-result-item:hover { background: var(--bg-card-hover); }
.tmdb-result-item img { width: 40px; height: 56px; border-radius: 4px; object-fit: cover; }
.tmdb-result-item .tmdb-info { flex: 1; }
.tmdb-result-item .tmdb-title { font-size: 0.88rem; font-weight: 500; }
.tmdb-result-item .tmdb-year { font-size: 0.75rem; color: var(--text-muted); }

/* Image preview */
.image-preview {
    width: 120px; height: 170px; border-radius: var(--radius-sm); object-fit: cover;
    border: 2px solid var(--border-color); margin-top: 10px;
}

/* ---- Buttons ---- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 10px 22px; border-radius: var(--radius-sm); font-weight: 600;
    font-size: 0.88rem; transition: var(--transition); border: none; cursor: pointer;
}
.btn-primary { background: var(--accent-primary); color: #fff; }
.btn-primary:hover { background: var(--accent-primary-hover); transform: translateY(-1px); }
.btn-secondary { background: var(--bg-card-hover); color: var(--text-primary); border: 1px solid var(--border-color); }
.btn-secondary:hover { background: var(--border-light); }
.btn-success { background: var(--accent-green); color: #fff; }
.btn-danger { background: #dc2626; color: #fff; }
.btn-danger:hover { background: #ef4444; }
.btn-sm { padding: 6px 14px; font-size: 0.8rem; }
.btn-lg { padding: 14px 30px; font-size: 1rem; }

/* ---- Alert ---- */
.alert {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 16px; border-radius: var(--radius-sm); margin-bottom: 20px;
    font-size: 0.88rem; animation: slideDown 0.4s ease;
}
@keyframes slideDown { from { transform: translateY(-10px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.alert-success { background: rgba(34,197,94,0.12); border: 1px solid rgba(34,197,94,0.3); color: #4ade80; }
.alert-error { background: rgba(229,9,20,0.12); border: 1px solid rgba(229,9,20,0.3); color: #ff6b6b; }
.alert-warning { background: rgba(245,197,24,0.12); border: 1px solid rgba(245,197,24,0.3); color: #f5c518; }
.alert-close { background: none; border: none; color: inherit; font-size: 1.1rem; cursor: pointer; }

/* ---- Charts ---- */
.chart-card {
    background: var(--bg-card); border: 1px solid var(--border-color); border-radius: var(--radius-md);
    padding: 24px; margin-bottom: 24px;
}
.chart-card h3 { font-size: 1rem; margin-bottom: 20px; }
.chart-container { position: relative; height: 250px; }

/* ---- Dashboard Grid ---- */
.dashboard-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 24px; }

/* Recent list */
.recent-list { }
.recent-item {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 0; border-bottom: 1px solid var(--border-color);
}
.recent-item:last-child { border-bottom: none; }
.recent-item img { width: 40px; height: 56px; border-radius: 4px; object-fit: cover; }
.recent-item .info { flex: 1; }
.recent-item .info .title { font-size: 0.88rem; font-weight: 500; }
.recent-item .info .meta { font-size: 0.75rem; color: var(--text-muted); }

/* ---- Pagination ---- */
.pagination { display: flex; justify-content: center; gap: 6px; padding: 20px; }
.page-btn {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 36px; height: 36px; padding: 0 10px;
    background: var(--bg-card); border: 1px solid var(--border-color);
    border-radius: var(--radius-sm); color: var(--text-secondary);
    font-size: 0.85rem; transition: var(--transition);
}
.page-btn:hover { background: var(--bg-card-hover); color: var(--text-primary); }
.page-btn.active { background: var(--accent-primary); color: #fff; border-color: var(--accent-primary); }

/* ---- Login Page ---- */
.login-page {
    min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px;
    background: var(--bg-primary);
}
.login-card {
    background: var(--bg-card); border: 1px solid var(--border-color); border-radius: var(--radius-lg);
    padding: 40px; max-width: 420px; width: 100%; box-shadow: var(--shadow-md);
}
.login-card .logo { text-align: center; margin-bottom: 30px; }
.login-card .logo h1 {
    font-size: 1.8rem;
    background: linear-gradient(135deg, #e50914, #f5c518);
    -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}
.login-card .logo p { color: var(--text-muted); font-size: 0.85rem; margin-top: 4px; }

/* ---- M3U Import ---- */
.m3u-preview { max-height: 300px; overflow-y: auto; margin-top: 16px; }
.m3u-item {
    display: flex; align-items: center; gap: 10px; padding: 8px;
    border-bottom: 1px solid var(--border-color); font-size: 0.85rem;
}
.m3u-item .ch-name { flex: 1; }

/* ---- Empty State ---- */
.empty-state { text-align: center; padding: 60px 20px; color: var(--text-muted); }
.empty-state i { font-size: 3rem; margin-bottom: 16px; opacity: 0.3; }
.empty-state h3 { font-size: 1.1rem; margin-bottom: 6px; color: var(--text-secondary); }

/* ---- Responsive ---- */
@media (max-width: 1024px) {
    .dashboard-grid { grid-template-columns: 1fr; }
    .form-row, .form-row-3 { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
    .admin-sidebar { transform: translateX(-100%); z-index: 200; }
    .admin-sidebar.open { transform: translateX(0); }
    .admin-main { margin-left: 0; }
    .mobile-sidebar-toggle { display: block; }
    .admin-content { padding: 16px; }
    .stats-grid { grid-template-columns: 1fr 1fr; gap: 12px; }
    .stat-card { padding: 16px; }
    .stat-card .stat-value { font-size: 1.5rem; }
    .data-table-wrapper { overflow-x: auto; }
    .sidebar-overlay {
        position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 199;
        display: none;
    }
    .sidebar-overlay.show { display: block; }
}

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; }
    .admin-topbar { padding: 12px 16px; }
    .admin-topbar h1 { font-size: 1.1rem; }
}
