/**
 * Warrior Floating TOC Stylesheet
 * 100% PARENT SCOPED ARCHITECTURE under #warrior-floating-toc-root
 * Zero style leakage to theme, zero override from theme.
 */

#warrior-floating-toc-root {
    position: relative;
    z-index: 99995;
    font-family: 'Noto Sans Thai', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    -webkit-font-smoothing: antialiased;
}

#warrior-floating-toc-root * {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

#warrior-floating-toc-root button {
    all: unset;
    cursor: pointer;
}

/* Mobile Backdrop */
#warrior-floating-toc-root .wft-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    z-index: 99990;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}

#warrior-floating-toc-root .wft-backdrop.wft-active {
    opacity: 1;
    pointer-events: auto;
}

/* Dock Wrapper: Center Screen */
#warrior-floating-toc-root .wft-dock {
    position: fixed;
    left: 50%;
    transform: translateX(-50%);
    z-index: 99995;
    width: auto;
    max-width: 88vw;
    transition: all 0.3s ease;
}

/* Position variants */
#warrior-floating-toc-root.wft-pos-bottom .wft-dock {
    bottom: 16px;
}

#warrior-floating-toc-root.wft-pos-top .wft-dock {
    top: 16px;
}

/* 1. Collapsed Floating Pill */
#warrior-floating-toc-root .wft-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 7px 16px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(226, 232, 240, 0.95);
    border-radius: 9999px;
    box-shadow: 0 8px 24px -4px rgba(15, 110, 140, 0.16), 0 2px 6px -1px rgba(15, 110, 140, 0.08);
    cursor: pointer;
    user-select: none;
    transition: all 0.25s ease;
    white-space: nowrap;
}

#warrior-floating-toc-root .wft-pill:hover {
    border-color: #5FAFC7;
    box-shadow: 0 12px 28px -4px rgba(15, 110, 140, 0.22);
    transform: translateY(-1px);
}

#warrior-floating-toc-root .wft-pill-icon {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #CFEFF7;
    color: #0F6E8C;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

#warrior-floating-toc-root .wft-pill-icon svg {
    width: 14px;
    height: 14px;
}

#warrior-floating-toc-root .wft-pill-label {
    display: flex;
    align-items: center;
    gap: 6px;
}

#warrior-floating-toc-root .wft-label-txt {
    font-size: 15px;
    font-weight: 700;
    color: #0F6E8C;
    line-height: 1;
}

#warrior-floating-toc-root .wft-badge-count {
    background: #0F6E8C;
    color: #FFFFFF;
    font-size: 11.5px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 9999px;
    line-height: 1;
}

#warrior-floating-toc-root .wft-divider {
    height: 13px;
    width: 1px;
    background: #E2E8F0;
    margin: 0 1px;
}

#warrior-floating-toc-root .wft-pill-progress {
    font-size: 12.5px;
    font-weight: 700;
    color: #0F6E8C;
    line-height: 1;
}

#warrior-floating-toc-root .wft-chevron {
    width: 14px;
    height: 14px;
    color: #94A3B8;
    transition: transform 0.3s ease;
}

#warrior-floating-toc-root .wft-chevron.wft-rotate {
    transform: rotate(180deg);
}

/* 2. Expanded Popover Card */
#warrior-floating-toc-root .wft-menu {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    width: 350px;
    max-width: 90vw;
    max-height: 48vh;
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(216, 231, 240, 0.95);
    border-radius: 18px;
    padding: 14px 16px;
    box-shadow: 0 20px 40px -10px rgba(15, 110, 140, 0.22), 0 8px 16px -4px rgba(15, 110, 140, 0.1);
    display: flex;
    flex-direction: column;
    transition: opacity 0.25s ease, transform 0.25s ease;
}

#warrior-floating-toc-root.wft-pos-bottom .wft-menu {
    bottom: calc(100% + 10px);
}

#warrior-floating-toc-root.wft-pos-top .wft-menu {
    top: calc(100% + 10px);
}

#warrior-floating-toc-root .wft-menu-enter {
    opacity: 0;
    transform: translate(-50%, 12px) scale(0.96);
    pointer-events: none;
}

#warrior-floating-toc-root .wft-menu-active {
    opacity: 1;
    transform: translate(-50%, 0) scale(1);
    pointer-events: auto;
}

/* Menu Header */
#warrior-floating-toc-root .wft-menu-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 8px;
    margin-bottom: 6px;
    border-bottom: 1px solid #E2E8F0;
    flex-shrink: 0;
}

#warrior-floating-toc-root .wft-header-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

#warrior-floating-toc-root .wft-header-icon {
    width: 26px;
    height: 26px;
    border-radius: 6px;
    background: #CFEFF7;
    color: #0F6E8C;
    display: flex;
    align-items: center;
    justify-content: center;
}

#warrior-floating-toc-root .wft-header-icon svg {
    width: 15px;
    height: 15px;
}

#warrior-floating-toc-root .wft-header-text {
    display: flex;
    flex-direction: column;
}

#warrior-floating-toc-root .wft-title {
    font-size: 15px;
    font-weight: 700;
    color: #0F6E8C;
    line-height: 1.25;
}

#warrior-floating-toc-root .wft-count-sub {
    font-size: 12px;
    color: #64748B;
    font-weight: 500;
}

#warrior-floating-toc-root .wft-header-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

#warrior-floating-toc-root .wft-btn-header {
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    color: #64748B;
    background: transparent;
    transition: all 0.15s ease;
    cursor: pointer;
}

#warrior-floating-toc-root .wft-btn-header:hover {
    background: #F1F5F9;
    color: #0F6E8C;
}

#warrior-floating-toc-root .wft-btn-gototop {
    color: #0F6E8C;
    background: #F0F9FB;
    border: 1px solid rgba(207, 239, 247, 0.8);
}

#warrior-floating-toc-root .wft-btn-gototop:hover {
    background: #CFEFF7;
    color: #0B546C;
}

#warrior-floating-toc-root .wft-btn-gototop svg {
    width: 14px;
    height: 14px;
}

#warrior-floating-toc-root .wft-btn-close {
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    color: #94A3B8;
    transition: all 0.15s ease;
}

#warrior-floating-toc-root .wft-btn-close:hover {
    background: #F1F5F9;
    color: #0F172A;
}

#warrior-floating-toc-root .wft-btn-close svg {
    width: 14px;
    height: 14px;
}

/* Menu Body: List */
#warrior-floating-toc-root .wft-list {
    overflow-y: auto;
    flex-grow: 1;
    max-height: 30vh;
    padding: 2px 2px 2px 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

/* Custom Scrollbar */
#warrior-floating-toc-root .wft-scrollbar::-webkit-scrollbar {
    width: 4px;
}
#warrior-floating-toc-root .wft-scrollbar::-webkit-scrollbar-track {
    background: #F1F5F9;
    border-radius: 4px;
}
#warrior-floating-toc-root .wft-scrollbar::-webkit-scrollbar-thumb {
    background: #CBD5E1;
    border-radius: 4px;
}
#warrior-floating-toc-root .wft-scrollbar::-webkit-scrollbar-thumb:hover {
    background: #94A3B8;
}

/* Items: H1 & H2 */
#warrior-floating-toc-root .wft-item {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 7px 10px;
    border-radius: 8px;
    text-decoration: none;
    transition: all 0.15s ease;
    border: 1px solid transparent;
}

#warrior-floating-toc-root .wft-item-h1 {
    font-size: 15px;
    font-weight: 700;
    color: #1E293B;
    margin-top: 3px;
}

#warrior-floating-toc-root .wft-item-h1:hover {
    background: #F1F7F9;
    color: #0F6E8C;
}

#warrior-floating-toc-root .wft-badge-h1 {
    width: 21px;
    height: 21px;
    border-radius: 5px;
    background: #CFEFF7;
    color: #0F6E8C;
    font-size: 11.5px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.15s ease;
}

#warrior-floating-toc-root .wft-item-h2 {
    font-size: 13.5px;
    font-weight: 400;
    color: #475569;
    padding-left: 28px;
}

#warrior-floating-toc-root .wft-item-h2:hover {
    background: #F8FAFC;
    color: #0F6E8C;
}

#warrior-floating-toc-root .wft-dot-h2 {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #CBD5E1;
    flex-shrink: 0;
}

#warrior-floating-toc-root .wft-item-txt {
    flex-grow: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    line-height: 1.45;
}

#warrior-floating-toc-root .wft-chevron-right {
    width: 14px;
    height: 14px;
    color: #CBD5E1;
    flex-shrink: 0;
}

/* Active State */
#warrior-floating-toc-root .wft-item.wft-active {
    background: #EAF5F8;
    color: #0F6E8C;
    font-weight: 700;
    border-color: rgba(95, 175, 199, 0.4);
}

#warrior-floating-toc-root .wft-item.wft-active .wft-badge-h1 {
    background: #0F6E8C;
    color: #FFFFFF;
}

#warrior-floating-toc-root .wft-item.wft-active .wft-dot-h2 {
    background: #0F6E8C;
}

/* Menu Footer */
#warrior-floating-toc-root .wft-menu-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: 8px;
    margin-top: 6px;
    border-top: 1px solid #E2E8F0;
    font-size: 12px;
    color: #64748B;
    flex-shrink: 0;
}

#warrior-floating-toc-root .wft-progress-wrap {
    display: flex;
    align-items: center;
    gap: 5px;
}

#warrior-floating-toc-root .wft-dot-active {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #3FAE7C;
}

#warrior-floating-toc-root .wft-tip {
    font-size: 11.5px;
    color: #94A3B8;
}

/* Heading Highlight Animation */
.wft-heading-highlight {
    animation: wftPulse 1.4s ease-out;
}

@keyframes wftPulse {
    0% { background-color: rgba(207, 239, 247, 0.7); border-radius: 6px; }
    100% { background-color: transparent; }
}
