/* ===== Reset y base ===== */
* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --primary: #ff5e3a;
  --primary-dark: #e54a28;
  --bg: #0f1115;
  --surface: #1a1d24;
  --surface-2: #242831;
  --border: #2d3340;
  --text: #e8eaed;
  --text-dim: #9ba1ad;
  --success: #2ecc71;
  --danger: #e74c3c;
}
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ===== Header ===== */
header.navbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}
.logo {
  display: inline-flex;
  align-items: center;
  height: 40px;
}
.logo img {
  height: 100%;
  width: auto;
  display: block;
}
.logo:hover { text-decoration: none; opacity: 0.85; }
.nav-actions { display: flex; gap: 0.75rem; align-items: center; }
.nav-actions a, .nav-actions button {
  font-size: 0.95rem;
}

/* ===== Botones ===== */
.btn {
  display: inline-block;
  padding: 0.55rem 1.1rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.15s;
  font-weight: 500;
}
.btn:hover { background: var(--border); text-decoration: none; }
.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-danger {
  background: transparent;
  color: var(--danger);
  border-color: var(--danger);
}
.btn-danger:hover { background: var(--danger); color: white; }
.btn-sm { padding: 0.3rem 0.65rem; font-size: 0.85rem; }

/* ===== Container ===== */
.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 2rem;
}

/* ===== Hero ===== */
.hero {
  text-align: center;
  padding: 3rem 1rem 2rem;
}
.hero h1 {
  font-size: 2.5rem;
  margin-bottom: 0.5rem;
}
.hero p { color: var(--text-dim); font-size: 1.1rem; }

/* ===== Grid de cursos ===== */
.course-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.5rem;
  margin-top: 2rem;
}
.course-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  transition: transform 0.15s, border-color 0.15s;
  cursor: pointer;
  display: block;
  color: inherit;
}
.course-card:hover {
  transform: translateY(-3px);
  border-color: var(--primary);
  text-decoration: none;
}
.course-card .thumb {
  width: 100%;
  height: 160px;
  background: var(--surface-2);
  background-size: cover;
  background-position: center;
}
.course-card .body {
  padding: 1rem;
}
.course-card h3 {
  font-size: 1.1rem;
  margin-bottom: 0.5rem;
}
.course-card p {
  color: var(--text-dim);
  font-size: 0.9rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.course-card .meta {
  margin-top: 0.75rem;
  font-size: 0.8rem;
  color: var(--text-dim);
}

/* ===== Formularios ===== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 2rem;
  max-width: 460px;
  margin: 2rem auto;
}
.card h2 { margin-bottom: 1.5rem; }
.form-group { margin-bottom: 1rem; }
.form-group label {
  display: block;
  margin-bottom: 0.35rem;
  font-size: 0.9rem;
  color: var(--text-dim);
}
.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 0.65rem 0.85rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 0.95rem;
  font-family: inherit;
}
.form-group input:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--primary);
}
.form-group textarea { min-height: 80px; resize: vertical; }
.form-actions { display: flex; gap: 0.5rem; margin-top: 1.25rem; }
.alert {
  padding: 0.75rem 1rem;
  border-radius: 8px;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}
.alert-error { background: rgba(231, 76, 60, 0.15); color: #ff8a7a; border: 1px solid rgba(231, 76, 60, 0.3); }
.alert-success { background: rgba(46, 204, 113, 0.15); color: #5edc97; border: 1px solid rgba(46, 204, 113, 0.3); }
.muted { color: var(--text-dim); font-size: 0.9rem; }
.center { text-align: center; }

/* ===== Vista de curso ===== */
.course-layout {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 2rem;
}
@media (max-width: 900px) {
  .course-layout { grid-template-columns: 1fr; }
}
.video-wrapper {
  position: relative;
  padding-bottom: 56.25%;
  background: black;
  border-radius: 12px;
  overflow: hidden;
}
.video-wrapper iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}
.lesson-list {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem;
  max-height: 500px;
  overflow-y: auto;
}
.lesson-list h3 { margin-bottom: 0.75rem; font-size: 1rem; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.05em; }
.lesson-item {
  padding: 0.75rem;
  border-radius: 8px;
  cursor: pointer;
  border: 1px solid transparent;
  margin-bottom: 0.35rem;
  transition: background 0.15s;
}
.lesson-item:hover { background: var(--surface-2); }
.lesson-item.active {
  background: var(--surface-2);
  border-color: var(--primary);
}
.lesson-item .lesson-title { font-weight: 500; font-size: 0.95rem; }
.lesson-item .lesson-num { color: var(--text-dim); font-size: 0.8rem; margin-bottom: 0.2rem; }

/* ===== Comentarios ===== */
.comments-section {
  margin-top: 2.5rem;
}
.comments-section h2 { margin-bottom: 1rem; }
.comment {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem;
  margin-bottom: 0.75rem;
}
.comment .author {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.4rem;
}
.comment .author strong { color: var(--primary); }
.comment .author small { color: var(--text-dim); }
.comment p { white-space: pre-wrap; }
.comment-form textarea {
  width: 100%;
  padding: 0.75rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: inherit;
  font-size: 0.95rem;
  min-height: 70px;
}

/* ===== Admin ===== */
.admin-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}
.admin-section h2 { margin-bottom: 1rem; font-size: 1.25rem; }
.admin-list { display: flex; flex-direction: column; gap: 0.5rem; }
.admin-list-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.85rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
}

/* Bloque que agrupa un curso + sus paneles (editar / lecciones) */
.course-admin-block {
  display: flex;
  flex-direction: column;
}

/* Item individual de lección en el panel admin */
.lesson-admin-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem;
  margin-bottom: 0.5rem;
  transition: box-shadow 0.15s, transform 0.15s;
}

/* Drag-and-drop: handle visible solo cuando se puede arrastrar */
.drag-handle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 36px;
  color: var(--text-dim);
  font-size: 1.1rem;
  letter-spacing: -2px;
  cursor: grab;
  user-select: none;
  border-radius: 6px;
  transition: background 0.15s, color 0.15s;
  flex-shrink: 0;
}
.drag-handle:hover {
  background: var(--surface-2);
  color: var(--primary);
}
.drag-handle:active { cursor: grabbing; }

/* Estado mientras se arrastra una lección */
.lesson-dragging-ghost {
  opacity: 0.35;
  background: var(--surface-2);
  border-style: dashed;
}
.lesson-dragging-chosen {
  box-shadow: 0 6px 20px rgba(0,0,0,0.4);
  border-color: var(--primary);
}
.lesson-admin-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.lesson-admin-info {
  flex: 1;
  min-width: 0;
}
.lesson-admin-info strong {
  display: block;
  margin-bottom: 0.15rem;
}
.lesson-order {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 36px;
  padding: 0 0.5rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--primary);
  font-weight: 600;
  font-size: 0.85rem;
  flex-shrink: 0;
}

@media (max-width: 600px) {
  .admin-list-item { flex-direction: column; align-items: stretch; }
  .lesson-admin-row { flex-wrap: wrap; }
}

/* Tabs sencillos */
.tabs { display: flex; gap: 0.5rem; margin-bottom: 1rem; border-bottom: 1px solid var(--border); }
.tab {
  padding: 0.5rem 1rem;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  color: var(--text-dim);
}
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }

.empty {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-dim);
}

/* ===== Avatares ===== */
.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-2);
  color: var(--text);
  font-weight: 600;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  user-select: none;
}
.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.avatar-sm { width: 32px; height: 32px; font-size: 0.85rem; }
.avatar-md { width: 48px; height: 48px; font-size: 1.05rem; }
.avatar-lg { width: 120px; height: 120px; font-size: 2.2rem; }

/* Botón con avatar dentro (para el navbar) */
.btn-avatar {
  padding: 0.25rem 0.65rem 0.25rem 0.3rem;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

/* Comentario con avatar */
.comment .author {
  align-items: flex-start;
}
.comment-row {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
}
.comment-row > .comment-body { flex: 1; }

/* ===== Hilos de comentarios y respuestas del admin ===== */
.comment-thread { margin-bottom: 0.75rem; }
.comment-thread .comment { margin-bottom: 0; }

.replies {
  margin-top: 0.5rem;
  margin-left: 2.5rem;
  padding-left: 1rem;
  border-left: 2px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

/* Respuestas (variante indentada) */
.comment-reply {
  background: var(--surface-2);
  border-color: var(--border);
}

/* Respuestas del administrador: acento rojo (color de marca) */
.comment-admin {
  border-color: rgba(255, 94, 58, 0.5);
  background: linear-gradient(180deg, rgba(255, 94, 58, 0.06), var(--surface-2));
}

/* Bloque flex que agrupa nombre y badge */
.comment .author-meta {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

/* Badge "Admin" */
.badge-admin {
  display: inline-block;
  padding: 0.12rem 0.5rem;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--primary);
  background: rgba(255, 94, 58, 0.12);
  border: 1px solid rgba(255, 94, 58, 0.35);
  border-radius: 999px;
}

/* Acciones bajo el cuerpo del comentario */
.comment-actions {
  margin-top: 0.5rem;
  display: flex;
  gap: 0.5rem;
}
.btn-reply {
  background: transparent;
  border-color: var(--border);
  color: var(--text-dim);
}
.btn-reply:hover {
  color: var(--primary);
  border-color: var(--primary);
}

/* Formulario de respuesta inline */
.reply-form-wrap {
  margin-top: 0.5rem;
  padding: 0.75rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.reply-form textarea {
  min-height: 60px;
}

@media (max-width: 600px) {
  .replies { margin-left: 1rem; }
}
