:root {
  --bg-primary: #0f0f1a;
  --bg-secondary: #1a1a2e;
  --bg-card: #16213e;
  --text-primary: #e0e0e0;
  --text-secondary: #a0a0b0;
  --accent-green: #00c853;
  --accent-red: #ff1744;
  --accent-blue: #448aff;
  --accent-yellow: #ffd600;
  --border: #2a2a4a;
  --radius: 8px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
}

nav {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  display: flex;
  align-items: center;
  height: 56px;
  gap: 24px;
}

nav h1 { font-size: 18px; font-weight: 700; color: var(--accent-blue); }

nav a {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 14px;
  padding: 4px 12px;
  border-radius: var(--radius);
  transition: all 0.2s;
}

nav a:hover, nav a.active { color: var(--text-primary); background: var(--bg-card); }

nav .user-info { margin-left: auto; font-size: 13px; color: var(--text-secondary); }
nav .logout-btn {
  background: none; border: 1px solid var(--border); color: var(--text-secondary);
  padding: 4px 12px; border-radius: var(--radius); cursor: pointer; font-size: 13px;
}
nav .logout-btn:hover { color: var(--accent-red); border-color: var(--accent-red); }

.container { max-width: 1200px; margin: 0 auto; padding: 24px; }

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

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.card h2 { font-size: 14px; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 12px; }
.card h3 { font-size: 13px; color: var(--text-secondary); margin-bottom: 8px; }

/* Status Indicator */
.status-indicator {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 600;
}

.status-indicator.live { background: rgba(0, 200, 83, 0.15); color: var(--accent-green); }
.status-indicator.offline { background: rgba(255, 23, 68, 0.15); color: var(--accent-red); }

.status-dot {
  width: 10px; height: 10px; border-radius: 50%;
  display: inline-block;
}

.status-dot.live { background: var(--accent-green); box-shadow: 0 0 8px var(--accent-green); animation: pulse 2s infinite; }
.status-dot.offline { background: var(--accent-red); }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border: none; border-radius: var(--radius);
  font-size: 14px; font-weight: 500; cursor: pointer;
  transition: all 0.2s;
}

.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary { background: var(--accent-blue); color: white; }
.btn-primary:hover:not(:disabled) { background: #2979ff; }

.btn-danger { background: var(--accent-red); color: white; }
.btn-danger:hover:not(:disabled) { background: #d50000; }

.btn-success { background: var(--accent-green); color: white; }
.btn-success:hover:not(:disabled) { background: #00a844; }

.btn-warning { background: var(--accent-yellow); color: #1a1a2e; }

.btn-sm { padding: 4px 10px; font-size: 12px; }

/* Controls */
.controls { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }

/* Video Info */
.video-info { margin-top: 12px; }
.video-info .label { color: var(--text-secondary); font-size: 12px; }
.video-info .value { font-size: 14px; margin-bottom: 8px; }

/* Progress bar */
.progress-bar {
  width: 100%; height: 6px;
  background: var(--bg-primary);
  border-radius: 3px; overflow: hidden; margin-top: 4px;
}

.progress-bar .fill {
  height: 100%; background: var(--accent-blue);
  border-radius: 3px; transition: width 1s linear;
}

/* Metrics */
.metrics-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.metric { text-align: center; padding: 12px; background: var(--bg-primary); border-radius: var(--radius); }
.metric .value { font-size: 28px; font-weight: 700; }
.metric .label { font-size: 11px; color: var(--text-secondary); text-transform: uppercase; }

.metric.green .value { color: var(--accent-green); }
.metric.blue .value { color: var(--accent-blue); }
.metric.yellow .value { color: var(--accent-yellow); }
.metric.red .value { color: var(--accent-red); }

/* Logs */
.logs-container {
  background: var(--bg-primary);
  border-radius: var(--radius);
  padding: 12px;
  max-height: 200px;
  overflow-y: auto;
  font-family: 'Consolas', 'Courier New', monospace;
  font-size: 12px;
  line-height: 1.6;
}

.log-entry { padding: 2px 0; border-bottom: 1px solid rgba(255,255,255,0.05); }
.log-entry .time { color: var(--text-secondary); margin-right: 8px; }
.log-entry.info { color: var(--text-primary); }
.log-entry.warn { color: var(--accent-yellow); }
.log-entry.error { color: var(--accent-red); }

/* Tables */
table { width: 100%; border-collapse: collapse; font-size: 13px; }

th {
  text-align: left; padding: 10px 12px;
  border-bottom: 2px solid var(--border);
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

td { padding: 10px 12px; border-bottom: 1px solid var(--border); }

tr:hover td { background: rgba(255,255,255,0.03); }

#videos-table td:first-child {
  overflow-wrap: break-word;
  word-break: break-word;
  max-width: 300px;
}

.table-responsive {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* Forms */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; color: var(--text-secondary); margin-bottom: 4px; }

input[type="text"], input[type="password"], input[type="file"], input[type="number"], select, textarea {
  width: 100%; padding: 10px 12px;
  background: #1e1e38; border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text-primary);
  font-size: 14px; transition: border-color 0.2s;
}

input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent-blue); box-shadow: 0 0 0 2px rgba(68, 138, 255, 0.15);
}

.modal .form-group > label:not(.toggle-row) {
  font-size: 12px; text-transform: uppercase; letter-spacing: 0.3px; color: #8899aa;
  margin-bottom: 6px;
}

.modal input[type="text"], .modal input[type="number"], .modal select, .modal textarea {
  background: #0a0a1a; border-color: #2a2a4a;
}

textarea { resize: vertical; min-height: 80px; font-family: inherit; }

/* Badge */
.badge {
  display: inline-block; padding: 2px 8px; border-radius: 10px;
  font-size: 11px; font-weight: 600;
}

.badge.success { background: rgba(0, 200, 83, 0.15); color: var(--accent-green); }
.badge.error { background: rgba(255, 23, 68, 0.15); color: var(--accent-red); }
.badge.warning { background: rgba(255, 214, 0, 0.15); color: var(--accent-yellow); }

/* Modal */
.modal-overlay {
  display: none;
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.7);
  z-index: 100;
  align-items: center; justify-content: center;
}

.modal-overlay.active { display: flex; }

.modal {
  display: flex; flex-direction: column;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  width: 90%;
  max-width: 500px;
  max-height: 90vh;
}

.modal h2 { margin-bottom: 16px; flex-shrink: 0; overflow-wrap: break-word; word-break: break-word; }

.modal .modal-body {
  overflow-y: auto; flex: 1;
  padding-right: 4px;
  min-height: 0;
}

.modal .btn-group {
  display: flex; gap: 8px; justify-content: flex-end;
  margin-top: 16px; padding-top: 12px;
  flex-shrink: 0;
  border-top: 1px solid var(--border);
}

/* Checkbox toggle */
.toggle { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.toggle input { display: none; }
.toggle .slider {
  width: 36px; height: 20px; background: var(--border);
  border-radius: 10px; position: relative; transition: 0.2s;
}
.toggle .slider::after {
  content: ''; width: 16px; height: 16px; background: var(--text-secondary);
  border-radius: 50%; position: absolute; top: 2px; left: 2px; transition: 0.2s;
}
.toggle input:checked + .slider { background: var(--accent-green); }
.toggle input:checked + .slider::after { left: 18px; background: white; }

/* Toggle row in modals */
.toggle-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px; border: 1px solid #3a3a5a;
  border-radius: var(--radius);
  background: rgba(255,255,255,0.03); transition: border-color 0.2s;
  font-size: 13px; font-weight: 500; color: #c0d0e0;
}
.toggle-row:hover { border-color: var(--accent-blue); background: rgba(68, 138, 255, 0.05); }
.toggle-row .toggle { display: inline-flex; align-items: center; gap: 0; }
.toggle-row .toggle .slider { width: 40px; height: 22px; background: #3a3a5a; }
.toggle-row .toggle .slider::after { width: 18px; height: 18px; top: 2px; left: 2px; background: #8899aa; }
.toggle-row .toggle input:checked + .slider { background: var(--accent-green); }
.toggle-row .toggle input:checked + .slider::after { left: 20px; background: white; }

/* Genre chip selector */
.genre-chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 6px 16px; border-radius: 16px; cursor: pointer;
  font-size: 13px; font-weight: 500; user-select: none;
  border: 1px solid #3a3a5a;
  background: rgba(255,255,255,0.04);
  color: #8899aa;
  transition: all 0.15s;
}
.genre-chip:hover { border-color: var(--accent-blue); color: #c0d0e0; background: rgba(68, 138, 255, 0.08); }
.genre-chip.checked {
  background: rgba(68, 138, 255, 0.2);
  border-color: var(--accent-blue);
  color: #82b1ff;
}
.genre-chip input { display: none; }

/* Login page */
.login-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

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

.login-card h1 { text-align: center; margin-bottom: 24px; color: var(--accent-blue); }

.error-msg { color: var(--accent-red); font-size: 13px; margin-top: 8px; display: none; }
.success-msg { color: var(--accent-green); font-size: 13px; margin-top: 8px; display: none; }

/* Upload zone */
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 40px;
  text-align: center;
  cursor: pointer;
  transition: 0.2s;
  margin-bottom: 16px;
}

.upload-zone:hover, .upload-zone.dragover { border-color: var(--accent-blue); background: rgba(68, 138, 255, 0.05); }

.upload-zone p { color: var(--text-secondary); }
.upload-zone .icon { font-size: 48px; margin-bottom: 8px; }

/* Responsive */
@media (max-width: 768px) {
  .dashboard-grid { grid-template-columns: 1fr; }
  .metrics-grid { grid-template-columns: 1fr 1fr; }
  nav { padding: 0 12px; gap: 8px; }
  nav h1 { font-size: 15px; }
  nav a { font-size: 13px; padding: 4px 8px; }
}

@media (max-width: 480px) {
  .hide-mobile { display: none; }
  nav { gap: 4px; }
  nav h1 { font-size: 13px; }
  nav a { font-size: 11px; padding: 4px 4px; }
  nav .user-info { display: none; }
  nav button.btn-sm { display: none; }
  nav .logout-btn { font-size: 11px; padding: 4px 8px; }
}
