/* ── Admin Panel CSS ─────────────────────────────────────────────────────── */
:root {
  --sidebar-w: 250px;
  --topbar-h:  60px;
  --primary:   #3b82f6;
  --danger:    #dc2626;
  --success:   #16a34a;
  --warning:   #d97706;
  --dark:      #0f172a;
  --card:      #1e293b;
  --border:    #334155;
  --text:      #e2e8f0;
  --muted:     #94a3b8;
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: system-ui, sans-serif; background: #0f172a; color: var(--text); display: flex; min-height: 100vh; }
a { color: inherit; text-decoration: none; }

/* ── Sidebar ─────────────────────────────────────────────────────────────── */
.admin-sidebar { width: var(--sidebar-w); background: #111827; position: fixed; top: 0; left: 0;
  height: 100vh; overflow-y: auto; display: flex; flex-direction: column; z-index: 100; }
.sidebar-brand { padding: 20px; border-bottom: 1px solid var(--border); }
.sidebar-brand a { font-size: 1.1rem; font-weight: 800; color: #fff; display: flex; gap: 8px; align-items: center; }
.sidebar-brand span { color: var(--primary); }
.sidebar-nav { padding: 16px 8px; flex: 1; }
.sidebar-nav a { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: 8px;
  font-size: .88rem; color: var(--muted); transition: all .15s; margin-bottom: 2px; }
.sidebar-nav a:hover, .sidebar-nav a.active { background: rgba(59,130,246,.15); color: var(--primary); }
.sidebar-nav a i { width: 16px; text-align: center; }
.sidebar-nav .sep { font-size: .7rem; color: #475569; text-transform: uppercase; letter-spacing: 1px;
  padding: 12px 14px 4px; }
.sidebar-footer { padding: 16px; border-top: 1px solid var(--border); }
.sidebar-footer a { display: flex; align-items: center; gap: 8px; color: #ef4444; font-size: .85rem; }

/* ── Topbar ──────────────────────────────────────────────────────────────── */
.admin-topbar { position: fixed; top: 0; left: var(--sidebar-w); right: 0; height: var(--topbar-h);
  background: var(--card); border-bottom: 1px solid var(--border); display: flex;
  align-items: center; padding: 0 24px; gap: 16px; z-index: 90; }
.topbar-title { font-size: 1rem; font-weight: 700; flex: 1; }
.topbar-user  { display: flex; align-items: center; gap: 10px; font-size: .85rem; color: var(--muted); }
.topbar-user .avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--primary);
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: .9rem; }

/* ── Main content ────────────────────────────────────────────────────────── */
.admin-main { margin-left: var(--sidebar-w); padding-top: var(--topbar-h); flex: 1; }
.admin-content { padding: 28px 24px; max-width: 1400px; }

/* ── Stat Cards ──────────────────────────────────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
@media (max-width: 900px)  { .stats-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 480px)  { .stats-grid { grid-template-columns: 1fr; } }
.stat-card { background: var(--card); border-radius: 12px; padding: 20px; border: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 8px; }
.stat-card .stat-icon { width: 44px; height: 44px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center; font-size: 1.1rem; }
.stat-card .stat-label { font-size: .78rem; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.stat-card .stat-value { font-size: 1.8rem; font-weight: 800; color: #fff; }
.stat-card .stat-change { font-size: .78rem; color: #4ade80; }
.stat-card .stat-change.negative { color: #f87171; }
.ic-blue   { background: rgba(59,130,246,.15); color: var(--primary); }
.ic-red    { background: rgba(220,38,38,.15);  color: #f87171; }
.ic-green  { background: rgba(22,163,74,.15);  color: #4ade80; }
.ic-yellow { background: rgba(217,119,6,.15);  color: #fbbf24; }

/* ── Cards / Panels ──────────────────────────────────────────────────────── */
.admin-card { background: var(--card); border-radius: 12px; border: 1px solid var(--border); }
.admin-card-header { padding: 16px 20px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; }
.admin-card-header h3 { font-size: .95rem; font-weight: 700; }
.admin-card-body { padding: 20px; }
.charts-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 24px; }
@media (max-width: 768px) { .charts-grid { grid-template-columns: 1fr; } }
.chart-wrap { position: relative; height: 240px; }

/* ── Tables ──────────────────────────────────────────────────────────────── */
.admin-table { width: 100%; border-collapse: collapse; font-size: .85rem; }
.admin-table th { padding: 10px 14px; text-align: left; font-size: .75rem; color: var(--muted);
  text-transform: uppercase; border-bottom: 1px solid var(--border); }
.admin-table td { padding: 12px 14px; border-bottom: 1px solid rgba(51,65,85,.5); vertical-align: middle; }
.admin-table tr:hover td { background: rgba(255,255,255,.03); }
.admin-table img { width: 50px; height: 35px; object-fit: cover; border-radius: 4px; }

/* ── Badges ──────────────────────────────────────────────────────────────── */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 20px; font-size: .72rem; font-weight: 600; }
.badge-green  { background: rgba(22,163,74,.2);  color: #4ade80; }
.badge-red    { background: rgba(220,38,38,.2);  color: #f87171; }
.badge-yellow { background: rgba(217,119,6,.2);  color: #fbbf24; }
.badge-blue   { background: rgba(59,130,246,.2); color: #93c5fd; }
.badge-gray   { background: rgba(71,85,105,.3);  color: var(--muted); }

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; border-radius: 8px;
  font-size: .85rem; font-weight: 600; cursor: pointer; border: none; transition: opacity .15s; }
.btn:hover { opacity: .85; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-danger  { background: var(--danger);  color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-ghost   { background: rgba(255,255,255,.08); color: var(--text); }
.btn-sm { padding: 5px 10px; font-size: .78rem; }
.btn-outline { background: transparent; color: var(--text); border: 1px solid var(--border); }
.btn-outline:hover { background: rgba(255,255,255,.08); }

/* ── Forms ───────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 18px; }
.form-label { display: block; font-size: .82rem; color: var(--muted); margin-bottom: 6px; font-weight: 500; }
.form-control { width: 100%; padding: 10px 14px; background: #0f172a; border: 1px solid var(--border);
  border-radius: 8px; color: var(--text); font-size: .9rem; transition: border-color .2s; }
.form-control:focus { outline: none; border-color: var(--primary); }
textarea.form-control { resize: vertical; min-height: 120px; }
select.form-control { cursor: pointer; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 600px) { .form-grid { grid-template-columns: 1fr; } }
.form-check { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.form-check input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--primary); cursor: pointer; }

/* ── Toggle Switch ───────────────────────────────────────────────────────── */
.toggle { position: relative; width: 40px; height: 22px; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider { position: absolute; inset: 0; background: #374151; border-radius: 22px; cursor: pointer; transition: .3s; }
.toggle-slider::before { content: ''; position: absolute; width: 16px; height: 16px;
  left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .3s; }
.toggle input:checked + .toggle-slider { background: var(--primary); }
.toggle input:checked + .toggle-slider::before { transform: translateX(18px); }

/* ── Flash messages ──────────────────────────────────────────────────────── */
.alert { padding: 12px 16px; border-radius: 8px; font-size: .88rem; margin-bottom: 20px; display: flex; align-items: center; gap: 10px; }
.alert-success { background: rgba(22,163,74,.15); border: 1px solid rgba(22,163,74,.3); color: #4ade80; }
.alert-danger   { background: rgba(220,38,38,.15);  border: 1px solid rgba(220,38,38,.3);  color: #f87171; }
.alert-warning  { background: rgba(217,119,6,.15);  border: 1px solid rgba(217,119,6,.3);  color: #fbbf24; }
.alert-info     { background: rgba(59,130,246,.15); border: 1px solid rgba(59,130,246,.3); color: #93c5fd; }

/* ── Filters bar ──────────────────────────────────────────────────────────── */
.filters-bar { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 20px; align-items: center; }
.filters-bar .form-control { width: auto; }

/* ── Progress bar ─────────────────────────────────────────────────────────── */
.progress { background: #1e293b; border-radius: 20px; height: 8px; overflow: hidden; }
.progress-bar { background: var(--primary); height: 100%; border-radius: 20px; transition: width .4s; }

/* ── Login page ──────────────────────────────────────────────────────────── */
.login-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 16px; background: #0f172a;
}
.login-card {
  background: var(--card); border-radius: 16px; padding: 40px;
  max-width: 420px; width: 100%;
  border: 1px solid var(--border); box-shadow: 0 20px 60px rgba(0,0,0,.6);
}
.login-logo {
  text-align: center; font-size: 1.5rem; font-weight: 900; margin-bottom: 28px;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
}
.login-logo img { max-height: 60px; max-width: 180px; object-fit: contain; }
.login-logo span { color: var(--primary); }
@media (max-width: 480px) {
  .login-card { padding: 28px 20px; border-radius: 12px; }
  .login-logo { font-size: 1.3rem; margin-bottom: 20px; }
}
@media (max-width: 360px) {
  .login-card { padding: 20px 14px; }
}

/* ── Responsive admin ─────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .admin-sidebar { transform: translateX(-100%); transition: transform .3s; }
  .admin-sidebar.open { transform: translateX(0); }
  .admin-main { margin-left: 0; }
  .admin-topbar { left: 0; }
  .admin-content { padding: 16px; }
}

/* ── Sidebar online badge ──────────────────────────────────────── */
.sidebar-brand { display:flex; justify-content:space-between; align-items:center; }
.sidebar-online { font-size:.7rem; color:#4ade80; display:flex; align-items:center; gap:4px; }
.sidebar-online .pulse { animation:pulseGreen 1.5s infinite; font-size:.5rem; }
@keyframes pulseGreen { 0%,100%{opacity:1;} 50%{opacity:.2;} }

/* ── TV Admin ─────────────────────────────────────────────────── */
.tv-admin-grid { display:grid; grid-template-columns:1fr 1fr; gap:24px; }
@media(max-width:900px) { .tv-admin-grid { grid-template-columns:1fr; } }
.channel-grid { display:grid; grid-template-columns:repeat(auto-fill,minmax(130px,1fr)); gap:12px; max-height:500px; overflow-y:auto; }
.channel-card { background:#f8f9fa; border:2px solid transparent; border-radius:8px; padding:12px;
  text-align:center; cursor:pointer; transition:.2s; }
.channel-card:hover { border-color:var(--primary,#e63946); background:#fff; }
.channel-card.selected { border-color:var(--primary,#e63946); background:#fff5f5; }
.channel-card img { width:60px; height:40px; object-fit:contain; margin:0 auto 6px; display:block; }
.no-logo { width:60px; height:40px; background:#e0e0e0; border-radius:4px; display:flex; align-items:center;
  justify-content:center; margin:0 auto 6px; color:#999; font-size:1.2rem; }
.channel-name { font-size:.75rem; font-weight:600; display:block; line-height:1.2; word-break:break-word; }
.channel-group { font-size:.65rem; color:#999; display:block; margin-top:2px; }

/* ── Stat cards extras ─────────────────────────────────────────── */
.stats-grid-4 { grid-template-columns:repeat(4,1fr); }
@media(max-width:900px) { .stats-grid-4 { grid-template-columns:repeat(2,1fr); } }
@media(max-width:500px) { .stats-grid-4 { grid-template-columns:1fr; } }
.bg-yellow { background:linear-gradient(135deg,#f59e0b,#d97706) !important; }

/* ── Charts grid ───────────────────────────────────────────────── */
.charts-grid { display:grid; grid-template-columns:2fr 1fr; gap:20px; }
.chart-card-wide { grid-column:1; }
.chart-card-sm   { grid-column:2; }
@media(max-width:900px) { .charts-grid { grid-template-columns:1fr; } .chart-card-wide,.chart-card-sm { grid-column:1; } }

/* ── Ads table extras ──────────────────────────────────────────── */
.row-inactive { opacity:.55; }
.status-badge { display:inline-block; padding:2px 10px; border-radius:20px; font-size:.75rem; font-weight:600; }
.status-active   { background:#dcfce7; color:#16a34a; }
.status-inactive { background:#fee2e2; color:#dc2626; }

/* ── online badge in topbar ────────────────────────────────────── */
.online-badge { display:inline-flex; align-items:center; gap:6px; background:#dcfce7;
  color:#16a34a; border-radius:20px; padding:4px 14px; font-size:.85rem; font-weight:600; }
.online-badge .pulse { font-size:.6rem; animation:pulseGreen 1s infinite; }

/* ══════════════════════════════════════════════════════════════════
   ADMIN RESPONSIVE — mobile & tablet
══════════════════════════════════════════════════════════════════ */

/* Hamburger toggle (hidden on desktop) */
.admin-hamburger {
  display:none; background:none; border:none; color:var(--text);
  font-size:1.3rem; cursor:pointer; padding:6px; flex-shrink:0;
}

/* Overlay backdrop */
.admin-sidebar-overlay {
  display:none; position:fixed; inset:0; background:rgba(0,0,0,.55);
  z-index:98; backdrop-filter:blur(2px);
}

@media (max-width: 900px) {
  /* Sidebar slides in off-canvas */
  .admin-sidebar {
    transform: translateX(-100%);
    transition: transform .28s ease;
    z-index: 200;
  }
  .admin-sidebar.open {
    transform: translateX(0);
  }
  .admin-sidebar-overlay.open { display:block; }

  /* Topbar fills full width */
  .admin-topbar { left: 0; }
  .admin-hamburger { display:flex; }

  /* Main no longer offset by sidebar */
  .admin-main { margin-left: 0; }
  .admin-content { padding: 20px 14px; }

  /* Stats: 2 cols */
  .stats-grid { grid-template-columns: repeat(2, 1fr); }

  /* Tables: scroll */
  .admin-table { font-size: .8rem; }
  .admin-table th:nth-child(n+4),
  .admin-table td:nth-child(n+4) { display: none; } /* hide extra cols on mobile */
  .admin-table-scroll { overflow-x: auto; }

  /* Page header */
  .admin-page-header { flex-wrap: wrap; gap: 10px; }
  .admin-page-header .btn { font-size:.8rem; padding:6px 12px; }

  /* Card grids */
  .admin-card-grid { grid-template-columns: 1fr !important; }
}

@media (max-width: 600px) {
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat-card { padding: 14px; }
  .stat-card .stat-value { font-size: 1.4rem; }
  .topbar-user span { display: none; }
  .charts-grid { grid-template-columns: 1fr; }
  .admin-content { padding: 14px 10px; }

  /* Forms: full width */
  .form-grid-2 { grid-template-columns: 1fr !important; }
}

/* Login responsive — handled above */
