/* ═══════════════════════════════════════
   RESET & ROOT
════════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:          #0e1621;
  --bg2:         #111d2c;
  --card:        #162032;
  --card2:       #1a2a3f;
  --border:      rgba(255,255,255,0.07);
  --border2:     rgba(255,255,255,0.12);

  --blue:        #2979ff;
  --blue-dim:    rgba(41,121,255,0.12);
  --green:       #00e676;
  --green-dim:   rgba(0,230,118,0.12);
  --red:         #ff1744;
  --red-dim:     rgba(255,23,68,0.12);
  --orange:      #ff6d00;
  --orange-dim:  rgba(255,109,0,0.12);
  --cyan:        #00b4d8;
  --yellow:      #ffd600;
  --purple:      #7c4dff;

  --text:        #e8edf5;
  --text2:       #8096ae;
  --text3:       #4a647a;
  --white:       #ffffff;

  --sidebar-w:   240px;
  --topbar-h:    58px;
  --radius:      10px;
  --radius-sm:   6px;
  --radius-lg:   16px;

  --font: 'Inter', system-ui, sans-serif;
}

html { font-size: 15px; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

a { color: inherit; text-decoration: none; }
button { font-family: var(--font); cursor: pointer; }
input, textarea, select { font-family: var(--font); }
img { display: block; max-width: 100%; }

::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--card2); border-radius: 3px; }

.hidden { display: none !important; }
.accent { color: var(--blue); }

/* ═══════════════════════════════════════
   UTILITY
════════════════════════════════════════ */
.flex        { display: flex; }
.items-center{ align-items: center; }
.gap-2       { gap: 8px; }
.gap-3       { gap: 12px; }
.ml-auto     { margin-left: auto; }
.mt-1        { margin-top: 6px; }
.mt-2        { margin-top: 12px; }
.mt-3        { margin-top: 20px; }
.w-full      { width: 100%; }
.text-muted  { color: var(--text2); font-size: 13px; }
.text-sm     { font-size: 13px; }
.truncate    { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ═══════════════════════════════════════
   BUTTONS
════════════════════════════════════════ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: opacity .15s, transform .1s;
  white-space: nowrap;
}
.btn:active { opacity: .82; transform: scale(.97); }

.btn-primary  { background: var(--blue);   color: #fff; }
.btn-success  { background: var(--green);  color: #000; }
.btn-danger   { background: var(--red);    color: #fff; }
.btn-ghost    { background: rgba(255,255,255,.06); color: var(--text); border: 1px solid var(--border2); }
.btn-icon     { padding: 7px; border-radius: var(--radius-sm); background: rgba(255,255,255,.06); color: var(--text2); border: 1px solid var(--border); }
.btn-sm       { padding: 5px 12px; font-size: 12px; }
.btn-full     { width: 100%; justify-content: center; padding: 11px; }

/* ═══════════════════════════════════════
   BADGES
════════════════════════════════════════ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .3px;
}
.badge-live     { background: var(--red-dim);    color: var(--red); }
.badge-upcoming { background: var(--blue-dim);   color: var(--blue); }
.badge-finished { background: rgba(84,110,122,.15); color: #546e7a; }
.badge-halftime { background: var(--orange-dim); color: var(--orange); }
.badge-active   { background: var(--green-dim);  color: var(--green); }
.badge-inactive { background: rgba(84,110,122,.15); color: #546e7a; }
.badge-hd       { background: rgba(0,180,216,.12); color: var(--cyan); }
.badge-backup   { background: var(--orange-dim); color: var(--orange); }

.live-dot {
  display: inline-block;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--red);
  animation: pulse-dot 1s infinite;
}

@keyframes pulse-dot {
  0%,100% { opacity:1; }
  50%      { opacity:.3; }
}

/* ═══════════════════════════════════════
   FORMS
════════════════════════════════════════ */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
@media (max-width: 600px) { .form-row { grid-template-columns: 1fr; } }

label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: .5px;
}

input[type=text],
input[type=email],
input[type=password],
input[type=number],
input[type=url],
input[type=datetime-local],
input[type=search],
textarea,
select {
  background: rgba(255,255,255,.04);
  border: 1px solid var(--border2);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 14px;
  padding: 9px 13px;
  width: 100%;
  outline: none;
  transition: border-color .15s;
}
input:focus, textarea:focus, select:focus {
  border-color: var(--blue);
}
select option { background: var(--card2); }
textarea { min-height: 90px; resize: vertical; }

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: rgba(255,255,255,.03);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.switch-row label { margin: 0; text-transform: none; font-size: 14px; color: var(--text); font-weight: 500; }

.toggle {
  position: relative;
  width: 42px; height: 24px;
  flex-shrink: 0;
}
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--bg2);
  border-radius: 12px;
  cursor: pointer;
  transition: background .2s;
  border: 1px solid var(--border2);
}
.toggle-slider::before {
  content: '';
  position: absolute;
  width: 16px; height: 16px;
  left: 3px; bottom: 3px;
  background: var(--text2);
  border-radius: 50%;
  transition: transform .2s, background .2s;
}
.toggle input:checked + .toggle-slider { background: var(--blue); border-color: var(--blue); }
.toggle input:checked + .toggle-slider::before { transform: translateX(18px); background: #fff; }

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}
.chip {
  padding: 5px 12px;
  border-radius: 20px;
  border: 1px solid var(--border2);
  background: var(--card2);
  color: var(--text2);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s;
}
.chip.active, .chip:hover { background: var(--blue); border-color: var(--blue); color: #fff; }

/* ═══════════════════════════════════════
   ALERTS
════════════════════════════════════════ */
.alert {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 14px;
}
.alert-error   { background: var(--red-dim);   color: var(--red);   border: 1px solid rgba(255,23,68,.25); }
.alert-success { background: var(--green-dim); color: var(--green); border: 1px solid rgba(0,230,118,.25); }
.alert-info    { background: var(--blue-dim);  color: var(--blue);  border: 1px solid rgba(41,121,255,.25); }

/* ═══════════════════════════════════════
   LOGIN SCREEN
════════════════════════════════════════ */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: radial-gradient(ellipse at 60% 30%, rgba(41,121,255,.08) 0%, transparent 60%),
              var(--bg);
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--card);
  border: 1px solid var(--border2);
  border-radius: var(--radius-lg);
  padding: 32px;
}

.login-logo {
  text-align: center;
  margin-bottom: 28px;
}
.login-logo .logo-icon { font-size: 42px; display: block; margin-bottom: 8px; }
.login-logo h1 { font-size: 26px; font-weight: 900; color: var(--white); letter-spacing: .5px; }
.login-logo p { color: var(--text2); font-size: 13px; margin-top: 3px; }

/* ═══════════════════════════════════════
   APP SHELL
════════════════════════════════════════ */
.app-shell {
  display: flex;
  min-height: 100vh;
}

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

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 16px 14px;
  border-bottom: 1px solid var(--border);
}
.sidebar-logo {
  font-size: 20px;
  font-weight: 900;
  color: var(--white);
  letter-spacing: .5px;
}
.sidebar-close {
  display: none;
  background: none;
  border: none;
  color: var(--text2);
  font-size: 16px;
  cursor: pointer;
}

.sidebar-user {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}
.user-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--blue);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 15px;
  color: #fff;
  flex-shrink: 0;
}
.user-name  { font-weight: 700; font-size: 13px; color: var(--white); }
.user-role  { font-size: 11px; color: var(--text2); text-transform: capitalize; }

.sidebar-nav {
  flex: 1;
  padding: 10px 8px;
  overflow-y: auto;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--text2);
  font-size: 14px;
  font-weight: 500;
  transition: all .15s;
  margin-bottom: 2px;
}
.nav-item:hover  { background: var(--blue-dim); color: var(--blue); }
.nav-item.active { background: var(--blue-dim); color: var(--blue); font-weight: 700; }
.nav-icon { font-size: 16px; width: 22px; text-align: center; }

.sidebar-logout {
  margin: 10px 8px 16px;
  padding: 10px 12px;
  border-radius: 8px;
  background: none;
  border: none;
  color: var(--red);
  font-size: 14px;
  font-weight: 600;
  text-align: left;
  width: calc(100% - 16px);
  transition: background .15s;
}
.sidebar-logout:hover { background: var(--red-dim); }

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.6);
  z-index: 99;
}

/* ── MAIN ── */
.main-wrap {
  flex: 1;
  margin-left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 20px;
  height: var(--topbar-h);
  background: var(--card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
}
.menu-btn {
  display: none;
  background: none;
  border: none;
  color: var(--text);
  font-size: 20px;
  cursor: pointer;
}
.topbar-title {
  font-weight: 800;
  font-size: 17px;
  color: var(--white);
  flex: 1;
}
.topbar-right { display: flex; align-items: center; gap: 10px; }
.live-indicator {
  font-size: 12px;
  font-weight: 700;
  color: var(--red);
  display: flex;
  align-items: center;
  gap: 5px;
}

.content {
  flex: 1;
  padding: 24px 24px 40px;
  max-width: 1200px;
  width: 100%;
}

/* ═══════════════════════════════════════
   CARDS & SECTIONS
════════════════════════════════════════ */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
}
.card-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--white);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 16px;
}
.stat-value { font-size: 32px; font-weight: 900; line-height: 1; }
.stat-label { font-size: 11px; color: var(--text2); font-weight: 600; text-transform: uppercase; letter-spacing: .4px; margin-top: 5px; }

/* ═══════════════════════════════════════
   TABLE
════════════════════════════════════════ */
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead tr { background: var(--card2); }
th {
  padding: 10px 14px;
  text-align: left;
  color: var(--text2);
  font-weight: 700;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .4px;
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
}
td {
  padding: 12px 14px;
  border-bottom: 1px solid rgba(255,255,255,.04);
  color: var(--text);
  vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(255,255,255,.02); }

.table-actions { display: flex; gap: 6px; align-items: center; }

/* ═══════════════════════════════════════
   TOOLBAR
════════════════════════════════════════ */
.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.search-input {
  flex: 1;
  min-width: 180px;
  max-width: 300px;
  padding: 8px 12px 8px 36px;
  background: var(--card2);
  border: 1px solid var(--border2);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 13px;
  outline: none;
  position: relative;
}
.search-wrap { position: relative; flex: 1; min-width: 180px; max-width: 300px; }
.search-wrap::before {
  content: '🔍';
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 12px;
  pointer-events: none;
}
.search-wrap input { padding-left: 32px; width: 100%; }

/* ═══════════════════════════════════════
   MODAL
════════════════════════════════════════ */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.7);
  z-index: 200;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 16px;
  overflow-y: auto;
}
.modal {
  background: var(--card);
  border: 1px solid var(--border2);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 560px;
  box-shadow: 0 20px 60px rgba(0,0,0,.5);
  animation: modal-in .2s ease;
}
@keyframes modal-in {
  from { transform: translateY(-16px); opacity: 0; }
  to   { transform: translateY(0);     opacity: 1; }
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 16px; font-weight: 800; color: var(--white); }
.modal-header button {
  background: none;
  border: none;
  color: var(--text2);
  font-size: 18px;
  cursor: pointer;
  line-height: 1;
  padding: 2px 6px;
  border-radius: 4px;
  transition: background .15s;
}
.modal-header button:hover { background: rgba(255,255,255,.08); }
.modal-body { padding: 20px; }
.modal-footer {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
}

/* ═══════════════════════════════════════
   TOAST
════════════════════════════════════════ */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 500;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  min-width: 220px;
  max-width: 360px;
  box-shadow: 0 4px 20px rgba(0,0,0,.4);
  animation: toast-in .2s ease;
  display: flex;
  align-items: center;
  gap: 8px;
}
.toast-success { background: #1a3a28; border: 1px solid rgba(0,230,118,.3); color: var(--green); }
.toast-error   { background: #3a1a1a; border: 1px solid rgba(255,23,68,.3);  color: var(--red);   }
.toast-info    { background: #1a2a3f; border: 1px solid var(--border2);      color: var(--text);  }

@keyframes toast-in {
  from { transform: translateX(20px); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

/* ═══════════════════════════════════════
   PAGINATION
════════════════════════════════════════ */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 20px;
}
.page-btn {
  min-width: 34px;
  height: 34px;
  border-radius: 6px;
  background: var(--card2);
  border: 1px solid var(--border);
  color: var(--text2);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s;
}
.page-btn.active, .page-btn:hover { background: var(--blue); border-color: var(--blue); color: #fff; }
.page-btn:disabled { opacity: .4; cursor: not-allowed; }

/* ═══════════════════════════════════════
   EMPTY STATE
════════════════════════════════════════ */
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text2);
}
.empty-state .empty-icon { font-size: 40px; margin-bottom: 12px; }
.empty-state h3 { font-size: 15px; font-weight: 700; color: var(--text); margin-bottom: 6px; }
.empty-state p  { font-size: 13px; }

/* ═══════════════════════════════════════
   STREAM URL CODE BLOCK
════════════════════════════════════════ */
.url-preview {
  font-family: 'Courier New', monospace;
  font-size: 11px;
  color: var(--text2);
  background: var(--bg2);
  padding: 4px 8px;
  border-radius: 4px;
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: block;
}

/* ═══════════════════════════════════════
   INFO BOX
════════════════════════════════════════ */
.info-box {
  background: var(--blue-dim);
  border: 1px solid rgba(41,121,255,.2);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 13px;
  color: var(--text2);
  line-height: 1.6;
}
.info-box strong { color: var(--blue); }

/* ═══════════════════════════════════════
   RESPONSIVE
════════════════════════════════════════ */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .sidebar-close { display: block; }
  .sidebar-overlay.visible { display: block; }
  .main-wrap { margin-left: 0; }
  .menu-btn  { display: block; }
  .content   { padding: 16px 16px 40px; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .form-row  { grid-template-columns: 1fr; }
  .topbar    { padding: 0 14px; }
  .modal-backdrop { padding: 20px 12px; }
}

@media (max-width: 480px) {
  .toolbar { flex-direction: column; align-items: stretch; }
  .search-wrap { max-width: 100%; }
  .table-actions { flex-wrap: wrap; }
}
