/* ============================================================= */
/*          ESTILOS GLOBALES Y VARIABLES REFINADAS             */
/* ============================================================= */
:root {
    /* Paleta de colores modernizada */
    --sidebar-bg: #1e293b;
    /* Azul oscuro profundo (Slate 800) */
    --sidebar-text: #94a3b8;
    /* Gris azulado claro */
    --sidebar-text-hover: #f1f5f9;
    /* Blanco casi puro */
    --sidebar-hover-bg: rgba(255, 255, 255, 0.1);
    /* Transparencia para hover */

    --link-color: #3b82f6;
    /* Azul vibrante */
    --content-bg: #f8fafc;
    /* Gris muy muy claro (Slate 50) */
    --card-bg: #ffffff;

    --text-color: #334155;
    /* Gris oscuro suave (Slate 700) */
    --heading-color: #0f172a;
    /* Negro azulado (Slate 900) */
    --border-color: #e2e8f0;
    /* Gris suave */

    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --radius: 8px;
    --header-bg: rgba(255, 255, 255, 0.85);
    /* Fondo claro por defecto */
}

html[data-theme="dark"] {
    --sidebar-bg: #020617;
    /* Slate 950 - Más oscuro para profundidad */
    --sidebar-text: #cbd5e1;
    /* Slate 300 */
    --sidebar-text-hover: #ffffff;
    --sidebar-hover-bg: rgba(255, 255, 255, 0.1);

    --link-color: #38bdf8;
    /* Sky 400 - Más brillante y legible */
    --content-bg: #0f172a;
    /* Slate 900 - Fondo principal más oscuro */
    --card-bg: #1e293b;
    /* Slate 800 - Tarjetas distinguibles */

    --text-color: #f8fafc;
    /* Slate 50 - Texto casi blanco para máximo contraste */
    --heading-color: #f1f5f9;
    /* Slate 100 - Títulos destacados */
    --border-color: #334155;
    /* Slate 700 - Bordes sutiles */

    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.5);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.5), 0 2px 4px -2px rgb(0 0 0 / 0.5);



    --header-bg: rgba(2, 6, 23, 0.95);
    /* Fondo casi negro (Slate 950) para máximo contraste con texto blanco */

    color-scheme: dark;
}

html[data-theme="dark"] body {
    background-color: #0f172a;
    /* Coincide con --content-bg */
    color: #e2e8f0;
}

/* Failsafe para párrafos en modo oscuro */
html[data-theme="dark"] .main-content p,
html[data-theme="dark"] .main-content li {
    color: #f8fafc !important;
    opacity: 1;
}

/* --- Botón de Tema --- */
.theme-toggle {
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    color: var(--text-color);
    transition: background-color 0.3s, color 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: 15px;
}

.theme-toggle:hover {
    background-color: rgba(0, 0, 0, 0.05);
    color: var(--link-color);
}

[data-theme="dark"] .theme-toggle:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.theme-toggle svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif;
    line-height: 1.6;
    margin: 0;
    background-color: var(--content-bg);
    color: var(--text-color);
    -webkit-font-smoothing: antialiased;
    /* Texto más nítido */
}

.main-container {
    display: flex;
    min-height: 100vh;
}

/* ============================================================= */
/*          MENÚ LATERAL (SIDEBAR)                             */
/* ============================================================= */
.sidebar {
    width: 280px;
    background-color: var(--sidebar-bg);
    color: var(--sidebar-text);
    position: fixed;
    height: 100%;
    overflow-y: auto;
    padding: 30px 20px;
    box-sizing: border-box;
    border-right: 1px solid rgba(255, 255, 255, 0.05);
    /* Scrollbar personalizada fina para el sidebar */
    scrollbar-width: thin;
    scrollbar-color: #475569 var(--sidebar-bg);
}

.sidebar h2 {
    color: var(--sidebar-text-hover);
    margin: 0 0 30px 10px;
    text-align: left;
    font-weight: 700;
    font-size: 1.5rem;
    letter-spacing: -0.5px;
}

#menu-tree,
.nested {
    list-style-type: none;
    padding: 0;
    margin: 0;
}

#menu-tree ul {
    padding-left: 15px;
    margin-top: 5px;
    border-left: 1px solid #334155;
    /* Línea guía para submenús */
    margin-left: 10px;
}

#menu-tree a {
    color: var(--sidebar-text);
    text-decoration: none;
    display: block;
    padding: 10px 12px;
    border-radius: var(--radius);
    transition: all 0.2s ease;
    font-size: 0.95rem;
}

#menu-tree a:hover {
    text-decoration: none;
    color: var(--sidebar-text-hover);
    background-color: var(--sidebar-hover-bg);
    transform: translateX(3px);
    /* Pequeño movimiento al hover */
}

/* Enlaces anidados */
#menu-tree .nested a {
    font-size: 0.9rem;
    padding: 8px 12px;
    color: #94a3b8;
}

#menu-tree .nested a:hover {
    color: var(--sidebar-text-hover);
    background-color: var(--sidebar-hover-bg);
}

/* Interactividad del Caret (Desplegable) */
.caret {
    cursor: pointer;
    user-select: none;
    display: flex;
    /* Flex para alinear mejor */
    align-items: center;
    padding: 10px 12px;
    font-weight: 600;
    color: var(--sidebar-text);
    border-radius: var(--radius);
    transition: background 0.2s;
}

.caret:hover {
    background-color: var(--sidebar-hover-bg);
    color: var(--sidebar-text-hover);
}

.caret::before {
    content: "\25B6";
    /* Triángulo unicode en lugar de + */
    font-size: 0.7em;
    color: var(--sidebar-text);
    display: inline-block;
    margin-right: 12px;
    transition: transform 0.2s ease;
    opacity: 0.7;
}

.caret-down::before {
    transform: rotate(90deg);
}

.nested {
    display: none;
}

.active {
    display: block;
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ============================================================= */
/*          ÁREA DE CONTENIDO PRINCIPAL                          */
/* ============================================================= */
.content-wrapper {
    margin-left: 280px;
    width: calc(100% - 280px);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: var(--header-bg);
    /* Transparencia */
    backdrop-filter: blur(10px);
    /* Efecto de vidrio */
    -webkit-backdrop-filter: blur(10px);
    padding: 0 40px;
    border-bottom: 1px solid var(--border-color);
    height: 70px;
    box-sizing: border-box;
    position: sticky;
    top: 0;
    z-index: 100;
}

html[data-theme="dark"] .top-bar {
    background-color: rgba(2, 6, 23, 0.95) !important;
    border-bottom: 1px solid #334155;
}

.top-bar .title {
    font-family: 'Segoe UI', monospace;
    /* Fuente más moderna pero técnica */
    font-size: 1.1em;
    font-weight: 700;
    color: var(--heading-color);
    letter-spacing: -0.5px;
}

.top-bar .icons span {
    margin-left: 20px;
    cursor: pointer;
    font-size: 1.2em;
    color: var(--text-color);
    transition: color 0.2s;
}

.top-bar .icons span:hover {
    color: var(--link-color);
}

.main-content {
    padding: 40px;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
    box-sizing: border-box;
}

/* Estilo de "Tarjetas" para las secciones */
.main-content section {
    background-color: var(--card-bg);
    padding: 40px;
    margin-bottom: 30px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.3s ease;
}

.main-content section:hover {
    box-shadow: var(--shadow-md);
}

h1,
h2,
h3 {
    color: var(--heading-color);
    margin-top: 0;
    margin-bottom: 20px;
    font-weight: 700;
    line-height: 1.3;
}

h1 {
    font-size: 2.2rem;
    letter-spacing: -1px;
}

h2 {
    font-size: 1.75rem;
    letter-spacing: -0.5px;
    border-bottom: 2px solid #f1f5f9;
    padding-bottom: 10px;
}

h3 {
    font-size: 1.4rem;
}

p {
    margin-top: 0;
    margin-bottom: 1.5em;
    color: #475569;
}

/* ============================================================= */
/*          COMPONENTES UI REFINADOS                             */
/* ============================================================= */

/* --- Alertas (Callouts) Modernas --- */
.alert {
    padding: 16px 20px;
    margin: 25px 0;
    border-radius: 8px;
    border-left: 4px solid;
    /* Fondo con gradiente muy sutil */
    background: linear-gradient(to right, var(--bg-color), transparent);
    font-size: 0.95em;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.02);
}

.alert::before {
    font-weight: 700;
    display: block;
    margin-bottom: 4px;
    font-size: 0.85em;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.alert-info {
    --bg-color: #eff6ff;
    background-color: #eff6ff;
    border-color: #3b82f6;
    color: #1e40af;
}

.alert-info::before {
    content: "ℹ️ NOTA";
    color: #2563eb;
}

.alert-success {
    --bg-color: #f0fdf4;
    background-color: #f0fdf4;
    border-color: #22c55e;
    color: #166534;
}

.alert-success::before {
    content: "✅ CONSEJO";
    color: #16a34a;
}

.alert-warning {
    --bg-color: #fffbeb;
    background-color: #fffbeb;
    border-color: #f59e0b;
    color: #92400e;
}

.alert-warning::before {
    content: "⚠️ ADVERTENCIA";
    color: #d97706;
}

.alert-danger {
    --bg-color: #fef2f2;
    background-color: #fef2f2;
    border-color: #ef4444;
    color: #991b1b;
}

.alert-danger::before {
    content: "🛑 PELIGRO";
    color: #dc2626;
}

/* --- Código y Teclas --- */
p code,
li code,
th code,
td code {
    background-color: #f1f5f9;
    color: #0f172a;
    padding: 2px 6px;
    border-radius: 6px;
    font-size: 0.85em;
    font-family: "Menlo", "Monaco", "Consolas", monospace;
    border: 1px solid #e2e8f0;
}

.key {
    display: inline-block;
    background-color: white;
    border: 1px solid #cbd5e1;
    border-bottom-width: 3px;
    border-radius: 6px;
    padding: 2px 8px;
    font-family: monospace;
    font-size: 0.85em;
    color: #475569;
    font-weight: 600;
}

/* --- Badges --- */
.badge {
    display: inline-block;
    padding: 4px 10px;
    font-size: 0.75em;
    font-weight: 700;
    border-radius: 20px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Colores de badges más sofisticados */
.badge-blue {
    background-color: #eff6ff;
    color: #2563eb;
    border: 1px solid #bfdbfe;
}

.badge-green {
    background-color: #f0fdf4;
    color: #16a34a;
    border: 1px solid #bbf7d0;
}

.badge-red {
    background-color: #fef2f2;
    color: #dc2626;
    border: 1px solid #fecaca;
}

.badge-yellow {
    background-color: #fffbeb;
    color: #d97706;
    border: 1px solid #fde68a;
}

.badge-gray {
    background-color: #f8fafc;
    color: #475569;
    border: 1px solid #e2e8f0;
}

/* ============================================================= */
/*                   TABLAS ESTILIZADAS                          */
/* ============================================================= */
.table-container {
    overflow-x: auto;
    margin: 30px 0;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: var(--shadow-sm);
    background: white;
}

.main-content table {
    width: 100%;
    border-collapse: separate;
    /* Necesario para border-radius en tr */
    border-spacing: 0;
    font-size: 0.95em;
}

.main-content th {
    background-color: #f8fafc;
    color: var(--heading-color);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.8rem;
    letter-spacing: 0.5px;
    padding: 16px 24px;
    border-bottom: 1px solid var(--border-color);
    text-align: left;
}

.main-content td {
    padding: 16px 24px;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
    color: var(--text-color);
}

.main-content tbody tr {
    transition: background-color 0.2s;
}

.main-content tbody tr:hover {
    background-color: #f8fafc;
}

.main-content tbody tr:last-child td {
    border-bottom: none;
}

/* Overrides para Modo Oscuro en Tablas */
html[data-theme="dark"] .table-container {
    background-color: var(--card-bg);
    border-color: var(--border-color);
}

html[data-theme="dark"] .main-content th {
    background-color: #0f172a;
    /* Slate 900 */
    color: #f8fafc;
    border-bottom-color: #334155;
}

html[data-theme="dark"] .main-content td {
    color: #e2e8f0;
    border-bottom-color: #334155;
}

html[data-theme="dark"] .main-content tbody tr:hover {
    background-color: rgba(255, 255, 255, 0.05);
}

/* ============================================================= */
/*                   HEADER Y NAVEGACIÓN SUPERIOR               */
/* ============================================================= */
.title-link {
    text-decoration: none;
    color: inherit;
}

.header-nav ul {
    margin: 0;
    padding: 0;
    list-style: none;
    display: flex;
    gap: 10px;
}

.header-nav a {
    text-decoration: none;
    color: #64748b;
    font-weight: 600;
    font-size: 0.9rem;
    padding: 8px 16px;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.header-nav a:hover {
    background-color: #f1f5f9;
    color: #0f172a;
}

.header-nav a.active-link {
    background-color: #eff6ff;
    color: #2563eb;
}

/* ============================================================= */
/*          IMÁGENES Y VIDEO                                     */
/* ============================================================= */
.main-content img {
    max-width: 100%;
    height: auto;
    display: block;
    border-radius: 12px;
    /* Bordes más redondeados */
}

.img-shadow {
    box-shadow: var(--shadow-md);
}

.img-border {
    border: 1px solid var(--border-color);
    padding: 4px;
    background: white;
}

.video-container {
    margin: 30px 0;
    padding: 20px;
    background-color: #f1f5f9;
    border-radius: 12px;
}

.video-responsive-wrapper {
    position: relative;
    overflow: hidden;
    width: 100%;
    padding-top: 56.25%;
    border-radius: 8px;
    box-shadow: var(--shadow-sm);
}

.video-responsive-wrapper iframe,
.video-responsive-wrapper video {
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    width: 100%;
    height: 100%;
    border: none;
}

/* ============================================================= */
/*          RESPONSIVE (MOBILE)                                  */
/* ============================================================= */

.menu-toggle-button {
    display: none;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 20px;
    color: var(--heading-color);
    cursor: pointer;
    margin-right: 15px;
    padding: 6px 10px;
    transition: background 0.2s;
}

.menu-toggle-button:hover {
    background-color: #f1f5f9;
}

.overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(15, 23, 42, 0.4);
    /* Slate oscuro semi-transparente */
    backdrop-filter: blur(2px);
    z-index: 999;
}

.overlay.overlay-visible {
    display: block;
    animation: fadeIn 0.2s ease-in-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@media screen and (max-width: 992px) {
    .menu-toggle-button {
        display: block;
    }

    .header-nav {
        display: none;
    }

    .sidebar {
        left: -290px;
        /* Asegurar que salga completo con sombra */
        box-shadow: 5px 0 25px rgba(0, 0, 0, 0.15);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        transform: translateX(0);
    }

    .sidebar.sidebar-visible {
        transform: translateX(290px);
    }

    .content-wrapper {
        margin-left: 0;
        width: 100%;
    }

    .main-content {
        padding: 20px;
    }

    .main-content section {
        padding: 25px 20px;
    }

    .top-bar {
        padding: 0 20px;
        height: 60px;
    }
}

/* ============================================================= */
/*          ESTILOS GLOBALES Y VARIABLES REFINADAS             */
/* ============================================================= */
:root {
    /* Paleta de colores modernizada */
    --sidebar-bg: #1e293b;
    /* Azul oscuro profundo (Slate 800) */
    --sidebar-text: #94a3b8;
    /* Gris azulado claro */
    --sidebar-text-hover: #f1f5f9;
    /* Blanco casi puro */
    --sidebar-hover-bg: rgba(255, 255, 255, 0.1);
    /* Transparencia para hover */

    --link-color: #3b82f6;
    /* Azul vibrante */
    --content-bg: #f8fafc;
    /* Gris muy muy claro (Slate 50) */
    --card-bg: #ffffff;

    --text-color: #334155;
    /* Gris oscuro suave (Slate 700) */
    --heading-color: #0f172a;
    /* Negro azulado (Slate 900) */
    --border-color: #e2e8f0;
    /* Gris suave */

    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --radius: 8px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif;
    line-height: 1.6;
    margin: 0;
    background-color: var(--content-bg);
    color: var(--text-color);
    -webkit-font-smoothing: antialiased;
    /* Texto más nítido */
}

.main-container {
    display: flex;
    min-height: 100vh;
}

/* ============================================================= */
/*          MENÚ LATERAL (SIDEBAR)                             */
/* ============================================================= */
.sidebar {
    width: 280px;
    background-color: var(--sidebar-bg);
    color: var(--sidebar-text);
    position: fixed;
    height: 100%;
    overflow-y: auto;
    padding: 30px 20px;
    box-sizing: border-box;
    border-right: 1px solid rgba(255, 255, 255, 0.05);
    /* Scrollbar personalizada fina para el sidebar */
    scrollbar-width: thin;
    scrollbar-color: #475569 var(--sidebar-bg);
}

.sidebar h2 {
    color: var(--sidebar-text-hover);
    margin: 0 0 30px 10px;
    text-align: left;
    font-weight: 700;
    font-size: 1.5rem;
    letter-spacing: -0.5px;
}

#menu-tree,
.nested {
    list-style-type: none;
    padding: 0;
    margin: 0;
}

#menu-tree ul {
    padding-left: 15px;
    margin-top: 5px;
    border-left: 1px solid #334155;
    /* Línea guía para submenús */
    margin-left: 10px;
}

#menu-tree a {
    color: var(--sidebar-text);
    text-decoration: none;
    display: block;
    padding: 10px 12px;
    border-radius: var(--radius);
    transition: all 0.2s ease;
    font-size: 0.95rem;
}

#menu-tree a:hover {
    text-decoration: none;
    color: var(--sidebar-text-hover);
    background-color: var(--sidebar-hover-bg);
    transform: translateX(3px);
    /* Pequeño movimiento al hover */
}

/* Enlaces anidados */
#menu-tree .nested a {
    font-size: 0.9rem;
    padding: 8px 12px;
    color: #94a3b8;
}

#menu-tree .nested a:hover {
    color: var(--sidebar-text-hover);
    background-color: var(--sidebar-hover-bg);
}

/* Interactividad del Caret (Desplegable) */
.caret {
    cursor: pointer;
    user-select: none;
    display: flex;
    /* Flex para alinear mejor */
    align-items: center;
    padding: 10px 12px;
    font-weight: 600;
    color: var(--sidebar-text);
    border-radius: var(--radius);
    transition: background 0.2s;
}

.caret:hover {
    background-color: var(--sidebar-hover-bg);
    color: var(--sidebar-text-hover);
}

.caret::before {
    content: "\25B6";
    /* Triángulo unicode en lugar de + */
    font-size: 0.7em;
    color: var(--sidebar-text);
    display: inline-block;
    margin-right: 12px;
    transition: transform 0.2s ease;
    opacity: 0.7;
}

.caret-down::before {
    transform: rotate(90deg);
}

.nested {
    display: none;
}

.active {
    display: block;
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ============================================================= */
/*          ÁREA DE CONTENIDO PRINCIPAL                          */
/* ============================================================= */
.content-wrapper {
    margin-left: 280px;
    width: calc(100% - 280px);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: rgba(255, 255, 255, 0.85);
    /* Transparencia */
    backdrop-filter: blur(10px);
    /* Efecto de vidrio */
    -webkit-backdrop-filter: blur(10px);
    padding: 0 40px;
    border-bottom: 1px solid var(--border-color);
    height: 70px;
    box-sizing: border-box;
    position: sticky;
    top: 0;
    z-index: 100;
}

.top-bar .title {
    font-family: 'Segoe UI', monospace;
    /* Fuente más moderna pero técnica */
    font-size: 1.1em;
    font-weight: 700;
    color: var(--heading-color);
    letter-spacing: -0.5px;
}

.top-bar .icons span {
    margin-left: 20px;
    cursor: pointer;
    font-size: 1.2em;
    color: var(--text-color);
    transition: color 0.2s;
}

.top-bar .icons span:hover {
    color: var(--link-color);
}

.main-content {
    padding: 40px;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
    box-sizing: border-box;
}

/* Estilo de "Tarjetas" para las secciones */
.main-content section {
    background-color: var(--card-bg);
    padding: 40px;
    margin-bottom: 30px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.3s ease;
}

.main-content section:hover {
    box-shadow: var(--shadow-md);
}

h1,
h2,
h3 {
    color: var(--heading-color);
    margin-top: 0;
    margin-bottom: 20px;
    font-weight: 700;
    line-height: 1.3;
}

h1 {
    font-size: 2.2rem;
    letter-spacing: -1px;
}

h2 {
    font-size: 1.75rem;
    letter-spacing: -0.5px;
    border-bottom: 2px solid #f1f5f9;
    padding-bottom: 10px;
}

h3 {
    font-size: 1.4rem;
}

p {
    margin-top: 0;
    margin-bottom: 1.5em;
    color: #475569;
}

/* ============================================================= */
/*          COMPONENTES UI REFINADOS                             */
/* ============================================================= */

/* --- Alertas (Callouts) Modernas --- */
.alert {
    padding: 16px 20px;
    margin: 25px 0;
    border-radius: 8px;
    border-left: 4px solid;
    /* Fondo con gradiente muy sutil */
    background: linear-gradient(to right, var(--bg-color), transparent);
    font-size: 0.95em;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.02);
}

.alert::before {
    font-weight: 700;
    display: block;
    margin-bottom: 4px;
    font-size: 0.85em;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.alert-info {
    --bg-color: #eff6ff;
    background-color: #eff6ff;
    border-color: #3b82f6;
    color: #1e40af;
}

.alert-info::before {
    content: "ℹ️ NOTA";
    color: #2563eb;
}

.alert-success {
    --bg-color: #f0fdf4;
    background-color: #f0fdf4;
    border-color: #22c55e;
    color: #166534;
}

.alert-success::before {
    content: "✅ CONSEJO";
    color: #16a34a;
}

.alert-warning {
    --bg-color: #fffbeb;
    background-color: #fffbeb;
    border-color: #f59e0b;
    color: #92400e;
}

.alert-warning::before {
    content: "⚠️ ADVERTENCIA";
    color: #d97706;
}

.alert-danger {
    --bg-color: #fef2f2;
    background-color: #fef2f2;
    border-color: #ef4444;
    color: #991b1b;
}

.alert-danger::before {
    content: "🛑 PELIGRO";
    color: #dc2626;
}

/* --- Código y Teclas --- */
p code,
li code,
th code,
td code {
    background-color: #f1f5f9;
    color: #0f172a;
    padding: 2px 6px;
    border-radius: 6px;
    font-size: 0.85em;
    font-family: "Menlo", "Monaco", "Consolas", monospace;
    border: 1px solid #e2e8f0;
}

.key {
    display: inline-block;
    background-color: white;
    border: 1px solid #cbd5e1;
    border-bottom-width: 3px;
    border-radius: 6px;
    padding: 2px 8px;
    font-family: monospace;
    font-size: 0.85em;
    color: #475569;
    font-weight: 600;
}

/* --- Badges --- */
.badge {
    display: inline-block;
    padding: 4px 10px;
    font-size: 0.75em;
    font-weight: 700;
    border-radius: 20px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Colores de badges más sofisticados */
.badge-blue {
    background-color: #eff6ff;
    color: #2563eb;
    border: 1px solid #bfdbfe;
}

.badge-green {
    background-color: #f0fdf4;
    color: #16a34a;
    border: 1px solid #bbf7d0;
}

.badge-red {
    background-color: #fef2f2;
    color: #dc2626;
    border: 1px solid #fecaca;
}

.badge-yellow {
    background-color: #fffbeb;
    color: #d97706;
    border: 1px solid #fde68a;
}

.badge-gray {
    background-color: #f8fafc;
    color: #475569;
    border: 1px solid #e2e8f0;
}

/* ============================================================= */
/*          OVERRIDES MODO OSCURO PARA COMPONENTES               */
/* ============================================================= */

/* --- Código y Teclas --- */
html[data-theme="dark"] p code,
html[data-theme="dark"] li code,
html[data-theme="dark"] th code,
html[data-theme="dark"] td code {
    background-color: #1e293b;
    /* Slate 800 */
    color: #e2e8f0;
    /* Slate 200 */
    border-color: #334155;
}

html[data-theme="dark"] .key {
    background-color: #334155;
    /* Slate 700 */
    border-color: #475569;
    color: #f8fafc;
}

/* --- Alertas en Modo Oscuro --- */
html[data-theme="dark"] .alert {
    background: linear-gradient(to right, var(--bg-color), transparent);
}

html[data-theme="dark"] .alert-info {
    --bg-color: rgba(59, 130, 246, 0.15);
    border-color: #3b82f6;
    color: #60a5fa;
    /* Blue 400 */
}

html[data-theme="dark"] .alert-success {
    --bg-color: rgba(34, 197, 94, 0.15);
    border-color: #22c55e;
    color: #4ade80;
    /* Green 400 */
}

html[data-theme="dark"] .alert-warning {
    --bg-color: rgba(245, 158, 11, 0.15);
    border-color: #f59e0b;
    color: #fbbf24;
    /* Amber 400 */
}

html[data-theme="dark"] .alert-danger {
    --bg-color: rgba(239, 68, 68, 0.15);
    border-color: #ef4444;
    color: #f87171;
    /* Red 400 */
}

/* --- Badges en Modo Oscuro --- */
html[data-theme="dark"] .badge-blue {
    background-color: rgba(59, 130, 246, 0.2);
    color: #60a5fa;
    border-color: rgba(59, 130, 246, 0.3);
}

html[data-theme="dark"] .badge-green {
    background-color: rgba(34, 197, 94, 0.2);
    color: #4ade80;
    border-color: rgba(34, 197, 94, 0.3);
}

html[data-theme="dark"] .badge-red {
    background-color: rgba(239, 68, 68, 0.2);
    color: #f87171;
    border-color: rgba(239, 68, 68, 0.3);
}

html[data-theme="dark"] .badge-yellow {
    background-color: rgba(245, 158, 11, 0.2);
    color: #fbbf24;
    border-color: rgba(245, 158, 11, 0.3);
}

html[data-theme="dark"] .badge-gray {
    background-color: #1e293b;
    color: #cbd5e1;
    border-color: #334155;
}

/* ============================================================= */
/*                   TABLAS ESTILIZADAS                          */
/* ============================================================= */
.table-container {
    overflow-x: auto;
    margin: 30px 0;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: var(--shadow-sm);
    background: white;
}

.main-content table {
    width: 100%;
    border-collapse: separate;
    /* Necesario para border-radius en tr */
    border-spacing: 0;
    font-size: 0.95em;
}

.main-content th {
    background-color: #f8fafc;
    color: var(--heading-color);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.8rem;
    letter-spacing: 0.5px;
    padding: 16px 24px;
    border-bottom: 1px solid var(--border-color);
    text-align: left;
}

.main-content td {
    padding: 16px 24px;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
    color: var(--text-color);
}

.main-content tbody tr {
    transition: background-color 0.2s;
}

.main-content tbody tr:hover {
    background-color: #f8fafc;
}

.main-content tbody tr:last-child td {
    border-bottom: none;
}

/* ============================================================= */
/*                   HEADER Y NAVEGACIÓN SUPERIOR               */
/* ============================================================= */
.title-link {
    text-decoration: none;
    color: inherit;
}

.header-nav ul {
    margin: 0;
    padding: 0;
    list-style: none;
    display: flex;
    gap: 10px;
}

.header-nav a {
    text-decoration: none;
    color: #64748b;
    font-weight: 600;
    font-size: 0.9rem;
    padding: 8px 16px;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.header-nav a:hover {
    background-color: #f1f5f9;
    color: #0f172a;
}

.header-nav a.active-link {
    background-color: #eff6ff;
    color: #2563eb;
}

/* ============================================================= */
/*          IMÁGENES Y VIDEO                                     */
/* ============================================================= */
.main-content img {
    max-width: 100%;
    height: auto;
    display: block;
    border-radius: 12px;
    /* Bordes más redondeados */
}

.img-shadow {
    box-shadow: var(--shadow-md);
}

.img-border {
    border: 1px solid var(--border-color);
    padding: 4px;
    background: white;
}

.video-container {
    margin: 30px 0;
    padding: 20px;
    background-color: #f1f5f9;
    border-radius: 12px;
}

.video-responsive-wrapper {
    position: relative;
    overflow: hidden;
    width: 100%;
    padding-top: 56.25%;
    border-radius: 8px;
    box-shadow: var(--shadow-sm);
}

.video-responsive-wrapper iframe,
.video-responsive-wrapper video {
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    width: 100%;
    height: 100%;
    border: none;
}

/* ============================================================= */
/*          DISEÑO RESPONSIVO (MÓVIL) - COPIA ESTO FINAL         */
/* ============================================================= */

@media screen and (max-width: 992px) {

    /* 1. ARREGLO DEL Z-INDEX (Soluciona lo borroso) */
    .overlay {
        z-index: 1000;
        /* Capa alta */
    }

    .sidebar {
        position: fixed;
        top: 0;
        left: -300px;
        height: 100vh;
        width: 280px;
        /* Z-INDEX CRÍTICO: Debe ser MAYOR que el overlay (1000) */
        z-index: 2000;
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: 5px 0 15px rgba(0, 0, 0, 0.2);
        transform: translateX(0);
    }

    .sidebar.sidebar-visible {
        transform: translateX(300px);
    }

    /* 2. ESTILOS PARA LOS ENLACES DEL HEADER DENTRO DEL SIDEBAR */
    /* Ocultamos la barra horizontal superior porque no cabe */
    .header-nav {
        display: none;
    }

    /* Mostramos la lista especial para móviles dentro del sidebar */
    .mobile-nav-links {
        display: block !important;
        /* Forzamos que se vea */
        margin-bottom: 20px;
        padding-bottom: 20px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    }

    .mobile-nav-links li a {
        color: #60a5fa !important;
        /* Un color azul claro para destacar */
        font-weight: bold;
        font-size: 1.1em;
    }

    /* Ajustes generales */
    .content-wrapper {
        margin-left: 0;
        width: 100%;
    }

    .menu-toggle-button {
        display: block;
    }

    .main-content {
        padding: 20px;
    }
}

/* Ocultar los enlaces móviles cuando estamos en PC */
.mobile-nav-links {
    display: none;
}

/* --- Estilos para los enlaces clonados (Móvil) --- */

/* Por defecto (escritorio) los ocultamos para no tener duplicados */
.mobile-links-container {
    display: none;
}

@media screen and (max-width: 992px) {

    /* En móvil, hacemos visible el contenedor clonado */
    .mobile-links-container {
        display: block;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        margin-bottom: 20px;
        padding-bottom: 10px;
    }

    .mobile-links-container h3 {
        color: var(--sidebar-text-hover);
        /* Color blanco/claro */
        font-size: 0.8em;
        text-transform: uppercase;
        opacity: 0.5;
        margin-bottom: 10px;
        padding-left: 12px;
        /* Alineado con los enlaces */
    }

    /* Estilizamos la lista UL clonada */
    .mobile-links-container ul {
        list-style: none;
        padding: 0;
        margin: 0;
        display: block;
        /* Aseguramos que sea vertical, no flex */
    }

    /* Estilo de los enlaces individuales */
    .mobile-links-container ul li a {
        display: block;
        padding: 12px 15px;
        color: #60a5fa;
        /* Azul claro para destacar */
        text-decoration: none;
        font-weight: 600;
        font-size: 1.1em;
        border-radius: 6px;
        transition: background 0.2s;
    }

    .mobile-links-container ul li a:hover {
        background-color: rgba(255, 255, 255, 0.1);
    }
}

/* ============================================================= */
/*          LIGHTBOX (ZOOM IMAGEN)                               */
/* ============================================================= */
.lightbox {
    display: none;
    position: fixed;
    z-index: 9999;
    /* Por encima de todo */
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9);
    justify-content: center;
    align-items: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.lightbox.active {
    display: flex;
    opacity: 1;
}

.lightbox img {
    max-width: 90%;
    max-height: 90vh;
    border-radius: 8px;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
    transform: scale(0.9);
    transition: transform 0.3s ease;
}

.lightbox.active img {
    transform: scale(1);
}

/* Cursor de zoom para las imágenes del contenido */
.main-content img {
    cursor: zoom-in;
}

/* ============================================================= */
/*          BLOQUES DE CÓDIGO CON LABEL Y BOTÓN COPIAR          */
/* ============================================================= */
.code-block-wrapper {
    position: relative;
    margin: 25px 0;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--border-color);
    background-color: #1e1e1e; /* Fondo oscuro para Prism */
    box-shadow: var(--shadow-md);
}

.code-block-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background-color: rgba(0, 0, 0, 0.3);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.code-language-label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #94a3b8;
    font-family: "Menlo", "Monaco", "Consolas", monospace;
}

.code-copy-button {
    background-color: rgba(59, 130, 246, 0.2);
    border: 1px solid rgba(59, 130, 246, 0.3);
    color: #60a5fa;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: "Menlo", "Monaco", "Consolas", monospace;
    display: flex;
    align-items: center;
    gap: 4px;
}

.code-copy-button:hover {
    background-color: rgba(59, 130, 246, 0.3);
    border-color: rgba(59, 130, 246, 0.5);
    color: #93c5fd;
}

.code-copy-button:active {
    transform: scale(0.95);
}

.code-copy-button.copied {
    background-color: rgba(34, 197, 94, 0.2);
    border-color: rgba(34, 197, 94, 0.3);
    color: #4ade80;
}

/* El texto del botón se maneja desde JavaScript */

.code-block-wrapper pre {
    margin: 0;
    padding: 16px;
    overflow-x: auto;
    background-color: transparent;
}

.code-block-wrapper pre code {
    background-color: transparent;
    border: none;
    padding: 0;
    font-size: 0.9rem;
    line-height: 1.6;
}

/* Modo oscuro para bloques de código */
html[data-theme="dark"] .code-block-wrapper {
    border-color: #334155;
    background-color: #1e293b;
}

html[data-theme="dark"] .code-block-header {
    background-color: rgba(15, 23, 42, 0.5);
    border-bottom-color: #334155;
}

html[data-theme="dark"] .code-language-label {
    color: #cbd5e1;
}

/* ============================================================= */
/*          BOTÓN SCROLL TO TOP (MÓVIL)                          */
/* ============================================================= */
.scroll-to-top {
    display: none; /* Oculto por defecto (escritorio) */
    position: fixed;
    bottom: 16px;
    right: 16px;
    width: 44px;
    height: 44px;
    background-color: rgba(51, 65, 85, 0.9); /* Slate 700 con transparencia */
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    color: #f1f5f9; /* Slate 100 - texto claro */
    border: 1px solid rgba(226, 232, 240, 0.2); /* Borde sutil */
    border-radius: 50%;
    cursor: pointer;
    z-index: 999; /* Por debajo del overlay pero visible */
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15), 0 1px 3px rgba(0, 0, 0, 0.1);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: 600;
    opacity: 0;
    transform: scale(0);
    pointer-events: none; /* No interfiere cuando está oculto */
    margin: 0; /* Sin márgenes que puedan afectar el layout */
    padding: 0; /* Sin padding */
}

.scroll-to-top.visible {
    opacity: 1;
    transform: scale(1);
    pointer-events: auto; /* Activar interacción cuando es visible */
}

.scroll-to-top:hover {
    background-color: rgba(30, 41, 59, 0.95); /* Slate 800 más opaco */
    border-color: rgba(226, 232, 240, 0.3);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2), 0 2px 6px rgba(0, 0, 0, 0.15);
}

.scroll-to-top:active {
    transform: translateY(0) scale(0.95);
}

/* Estilos para modo oscuro */
html[data-theme="dark"] .scroll-to-top {
    background-color: rgba(148, 163, 184, 0.9); /* Slate 400 - Gris claro con transparencia */
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-color: rgba(226, 232, 240, 0.3); /* Slate 200 - Borde más visible */
    color: #0f172a; /* Slate 900 - Texto oscuro para contraste */
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5), 0 2px 4px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(255, 255, 255, 0.05);
}

html[data-theme="dark"] .scroll-to-top:hover {
    background-color: rgba(203, 213, 225, 0.95); /* Slate 300 - Más claro en hover */
    border-color: rgba(241, 245, 249, 0.4); /* Slate 100 - Borde más brillante */
    color: #020617; /* Slate 950 - Texto más oscuro */
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.6), 0 2px 6px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.1);
}

/* Solo mostrar en móvil */
@media screen and (max-width: 992px) {
    .scroll-to-top {
        display: flex;
    }
}