/* Reset y Variables */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Colores Dark Mode - Similar a Angular */
    --bg-primary: #0d1117;
    --bg-secondary: #161b22;
    --bg-tertiary: #1c2128;
    --bg-hover: #21262d;
    --border-color: #30363d;
    
    --text-primary: #e6edf3;
    --text-secondary: #8b949e;
    --text-muted: #6e7681;
    
    --accent-primary: #3b82f6;
    --accent-hover: #2563eb;
    --accent-light: rgba(59, 130, 246, 0.1);
    
    --success: #3fb950;
    --warning: #d29922;
    --error: #f85149;
    
    --code-bg: #0d1117;
    --code-border: #30363d;
    
    --header-height: 60px;
    --sidebar-width: 280px;
    
    --font-main: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 
                 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;
    --font-mono: 'Fira Code', 'Courier New', Courier, monospace;
}

body {
    font-family: var(--font-main);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
}

body.sidebar-active {
    overflow: hidden;
}

/* Overlay */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1001;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.overlay.active {
    opacity: 1;
    visibility: visible;
}

/* Header */
.header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    background-color: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    z-index: 1000;
}

.header-content {
    display: flex;
    align-items: center;
    height: 100%;
    padding: 0 1.5rem;
    gap: 1rem;
}

.header-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.menu-toggle {
    display: none;
    flex-direction: column;
    gap: 4px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 6px;
    transition: background-color 0.2s;
    z-index: 1003;
}

.menu-toggle:hover {
    background-color: var(--bg-hover);
}

.menu-toggle span {
    display: block;
    width: 20px;
    height: 2px;
    background-color: var(--text-primary);
    transition: transform 0.3s, opacity 0.3s;
}

.menu-toggle.active span:nth-child(1) {
    transform: rotate(45deg) translate(5px, 5px);
}

.menu-toggle.active span:nth-child(2) {
    opacity: 0;
}

.menu-toggle.active span:nth-child(3) {
    transform: rotate(-45deg) translate(7px, -6px);
}

/* Container */
.container {
    display: flex;
    margin-top: var(--header-height);
    min-height: calc(100vh - var(--header-height));
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    overflow-y: auto;
    height: calc(100vh - var(--header-height));
    position: fixed;
    left: 0;
    top: var(--header-height);
    transition: transform 0.3s ease;
    z-index: 1002;
}

.sidebar::-webkit-scrollbar {
    width: 8px;
}

.sidebar::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

.sidebar::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

.nav {
    padding: 1.5rem 0;
}

.nav-section {
    padding: 0 1rem;
}

.nav-title {
    font-size: 0.875rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 1rem;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.nav-category {
    margin-bottom: 0.5rem;
}

.nav-category-title {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 0.75rem;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 0.9375rem;
    font-weight: 600;
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.2s;
    text-align: left;
}

.nav-category-title:hover {
    background-color: var(--bg-hover);
    color: var(--text-primary);
}

.nav-category-title.active {
    color: var(--text-primary);
}

.chevron {
    font-size: 1.25rem;
    transition: transform 0.3s;
    display: inline-block;
    line-height: 1;
}

.nav-category-title.active .chevron {
    transform: rotate(90deg);
}

.nav-items {
    list-style: none;
    padding-left: 1.75rem;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.nav-items.active {
    max-height: 1000px;
    margin-top: 0.25rem;
}

.nav-items li {
    margin: 0.125rem 0;
}

.nav-link {
    display: block;
    padding: 0.5rem 0.75rem;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.875rem;
    border-radius: 6px;
    transition: all 0.2s;
    border-left: 2px solid transparent;
}

.nav-link:hover {
    background-color: var(--bg-hover);
    color: var(--text-primary);
}

.nav-link.active {
    background-color: var(--accent-light);
    color: var(--accent-primary);
    border-left-color: var(--accent-primary);
    font-weight: 500;
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: 2rem;
    max-width: 1200px;
}

.content-section {
    margin-bottom: 3rem;
    animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.content-section h1 {
    font-size: 2.75rem;
    font-weight: 800;
    color: #ffffff;
    margin-bottom: 2rem;
    line-height: 1.2;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.5px;
}

.content-section h2 {
    font-size: 2rem;
    font-weight: 700;
    color: #e6edf3;
    margin-top: 3rem;
    margin-bottom: 1.25rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid rgba(102, 126, 234, 0.3);
    letter-spacing: -0.3px;
}

.content-section h3 {
    font-size: 1.5rem;
    font-weight: 600;
    color: #b4befe;
    margin-top: 2.5rem;
    margin-bottom: 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.content-section h3::before {
    content: '';
    display: inline-block;
    width: 4px;
    height: 1.5rem;
    background: linear-gradient(180deg, #667eea 0%, #764ba2 100%);
    border-radius: 2px;
}

.content-section h4 {
    font-size: 1.25rem;
    font-weight: 600;
    color: #9ca3af;
    margin-top: 2rem;
    margin-bottom: 1rem;
}

.content-section p {
    color: var(--text-secondary);
    font-size: 1rem;
    margin-bottom: 1rem;
    line-height: 1.75;
}

.content-section ul {
    color: var(--text-secondary);
    margin: 1rem 0;
    padding-left: 1.5rem;
}

.content-section li {
    margin: 0.5rem 0;
}

code {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.15) 0%, rgba(118, 75, 162, 0.15) 100%);
    color: #c792ea;
    padding: 0.25rem 0.6rem;
    border-radius: 6px;
    font-family: 'JetBrains Mono', 'Fira Code', 'Consolas', 'Monaco', monospace;
    font-size: 0.9em;
    font-weight: 600;
    border: 1px solid rgba(102, 126, 234, 0.3);
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.1);
    letter-spacing: 0.3px;
}

.code-block {
    margin: 2rem 0;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid #3C3C3C;
    background: #1E1E1E;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4),
                0 2px 8px rgba(0, 0, 0, 0.2);
    position: relative;
}

.code-block::before {
    content: 'PHP';
    position: absolute;
    top: 0;
    right: 0;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 0.4rem 1rem;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.5px;
    border-bottom-left-radius: 8px;
    text-transform: uppercase;
    z-index: 10;
}

.code-block pre {
    background: #1E1E1E;
    padding: 3rem 1.5rem 1.5rem 1.5rem;
    overflow-x: auto;
    margin: 0;
    border-radius: 0;
    position: relative;
}


.code-block code {
    background: none;
    color: #D4D4D4;
    padding: 0;
    font-size: 0.925rem;
    line-height: 1.8;
    font-family: 'Consolas', 'Courier New', monospace;
    display: inline-block;
    white-space: pre;
}

/* Números de línea con CSS Counter - Simple y Efectivo */
.code-block pre code.has-line-numbers {
    counter-reset: line;
    display: block;
    padding-left: 4rem;
    position: relative;
}

.code-block pre code.has-line-numbers::before {
    counter-increment: line 0;
}

/* Cada línea con su número */
.code-block pre code.has-line-numbers {
    background-image: linear-gradient(transparent 50%, rgba(255, 255, 255, 0.02) 50%);
    background-size: 100% 2.9em;
    background-position: 0 0.5em;
}

/* Generar números de línea con CSS */
.code-block pre code.has-line-numbers::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3.5rem;
    background: rgba(0, 0, 0, 0.2);
    border-right: 2px solid #3e4451;
    padding: 0 0.75rem 0 0;
    text-align: right;
    color: #5c6370;
    font-variant-numeric: tabular-nums;
    line-height: 1.8;
    user-select: none;
    
    /* Generar los números automáticamente */
    counter-reset: line;
}

/* Simular números con un gradiente de fondo */
.has-line-numbers {
    background-image: 
        /* Números de línea generados */
        repeating-linear-gradient(
            transparent,
            transparent 1.8em,
            rgba(255, 255, 255, 0.02) 1.8em,
            rgba(255, 255, 255, 0.02) 3.6em
        );
    padding-left: 4.5rem !important;
    position: relative;
}

/* Overlay con números */
.code-block pre::after {
    content: attr(data-lines);
    position: absolute;
    left: 0;
    top: 3rem;
    bottom: 1.5rem;
    width: 3.5rem;
    background: transparent;
    border-right: 1px solid #3C3C3C;
    padding: 0 0.75rem 0 0;
    text-align: right;
    color: #858585;
    font-family: 'Consolas', 'Courier New', monospace;
    font-size: 0.925rem;
    line-height: 1.8;
    white-space: pre;
    pointer-events: none;
    user-select: none;
    overflow: hidden;
}

/* Highlight.js - Colores VS Code Dark+ */

/* Variables ($nombre, $edad) - Azul brillante */
.hljs-variable {
    color: #9CDCFE !important;
    font-weight: 400;
}

/* Strings ("Juan", "Pedro") - Naranja/Salmón */
.hljs-string {
    color: #CE9178 !important;
}

/* Números (25, 19.99) - Naranja claro */
.hljs-number {
    color: #B5CEA8 !important;
    font-weight: 400;
}

/* Comentarios (// Declaración...) - Verde */
.hljs-comment {
    color: #6A9955 !important;
    font-style: italic;
}

/* Keywords (true, false, null, echo) - Azul/Cyan */
.hljs-keyword,
.hljs-literal {
    color: #569CD6 !important;
    font-weight: 400;
}

/* Funciones (echo cuando es función) - Amarillo */
.hljs-function,
.hljs-title {
    color: #DCDCAA !important;
    font-weight: 400;
}

/* Constantes MAYÚSCULAS - Azul claro */
.hljs-built_in,
.hljs-constant {
    color: #4FC1FF !important;
    font-weight: 400;
}

/* Clases y tipos - Verde agua */
.hljs-class,
.hljs-type {
    color: #4EC9B0 !important;
    font-weight: 400;
}

/* Tags PHP (<?php ?>) - Gris */
.hljs-meta,
.hljs-tag {
    color: #808080 !important;
}

/* Nombres de propiedades y atributos - Azul claro */
.hljs-attribute,
.hljs-attr,
.hljs-property {
    color: #9CDCFE !important;
}

/* Operadores (=, +, -) - Blanco/Gris claro */
.hljs-operator,
.hljs-punctuation {
    color: #D4D4D4 !important;
}

/* Nombres de funciones cuando se declaran */
.hljs-title.function_ {
    color: #DCDCAA !important;
}

/* Parámetros de función */
.hljs-params {
    color: #9CDCFE !important;
}

/* Símbolos especiales */
.hljs-symbol {
    color: #4FC1FF !important;
}

/* Regexp */
.hljs-regexp {
    color: #D16969 !important;
}

/* Built-in de PHP (echo, print, etc cuando son lenguaje) */
.hljs-name {
    color: #569CD6 !important;
}

/* Sobrescribir estilos de Highlight.js */
.hljs {
    color: #D4D4D4;
    background: #1E1E1E;
    font-family: 'Consolas', 'Courier New', monospace;
    font-size: 0.925rem;
    line-height: 1.8;
    direction: ltr;
    text-align: left;
    white-space: pre;
    word-spacing: normal;
    word-break: normal;
    tab-size: 4;
    font-weight: 400;
    letter-spacing: 0.3px;
}

.code-block pre code {
    display: block;
    overflow-x: auto;
    padding: 0;
}


.hljs::selection,
.hljs *::selection {
    background: rgba(97, 175, 239, 0.3);
}


/* Animación sutil al cargar */
@keyframes codeAppear {
    from {
        opacity: 0;
        transform: translateY(5px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.code-block pre {
    animation: codeAppear 0.4s ease-out;
}


/* Scrollbar personalizado para código */
.code-block pre::-webkit-scrollbar {
    height: 10px;
}

.code-block pre::-webkit-scrollbar-track {
    background: #1e1e1e;
}

.code-block pre::-webkit-scrollbar-thumb {
    background: #3e3e42;
    border-radius: 4px;
}

.code-block pre::-webkit-scrollbar-thumb:hover {
    background: #4e4e52;
}

/* Highlight de líneas importantes */
.code-block pre .highlight-line {
    background-color: rgba(255, 255, 255, 0.05);
    display: block;
    margin: 0 -1.5rem;
    padding: 0 1.5rem;
}

/* Botón de copiar */
.copy-button {
    position: absolute;
    top: 0.75rem;
    right: 4.5rem;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.9) 0%, rgba(118, 75, 162, 0.9) 100%);
    color: white;
    border: none;
    padding: 0.6rem 1.2rem;
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    opacity: 0;
    z-index: 20;
    backdrop-filter: blur(10px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.copy-button svg {
    width: 16px;
    height: 16px;
}

.code-block:hover .copy-button {
    opacity: 1;
}

.copy-button:hover {
    transform: translateY(-2px) scale(1.05);
    box-shadow: 0 8px 24px rgba(102, 126, 234, 0.6);
    border-color: rgba(255, 255, 255, 0.2);
}

.copy-button:active {
    transform: translateY(0) scale(0.98);
}

.copy-button.copied {
    background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
    box-shadow: 0 4px 12px rgba(34, 197, 94, 0.4);
}

/* Animación de fade in para secciones */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.content-section {
    animation: fadeInUp 0.5s ease-out;
}

/* Mejorar párrafos */
.content-section p {
    color: #d1d5db;
    font-size: 1.05rem;
    margin-bottom: 1.25rem;
    line-height: 1.85;
}

/* Info Boxes */
.info-box,
.warning-box,
.success-box {
    padding: 1.25rem 1.5rem;
    border-radius: 12px;
    margin: 2rem 0;
    border-left: 4px solid;
    position: relative;
    backdrop-filter: blur(10px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

.info-box {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.15) 0%, rgba(59, 130, 246, 0.05) 100%);
    border-left-color: #3b82f6;
    color: #a5b4fc;
}

.info-box::before {
    content: '💡';
    position: absolute;
    right: 1.5rem;
    top: 1.25rem;
    font-size: 1.5rem;
    opacity: 0.6;
}

.warning-box {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.15) 0%, rgba(245, 158, 11, 0.05) 100%);
    border-left-color: #f59e0b;
    color: #fcd34d;
}

.warning-box::before {
    content: '⚠️';
    position: absolute;
    right: 1.5rem;
    top: 1.25rem;
    font-size: 1.5rem;
    opacity: 0.6;
}

.success-box {
    background: linear-gradient(135deg, rgba(34, 197, 94, 0.15) 0%, rgba(34, 197, 94, 0.05) 100%);
    border-left-color: #22c55e;
    color: #86efac;
}

.success-box::before {
    content: '✅';
    position: absolute;
    right: 1.5rem;
    top: 1.25rem;
    font-size: 1.5rem;
    opacity: 0.6;
}

.info-box strong,
.warning-box strong,
.success-box strong {
    color: #ffffff;
    display: block;
    margin-bottom: 0.75rem;
    font-size: 1.05rem;
    font-weight: 700;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .main-content {
        margin-left: 0;
        padding: 1.5rem;
    }
    
    .sidebar {
        transform: translateX(-100%);
        box-shadow: 2px 0 15px rgba(0, 0, 0, 0.5);
    }
    
    .sidebar.active {
        transform: translateX(0);
    }
    
    .menu-toggle {
        display: flex;
    }
    
    :root {
        --sidebar-width: 280px;
    }
}

@media (max-width: 768px) {
    .header-title {
        font-size: 1.125rem;
    }
    
    .content-section h1 {
        font-size: 2rem;
    }
    
    .content-section h2 {
        font-size: 1.5rem;
    }
    
    .content-section h3 {
        font-size: 1.25rem;
    }
    
    .main-content {
        padding: 1rem;
    }
    
    .code-block pre {
        padding: 1.5rem 1rem;
        font-size: 0.875rem;
    }

    .copy-button {
        right: 0.5rem;
        padding: 0.5rem 1rem;
    }
}

@media (max-width: 480px) {
    .header-content {
        padding: 0 1rem;
        justify-content: space-between;
    }
    
    .header-title {
        font-size: 1rem;
    }
    
    .content-section h1 {
        font-size: 1.75rem;
    }
    
    .sidebar {
        width: 85vw;
    }

    .code-block pre::after {
        display: none;
    }

    .code-block pre code.has-line-numbers {
        padding-left: 0.5rem;
    }
}

@media (max-width: 360px) {
    .header-title {
        display: none;
    }
}

/* Scroll Smooth */
html {
    scroll-behavior: smooth;
}

/* Selection */
::selection {
    background-color: var(--accent-primary);
    color: white;
}
