/* Pivot wrapper */
.pivot-wrapper {
    width: 100%;
    height: 100%;
    background-color: var(--background-color, #fafafa);
    border: 1px solid var(--divider-color, #e2e2e2);
    overflow: hidden;
    position: relative;
}

/* Scroll container */
.pivot-scroll-container {
    width: 100%;
    height: 100%;
    overflow: auto;
    position: relative;
    scrollbar-color: var(--faded-color, #e1e1e1) transparent;
    scrollbar-width: auto;
}

.pivot-scroll-container::-webkit-scrollbar {
    width: 13px;
    height: 13px;
}

.pivot-scroll-container::-webkit-scrollbar-track {
    background: var(--alt-background-color, #f5f5f5);
}

.pivot-scroll-container::-webkit-scrollbar-thumb {
    background-color: #c7c7c7;
    border-radius: 0;
    border: 3px solid var(--alt-background-color, #f5f5f5);
}

.pivot-scroll-container::-webkit-scrollbar-thumb:hover {
    background-color: #aaa;
}

/* Virtual size */
.pivot-virtual-content {
    position: relative;
    display: block;
    pointer-events: none;
}

/* Canvas */
.pivot-canvas {
    position: absolute;
    top: 0;
    left: 0;
    display: block;
    z-index: 1;
    cursor: default;
    /* Browser-managed touch and precision-trackpad panning, with momentum. */
    touch-action: pan-x pan-y;
    image-rendering: auto;
}

/*
 * This layer is a descendant of the native scroll container but does not take
 * any layout space. Sticky positioning keeps its overflowing canvas pinned to
 * the viewport as the virtual content scrolls underneath it.
 */
.pivot-canvas-layer {
    position: sticky;
    top: 0;
    left: 0;
    z-index: 1;
    width: 0;
    height: 0;
    overflow: visible;
}

/* The resize strip deliberately keeps custom pointer handling on touch. */
.pivot-resize-handle {
    position: absolute;
    top: 0;
    z-index: 2;
    width: 12px;
    cursor: col-resize;
    touch-action: none;
}

.pivot-canvas:focus,
.pivot-canvas:focus-visible {
    outline: none;
}

/* Loading */
.pivot-loading-overlay {
    position: absolute;
    inset: 0;
    z-index: 6;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    background: rgba(250, 250, 250, 0.88);
    color: var(--color, #111);
    font-weight: 500;
}

.pivot-loading-overlay.is-hidden {
    display: none;
}

.pivot-loading-spinner {
    width: 22px;
    height: 22px;
    border: 2px solid var(--base-light-color, #bbdefb);
    border-top-color: var(--base-color, #2196f3);
    border-radius: 50%;
    animation: pivot-loading-spin 0.8s linear infinite;
}

.pivot-loading-label {
    font-size: 13px;
    color: var(--highlight-color, rgba(17, 17, 17, 0.54));
}

/* Cell detail overlay */
.pivot-cell-info-overlay {
    position: absolute;
    inset: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: clamp(10px, 3vw, 32px);
    box-sizing: border-box;
    background: rgba(15, 23, 42, 0.45);
    backdrop-filter: blur(2px);
}

.pivot-cell-info-overlay.is-hidden {
    display: none;
}

.pivot-cell-info-panel {
    width: 640px;
    max-width: 100%;
    height: min(680px, 100%);
    box-sizing: border-box;
    min-width: 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid var(--divider-color, #e2e2e2);
    border-radius: 12px;
    background: var(--background-color, #fff);
    color: var(--color, #111);
    box-shadow: 0 24px 70px rgba(15, 23, 42, 0.32);
}

.pivot-cell-info-header {
    position: relative;
    flex: 0 0 auto;
    min-height: 78px;
    box-sizing: border-box;
    display: flex;
    align-items: flex-start;
    gap: 16px;
    padding: 16px 18px;
    border-bottom: 1px solid var(--divider-color, #e2e2e2);
    background: var(--alt-background-color, #f8fafc);
}

.pivot-cell-info-heading {
    flex: 1;
    min-width: 0;
}

.pivot-cell-info-title {
    margin: 0;
    font-size: 16px;
    line-height: 1.35;
}

.pivot-cell-info-context {
    margin-top: 5px;
    overflow: hidden;
    color: var(--highlight-color, #64748b);
    font-size: 12px;
    line-height: 1.45;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pivot-cell-info-close {
    flex: 0 0 auto;
    width: 34px;
    height: 34px;
    border: 1px solid var(--divider-color, #e2e2e2);
    border-radius: 8px;
    background: var(--background-color, #fff);
    color: inherit;
    font: 24px/1 sans-serif;
    cursor: pointer;
}

.pivot-cell-info-actions {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 8px;
}

.pivot-cell-info-export {
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--divider-color, #e2e2e2);
    border-radius: 8px;
    background: var(--background-color, #fff);
    color: inherit;
    cursor: pointer;
}

.pivot-cell-info-search-trigger {
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--divider-color, #e2e2e2);
    border-radius: 8px;
    background: var(--background-color, #fff);
    color: inherit;
    cursor: pointer;
}

.pivot-cell-info-search-trigger:hover {
    background: var(--hovered-background-color, #eee);
}

.pivot-cell-info-search-trigger:disabled {
    opacity: 0.5;
    cursor: wait;
}

.pivot-cell-info-export:hover {
    background: var(--hovered-background-color, #eee);
}

.pivot-cell-info-export:disabled {
    opacity: 0.5;
    cursor: wait;
}

.pivot-cell-info-close:hover {
    background: var(--hovered-background-color, #eee);
}

.pivot-cell-info-body {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.pivot-cell-info-search {
    position: absolute;
    inset: 0;
    z-index: 2;
    box-sizing: border-box;
    padding: 10px 18px;
    background: var(--alt-background-color, #f8fafc);
}

.pivot-cell-info-search .pivot-search-main {
    flex-wrap: nowrap;
}

.pivot-cell-info-search .pivot-search-meta {
    min-width: 0;
    flex-direction: row;
    gap: 8px;
    margin-top: 5px;
    line-height: 17px;
}

.pivot-cell-info-search .pivot-search-status {
    flex: 0 0 auto;
    white-space: nowrap;
}

.pivot-cell-info-search .pivot-search-path {
    flex: 1 1 auto;
    min-width: 0;
    min-height: 0;
}

.pivot-cell-info-search.is-hidden {
    display: none;
}

@media (max-width: 420px) {
    .pivot-cell-info-search {
        padding-right: 10px;
        padding-left: 10px;
    }

    .pivot-cell-info-search .pivot-search-main {
        gap: 4px;
    }

    .pivot-cell-info-search .pivot-search-button,
    .pivot-cell-info-search .pivot-search-close {
        padding-right: 6px;
        padding-left: 6px;
        font-size: 12px;
    }
}

.pivot-cell-info-canvas-root {
    flex: 1 1 auto;
    min-width: 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.pivot-cell-info-canvas-scroll {
    position: relative;
    flex: 1 1 auto;
    min-width: 0;
    min-height: 0;
    overflow: auto;
    scrollbar-gutter: stable;
    scrollbar-color: var(--faded-color, #c7c7c7) transparent;
}

.pivot-cell-info-canvas-layer {
    position: sticky;
    top: 0;
    left: 0;
    z-index: 1;
    width: 0;
    height: 0;
    overflow: visible;
}

.pivot-cell-info-canvas {
    position: absolute;
    top: 0;
    left: 0;
    display: block;
    pointer-events: auto;
    touch-action: pan-x pan-y;
}

.pivot-cell-info-canvas-virtual {
    position: relative;
    display: block;
    pointer-events: none;
}

.pivot-cell-info-state {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 28px;
    color: var(--highlight-color, #64748b);
    font-size: 13px;
}

.pivot-cell-info-error {
    color: #b91c1c;
}

@media (max-width: 600px) {
    .pivot-cell-info-overlay {
        padding: 0;
    }

    .pivot-cell-info-panel {
        width: 100%;
        height: 100%;
        border: 0;
        border-radius: 0;
    }
}

/* Search trigger */
.pivot-search-trigger,
.pivot-export-trigger {
    position: absolute;
    top: 14px;
    left: 14px;
    z-index: 7;
    width: 39px;
    height: 39px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--divider-color, #e2e2e2);
    border-radius: 10px;
    background: var(--background-color, #fafafa);
    color: var(--color, #111);
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.05);
    cursor: pointer;
}

.pivot-search-trigger:hover,
.pivot-export-trigger:hover {
    background: var(--hovered-background-color, #eee);
    border-color: var(--base-light-color, #bbdefb);
}

.pivot-search-trigger:active,
.pivot-export-trigger:active {
    background: var(--selected-background-color, #e0e0e0);
}

.pivot-search-trigger:disabled,
.pivot-export-trigger:disabled {
    opacity: 0.55;
    cursor: wait;
}

.pivot-export-trigger {
    position: absolute;
    top: 14px;
    left: 61px;
    z-index: 7;
    width: 39px;
    height: 39px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--divider-color, #e2e2e2);
    border-radius: 10px;
    background: var(--background-color, #fafafa);
    color: var(--color, #111);
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.05);
    cursor: pointer;
}

.pivot-export-trigger-solo {
    left: 14px;
}

.pivot-export-trigger-icon {
    width: 18px;
    height: 18px;
    display: block;
}

.pivot-export-trigger-icon svg {
    width: 100%;
    height: 100%;
    display: block;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.15;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.pivot-export-trigger-icon .pivot-export-icon-panel {
    fill: var(--background-color, #fafafa);
}

.pivot-export-trigger-icon .pivot-export-icon-x {
    stroke-width: 1.35;
}

/* Search overlay */
.pivot-search-overlay {
    position: absolute;
    top: 14px;
    right: 14px;
    z-index: 5;
    width: min(360px, calc(100% - 28px));
    min-width: 0;
    max-width: min(520px, calc(100% - 28px));
    padding: 10px;
    border: 1px solid var(--divider-color, #e2e2e2);
    border-radius: 4px;
    background: var(--background-color, #fafafa);
    color: var(--color, #111);
    box-shadow: 0 8px 22px rgba(0, 0, 0, 0.18);
}

.pivot-search-overlay.is-hidden {
    display: none;
}

.pivot-search-main {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.pivot-search-input {
    flex: 1;
    min-width: 0;
    height: 36px;
    padding: 0 10px;
    border: 1px solid var(--divider-color, #e2e2e2);
    border-radius: 3px;
    background: #fff;
    color: var(--color, #111);
    font: inherit;
}

.pivot-search-input:focus {
    outline: none;
    border-color: var(--base-color, #2196f3);
    box-shadow: 0 0 0 2px rgba(33, 150, 243, 0.18);
}

/* Search buttons */
.pivot-search-button,
.pivot-search-close {
    height: 36px;
    padding: 0 12px;
    border: 0;
    border-radius: 3px;
    font: inherit;
    font-weight: 500;
    cursor: pointer;
}

.pivot-search-button {
    background: var(--base-color, #2196f3);
    color: var(--base-foreground-color, #fff);
}

.pivot-search-button:hover {
    background: var(--base-dark-color, #1976d2);
}

.pivot-search-button:active {
    background: var(--base-pressed-color, #6ab8f7);
}

.pivot-search-button-secondary,
.pivot-search-close {
    background: var(--selected-background-color, #e0e0e0);
    color: var(--color, #111);
}

.pivot-search-button-secondary:hover,
.pivot-search-close:hover {
    background: var(--hovered-background-color, #eee);
}

.pivot-search-button:disabled,
.pivot-search-close:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

/* Search status/path */
.pivot-search-meta {
    display: flex;
    flex-direction: column;
    gap: 3px;
    margin-top: 8px;
}

.pivot-search-status {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: var(--highlight-color, rgba(17, 17, 17, 0.54));
    line-height: 1.35;
}

.pivot-search-path {
    display: block;
    min-height: 17px;
    font-size: 12px;
    color: var(--color, #111);
    opacity: 0.75;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

@keyframes pivot-loading-spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}
