/**
 * TOC Expandable Styles
 * AffiliateCMS
 *
 * @package AffiliateCMS
 * @since 4.0.0
 */

/* ================================================================
   INLINE EXPANDABLE TOC
   ================================================================ */

.toc-expandable {
    max-width: 720px;
    margin: 0 auto var(--space-8);
}

/* Card Container */
.toc-expandable__card {
    background-color: var(--color-surface);
    border: 1px solid var(--color-border-subtle);
    border-radius: var(--radius-xl);
    overflow: hidden;
}

/* Header Row */
.toc-expandable__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-4);
    border-bottom: 1px solid var(--color-border-subtle);
}

.toc-expandable__header-left {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

/* Icon */
.toc-expandable__icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-hover) 100%);
    border-radius: var(--radius-lg);
    color: white;
    font-size: var(--text-lg);
    flex-shrink: 0;
}

/* Title & Meta */
.toc-expandable__header-text {
    display: flex;
    flex-direction: column;
    gap: var(--space-0-5);
}

h4.toc-expandable__title {
    font-size: var(--text-base);
    font-weight: var(--font-bold);
    color: var(--color-text);
    margin: 0;
}
.toc-expandable__title {
    font-size: var(--text-base);
    font-weight: var(--font-bold);
    color: var(--color-text);
    margin: 0;
}

.toc-expandable__meta {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    font-size: var(--text-xs);
    color: var(--color-text-muted);
}

.toc-expandable__meta-item {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
}

.toc-expandable__meta-item i {
    font-size: 12px;
    color: var(--color-text-subtle);
}

/* Progress Bar */
.toc-expandable__progress {
    height: 3px;
    background-color: var(--color-bg-alt);
}

.toc-expandable__progress-bar {
    height: 100%;
    width: 100%;
    background: linear-gradient(90deg, var(--color-primary) 0%, var(--color-accent) 100%);
    /* Use transform instead of width for better performance */
    transform: scaleX(0);
    transform-origin: left;
    transition: transform var(--duration-150) var(--ease-out);
    will-change: transform;
}

/* TOC List Container */
.toc-expandable__body {
    padding: var(--space-3) var(--space-4);
}

.toc-expandable__list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
}

/* TOC Link Item */
.toc-expandable__link {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-3);
    font-size: var(--text-sm);
    color: var(--color-text-secondary);
    text-decoration: none;
    border-radius: var(--radius-md);
    transition: all var(--duration-150) var(--ease-out);
}

.toc-expandable__link:hover {
    color: var(--color-primary);
    background-color: var(--color-primary-light);
}

.toc-expandable__link.is-active {
    color: var(--color-primary);
    background-color: var(--color-primary-light);
    font-weight: var(--font-medium);
}

/* Number Badge */
.toc-expandable__number {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 24px;
    height: 24px;
    padding: 0 var(--space-1);
    font-size: var(--text-xs);
    font-weight: var(--font-semibold);
    color: var(--color-text-subtle);
    background-color: var(--color-bg-alt);
    border-radius: var(--radius-sm);
    transition: all var(--duration-150) var(--ease-out);
}

.toc-expandable__link:hover .toc-expandable__number,
.toc-expandable__link.is-active .toc-expandable__number {
    color: white;
    background-color: var(--color-primary);
}

/* Link Text - Truncated to single line */
.toc-expandable__text {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* H3 Nested Items */
.toc-expandable__link--h3 {
    padding-left: var(--space-8);
    font-size: var(--text-xs);
    color: var(--color-text-muted);
}

.toc-expandable__link--h3 .toc-expandable__number {
    min-width: 20px;
    height: 20px;
    font-size: 10px;
}

/* Hidden Items (collapsed) */
.toc-expandable__hidden {
    display: none;
}

.toc-expandable__card.is-expanded .toc-expandable__hidden {
    display: block;
}

/* Expand Button */
.toc-expandable__expand {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    width: 100%;
    padding: var(--space-3);
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
    color: var(--color-primary);
    background-color: var(--color-bg-alt);
    border: none;
    border-top: 1px solid var(--color-border-subtle);
    cursor: pointer;
    transition: all var(--duration-150) var(--ease-out);
}

.toc-expandable__expand:hover {
    background-color: var(--color-primary-light);
}

.toc-expandable__expand i {
    font-size: 14px;
    transition: transform var(--duration-200) var(--ease-out);
}

.toc-expandable__card.is-expanded .toc-expandable__expand i {
    transform: rotate(180deg);
}

/* Toggle text visibility */
.toc-expandable__card.is-expanded .toc-expandable__expand-text {
    display: none;
}

.toc-expandable__collapse-text {
    display: none;
}

.toc-expandable__card.is-expanded .toc-expandable__collapse-text {
    display: inline;
}


/* ================================================================
   FLOATING ACTION BAR
   ================================================================ */

.toc-action-bar {
    position: fixed;
    bottom: var(--space-6);
    right: var(--space-6);
    z-index: var(--z-fixed);
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: var(--space-3);
    /* Hidden by default */
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px);
    transition: opacity var(--duration-200) var(--ease-out),
                visibility var(--duration-200) var(--ease-out),
                transform var(--duration-200) var(--ease-out);
    /* Prevent affecting other elements during animation */
    contain: layout;
    will-change: opacity, transform;
}

.toc-action-bar.is-visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}


/* ================================================================
   LIKE BUTTON (REMOVED - Feature deprecated)
   ================================================================ */

/* Removed like button styles - feature no longer in use */


/* ================================================================
   TOC BUBBLE
   ================================================================ */

.toc-bubble {
    position: relative;
}

/* Trigger Button */
.toc-bubble__trigger {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-hover) 100%);
    border: none;
    border-radius: var(--radius-full);
    color: white;
    font-size: var(--text-xl);
    cursor: pointer;
    box-shadow: var(--shadow-xl), var(--shadow-primary);
    transition: transform var(--duration-200) var(--ease-out),
                box-shadow var(--duration-200) var(--ease-out),
                background var(--duration-200) var(--ease-out),
                color var(--duration-200) var(--ease-out),
                border var(--duration-200) var(--ease-out);
}

.toc-bubble__trigger:hover {
    transform: scale(1.1);
    box-shadow: var(--shadow-2xl), 0 8px 24px rgba(13, 115, 119, 0.35);
}

.toc-bubble__trigger.is-open {
    background: var(--color-surface);
    color: var(--color-primary);
    border: 2px solid var(--color-primary);
}

/* Progress Ring */
.toc-bubble__progress {
    position: absolute;
    top: -4px;
    left: -4px;
    width: 64px;
    height: 64px;
    transform: rotate(-90deg);
    pointer-events: none;
}

.toc-bubble__progress-bg {
    fill: none;
    stroke: rgba(255, 255, 255, 0.25);
    stroke-width: 3;
}

.toc-bubble__progress-bar {
    fill: none;
    stroke: white;
    stroke-width: 3;
    stroke-linecap: round;
    stroke-dasharray: 188.5;
    stroke-dashoffset: 188.5;
    transition: stroke-dashoffset var(--duration-150) var(--ease-out);
}

/* Icon inside trigger */
.toc-bubble__trigger > i.bi-list-nested {
    font-size: var(--text-xl);
}

/* Section Countdown Badge - Positioned bottom-right of trigger button */
.toc-bubble__badge {
    position: absolute;
    bottom: -8px;
    right: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--text-xs);
    font-weight: var(--font-bold);
    color: var(--color-text-muted);
    background-color: var(--color-surface);
    padding: var(--space-0-5) var(--space-2);
    border-radius: var(--radius-full);
    box-shadow: var(--shadow-sm);
}

/* Dropdown Panel */
.toc-bubble__panel {
    position: absolute;
    bottom: calc(100% + var(--space-3));
    right: 0;
    width: 300px;
    max-height: 400px;
    background-color: var(--color-surface);
    border: 1px solid var(--color-border-subtle);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-2xl);
    overflow: hidden;
    /* Hidden */
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px) scale(0.95);
    transform-origin: bottom right;
    transition: opacity var(--duration-200) var(--ease-out),
                visibility var(--duration-200) var(--ease-out),
                transform var(--duration-200) var(--ease-out);
    contain: layout;
}

.toc-bubble__panel.is-open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

/* Panel Header */
.toc-bubble__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-3) var(--space-4);
    border-bottom: 1px solid var(--color-border-subtle);
    background-color: var(--color-bg-alt);
}

.toc-bubble__header-left {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.toc-bubble__header-icon {
    color: var(--color-primary);
    font-size: var(--text-base);
}

.toc-bubble__header-title {
    font-size: var(--text-sm);
    font-weight: var(--font-bold);
    color: var(--color-text);
    margin: 0;
}

.toc-bubble__close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: none;
    border: none;
    color: var(--color-text-muted);
    cursor: pointer;
    border-radius: var(--radius-md);
    transition: all var(--duration-150) var(--ease-out);
}

.toc-bubble__close:hover {
    background-color: var(--color-surface);
    color: var(--color-text);
}

/* Panel List */
.toc-bubble__list {
    list-style: none;
    margin: 0;
    padding: var(--space-2);
    max-height: 300px;
    overflow-y: auto;
}

/* Panel Link - Truncated */
.toc-bubble__link {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-3);
    font-size: var(--text-sm);
    color: var(--color-text-secondary);
    text-decoration: none;
    border-radius: var(--radius-md);
    transition: all var(--duration-150) var(--ease-out);
}

.toc-bubble__link span:last-child {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.toc-bubble__link:hover {
    color: var(--color-primary);
    background-color: var(--color-primary-light);
}

.toc-bubble__link.is-active {
    color: white;
    background-color: var(--color-primary);
}

.toc-bubble__link.is-active .toc-bubble__number {
    background-color: rgba(255, 255, 255, 0.2);
    color: white;
}

/* Number Badge */
.toc-bubble__number {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 22px;
    height: 22px;
    padding: 0 var(--space-1);
    font-size: var(--text-xs);
    font-weight: var(--font-semibold);
    color: var(--color-text-subtle);
    background-color: var(--color-bg-alt);
    border-radius: var(--radius-sm);
}

/* H3 Nested */
.toc-bubble__link--h3 {
    padding-left: var(--space-8);
    font-size: var(--text-xs);
}

.toc-bubble__link--h3 .toc-bubble__number {
    min-width: 18px;
    height: 18px;
    font-size: 10px;
}

/* Panel Footer */
.toc-bubble__footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-2) var(--space-3);
    border-top: 1px solid var(--color-border-subtle);
    background-color: var(--color-bg-alt);
}

.toc-bubble__progress-text {
    font-size: var(--text-xs);
    color: var(--color-text-muted);
}

.toc-bubble__back-top {
    display: flex;
    align-items: center;
    gap: var(--space-1);
    padding: var(--space-1) var(--space-2);
    font-size: var(--text-xs);
    font-weight: var(--font-medium);
    color: var(--color-primary);
    background: none;
    border: 1px solid var(--color-primary);
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: all var(--duration-150) var(--ease-out);
}

.toc-bubble__back-top:hover {
    background-color: var(--color-primary);
    color: white;
}

.toc-bubble__back-top i {
    font-size: 10px;
}


/* ================================================================
   DARK MODE
   ================================================================ */

[data-theme="dark"] .toc-expandable__card,
[data-theme="dark"] .toc-bubble__panel {
    background-color: var(--color-surface);
    border-color: var(--color-border);
}

[data-theme="dark"] .toc-expandable__number,
[data-theme="dark"] .toc-bubble__number {
    background-color: var(--color-surface-raised);
}

[data-theme="dark"] .toc-expandable__expand,
[data-theme="dark"] .toc-bubble__header,
[data-theme="dark"] .toc-bubble__footer {
    background-color: var(--color-surface-raised);
}

[data-theme="dark"] .toc-bubble__trigger.is-open {
    background-color: var(--color-surface);
}

/* Removed dark mode like button styles - feature no longer in use */


/* ================================================================
   RESPONSIVE
   ================================================================ */

@media (max-width: 639px) {
    /* Action bar position */
    .toc-action-bar {
        bottom: var(--space-4);
        right: var(--space-4);
        gap: var(--space-2);
    }

    /* Smaller trigger */
    .toc-bubble__trigger {
        width: 48px;
        height: 48px;
        font-size: var(--text-lg);
    }

    .toc-bubble__progress {
        width: 56px;
        height: 56px;
    }

    /* Panel full width */
    .toc-bubble__panel {
        width: calc(100vw - var(--space-8));
        right: 0;
    }

    /* Smaller expandable */
    .toc-expandable__header {
        padding: var(--space-3);
    }

    .toc-expandable__icon {
        width: 36px;
        height: 36px;
        font-size: var(--text-base);
    }

    .toc-expandable__title {
        font-size: var(--text-sm);
    }

    .toc-expandable__body {
        padding: var(--space-2) var(--space-3);
    }
}
