/**
 * PRISM Drawer Styles
 *
 * Slide-in drawer panels that dock to left/right edges.
 * Drawers can hold multiple stacked node panels with click-to-toggle behavior.
 *
 * Uses BEM naming: .prism-drawer__element--modifier
 */

/* =============================================================================
   DRAWER CONTAINER
   Slide-in panel from left or right edge
   ============================================================================= */

.prism-drawer {
    position: fixed;
    top: var(--header-height, 72px);
    bottom: 0;
    width: 340px;
    z-index: 800; /* Above panels (600) but below header (1000) */

    display: flex;
    flex-direction: column;

    /* Frosted glass effect */
    background: rgba(18, 18, 20, 0.92);
    backdrop-filter: blur(16px) saturate(1.3);
    -webkit-backdrop-filter: blur(16px) saturate(1.3);

    box-shadow:
        0 0 40px rgba(0, 0, 0, 0.3),
        inset 0 0 0 1px rgba(255, 255, 255, 0.06);

    /* Slide animation */
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Left drawer */
.prism-drawer--left {
    left: 0;
    border-right: 1px solid rgba(255, 255, 255, 0.08);
    transform: translateX(-100%);
}

.prism-drawer--left.is-open {
    transform: translateX(0);
}

/* Right drawer */
.prism-drawer--right {
    right: 0;
    border-left: 1px solid rgba(255, 255, 255, 0.08);
    transform: translateX(100%);
}

.prism-drawer--right.is-open {
    transform: translateX(0);
}

/* =============================================================================
   DRAWER TOGGLE TAB
   Small clickable tab visible when drawer is closed
   ============================================================================= */

.prism-drawer-tab {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    z-index: 799; /* Just below drawer */

    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 4px;

    width: 24px;
    height: 64px;
    padding: 8px 4px;

    background: rgba(18, 18, 20, 0.85);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);

    cursor: pointer;
    transition: background 0.15s ease, width 0.15s ease, opacity 0.2s ease;
}

.prism-drawer-tab--left {
    left: 0;
    border-radius: 0 8px 8px 0;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-left: none;
}

.prism-drawer-tab--right {
    right: 0;
    border-radius: 8px 0 0 8px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-right: none;
}

.prism-drawer-tab:hover {
    background: rgba(30, 30, 35, 0.9);
    width: 28px;
}

/* Hide tab when drawer is open */
.prism-drawer.is-open + .prism-drawer-tab {
    opacity: 0;
    pointer-events: none;
}

/* Tab icon */
.prism-drawer-tab__icon {
    width: 14px;
    height: 14px;
    color: rgba(255, 255, 255, 0.5);
    transition: color 0.15s ease;
}

.prism-drawer-tab:hover .prism-drawer-tab__icon {
    color: rgba(255, 255, 255, 0.8);
}

/* Tab count badge */
.prism-drawer-tab__count {
    font-size: 10px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.7);
    min-width: 14px;
    height: 14px;
    line-height: 14px;
    text-align: center;
    background: rgba(0, 217, 255, 0.2);
    border-radius: 7px;
}

.prism-drawer-tab__count:empty {
    display: none;
}

/* =============================================================================
   DRAWER HEADER
   Title and close button
   ============================================================================= */

.prism-drawer__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    flex-shrink: 0;
}

.prism-drawer__title {
    font-size: 12px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.9);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.prism-drawer__close-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;
}

.prism-drawer__close-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.8);
}

.prism-drawer__close-btn svg {
    width: 14px;
    height: 14px;
}

/* =============================================================================
   DRAWER CONTENT
   Scrollable container for stacked panels
   ============================================================================= */

.prism-drawer__content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Custom scrollbar */
.prism-drawer__content::-webkit-scrollbar {
    width: 6px;
}

.prism-drawer__content::-webkit-scrollbar-track {
    background: transparent;
}

.prism-drawer__content::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 3px;
}

.prism-drawer__content::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.25);
}

/* =============================================================================
   DRAWER EMPTY STATE
   Shown when no panels are in the drawer
   ============================================================================= */

.prism-drawer__empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 40px 20px;
    color: rgba(255, 255, 255, 0.35);
    text-align: center;
}

.prism-drawer__empty-icon {
    width: 32px;
    height: 32px;
    opacity: 0.5;
}

.prism-drawer__empty-text {
    font-size: 12px;
    line-height: 1.4;
}

/* =============================================================================
   DRAWER PANEL ITEM
   Individual panel representation within a drawer
   ============================================================================= */

.prism-drawer-panel {
    display: flex;
    flex-direction: column;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 8px;
    overflow: hidden;
    transition: box-shadow 0.15s ease, border-color 0.15s ease;
}

.prism-drawer-panel:hover {
    border-color: rgba(255, 255, 255, 0.1);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

/* Panel header (collapsible toggle) */
.prism-drawer-panel__header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    background: rgba(255, 255, 255, 0.02);
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    cursor: pointer;
    transition: background 0.15s ease;
}

.prism-drawer-panel__header:hover {
    background: rgba(255, 255, 255, 0.05);
}

/* Accent bar */
.prism-drawer-panel__header::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--node-accent, var(--color-cyan, #00d9ff));
    opacity: 0.7;
    border-radius: 8px 0 0 8px;
}

/* Collapse chevron */
.prism-drawer-panel__chevron {
    width: 14px;
    height: 14px;
    color: rgba(255, 255, 255, 0.4);
    transition: transform 0.2s ease;
    flex-shrink: 0;
}

.prism-drawer-panel.is-collapsed .prism-drawer-panel__chevron {
    transform: rotate(-90deg);
}

/* Panel icon */
.prism-drawer-panel__icon {
    width: 16px;
    height: 16px;
    color: var(--node-accent, var(--color-cyan, #00d9ff));
    flex-shrink: 0;
}

/* Panel title */
.prism-drawer-panel__title {
    flex: 1;
    font-size: 12px;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.85);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Panel actions */
.prism-drawer-panel__actions {
    display: flex;
    gap: 2px;
    opacity: 0;
    transition: opacity 0.15s ease;
}

.prism-drawer-panel__header:hover .prism-drawer-panel__actions {
    opacity: 1;
}

.prism-drawer-panel__btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    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;
}

.prism-drawer-panel__btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.8);
}

.prism-drawer-panel__btn svg {
    width: 12px;
    height: 12px;
}

/* Pop-out button hover state */
.prism-drawer-panel__btn--popout:hover {
    color: var(--color-cyan, #00d9ff);
}

/* Panel content (collapsible) */
.prism-drawer-panel__content {
    max-height: 400px;
    overflow: hidden;
    transition: max-height 0.2s ease;
}

.prism-drawer-panel.is-collapsed .prism-drawer-panel__content {
    max-height: 0;
    border-bottom: none;
}

/* The actual node panel content rendered inside */
.prism-drawer-panel__inner {
    padding: 12px;
}

/* =============================================================================
   DROP ZONE
   Visual feedback when dragging a panel toward drawer
   ============================================================================= */

.prism-drawer-dropzone {
    position: fixed;
    top: var(--header-height, 72px);
    bottom: 0;
    width: 100px;
    z-index: 998;
    pointer-events: none;
    animation: drawer-dropzone-pulse 1.2s ease-in-out infinite;
}

.prism-drawer-dropzone--left {
    left: 0;
    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);
}

.prism-drawer-dropzone--right {
    right: 0;
    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);
}

@keyframes drawer-dropzone-pulse {
    0%, 100% {
        opacity: 0.8;
    }
    50% {
        opacity: 1;
    }
}

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

@media (max-width: 768px) {
    .prism-drawer {
        width: 280px;
    }

    .prism-drawer-tab {
        width: 20px;
        height: 48px;
    }

    .prism-drawer-tab:hover {
        width: 24px;
    }
}

/* Very narrow screens - full width drawers */
@media (max-width: 480px) {
    .prism-drawer {
        width: 100%;
    }

    .prism-drawer-tab {
        display: none;
    }
}

/* =============================================================================
   ADJUST CONTENT WHEN DRAWERS ARE OPEN
   ============================================================================= */

body.drawer-left-open .preview-layout {
    margin-left: 340px;
    transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

body.drawer-right-open .preview-layout {
    margin-right: 340px;
    transition: margin-right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@media (max-width: 768px) {
    body.drawer-left-open .preview-layout {
        margin-left: 280px;
    }

    body.drawer-right-open .preview-layout {
        margin-right: 280px;
    }
}

@media (max-width: 480px) {
    body.drawer-left-open .preview-layout,
    body.drawer-right-open .preview-layout {
        margin-left: 0;
        margin-right: 0;
    }
}
