/* =========================
   RESET + BASE
========================= */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  background: #0f1117;
  color: #e5e7eb;
  font-family: "Inter", "Segoe UI", sans-serif;
}

/* =========================
   TOPBAR
========================= */
.topbar {
  block-size: 60px;
  background: #111318;
  border-block-end: 1px solid #1f2937;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
}

.topbar button {
  background: transparent;
  border: 1px solid #374151;
  color: #e5e7eb;
  padding: 6px 12px;
  border-radius: 6px;
  transition: 0.2s;
}

.topbar button:hover {
  border-color: #7c3aed;
  color: #7c3aed;
}

.btn-export {
  background: #7c3aed !important;
  border: none !important;
  color: white !important;
  padding: 8px 16px !important;
  border-radius: 6px !important;
}

.btn-export:hover {
  background: #6d28d9 !important;
  border-color: #6d28d9 !important;
}

/* =========================
   LAYOUT
========================= */
.container {
  display: flex;
  block-size: calc(100vh - 60px);
}

/* =========================
   SIDEBAR
========================= */
.sidebar {
  inline-size: 260px;
  background: #111318;
  border-inline-end: 1px solid #1f2937;
  padding: 15px;
}

.sidebar h3 {
  margin-block-end: 10px;
  font-size: 14px;
  color: #9ca3af;
}

.sidebar button {
  inline-size: 100%;
  background: #7c3aed;
  border: none;
  color: #fff;
  padding: 8px;
  border-radius: 8px;
  margin-block-end: 10px;
  cursor: pointer;
  transition: 0.2s;
}

.sidebar button:hover {
  background: #6d28d9;
}

.sidebar ul {
  list-style: none;
}

.sidebar ul li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 8px;
  border-radius: 6px;
  cursor: pointer;
  transition: 0.2s;
  color: #d1d5db;
  margin-block-end: 6px;
}

.sidebar ul li:hover {
  background: #1f2937;
  color: #e5e7eb;
}

.sidebar ul li.active {
  background: #7c3aed;
  color: white;
  font-weight: 500;
}

.topic-item, .subtopic-item {
  display: flex !important;
  align-items: center;
  gap: 8px;
}

.btn-delete-item {
  background: transparent !important;
  border: none !important;
  color: #9ca3af !important;
  padding: 0 4px !important;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  min-width: 24px;
  margin-left: auto;
  flex-shrink: 0;
}

.btn-delete-item:hover {
  color: #ef4444 !important;
}

/* =========================
   MAIN PANEL
========================= */
.main {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
}

.main h3, .main h4 {
  margin-block-end: 12px;
  font-size: 16px;
  font-weight: 600;
  color: #e5e7eb;
}

.main button {
  inline-size: 100%;
  background: #7c3aed;
  border: none;
  color: #fff;
  padding: 8px;
  border-radius: 8px;
  margin-block-end: 12px;
  cursor: pointer;
  transition: 0.2s;
  font-weight: 500;
}

.main button:hover {
  background: #6d28d9;
}

#subtopicsList {
  list-style: none;
  margin-block-end: 20px;
}

#subtopicsList li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border-radius: 6px;
  cursor: pointer;
  transition: 0.2s;
  color: #d1d5db;
  margin-block-end: 6px;
}

#subtopicsList li span {
  flex: 1;
  white-space: nowrap;
}

#subtopicsList li:hover {
  background: #1f2937;
  color: #e5e7eb;
}

#subtopicsList li.active {
  background: #7c3aed;
  color: white;
  font-weight: 500;
}

/* =========================
   BOTONES GENERALES
========================= */
button {
  font-size: 13px;
}

/* =========================
   CARDS / BLOQUES
========================= */
.block {
  background: #111318;
  border: 1px solid #1f2937;
  border-radius: 10px;
  padding: 12px;
  margin-block-end: 12px;
  transition: 0.2s;
}

.block:hover {
  border-color: #374151;
}

#blocksContainer ul {
  list-style: none;
  margin-block-end: 20px;
}

.block-item {
  display: flex !important;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border-radius: 6px;
  cursor: pointer;
  transition: 0.2s;
  color: #d1d5db;
  margin-block-end: 6px;
}

.block-item:hover {
  background: #1f2937;
  color: #e5e7eb;
}

.block-item.active {
  background: #7c3aed;
  color: white;
  font-weight: 500;
}

.block-editor {
  background: #111318;
  border: 1px solid #374151;
  border-radius: 10px;
  padding: 15px;
  margin-top: 15px;
}

.block-editor h4 {
  font-size: 14px;
  font-weight: 600;
  margin-block-end: 12px;
}

.block-actions {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}

.btn-save, .btn-cancel {
  flex: 1;
  padding: 8px 12px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 500;
  font-size: 13px;
  transition: 0.2s;
}

.btn-save {
  background: #10b981;
  color: white;
}

.btn-save:hover {
  background: #059669;
}

.btn-cancel {
  background: #6b7280;
  color: white;
}

.btn-cancel:hover {
  background: #4b5563;
}

/* =========================
   INPUTS
========================= */
input, textarea, select {
  inline-size: 100%;
  background: #0f1117;
  border: 1px solid #374151;
  color: #e5e7eb;
  border-radius: 6px;
  padding: 6px 8px;
  margin-block-end: 6px;
  font-size: 13px;
}

input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: #7c3aed;
}

/* =========================
   TEXTAREA
========================= */
textarea {
  resize: vertical;
  min-block-size: 80px;
}

.block-editor textarea {
  min-height: 160px;
}

/* =========================
   BOTÓN ELIMINAR
========================= */
.block button {
  background: #dc2626;
  border: none;
  color: white;
  padding: 5px 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: 0.2s;
}

.block button:hover {
  background: #b91c1c;
}

/* =========================
   SCROLLBAR
========================= */
::-webkit-scrollbar {
  inline-size: 8px;
}

::-webkit-scrollbar-track {
  background: #0f1117;
}

::-webkit-scrollbar-thumb {
  background: #374151;
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: #4b5563;
}

/* =========================
   SUBTLE TEXT
========================= */
.muted {
  color: #9ca3af;
  font-size: 12px;
}

/* =========================
   SEPARADORES
========================= */
.section {
  margin-block-end: 25px;
  padding-block-end: 10px;
  border-block-end: 1px solid #1f2937;
}

/* =========================
   ÁRBOL DE TEMAS/SUBTEMAS
========================= */
#topicsTree {
  margin-top: 10px;
}

.tree-topic {
  margin-bottom: 8px;
}

.tree-topic-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px;
  border-radius: 6px;
  cursor: pointer;
  transition: 0.2s;
  color: #d1d5db;
}

.tree-topic-header:hover {
  background: #1f2937;
  color: #e5e7eb;
}

.tree-topic-header.active {
  background: #7c3aed;
  color: white;
  font-weight: 500;
}

.tree-toggle {
  display: inline-block;
  width: 20px;
  text-align: center;
  font-size: 12px;
  user-select: none;
  cursor: pointer;
  flex-shrink: 0;
}

.tree-label {
  flex: 1;
}

.tree-subtopics {
  margin-left: 20px;
  padding-left: 12px;
  border-left: 1px solid #374151;
  margin-top: 4px;
}

.tree-subtopic {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 4px;
  cursor: pointer;
  transition: 0.2s;
  color: #d1d5db;
  margin-bottom: 4px;
}

.tree-subtopic:hover {
  background: #1f2937;
  color: #e5e7eb;
}

.tree-subtopic.active {
  background: #7c3aed;
  color: white;
  font-weight: 500;
}

/* =========================
   SELECTION INFO Y BOTONES
========================= */
.selection-info {
  background: #111318;
  border: 1px solid #374151;
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 15px;
}

.info-item {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  font-size: 14px;
}

.info-item:last-child {
  margin-bottom: 0;
}

.info-label {
  color: #9ca3af;
  font-weight: 500;
  min-width: 90px;
}

.info-value {
  color: #e5e7eb;
  font-weight: 500;
}

.creation-buttons {
  display: flex;
  gap: 8px;
  margin-bottom: 15px;
}

.creation-buttons button {
  flex: 1;
  background: #7c3aed;
  border: none;
  color: white;
  padding: 8px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 500;
  transition: 0.2s;
  font-size: 13px;
}

.creation-buttons button:hover {
  background: #6d28d9;
}

/* =========================
   NOTIFICACIONES
========================= */
.notification {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: #10b981;
  color: white;
  padding: 12px 20px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  animation: slideIn 0.3s ease-out;
  z-index: 1000;
}

@keyframes slideIn {
  from {
    transform: translateX(400px);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}