/* =========================================
   RESETEO DE TABLAS (Evitar conflictos con el tema)
   ========================================= */
.prose .highlighttable,
.highlighttable {
  background-color: transparent !important;
  border: none !important;
  margin: 0 !important;
  padding: 0 !important;
  width: 100% !important;
  display: flex !important;
}

.prose .highlighttable td,
.prose .highlighttable th,
.highlighttable td,
.highlighttable th {
  border: none !important;
  padding: 0 !important;
  margin: 0 !important;
  background-color: transparent !important;
}

.prose .highlighttable tr,
.highlighttable tr {
  border: none !important;
  background-color: transparent !important;
  display: flex !important;
  width: 100% !important;
}

.highlighttable tbody {
  display: flex !important;
  width: 100% !important;
}

/* =========================================
   CONTENEDOR PRINCIPAL
   ========================================= */
.highlight {
  position: relative;
  border-radius: 0.5rem;
  margin: 1.5em 0;
  overflow: hidden;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.2), 0 2px 4px -1px rgba(0, 0, 0, 0.1);
  background-color: #282a36 !important; /* Fondo principal Dracula */
}

/* Base Pre */
.highlight pre {
  margin: 0 !important;
  padding: 1.25rem 1rem !important;
  overflow-x: auto;
  background-color: transparent !important; /* Deja ver el fondo del contenedor */
  color: #f8f8f2 !important;
  font-size: 0.9em;
  line-height: 1.5;
  border: none !important;
}

/* =========================================
   NÚMEROS DE LÍNEA
   ========================================= */
.highlighttable td.linenos {
  padding: 0 !important; /* El pre de dentro ya tiene el padding */
  border-right: 1px solid rgba(255, 255, 255, 0.1) !important;
  background-color: #21222c !important; /* Un tono ligeramente más oscuro para la barra lateral */
  user-select: none;
  min-width: 2.5rem;
  text-align: right;
}

/* Ajustar el padding horizontal del pre de los números de línea para que quede bien */
.highlighttable td.linenos pre {
  padding-left: 0.5rem !important;
  padding-right: 0.5rem !important;
  /* El padding superior e inferior (1.25rem) lo hereda de .highlight pre, alineándose perfecto con el código */
}

/* Sobrescribir el estilo feo que Pygments aplica por defecto a los linenos */
.highlighttable td.linenos .normal,
.highlighttable td.linenos .special,
.highlight span.linenos {
  background-color: transparent !important;
  color: #6272a4 !important; /* Color comentario de dracula para que sea sutil */
  padding: 0 !important;
}

/* Los números de línea son enlaces (<a>), así que tenemos que estilizarlos explícitamente */
.highlighttable td.linenos a {
  color: #6272a4 !important;
  text-decoration: none !important;
  pointer-events: none; /* Opcional: evita que parezcan clickables si no queremos */
}
.highlighttable td.linenos a:hover {
  color: #f8f8f2 !important;
}

/* Contenedor del código en sí */
.highlighttable td.code {
  flex: 1;
  width: calc(100% - 3rem);
  overflow-x: auto;
}

/* =========================================
   BOTÓN DE COPIAR
   ========================================= */
.copy-button {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  padding: 0.4rem;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 0.375rem;
  color: #f8f8f2;
  cursor: pointer;
  opacity: 0;
  transition: all 0.2s ease-in-out;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
}

.highlight:hover .copy-button {
  opacity: 1;
}

.copy-button:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: scale(1.05);
}

.copy-button.copied {
  background: #50fa7b; /* Verde Dracula */
  color: #282a36;
  border-color: #50fa7b;
}

/* =========================================
   SCROLLBAR MODERNO
   ========================================= */
pre::-webkit-scrollbar,
.highlighttable td.code::-webkit-scrollbar {
  height: 8px;
}
pre::-webkit-scrollbar-track,
.highlighttable td.code::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 0 0 0.5rem 0.5rem;
}
pre::-webkit-scrollbar-thumb,
.highlighttable td.code::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 4px;
}
pre::-webkit-scrollbar-thumb:hover,
.highlighttable td.code::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* =========================================
   ETIQUETA DE LENGUAJE
   ========================================= */
.language-badge {
  position: absolute;
  top: 0.9rem;
  right: 3rem; /* Espacio para que no pise el botón de copiar */
  color: #6272a4;
  font-size: 0.75rem;
  font-family: monospace;
  text-transform: uppercase;
  font-weight: bold;
  user-select: none;
  pointer-events: none;
  z-index: 5;
  opacity: 0.7;
}
