/* ═══════════════════════════════════════════════════════
   TVONE — Panel Admin Styles
   Dark theme moderno
═══════════════════════════════════════════════════════ */

/* ── Variables ────────────────────────────────────────── */
:root {
  --bg-dark:      #0d1117;
  --bg-card:      #161b22;
  --bg-input:     #1c2128;
  --bg-hover:     #21262d;
  --border:       #30363d;
  --accent:       #2f81f7;
  --accent-hover: #1f6feb;
  --accent-light: rgba(47,129,247,0.15);
  --success:      #3fb950;
  --warning:      #d29922;
  --danger:       #f85149;
  --text-primary: #e6edf3;
  --text-muted:   #8b949e;
  --text-dim:     #484f58;
  --sidebar-w:    240px;
  --topbar-h:     60px;
  --radius:       8px;
  --radius-lg:    12px;
  --shadow:       0 4px 24px rgba(0,0,0,0.4);
  --transition:   0.2s ease;
}

/* ── Reset ────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg-dark);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.5;
}
a { color: var(--accent); text-decoration: none; }
button { cursor: pointer; border: none; background: none; font-family: inherit; }
input, select, textarea { font-family: inherit; }
ul { list-style: none; }

/* ── Utilities ────────────────────────────────────────── */
.hidden { display: none !important; }
.flex   { display: flex; }
.gap-1  { gap: 8px; }
.gap-2  { gap: 16px; }
.mt-1   { margin-top: 8px; }
.mt-2   { margin-top: 16px; }
.text-muted  { color: var(--text-muted); }
.text-danger { color: var(--danger); }
.text-success{ color: var(--success); }

/* ── LOGIN SCREEN ─────────────────────────────────────── */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at top, #1a2a4a 0%, var(--bg-dark) 70%);
}
.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 40px;
  width: 100%;
  max-width: 380px;
  box-shadow: var(--shadow);
}
.login-logo {
  text-align: center;
  margin-bottom: 32px;
}
.login-logo i {
  font-size: 48px;
  color: var(--accent);
  display: block;
  margin-bottom: 12px;
}
.login-logo h1 {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: 4px;
  color: var(--text-primary);
}
.login-logo p {
  color: var(--text-muted);
  font-size: 13px;
  margin-top: 4px;
}

/* ── FORM ─────────────────────────────────────────────── */
.form-group {
  margin-bottom: 16px;
}
.form-group label {
  display: block;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}
.form-group label i { margin-right: 6px; }
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  padding: 10px 14px;
  font-size: 14px;
  transition: border-color var(--transition);
  outline: none;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}
.form-group textarea { resize: vertical; min-height: 80px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ── BUTTONS ──────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 18px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  transition: all var(--transition);
  white-space: nowrap;
}
.btn-full { width: 100%; justify-content: center; }
.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary {
  background: var(--bg-hover);
  color: var(--text-primary);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--border); }
.btn-danger  { background: rgba(248,81,73,0.15); color: var(--danger); border: 1px solid rgba(248,81,73,0.3); }
.btn-danger:hover  { background: rgba(248,81,73,0.25); }
.btn-success { background: rgba(63,185,80,0.15); color: var(--success); border: 1px solid rgba(63,185,80,0.3); }
.btn-success:hover { background: rgba(63,185,80,0.25); }
.btn-sm { padding: 5px 12px; font-size: 13px; }
.btn-icon { padding: 7px; width: 32px; height: 32px; justify-content: center; }

/* ── ALERTS ───────────────────────────────────────────── */
.alert {
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  margin-bottom: 16px;
}
.alert-error   { background: rgba(248,81,73,0.1); border: 1px solid rgba(248,81,73,0.3); color: var(--danger); }
.alert-success { background: rgba(63,185,80,0.1); border: 1px solid rgba(63,185,80,0.3); color: var(--success); }
.alert-warning { background: rgba(210,153,34,0.1); border: 1px solid rgba(210,153,34,0.3); color: var(--warning); }

/* ── BADGES ───────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
}
.badge-admin   { background: rgba(47,129,247,0.15); color: var(--accent); }
.badge-user    { background: rgba(139,148,158,0.15); color: var(--text-muted); }
.badge-active  { background: rgba(63,185,80,0.15);  color: var(--success); }
.badge-inactive{ background: rgba(248,81,73,0.15);  color: var(--danger); }

/* ── APP LAYOUT ───────────────────────────────────────── */
.app {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ── SIDEBAR ──────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: width var(--transition), transform var(--transition);
}
.sidebar-header {
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--border);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 3px;
  color: var(--accent);
}
.sidebar-header i { font-size: 22px; }
.sidebar-nav {
  flex: 1;
  padding: 12px 0;
  overflow-y: auto;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 20px;
  color: var(--text-muted);
  font-size: 14px;
  transition: all var(--transition);
  border-left: 3px solid transparent;
}
.nav-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}
.nav-item.active {
  background: var(--accent-light);
  color: var(--accent);
  border-left-color: var(--accent);
  font-weight: 500;
}
.nav-item i { width: 18px; text-align: center; }
.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.user-info {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  overflow: hidden;
}
.user-info i { color: var(--accent); font-size: 18px; flex-shrink: 0; }
.user-info span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.btn-logout {
  color: var(--text-muted);
  padding: 6px;
  border-radius: var(--radius);
  transition: all var(--transition);
  flex-shrink: 0;
}
.btn-logout:hover { color: var(--danger); background: rgba(248,81,73,0.1); }

/* ── TOPBAR ───────────────────────────────────────────── */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.topbar {
  height: var(--topbar-h);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  flex-shrink: 0;
}
.sidebar-toggle {
  color: var(--text-muted);
  font-size: 18px;
  padding: 6px;
  border-radius: var(--radius);
  transition: color var(--transition);
}
.sidebar-toggle:hover { color: var(--text-primary); }
.topbar h2 { font-size: 17px; font-weight: 600; flex: 1; }
.topbar-time { color: var(--text-muted); font-size: 13px; font-variant-numeric: tabular-nums; }

/* ── PAGE CONTENT ─────────────────────────────────────── */
.page-content {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}
.page { display: block; }
.page.hidden { display: none; }

/* ── STAT CARDS ───────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: border-color var(--transition);
}
.stat-card:hover { border-color: var(--accent); }
.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}
.stat-icon.blue   { background: rgba(47,129,247,0.15);  color: var(--accent); }
.stat-icon.green  { background: rgba(63,185,80,0.15);   color: var(--success); }
.stat-icon.yellow { background: rgba(210,153,34,0.15);  color: var(--warning); }
.stat-icon.red    { background: rgba(248,81,73,0.15);   color: var(--danger); }
.stat-info .stat-value { font-size: 28px; font-weight: 700; line-height: 1; }
.stat-info .stat-label { color: var(--text-muted); font-size: 12px; margin-top: 4px; }

/* ── CARDS ────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: 20px;
}
.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.card-header h3 { font-size: 15px; font-weight: 600; }
.card-body { padding: 20px; }

/* ── TABLE ────────────────────────────────────────────── */
.table-wrapper { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th {
  text-align: left;
  padding: 10px 16px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--bg-hover); }
.td-actions { display: flex; gap: 6px; justify-content: flex-end; }

/* ── SEARCH & FILTERS ─────────────────────────────────── */
.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.search-input {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  padding: 8px 14px 8px 36px;
  font-size: 13px;
  outline: none;
  min-width: 220px;
  transition: border-color var(--transition);
}
.search-input:focus { border-color: var(--accent); }
.search-wrapper { position: relative; }
.search-wrapper i {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 13px;
}

/* ── MODAL ────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
  animation: fadeIn 0.15s ease;
}
.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow);
  animation: slideUp 0.2s ease;
}
@keyframes modalShake {
  0%, 100% { transform: scale(1); }
  25% { transform: scale(1.015); }
  50% { transform: scale(0.995); }
  75% { transform: scale(1.01); }
}
.modal-shake {
  animation: modalShake 0.25s ease-in-out !important;
}
.modal-header {
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-header h3 { font-size: 16px; font-weight: 600; }
.modal-close {
  color: var(--text-muted);
  font-size: 18px;
  padding: 4px;
  border-radius: var(--radius);
  transition: color var(--transition);
}
.modal-close:hover { color: var(--text-primary); }
.modal-body { padding: 20px; overflow-y: auto; }
.modal-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* ── TOAST ────────────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.toast {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
  min-width: 280px;
  max-width: 360px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: var(--shadow);
  animation: slideIn 0.25s ease;
}
.toast.success { border-left: 3px solid var(--success); }
.toast.error   { border-left: 3px solid var(--danger);  }
.toast.warning { border-left: 3px solid var(--warning); }
.toast i.success { color: var(--success); }
.toast i.error   { color: var(--danger);  }
.toast i.warning { color: var(--warning); }
.toast-msg { flex: 1; font-size: 13px; word-break: break-word; }
.toast-close {
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  font-size: 14px;
  border-radius: 4px;
  line-height: 1;
  transition: color 0.15s ease;
}
.toast-close:hover {
  color: var(--text-primary);
}

/* ── EMPTY STATE ──────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.empty-state i { font-size: 48px; margin-bottom: 16px; opacity: 0.4; display: block; }
.empty-state p { font-size: 15px; }

/* ── LOADING ──────────────────────────────────────────── */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px;
  color: var(--text-muted);
}
.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin-right: 12px;
}

/* ── STREAM ASSIGN PANEL ──────────────────────────────── */
.stream-list-modal { max-height: 300px; overflow-y: auto; margin-top: 12px; }
.stream-item-check {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background var(--transition);
}
.stream-item-check:hover { background: var(--bg-hover); }
.stream-item-check input[type="checkbox"] { accent-color: var(--accent); width: 16px; height: 16px; }
.stream-group-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-dim);
  padding: 8px 12px 4px;
}

/* ── PAGINATION ───────────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 16px;
}
.pagination button {
  padding: 6px 12px;
  border-radius: var(--radius);
  background: var(--bg-hover);
  color: var(--text-primary);
  font-size: 13px;
  border: 1px solid var(--border);
  transition: all var(--transition);
}
.pagination button:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.pagination button:disabled { opacity: 0.4; cursor: not-allowed; }
.pagination .page-info { color: var(--text-muted); font-size: 13px; }

/* ── ANIMATIONS ───────────────────────────────────────── */
@keyframes fadeIn   { from { opacity:0 } to { opacity:1 } }
@keyframes slideUp  { from { transform: translateY(20px); opacity:0 } to { transform:translateY(0); opacity:1 } }
@keyframes slideIn  { from { transform: translateX(50px); opacity:0 } to { transform:translateX(0); opacity:1 } }
@keyframes slideOut { from { transform: translateX(0); opacity:1 } to { transform: translateX(50px); opacity:0 } }
@keyframes spin     { to { transform: rotate(360deg) } }

.toast.toast-out {
  animation: slideOut 0.3s ease forwards !important;
}

/* ── RESPONSIVE ───────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 100;
    transform: translateX(-100%);
  }
  .sidebar.open { transform: translateX(0); }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .form-row { grid-template-columns: 1fr; }
}

/* ── FILTROS AVANZADOS ───────────────────────────────── */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 12px 20px;
  background: var(--bg-hover);
  border-bottom: 1px solid var(--border);
}
.filter-select {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  padding: 7px 12px;
  font-size: 13px;
  outline: none;
  cursor: pointer;
  transition: border-color var(--transition);
}
.filter-select:focus {
  border-color: var(--accent);
}
.health-chip {
  cursor: pointer;
  padding: 4px 10px;
  border-radius: 6px;
  transition: all var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  user-select: none;
}
.health-chip:hover {
  background: var(--bg-hover);
}
.health-chip.active {
  background: var(--accent-light);
  outline: 1px solid var(--accent);
}

/* ── ORDENAMIENTO EN TABLA ───────────────────────────── */
th.sortable {
  cursor: pointer;
  user-select: none;
  transition: color var(--transition);
  white-space: nowrap;
}
th.sortable:hover {
  color: var(--accent);
}
th.sortable .sort-icon {
  margin-left: 6px;
  font-size: 11px;
  opacity: 0.35;
  transition: opacity var(--transition), color var(--transition);
}
th.sortable:hover .sort-icon {
  opacity: 0.8;
}
th.sortable.sorted .sort-icon {
  opacity: 1;
  color: var(--accent);
}

/* -- MVIL RESPONSIVE FIXES -- */
@media (max-width: 768px) {
  .topbar { padding: 0 12px; gap: 8px; }
  .page-content { padding: 16px; }
  .filter-bar { padding: 12px; }
  .page-header { flex-direction: column; align-items: stretch; gap: 12px; }
  .page-header h1 { font-size: 20px; text-align: center; }
  .page-header .btn { width: 100%; justify-content: center; }
  .search-input { min-width: unset; width: 100%; }
  .filter-select { width: 100%; }
}
@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .modal-overlay { padding: 10px; }
  .modal-body { padding: 15px; }
  .form-group label { font-size: 13px; }
  .toast-container { left: 16px; right: 16px; bottom: 16px; }
  .toast { min-width: unset; width: 100%; }
  .table-wrapper { border: 1px solid var(--border); border-radius: var(--radius); }
  td, th { padding: 8px 10px; font-size: 12px; }
  .btn-icon { width: 28px; height: 28px; font-size: 12px; }
}

