:root {
    --bg-page: #fff5f7;
    --bg-sidebar: #fce4ec;
    --bg-content: #ffffff;
    --accent-pink: #f06292;
    --accent-green: #66bb6a;
    --text-main: #455a64;
    --text-title: #263238;
    --border: #f8bbd0;
    --code-bg: #272822;
    --shadow: rgba(0, 0, 0, 0.08);
}

/* Colores Modo Oscuro */
[data-theme='dark'] {
    --bg-page: #1d1d1d;
    --bg-sidebar: #242424;
    --bg-content: #2d2d2d;
    --accent-pink: #ff80ab;
    --accent-green: #81c784;
    --text-main: #cfd8dc;
    --text-title: #ffffff;
    --border: #424242;
    --code-bg: #1a1a1a;
    --shadow: rgba(0, 0, 0, 0.3);
}

* {
    box-sizing: border-box;
}

body {
    font-family: 'Inter', 'Segoe UI', sans-serif;
    margin: 0;
    padding: 0;
    background-color: var(--bg-page);
    color: var(--text-main);
    transition: all 0.3s ease;
    line-height: 1.6;
    overflow-x: hidden;
    width: 100%;
}

/* Sidebar fijo tipo Godot */
body>ol:first-of-type {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: 280px;
    background: var(--bg-sidebar);
    margin: 0;
    padding: 80px 20px 20px 30px;
    overflow-y: auto;
    border-right: 2px solid var(--border);
    list-style: none;
    z-index: 10;
    box-shadow: 2px 0 10px var(--shadow);
}

/* Ocultar el título "Índice" */
h2#índice {
    display: none;
}

/* Enlaces del sidebar */
body>ol:first-of-type li {
    margin-bottom: 8px;
}

body>ol:first-of-type li a {
    color: var(--text-main);
    text-decoration: none;
    font-size: 0.95rem;
    display: block;
    padding: 10px 12px;
    border-radius: 6px;
    transition: all 0.2s ease;
}

body>ol:first-of-type li a:hover {
    background: var(--bg-content);
    color: var(--accent-pink);
    transform: translateX(4px);
}

/* Contenedor principal */
body {
    padding-left: 280px;
}

/* Todos los elementos principales con margen */
body>*:not(ol):not(button):not(script) {
    max-width: 900px;
    /* Límite máximo */
    width: 90%;
    /* Flexible en pantallas pequeñas */
    margin-left: auto;
    margin-right: auto;
    padding: 0 20px;
    /* Espacio interno para que no toque los bordes del navegador */
}

body>h1:first-of-type {
    background: linear-gradient(135deg, var(--accent-pink), var(--accent-green));
    color: white;
    padding: 40px 60px;
    margin: 0 0 40px 0;
    max-width: 100%;
    box-shadow: 0 4px 20px var(--shadow);
}

body>hr {
    border: none;
    border-top: 2px solid var(--border);
    margin: 40px 60px;
    opacity: 0.5;
}

/* Títulos */
h1,
h2,
h3 {
    color: var(--text-title);
    margin-top: 2rem;
    margin-bottom: 1rem;
}

h1 {
    font-size: 2.5rem;
    border-bottom: none;
    padding-bottom: 0;
}

h2 {
    font-size: 1.8rem;
    background: var(--bg-sidebar);
    padding: 16px 28px;
    border-radius: 8px;
    border-left: 5px solid var(--accent-pink);
    box-shadow: 0 2px 8px var(--shadow);
    margin-top: 3rem;
}

h3 {
    font-size: 1.3rem;
    color: var(--accent-green);
    border-bottom: 2px solid var(--accent-green);
    padding-bottom: 8px;
}

/* Párrafos y texto */
p {
    margin: 1rem 0;
    line-height: 1.8;
}

strong {
    color: var(--accent-pink);
}

code {
    background: var(--bg-sidebar);
    padding: 3px 8px;
    border-radius: 4px;
    font-family: 'Fira Code', 'Courier New', monospace;
    font-size: 0.9em;
    color: var(--accent-pink);
    border: 1px solid var(--border);
}

code.eva {
    background: var(--bg-sidebar);
    /* O un color que resalte */
    color: var(--accent-green);
    /* Color distintivo */
    padding: 4px 10px;
    border-radius: 6px;
    font-family: 'Fira Code', monospace;
    font-weight: 600;
    border: 1px solid var(--accent-green);
    display: inline-block;
    /* Evita que se rompa en líneas raras */
    margin: 2px 0;
    transition: all 0.2s ease;
    word-break: break-word;
    /* Si el nombre de la clase es muy largo, se ajusta al párrafo */
    padding: 2px 6px;
}

code.eva:hover {
    background: var(--accent-green);
    color: white;
    transform: translateY(-1px);
}

/* Bloques de código */
pre {
    background: var(--code-bg) !important;
    padding: 24px !important;
    border-radius: 10px !important;
    margin: 2rem auto !important;
    /* Centra el bloque */
    max-width: 900px !important;
    /* Misma medida que tus H2 */
    width: calc(100% - 40px) !important;
    /* Margen de seguridad en móviles */
    box-sizing: border-box !important;
    overflow-x: auto;
}

pre code {
    background: none !important;
    padding: 0 !important;
    border: none !important;
    color: #f8f8f2 !important;
    font-size: inherit !important;
    font-family: 'Fira Code', 'Consolas', monospace !important;
    display: block !important;
    white-space: pre !important;
    overflow-x: auto !important;
}

/* Listas */
ul,
ol {
    margin: 1rem 0;
    padding-left: 2rem;
}

ul li,
ol li {
    margin: 0.5rem 0;
    line-height: 1.6;
}

ul li {
    list-style-type: none;
    position: relative;
    padding-left: 1.5rem;
}

ul li::before {
    content: "▸";
    color: var(--accent-pink);
    position: absolute;
    left: 0;
    font-weight: bold;
}

/* Tablas */
table {
    width: 100%;
    display: table;
    border-collapse: separate;
    border-spacing: 0;
    margin: 2rem 0;
    background: var(--bg-content);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 12px var(--shadow);
}

thead {
    background: var(--accent-green);
    color: white;
}

th {
    padding: 16px;
    text-align: left;
    font-weight: 600;
    border-bottom: 2px solid var(--border);
}

td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
}

tbody tr:hover {
    background: var(--bg-sidebar);
    transition: background 0.2s ease;
}

tbody tr:last-child td {
    border-bottom: none;
}

/* Botón de tema */
#theme-toggle {
    position: fixed;
    bottom: 30px;
    right: 30px;
    padding: 14px 24px;
    border-radius: 50px;
    border: none;
    background: linear-gradient(135deg, var(--accent-pink), var(--accent-green));
    color: white;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.95rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
    z-index: 100;
    transition: all 0.3s ease;
}

#theme-toggle:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 25px rgba(0, 0, 0, 0.35);
}

#theme-toggle:active {
    transform: translateY(-1px);
}

/* Links */
a {
    color: var(--accent-pink);
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: all 0.2s ease;
}

a:hover {
    border-bottom-color: var(--accent-pink);
}

/* Scrollbar personalizado */
::-webkit-scrollbar {
    width: 12px;
}

::-webkit-scrollbar-track {
    background: var(--bg-sidebar);
}

::-webkit-scrollbar-thumb {
    background: var(--accent-pink);
    border-radius: 6px;
    border: 2px solid var(--bg-sidebar);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--accent-green);
}

/* Responsivo */
@media (max-width: 900px) {
    body {
        padding-left: 0;
    }

    body>ol:first-of-type {
        position: relative;
        width: 100%;
        padding: 20px;
        border-right: none;
        border-bottom: 2px solid var(--border);
    }

    body>*:not(ol):not(button):not(script) {
        width: 100%;
        padding-left: 20px;
        padding-right: 20px;
        max-width: 100%;
    }

    body>h1:first-of-type {
        padding: 30px 20px;
    }

    body>hr {
        margin: 30px 20px;
    }

    h1 {
        font-size: 2rem;
    }

    h2 {
        font-size: 1.5rem;
        padding: 14px 16px;
    }

    h3 {
        font-size: 1.2rem;
    }

    #theme-toggle {
        bottom: 20px;
        right: 20px;
        padding: 12px 20px;
        font-size: 0.9rem;
    }

    pre {
        width: 100% !important;
        max-width: 100% !important;
        margin: 1.5rem 0 !important;
        padding: 16px !important;
        box-sizing: border-box !important;
        overflow-x: auto !important;
        /* Habilita el scroll lateral si el código es largo */
        white-space: pre;
        /* Mantiene el formato sin romper líneas a la fuerza */
    }

    table {
        display: block;
        /* Convertimos la tabla en bloque */
        overflow-x: auto;
        /* Habilitamos el scroll lateral */
        white-space: nowrap;
        /* Evita que el texto se amontone en varias líneas */
        -webkit-overflow-scrolling: touch;
        /* Scroll suave en iPhone */
    }

    /* Evita que el texto del código sea demasiado pequeño */
    pre code {
        font-size: 0.85rem !important;
        display: block;
        word-wrap: normal;
        /* No rompe palabras, permite el scroll */
    }
}

/* Animaciones suaves */
@media (prefers-reduced-motion: no-preference) {
    * {
        scroll-behavior: smooth;
    }
}