/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0c0a1a;
  --bg-card: #14102e;
  --bg-input: #1e1a3a;
  --border: #2a2550;
  --text: #f0eff5;
  --text-secondary: #8b86a8;
  --primary: #7c3aed;
  --primary-hover: #6d28d9;
  --primary-light: rgba(124, 58, 237, 0.15);
  --danger: #ef4444;
  --danger-hover: #dc2626;
  --success: #22c55e;
  --radius: 12px;
  --radius-sm: 8px;
}

body {
  font-family: 'Inter', -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

/* ── Login Page ── */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: radial-gradient(ellipse at 50% 0%, #1e1a3a 0%, var(--bg) 70%);
  padding: 20px;
}

.login-container { text-align: center; }

.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 40px 36px;
  width: 380px;
  max-width: 100%;
  box-shadow: 0 25px 50px rgba(0,0,0,0.5);
}

.logo-icon {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  background: linear-gradient(135deg, #7c3aed, #a855f7);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  font-weight: 800;
  color: white;
  margin-bottom: 8px;
}

.logo-icon.small {
  width: 40px;
  height: 40px;
  font-size: 18px;
  border-radius: 10px;
}

.login-title {
  font-size: 24px;
  font-weight: 700;
  margin-top: 16px;
}

.login-subtitle {
  color: var(--text-secondary);
  font-size: 14px;
  margin-top: 4px;
  margin-bottom: 28px;
}

.login-form { text-align: left; }

.login-footer {
  color: var(--text-secondary);
  font-size: 12px;
  margin-top: 24px;
}

/* ── Form Elements ── */
.form-group { margin-bottom: 16px; }

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text-secondary);
}

.form-group input {
  width: 100%;
  padding: 12px 16px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
}

.form-group input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.form-group input::placeholder { color: #4a4570; }

.form-inline {
  display: flex;
  gap: 12px;
  align-items: flex-end;
}

.form-inline .form-group { margin-bottom: 0; }

.flex-1 { flex: 1; }

.error-message {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #fca5a5;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 16px;
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary {
  background: var(--primary);
  color: white;
}
.btn-primary:hover { background: var(--primary-hover); transform: translateY(-1px); }

.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}
.btn-outline:hover { background: var(--bg-input); border-color: var(--primary); }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}
.btn-ghost:hover { background: var(--bg-input); color: var(--text); }

.btn-danger {
  background: var(--danger);
  color: white;
}
.btn-danger:hover { background: var(--danger-hover); }

.btn-sm { padding: 8px 14px; font-size: 13px; }

.btn-xs { padding: 5px 10px; font-size: 12px; }

.btn-full { width: 100%; }

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

/* ── Admin Header ── */
.admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 32px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-card);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-left { display: flex; align-items: center; gap: 14px; }

.header-title { font-size: 18px; font-weight: 700; }
.header-subtitle { font-size: 12px; color: var(--text-secondary); margin-top: 1px; }

.header-right { display: flex; align-items: center; gap: 10px; }

/* ── Main Content ── */
.admin-main { max-width: 1200px; margin: 0 auto; padding: 28px 32px; }

/* ── Stats ── */
.stats-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.stat-icon { font-size: 28px; }
.stat-value { font-size: 26px; font-weight: 800; }
.stat-label { font-size: 13px; color: var(--text-secondary); margin-top: 2px; }

/* ── Section Card ── */
.section-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 20px;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

.section-header h2 { font-size: 16px; font-weight: 700; }

.search-box input {
  padding: 8px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  outline: none;
  width: 280px;
}

.search-box input:focus { border-color: var(--primary); }

/* ── Videos Grid ── */
.videos-grid { display: grid; gap: 12px; }

.video-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: all 0.2s;
}

.video-card:hover { border-color: var(--primary); background: rgba(124, 58, 237, 0.04); }

.video-thumb {
  width: 90px;
  height: 50px;
  border-radius: 6px;
  background: linear-gradient(135deg, #2a2550, #1e1a3a);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
  overflow: hidden;
}

.video-thumb img { width: 100%; height: 100%; object-fit: cover; }

.video-info { flex: 1; min-width: 0; }

.video-title {
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.video-meta {
  display: flex;
  gap: 12px;
  margin-top: 4px;
  font-size: 12px;
  color: var(--text-secondary);
}

.video-meta span { display: flex; align-items: center; gap: 4px; }

.video-actions { display: flex; gap: 6px; flex-shrink: 0; }

.video-materials-badges {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-top: 6px;
}

.material-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 8px;
  border-radius: 100px;
  font-size: 11px;
  background: var(--primary-light);
  color: #c49bff;
}

.material-badge.empty {
  background: rgba(139, 134, 168, 0.1);
  color: var(--text-secondary);
}

.material-badge.filled { background: rgba(34, 197, 94, 0.12); color: #86efac; }

/* ── Modal ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 60px 20px;
  z-index: 200;
  overflow-y: auto;
}

.modal-content {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  width: 700px;
  max-width: 100%;
  box-shadow: 0 25px 60px rgba(0,0,0,0.6);
  animation: modalIn 0.2s ease-out;
}

.modal-sm { width: 420px; }

@keyframes modalIn {
  from { opacity: 0; transform: translateY(-10px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}

.modal-header h2 { font-size: 18px; font-weight: 700; }

.modal-subtitle { font-size: 13px; color: var(--text-secondary); margin-top: 2px; }

.modal-body { padding: 20px 24px; max-height: 60vh; overflow-y: auto; }

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 24px;
  border-top: 1px solid var(--border);
}

/* ── Material Editor ── */
.material-editor {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 12px;
  overflow: hidden;
}

.material-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: rgba(255,255,255,0.02);
  cursor: pointer;
  user-select: none;
}

.material-header:hover { background: rgba(255,255,255,0.04); }

.material-icon { font-size: 18px; }
.material-label { flex: 1; font-size: 13px; font-weight: 600; }
.material-status { font-size: 11px; color: var(--text-secondary); }

.material-body { padding: 0 14px 14px; display: none; }
.material-body.open { display: block; }

.material-body textarea {
  width: 100%;
  min-height: 100px;
  padding: 10px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 12px;
  line-height: 1.6;
  outline: none;
  resize: vertical;
}

.material-body textarea:focus { border-color: var(--primary); }

.material-hint {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 4px;
  display: flex;
  justify-content: space-between;
}

/* ── Toast ── */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--success);
  color: white;
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  box-shadow: 0 8px 30px rgba(0,0,0,0.3);
  z-index: 300;
  animation: toastIn 0.3s ease-out;
}

.toast.error { background: var(--danger); }

@keyframes toastIn {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ── Empty State ── */
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-secondary);
}

.empty-state .icon { font-size: 48px; margin-bottom: 12px; }
.empty-state p { font-size: 14px; }

/* ── Responsive ── */
/* ── Chat Modal ── */
.modal-chat { width: 600px; }

.chat-message {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  margin-bottom: 12px;
  background: rgba(255,255,255,0.02);
}

.chat-message:last-child { margin-bottom: 0; }

.chat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.chat-user {
  font-weight: 600;
  font-size: 14px;
}

.chat-login {
  color: var(--primary);
  font-size: 12px;
  font-weight: 500;
  margin-left: 4px;
}

.chat-date {
  font-size: 11px;
  color: var(--text-secondary);
}

.chat-text {
  font-size: 13px;
  line-height: 1.5;
  color: #d4d0eb;
  white-space: pre-wrap;
  word-break: break-word;
}

.chat-userid {
  font-size: 10px;
  color: var(--text-secondary);
  margin-top: 6px;
  font-family: monospace;
  opacity: 0.6;
}

.chat-answer {
  margin-top: 10px;
  padding: 10px 12px;
  background: rgba(34, 197, 94, 0.08);
  border: 1px solid rgba(34, 197, 94, 0.2);
  border-radius: 6px;
}

.chat-answer-label {
  font-size: 11px;
  color: #86efac;
  font-weight: 600;
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.modal-header .header-right {
  display: flex;
  align-items: center;
  gap: 6px;
}

@media (max-width: 768px) {
  .admin-header { padding: 12px 16px; flex-direction: column; gap: 12px; align-items: flex-start; }
  .admin-main { padding: 16px; }
  .stats-row { grid-template-columns: 1fr; }
  .form-inline { flex-direction: column; }
  .form-inline .form-group { width: 100%; }
  .search-box input { width: 100%; }
  .video-card { flex-direction: column; align-items: flex-start; }
  .video-actions { width: 100%; justify-content: flex-end; }
}
