/**
 * Smart TOC - Estilos
 */

/* Reset y base */
.smart-toc {
    --toc-bg: #ffffff;
    --toc-border: #e5e7eb;
    --toc-title: #1f2937;
    --toc-link: #4b5563;
    --toc-hover: #3b82f6;
    --toc-active: #2563eb;
    --toc-highlight: #fef3c7;

    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--toc-bg) !important;
    border: 1px solid var(--toc-border) !important;
    border-radius: 12px !important;
    padding: 20px 24px !important;
    margin: 24px 0 !important;
    box-sizing: border-box !important;
}

.smart-toc *,
.smart-toc *::before,
.smart-toc *::after {
    box-sizing: border-box !important;
}

/* Header */
.smart-toc .toc-header {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    margin-bottom: 16px !important;
    padding-bottom: 12px !important;
    border-bottom: 1px solid var(--toc-border) !important;
}

.smart-toc .toc-title {
    font-size: 18px !important;
    font-weight: 600 !important;
    color: var(--toc-title) !important;
    margin: 0 !important;
    padding: 0 !important;
}

.smart-toc .toc-toggle {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 32px !important;
    height: 32px !important;
    padding: 0 !important;
    background: transparent !important;
    border: none !important;
    border-radius: 6px !important;
    cursor: pointer !important;
    color: var(--toc-link) !important;
    transition: all 0.2s ease !important;
}

.smart-toc .toc-toggle:hover {
    background: rgba(0, 0, 0, 0.05) !important;
    color: var(--toc-active) !important;
}

.smart-toc .toc-toggle svg {
    transition: transform 0.3s ease !important;
}

.smart-toc.toc-collapsed .toc-toggle svg {
    transform: rotate(-90deg) !important;
}

/* Content */
.smart-toc .toc-content {
    overflow: hidden !important;
    transition: max-height 0.3s ease, opacity 0.3s ease !important;
}

.smart-toc.toc-collapsed .toc-content {
    max-height: 0 !important;
    opacity: 0 !important;
}

/* Lista */
.smart-toc .toc-list {
    list-style: none !important;
    margin: 0 !important;
    padding: 0 !important;
    background: transparent !important;
}

.smart-toc .toc-item {
    list-style: none !important;
    margin: 0 !important;
    padding: 0 !important;
    background: transparent !important;
    border: none !important;
}

.smart-toc .toc-item::before,
.smart-toc .toc-item::after,
.smart-toc .toc-item::marker {
    content: none !important;
    display: none !important;
}

/* Indentación */
.smart-toc .toc-depth-0 {
    padding-left: 0 !important;
}

.smart-toc .toc-depth-1 {
    padding-left: 20px !important;
}

.smart-toc .toc-depth-2 {
    padding-left: 40px !important;
}

.smart-toc .toc-depth-3 {
    padding-left: 60px !important;
}

.smart-toc .toc-depth-4 {
    padding-left: 80px !important;
}

/* Links */
.smart-toc .toc-link {
    display: flex !important;
    align-items: baseline !important;
    gap: 8px !important;
    padding: 8px 12px !important;
    color: var(--toc-link) !important;
    font-size: 15px !important;
    line-height: 1.5 !important;
    text-decoration: none !important;
    border-radius: 6px !important;
    border-left: 3px solid transparent !important;
    transition: all 0.2s ease !important;
    cursor: pointer !important;
    background: transparent !important;
}

.smart-toc .toc-link:hover {
    color: var(--toc-hover) !important;
    background: rgba(59, 130, 246, 0.08) !important;
    border-left-color: var(--toc-hover) !important;
}

.smart-toc .toc-link.active {
    color: var(--toc-active) !important;
    background: rgba(37, 99, 235, 0.1) !important;
    border-left-color: var(--toc-active) !important;
    font-weight: 500 !important;
}

.smart-toc .toc-number {
    color: #9ca3af !important;
    font-size: 0.9em !important;
    font-weight: 500 !important;
    min-width: 24px !important;
    flex-shrink: 0 !important;
}

.smart-toc .toc-text {
    flex: 1 !important;
}

/* Efecto highlight en headings - 4 segundos */
.toc-heading-highlight {
    animation: tocHighlight 4s ease-out !important;
}

@keyframes tocHighlight {
    0% {
        background-color: var(--toc-highlight, #fef3c7) !important;
        box-shadow: 0 0 0 8px var(--toc-highlight, #fef3c7) !important;
    }

    100% {
        background-color: transparent !important;
        box-shadow: 0 0 0 8px transparent !important;
    }
}

/* ============ DISEÑOS ============ */

/* Minimal Elegant (default) */
.smart-toc.toc-design-minimal {
    border-left: 4px solid var(--toc-active) !important;
}

/* Dark Modern */
.smart-toc.toc-design-dark {
    --toc-bg: #1a1a2e;
    --toc-border: #2d2d44;
    --toc-title: #ffffff;
    --toc-link: #a0a0b8;
    --toc-hover: #818cf8;
    --toc-active: #a78bfa;

    background: var(--toc-bg) !important;
    border-color: var(--toc-border) !important;
}

.smart-toc.toc-design-dark .toc-title {
    color: var(--toc-title) !important;
}

.smart-toc.toc-design-dark .toc-link {
    color: var(--toc-link) !important;
}

.smart-toc.toc-design-dark .toc-link:hover {
    color: var(--toc-hover) !important;
    background: rgba(129, 140, 248, 0.15) !important;
}

.smart-toc.toc-design-dark .toc-link.active {
    color: var(--toc-active) !important;
    background: rgba(167, 139, 250, 0.2) !important;
}

/* Minimalist Line */
.smart-toc.toc-design-line {
    background: transparent !important;
    border: none !important;
    border-left: 2px solid var(--toc-border) !important;
    border-radius: 0 !important;
    padding-left: 20px !important;
}

.smart-toc.toc-design-line .toc-header {
    border-bottom: none !important;
    padding-bottom: 8px !important;
}

.smart-toc.toc-design-line .toc-link {
    padding: 6px 10px !important;
    border-left: none !important;
    border-radius: 4px !important;
}

/* Card Float */
.smart-toc.toc-design-card {
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08) !important;
    border: none !important;
}

.smart-toc.toc-design-card .toc-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
    margin: -20px -24px 16px -24px !important;
    padding: 16px 24px !important;
    border-radius: 12px 12px 0 0 !important;
    border-bottom: none !important;
}

.smart-toc.toc-design-card .toc-title {
    color: #ffffff !important;
}

.smart-toc.toc-design-card .toc-toggle {
    color: #ffffff !important;
}

.smart-toc.toc-design-card .toc-toggle:hover {
    background: rgba(255, 255, 255, 0.2) !important;
}

/* ============ BOTÓN COPIAR ENLACE ============ */

.toc-copy-link {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 28px !important;
    height: 28px !important;
    margin-left: 10px !important;
    padding: 4px !important;
    background: rgba(59, 130, 246, 0.1) !important;
    border: 1px solid rgba(59, 130, 246, 0.3) !important;
    border-radius: 6px !important;
    cursor: pointer !important;
    color: #3b82f6 !important;
    opacity: 1 !important;
    transition: all 0.2s ease !important;
    vertical-align: middle !important;
    position: relative !important;
}

.toc-copy-link:hover {
    background: rgba(59, 130, 246, 0.2) !important;
    border-color: #3b82f6 !important;
    color: #2563eb !important;
    transform: scale(1.1) !important;
}

.toc-copy-link.copied {
    background: rgba(16, 185, 129, 0.15) !important;
    border-color: #10b981 !important;
    color: #10b981 !important;
}

.toc-copy-link svg {
    width: 18px !important;
    height: 18px !important;
}

/* Tooltip de copiado */
.toc-copy-tooltip {
    position: absolute !important;
    bottom: 100% !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
    background: #1f2937 !important;
    color: #ffffff !important;
    font-size: 12px !important;
    font-weight: 500 !important;
    padding: 4px 8px !important;
    border-radius: 4px !important;
    white-space: nowrap !important;
    margin-bottom: 4px !important;
    animation: tooltipFadeIn 0.2s ease !important;
}

.toc-copy-tooltip::after {
    content: '' !important;
    position: absolute !important;
    top: 100% !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
    border: 4px solid transparent !important;
    border-top-color: #1f2937 !important;
}

@keyframes tooltipFadeIn {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(4px);
    }

    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}