/**
 * ClawTools TOC Styles - Enhanced Version
 * Article table of contents with modern design
 */

/* CSS Variables */
:root {
    --toc-accent: #4d7cfe;
    --toc-accent-light: rgba(77, 124, 254, 0.1);
    --toc-accent-glow: rgba(77, 124, 254, 0.4);
    --toc-text: #4a4a4a;
    --toc-text-light: #666666;
    --toc-bg-hover: rgba(77, 124, 254, 0.06);
    --toc-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    --toc-shadow-hover: 0 6px 24px rgba(0, 0, 0, 0.12);
}

/* Widget Container */
.meteor-toc-widget {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* Header */
.meteor-toc-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding-bottom: 14px;
    margin-bottom: 16px;
    border-bottom: 1px solid #eee;
}

.meteor-toc-header .dashicons {
    font-size: 22px;
    width: 22px;
    height: 22px;
    color: var(--toc-accent);
}

.meteor-toc-main-title {
    font-size: 16px;
    font-weight: 600;
    color: #333;
    letter-spacing: 0.5px;
}

.meteor-toc-sub-title {
    font-size: 10px;
    color: #999;
    opacity: 0.8;
    text-transform: uppercase;
    letter-spacing: 2px;
}

/* Navigation List */
.meteor-toc-lists {
    max-height: 450px;
    overflow-y: auto;
    padding: 4px 0;
}

.meteor-toc-nav {
    list-style: none;
    padding: 0;
    margin: 0;
}

.meteor-toc-nav li {
    margin: 0;
    padding: 0;
}

/* Navigation Items - Enhanced */
.meteor-toc-nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    margin: 4px 0;
    color: var(--toc-text-light);
    text-decoration: none;
    font-size: 14px;
    line-height: 1.6;
    border-radius: 8px;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

/* Icon - Small circle indicator */
.meteor-toc-nav .toc-icon {
    width: 8px;
    height: 8px;
    min-width: 8px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--toc-accent) 0%, #6b8cff 100%);
    box-shadow: 0 0 8px var(--toc-accent-glow);
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Hover state */
.meteor-toc-nav a:hover {
    color: #333;
    background: var(--toc-bg-hover);
}

.meteor-toc-nav a:hover .toc-icon {
    transform: scale(1.3);
    box-shadow: 0 0 12px var(--toc-accent-glow);
}

/* Active state */
.meteor-toc-nav a.active {
    color: var(--toc-accent);
    background: var(--toc-accent-light);
    font-weight: 500;
}

.meteor-toc-nav a.active .toc-icon {
    background: var(--toc-accent);
    box-shadow: 0 0 16px var(--toc-accent-glow);
    animation: toc-pulse 2s ease-in-out infinite;
}

@keyframes toc-pulse {
    0%, 100% { box-shadow: 0 0 8px var(--toc-accent-glow); }
    50% { box-shadow: 0 0 16px var(--toc-accent-glow); }
}

/* Text span */
.meteor-toc-nav .toc-text {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Level Indentation */
.meteor-toc-nav .toc-level-2 { padding-left: 8px; }
.meteor-toc-nav .toc-level-3 { padding-left: 20px; }
.meteor-toc-nav .toc-level-4 { padding-left: 32px; }
.meteor-toc-nav .toc-level-5 { padding-left: 44px; }
.meteor-toc-nav .toc-level-6 { padding-left: 56px; }

.meteor-toc-nav .toc-level-3 .toc-icon { width: 6px; height: 6px; min-width: 6px; }
.meteor-toc-nav .toc-level-4 .toc-icon { width: 5px; height: 5px; min-width: 5px; }

/* Scrollbar */
.meteor-toc-lists::-webkit-scrollbar {
    width: 5px;
}

.meteor-toc-lists::-webkit-scrollbar-track {
    background: transparent;
}

.meteor-toc-lists::-webkit-scrollbar-thumb {
    background: rgba(77, 124, 254, 0.2);
    border-radius: 3px;
}

.meteor-toc-lists::-webkit-scrollbar-thumb:hover {
    background: rgba(77, 124, 254, 0.4);
}

/* ============================================
   Floating TOC - Card Style with Glow Border
   ============================================ */
.meteor-toc-float {
    position: fixed !important;
    top: var(--toc-float-top, 120px) !important;
    width: var(--toc-float-width, 260px) !important;
    max-height: calc(100vh - 200px);
    background: #fff !important;
    border-radius: 16px !important;
    padding: 20px !important;
    box-shadow: var(--toc-shadow) !important;
    z-index: 9999 !important;
    overflow: visible !important;
    transition: box-shadow 0.3s ease, transform 0.3s ease;
    pointer-events: auto !important;
}

/* 确保目录链接可点击 */
.meteor-toc-float .meteor-toc-nav a {
    pointer-events: auto !important;
    cursor: pointer !important;
}

.meteor-toc-float:hover {
    box-shadow: var(--toc-shadow-hover) !important;
    transform: translateX(2px);
}

/* Left glow border - gradient effect */
.meteor-toc-float.float-left {
    left: 20px !important;
    border-left: 3px solid transparent;
    background: linear-gradient(#fff, #fff) padding-box,
                linear-gradient(180deg, var(--toc-accent), #8ba8ff, var(--toc-accent)) border-box;
}

.meteor-toc-float.float-left .meteor-toc-lists {
    padding-left: 14px;
    border-left: 2px solid;
    border-image: linear-gradient(180deg, var(--toc-accent), rgba(77, 124, 254, 0.2)) 1;
}

/* Shortcode TOC */
.meteor-toc-shortcode {
    border-radius: 16px;
    padding: 24px;
    margin: 24px 0;
    background: #fff;
    box-shadow: var(--toc-shadow);
    border: 1px solid rgba(77, 124, 254, 0.1);
}

.meteor-toc-shortcode .meteor-toc-header {
    margin-bottom: 16px;
}

.meteor-toc-shortcode .meteor-toc-lists {
    max-height: 350px;
}

/* Auto-created TOC */
.meteor-toc-auto {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

.meteor-toc-auto .meteor-toc-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding-bottom: 14px;
    margin-bottom: 16px;
    border-bottom: 1px solid #eee;
}

.meteor-toc-auto .meteor-toc-header .dashicons {
    font-size: 22px;
    width: 22px;
    height: 22px;
    color: var(--toc-accent);
}

.meteor-toc-auto .meteor-toc-main-title {
    font-size: 16px;
    font-weight: 600;
    color: #333;
    letter-spacing: 0.5px;
}

.meteor-toc-auto .meteor-toc-sub-title {
    font-size: 10px;
    color: #999;
    opacity: 0.8;
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-left: auto;
}

.meteor-toc-auto .meteor-toc-lists {
    max-height: 450px;
    overflow-y: auto;
    padding: 4px 0;
}

.meteor-toc-auto .meteor-toc-nav {
    list-style: none;
    padding: 0;
    margin: 0;
}

.meteor-toc-auto .meteor-toc-nav li {
    margin: 0;
    padding: 0;
}

.meteor-toc-auto .meteor-toc-nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    margin: 4px 0;
    color: var(--toc-text-light);
    text-decoration: none;
    font-size: 14px;
    line-height: 1.6;
    border-radius: 8px;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.meteor-toc-auto .meteor-toc-nav a:hover {
    color: #333;
    background: var(--toc-bg-hover);
}

.meteor-toc-auto .meteor-toc-nav a.active {
    color: var(--toc-accent);
    background: var(--toc-accent-light);
    font-weight: 500;
}

/* Auto-created floating TOC */
.meteor-toc-auto.meteor-toc-float {
    position: fixed;
    top: var(--toc-float-top, 120px);
    width: var(--toc-float-width, 260px);
    max-height: calc(100vh - 200px);
    background: #fff;
    border-radius: 16px;
    padding: 20px;
    box-shadow: var(--toc-shadow);
    z-index: 9999;
    overflow: visible;
    transition: box-shadow 0.3s ease, transform 0.3s ease;
    pointer-events: auto;
}

.meteor-toc-auto.meteor-toc-float .meteor-toc-nav a {
    pointer-events: auto;
    cursor: pointer;
}

.meteor-toc-auto.meteor-toc-float.float-left {
    left: 20px;
    border-left: 3px solid transparent;
    background: linear-gradient(#fff, #fff) padding-box,
                linear-gradient(180deg, var(--toc-accent), #8ba8ff, var(--toc-accent)) border-box;
}

.meteor-toc-auto.meteor-toc-float.float-left .meteor-toc-lists {
    padding-left: 14px;
    border-left: 2px solid;
    border-image: linear-gradient(180deg, var(--toc-accent), rgba(77, 124, 254, 0.2)) 1;
}

/* Auto-created inline TOC */
.meteor-toc-auto.meteor-toc-inline {
    border-radius: 16px;
    padding: 24px;
    margin: 24px 0;
    background: #fff;
    box-shadow: var(--toc-shadow);
    border: 1px solid rgba(77, 124, 254, 0.1);
}

.meteor-toc-auto.meteor-toc-inline .meteor-toc-lists {
    max-height: 350px;
}

/* Smooth scroll behavior for page anchors */
.meteor-toc-nav a[href^="#"] {
    scroll-behavior: smooth;
}

/* ============================================
   Responsive - Hide TOC on smaller screens
   ============================================ */
@media (max-width: 1024px) {
    .meteor-toc-float.meteor-toc-auto {
        display: none !important;
    }
    
    .meteor-toc-float.meteor-toc-auto.toc-visible {
        display: block !important;
    }
}

@media (max-width: 768px) {
    .meteor-toc-shortcode,
    .meteor-toc-auto.meteor-toc-inline {
        padding: 16px;
    }
}

/* ============================================
   TOC Collapse/Expand States
   ============================================ */
.meteor-toc-float.meteor-toc-auto {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Collapsed state - only show toggle button area */
.meteor-toc-float.meteor-toc-auto.toc-collapsed {
    width: 48px !important;
    min-height: 48px;
    padding: 8px !important;
    cursor: pointer;
}

.meteor-toc-float.meteor-toc-auto.toc-collapsed .meteor-toc-header > *:not(.meteor-toc-toggle),
.meteor-toc-float.meteor-toc-auto.toc-collapsed .meteor-toc-lists {
    display: none;
}

.meteor-toc-float.meteor-toc-auto.toc-collapsed .meteor-toc-toggle {
    width: 32px;
    height: 32px;
    margin: 0 auto;
}

.meteor-toc-float.meteor-toc-auto.toc-collapsed .meteor-toc-header {
    justify-content: center;
}

/* Toggle button */
.meteor-toc-toggle {
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 6px;
    background: linear-gradient(135deg, var(--toc-accent) 0%, #6b8cff 100%);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.25s ease;
    box-shadow: 0 2px 8px var(--toc-accent-glow);
    flex-shrink: 0;
    margin-left: 8px;
}

.meteor-toc-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px var(--toc-accent-glow);
}

.meteor-toc-toggle:active {
    transform: scale(0.95);
}

/* Toggle icon - hamburger/close icon using CSS */
.meteor-toc-toggle .toggle-icon {
    position: relative;
    width: 14px;
    height: 14px;
}

.meteor-toc-toggle .toggle-icon::before,
.meteor-toc-toggle .toggle-icon::after {
    content: '';
    position: absolute;
    left: 0;
    width: 100%;
    height: 2px;
    background: #fff;
    border-radius: 1px;
    transition: all 0.25s ease;
}

.meteor-toc-toggle .toggle-icon::before {
    top: 3px;
}

.meteor-toc-toggle .toggle-icon::after {
    bottom: 3px;
}

/* Collapsed state - change icon to plus */
.meteor-toc-float.meteor-toc-auto.toc-collapsed .toggle-icon::before {
    transform: rotate(90deg);
    top: 6px;
}

.meteor-toc-float.meteor-toc-auto.toc-collapsed .toggle-icon::after {
    transform: rotate(180deg);
    bottom: 6px;
}

/* Hover effect on collapsed TOC */
.meteor-toc-float.meteor-toc-auto.toc-collapsed:hover {
    box-shadow: var(--toc-shadow-hover) !important;
    transform: translateX(4px);
}

/* Visible state */
.meteor-toc-float.meteor-toc-auto.toc-visible {
    display: block !important;
}

/* Responsive hide */
.meteor-toc-float.meteor-toc-auto.toc-hidden-responsive {
    display: none !important;
}

/* Numbered List Style */
.meteor-toc-nav.numbered .toc-item::before {
    display: none;
}

.meteor-toc-nav.numbered .toc-number {
    min-width: 20px;
    margin-right: 8px;
    color: var(--toc-accent);
    font-weight: 500;
    font-size: 12px;
}

/* Bullet List Style */
.meteor-toc-nav.bullet .toc-icon {
    /* Already styled above */
}

/* Preset: Minimal */
.meteor-toc-widget.preset-minimal .meteor-toc-header {
    padding-bottom: 10px;
}

.meteor-toc-widget.preset-minimal .meteor-toc-nav a {
    padding: 8px 10px;
    font-size: 13px;
}

/* Preset: Modern */
.meteor-toc-widget.preset-modern {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
}

.meteor-toc-widget.preset-modern .meteor-toc-header {
    border-bottom-color: rgba(255, 255, 255, 0.2);
}

.meteor-toc-widget.preset-modern .meteor-toc-main-title,
.meteor-toc-widget.preset-modern .meteor-toc-sub-title {
    color: #fff;
}

.meteor-toc-widget.preset-modern .meteor-toc-nav a {
    color: rgba(255, 255, 255, 0.85);
}

.meteor-toc-widget.preset-modern .meteor-toc-nav a:hover,
.meteor-toc-widget.preset-modern .meteor-toc-nav a.active {
    color: #fff;
    background: rgba(255, 255, 255, 0.15);
}
