/**
 * Node Pancake Styles
 *
 * Styling for "pancaked" node panels - single-line headers that dock to the
 * site header area. When a collapsed panel is dragged to the top of the viewport,
 * it transforms into a slim, full-width header strip.
 *
 * Uses BEM naming: .node-pancake__element--modifier
 */

/* =============================================================================
   PANCAKE STRIP CONTAINER
   Sits directly below the site-header, holds all pancaked panels
   ============================================================================= */

.node-pancake-strip {
    position: fixed;
    left: 0;
    right: 0;
    z-index: 1001; /* Above site-header (1000) so pancaked panels are visible */
    display: flex;
    flex-direction: column;
    gap: 0;
    pointer-events: none; /* Pass through clicks when empty */
    opacity: 0;
    transition: transform 0.25s ease-out, opacity 0.2s ease-out;
}

/* Header strip - below site header */
.node-pancake-strip--header {
    top: var(--header-height, 72px);
    transform: translateY(calc(-100% - 20px));
}

/* Footer strip - at bottom of viewport */
.node-pancake-strip--footer {
    bottom: 0;
    transform: translateY(calc(100% + 20px));
}

/* Footer items grow upward from bottom */
.node-pancake-strip--footer {
    flex-direction: column-reverse;
}

.node-pancake-strip.has-items {
    pointer-events: auto;
    transform: translateY(0);
    opacity: 1;
}

/* =============================================================================
   PANCAKE ZONE INDICATOR
   Visual feedback when dragging collapsed panel toward top edge
   ============================================================================= */

.node-pancake-zone {
    position: fixed;
    left: 0;
    right: 0;
    height: 100px;
    z-index: 998;
    pointer-events: none;
    animation: pancake-zone-pulse 1.2s ease-in-out infinite;
}

/* Header zone - top of viewport */
.node-pancake-zone--header {
    top: 0;
    background: linear-gradient(
        to bottom,
        rgba(0, 217, 255, 0.15) 0%,
        rgba(0, 217, 255, 0.08) 50%,
        transparent 100%
    );
    border-bottom: 2px solid rgba(0, 217, 255, 0.5);
}

/* Footer zone - bottom of viewport */
.node-pancake-zone--footer {
    bottom: 0;
    background: linear-gradient(
        to top,
        rgba(0, 217, 255, 0.15) 0%,
        rgba(0, 217, 255, 0.08) 50%,
        transparent 100%
    );
    border-top: 2px solid rgba(0, 217, 255, 0.5);
}

@keyframes pancake-zone-pulse {
    0%, 100% {
        opacity: 0.8;
        border-bottom-color: rgba(0, 217, 255, 0.5);
    }
    50% {
        opacity: 1;
        border-bottom-color: rgba(0, 217, 255, 0.8);
    }
}

/* =============================================================================
   INDIVIDUAL PANCAKE ITEM
   Single-line representation of a pancaked node panel
   ============================================================================= */

.node-pancake-item {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    width: 100%;
    min-height: 36px;
    padding: 4px 0;

    /* Frosted glass effect matching site-header */
    background: rgba(18, 18, 20, 0.85);
    backdrop-filter: blur(12px) saturate(1.3);
    -webkit-backdrop-filter: blur(12px) saturate(1.3);

    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    cursor: default; /* Changed from pointer - individual cells are clickable */
    transition: background 0.15s ease, box-shadow 0.15s ease;

    /* Entry animation */
    animation: pancake-slide-in 0.3s ease-out;
}

@keyframes pancake-slide-in {
    from {
        opacity: 0;
        transform: translateY(-100%);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pancake-slide-in-up {
    from {
        opacity: 0;
        transform: translateY(100%);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Footer items slide up from bottom and have top border */
.node-pancake-strip--footer .node-pancake-item {
    animation: pancake-slide-in-up 0.3s ease-out;
    border-bottom: none;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.node-pancake-item:hover {
    background: rgba(30, 30, 35, 0.9);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.node-pancake-item:active {
    background: rgba(25, 25, 28, 0.95);
}

/* Accent color bar on left edge */
.node-pancake-item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--node-accent, var(--color-cyan, #00d9ff));
    opacity: 0.8;
}

/* =============================================================================
   DRAG HANDLE
   Grip icon on the left for reordering
   ============================================================================= */

.node-pancake-item__drag-handle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 100%;
    cursor: grab;
    color: rgba(255, 255, 255, 0.25);
    transition: color 0.15s ease, background 0.15s ease;
    flex-shrink: 0;
    margin-left: 8px;
}

.node-pancake-item__drag-handle:hover {
    color: rgba(255, 255, 255, 0.5);
    background: rgba(255, 255, 255, 0.05);
}

.node-pancake-item__drag-handle:active {
    cursor: grabbing;
    color: rgba(255, 255, 255, 0.7);
}

/* =============================================================================
   DRAG STATES
   Visual feedback during drag operations
   ============================================================================= */

/* Item being dragged */
.node-pancake-item.is-dragging {
    opacity: 0.9;
    box-shadow:
        0 8px 24px rgba(0, 0, 0, 0.4),
        0 0 0 2px rgba(0, 217, 255, 0.3);
    border-radius: 4px;
    pointer-events: none;
}

/* Item being dragged into undock zone */
.node-pancake-item.is-undocking {
    opacity: 0.7;
    box-shadow:
        0 12px 32px rgba(0, 0, 0, 0.5),
        0 0 0 2px rgba(255, 100, 100, 0.5);
    transform: scale(0.95);
}

/* Placeholder during drag */
.node-pancake-item__placeholder {
    background: rgba(0, 217, 255, 0.1);
    border: 2px dashed rgba(0, 217, 255, 0.3);
    border-radius: 4px;
    transition: height 0.15s ease;
}

/* =============================================================================
   PANCAKE ITEM STRUCTURE
   [Handle][Icon][Title] [Field 1] [Field 2] [Field 3] [Field 4] [Undock]
   ============================================================================= */

.node-pancake-item__identity {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 12px 0 16px;
    min-width: 140px;
    max-width: 180px;
    border-right: 1px solid rgba(255, 255, 255, 0.06);
    flex-shrink: 0;
}

.node-pancake-item__icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    color: var(--node-accent, var(--color-cyan, #00d9ff));
    opacity: 0.9;
}

.node-pancake-item__icon svg {
    width: 16px;
    height: 16px;
}

.node-pancake-item__title {
    font-size: 12px;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.9);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* =============================================================================
   PANCAKE FIELDS
   Wrap onto multiple lines, label-only cells with piping support
   ============================================================================= */

.node-pancake-item__fields {
    display: flex;
    flex-wrap: wrap;
    flex: 1;
    min-width: 0;
    align-content: flex-start;
    padding: 4px 0;
    gap: 2px 0;
}

.node-pancake-field {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2px 10px;
    border-right: 1px solid rgba(255, 255, 255, 0.04);
    cursor: pointer;
    transition: background 0.12s ease, color 0.12s ease;
    border-radius: 3px;
    margin: 1px 0;
}

.node-pancake-field:hover {
    background: rgba(255, 255, 255, 0.08);
}

.node-pancake-field:active {
    background: rgba(255, 255, 255, 0.12);
}

/* Piped state - show accent color */
.node-pancake-field.is-piped {
    background: rgba(0, 217, 255, 0.15);
}

.node-pancake-field.is-piped .node-pancake-field__label {
    color: var(--pipe-color, var(--color-cyan, #00d9ff));
}

/* Dragging state */
.node-pancake-field.is-dragging {
    opacity: 0.6;
    background: rgba(0, 217, 255, 0.2);
}

/* Drop target state */
.node-pancake-field.is-drop-target {
    background: rgba(0, 217, 255, 0.25);
    box-shadow: inset 0 0 0 1px rgba(0, 217, 255, 0.5);
}

.node-pancake-field__label {
    font-size: 9px;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.5);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
    transition: color 0.15s ease;
}

/* =============================================================================
   PANCAKE ACTIONS
   Undock button on the right side
   ============================================================================= */

.node-pancake-item__actions {
    display: flex;
    align-items: center;
    padding: 0 8px;
    gap: 4px;
    flex-shrink: 0;
}

.node-pancake-item__btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border: none;
    border-radius: 4px;
    background: transparent;
    color: rgba(255, 255, 255, 0.4);
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

.node-pancake-item__btn:hover {
    background: rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.8);
}

.node-pancake-item__btn:active {
    background: rgba(255, 255, 255, 0.12);
}

.node-pancake-item__btn svg {
    width: 14px;
    height: 14px;
}

/* Undock button specific styling */
.node-pancake-item__btn--undock:hover {
    color: var(--color-cyan, #00d9ff);
}

/* =============================================================================
   PANEL STATE: PANCAKED
   Hide the floating panel when it's pancaked (represented in strip instead)
   ============================================================================= */

.node-panel.is-pancaked {
    display: none !important;
}

/* Indicator class for panels that are pancake-able (collapsed and being dragged) */
.node-panel.is-collapsed.is-dragging.is-near-pancake {
    opacity: 0.6;
    transform: scale(0.95);
}

/* =============================================================================
   RESPONSIVE ADJUSTMENTS
   ============================================================================= */

@media (max-width: 768px) {
    .node-pancake-item {
        height: 32px;
        min-height: 32px;
    }

    .node-pancake-item__identity {
        min-width: 100px;
        max-width: 120px;
        padding: 0 8px 0 12px;
    }

    .node-pancake-field__label {
        display: none; /* Hide labels on mobile, show values only */
    }

    .node-pancake-field {
        padding: 0 6px;
    }
}

/* Very narrow screens - minimal pancake view */
@media (max-width: 480px) {
    .node-pancake-item__fields {
        display: none; /* Hide fields, show only title */
    }

    .node-pancake-item__identity {
        flex: 1;
        max-width: none;
    }
}

/* =============================================================================
   LEFT/RIGHT PANCAKE STRIPS
   Vertical strips on viewport edges for side-pancaked panels
   ============================================================================= */

.node-pancake-strip--left,
.node-pancake-strip--right {
    position: fixed;
    top: var(--header-height, 72px);
    bottom: 0;
    width: 180px;
    left: auto;
    right: auto;
    z-index: 1001; /* Above site-header (1000) so pancaked panels are visible */
    display: flex;
    flex-direction: column;
    gap: 0;
    pointer-events: none;
    opacity: 0;
    transition: transform 0.25s ease-out, opacity 0.2s ease-out;
}

.node-pancake-strip--left {
    left: 0;
    transform: translateX(-100%);
}

.node-pancake-strip--right {
    right: 0;
    transform: translateX(100%);
}

.node-pancake-strip--left.has-items,
.node-pancake-strip--right.has-items {
    pointer-events: auto;
    transform: translateX(0);
    opacity: 1;
}

/* Vertical pancake item styling */
.node-pancake-item--vertical {
    width: 100%;
    min-width: 180px;
    min-height: auto;
    flex-direction: column;
    align-items: stretch;
    padding: 8px;
    flex-wrap: nowrap;
}

.node-pancake-item--vertical .node-pancake-item__drag-handle {
    align-self: center;
    margin-bottom: 4px;
}

.node-pancake-item--vertical .node-pancake-item__identity {
    border-right: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    max-width: none;
    padding: 4px 0 8px 0;
    justify-content: center;
}

.node-pancake-item--vertical .node-pancake-item__fields {
    padding: 8px 0;
    flex-wrap: wrap;
    justify-content: center;
}

.node-pancake-item--vertical .node-pancake-item__actions {
    justify-content: center;
    padding-top: 4px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}

/* Left strip accent bar on left edge */
.node-pancake-strip--left .node-pancake-item::before {
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    height: auto;
}

/* Right strip accent bar on right edge */
.node-pancake-strip--right .node-pancake-item::before {
    left: auto;
    right: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    height: auto;
}

/* Zone indicators for left/right */
.node-pancake-zone--left {
    left: 0;
    right: auto;
    top: var(--header-height, 72px);
    bottom: 0;
    width: 100px;
    height: auto;
    background: linear-gradient(
        to right,
        rgba(0, 217, 255, 0.15) 0%,
        rgba(0, 217, 255, 0.08) 50%,
        transparent 100%
    );
    border-right: 2px solid rgba(0, 217, 255, 0.5);
    border-bottom: none;
}

.node-pancake-zone--right {
    right: 0;
    left: auto;
    top: var(--header-height, 72px);
    bottom: 0;
    width: 100px;
    height: auto;
    background: linear-gradient(
        to left,
        rgba(0, 217, 255, 0.15) 0%,
        rgba(0, 217, 255, 0.08) 50%,
        transparent 100%
    );
    border-left: 2px solid rgba(0, 217, 255, 0.5);
    border-bottom: none;
}

/* Slide animations for left/right */
@keyframes pancake-slide-in-left {
    from {
        opacity: 0;
        transform: translateX(-100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes pancake-slide-in-right {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.node-pancake-strip--left .node-pancake-item {
    animation: pancake-slide-in-left 0.3s ease-out;
    border-bottom: none;
    border-right: 1px solid rgba(255, 255, 255, 0.06);
}

.node-pancake-strip--right .node-pancake-item {
    animation: pancake-slide-in-right 0.3s ease-out;
    border-bottom: none;
    border-left: 1px solid rgba(255, 255, 255, 0.06);
}
