/* =========================================================================
   PATCHWORK DOCK & WINDOW SYSTEM (Adobe-style Minimalist Stacking Workspace)
   PatchWork Standard: the --adobe-* names are kept (panels read them) but
   now resolve to css/slate.css tokens — Panel surface, hairlines, 3 text
   steps, one accent.
   ========================================================================= */

:root {
    --adobe-bg-base: var(--sl-app);
    --adobe-bg-panel: var(--sl-panel);
    --adobe-bg-header: var(--sl-panel);
    --adobe-bg-header-hover: var(--sl-row-hover);
    --adobe-bg-surface: var(--sl-card);
    --adobe-bg-surface-hover: var(--sl-wash);
    --adobe-border: var(--sl-hairline);
    --adobe-border-subtle: var(--sl-hairline);
    --adobe-border-focus: var(--sl-focus);
    --adobe-fg: var(--sl-text-1);
    --adobe-fg-2: var(--sl-text-2);
    --adobe-fg-muted: var(--sl-text-2);
    --adobe-fg-dim: var(--sl-text-3);
    --adobe-accent: var(--sl-accent);
    --adobe-accent-rgb: 56, 189, 248;
    --adobe-header-h: 34px;
    --adobe-dock-w: 420px;
}

/* ---- Right Dock Container ---- */
.panels-dock {
    position: relative;
    flex-shrink: 0;
    width: var(--adobe-dock-w);
    min-width: 320px;
    max-width: 60vw;
    height: 100%;
    display: flex;
    flex-direction: column;
    background: var(--adobe-bg-base);
    border-left: 1px solid var(--adobe-border);
    box-shadow: none;
    z-index: 100;
    overflow: hidden;
    user-select: none;
}

/* Left-edge grab handle for resizing dock width */
.dock-resize-handle-left {
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    width: 6px;
    cursor: ew-resize;
    z-index: 200;
    transition: background 0.15s ease;
}
.dock-resize-handle-left:hover,
.dock-resize-handle-left.is-resizing {
    background: var(--sl-accent-line);
}

/* ---- Stacked Panel Items in Dock ---- */
.dock-item {
    position: relative;
    display: flex;
    flex-direction: column;
    min-height: var(--adobe-header-h);
    overflow: hidden;
    background: var(--adobe-bg-panel);
    border-bottom: 1px solid var(--adobe-border);
    user-select: auto;
}

/* When expanded, panels share vertical space */
.dock-item.is-expanded {
    flex: 1 1 auto;
    min-height: 140px;
}

/* When collapsed, panel shrinks to header only */
.dock-item.is-collapsed {
    flex: 0 0 var(--adobe-header-h) !important;
    height: var(--adobe-header-h) !important;
    min-height: var(--adobe-header-h) !important;
}
.dock-item.is-collapsed .dock-panel-body,
.dock-item.is-collapsed .asset-window-body,
.dock-item.is-collapsed .rp-body,
.dock-item.is-collapsed .rp-foot,
.dock-item.is-collapsed .rp-stats,
.dock-item.is-collapsed .rp-tabs,
.dock-item.is-collapsed #output-content,
.dock-item.is-collapsed .agc-body,
.dock-item.is-collapsed .agc-compose {
    display: none !important;
}

/* ---- Adobe Panel Header ---- */
.dock-panel-head {
    height: var(--adobe-header-h);
    min-height: var(--adobe-header-h);
    max-height: var(--adobe-header-h);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 8px 0 10px;
    background: var(--adobe-bg-header);
    border-bottom: 1px solid var(--adobe-border);
    user-select: none;
    cursor: pointer;
    transition: background 0.12s ease;
}
.dock-panel-head:hover {
    background: var(--adobe-bg-header-hover);
}

/* Accordion Chevron */
.dock-chevron {
    width: 14px;
    height: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--adobe-fg-muted);
    transition: transform 0.15s ease, color 0.15s ease;
}
.dock-chevron svg {
    width: 10px;
    height: 10px;
    stroke-width: 2.5;
}
.dock-item.is-expanded .dock-chevron {
    transform: rotate(90deg);
    color: var(--adobe-fg);
}
.dock-item.is-collapsed .dock-chevron {
    transform: rotate(0deg);
}

/* Panel Title */
.dock-panel-title {
    font-family: var(--sl-font-ui);
    font-size: 12.5px;
    font-weight: 600;
    color: var(--adobe-fg);
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}
.dock-panel-title svg {
    width: 13px;
    height: 13px;
    color: var(--adobe-fg-muted);
}

/* Header Badge */
.dock-panel-badge {
    padding: 1px 6px;
    border-radius: var(--sl-r-6);
    background: oklch(1 0 0 / 0.07);
    border: none;
    font-family: var(--sl-font-mono);
    font-size: 10.5px;
    font-weight: 600;
    color: var(--adobe-fg-muted);
    white-space: nowrap;
}
.dock-panel-badge.is-active {   /* status: coloured text, never a fill */
    background: transparent;
    padding: 0;
    color: var(--sl-success);
}

/* Header Actions */
.dock-panel-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 3px;
}
.dock-icon-btn {
    width: var(--sl-h-sm);
    height: var(--sl-h-sm);
    padding: 0;
    border: 0;
    border-radius: var(--sl-r-6);
    background: transparent;
    color: var(--adobe-fg-muted);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.12s ease;
}
.dock-icon-btn:hover {
    background: var(--sl-wash);
    color: var(--sl-text-1);
}
.dock-icon-btn svg {
    width: 13px;
    height: 13px;
}

/* ---- Vertical Splitter between Stacked Panels ---- */
.dock-splitter {
    position: relative;
    height: 6px;
    flex-shrink: 0;
    background: transparent;
    cursor: ns-resize;
    z-index: 50;
    margin: -3px 0;
    display: flex;
    align-items: center;
    justify-content: center;
}
.dock-splitter::before {
    content: '';
    display: block;
    width: 100%;
    height: 1px;
    background: var(--adobe-border);
    transition: background 0.15s ease, height 0.15s ease;
}
.dock-splitter:hover::before,
.dock-splitter.is-resizing::before {
    background: var(--adobe-accent);
    height: 2px;
}

/* ---- Panel Body Content Container ---- */
.dock-panel-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
}

/* Adobe-style minimalist scrollbars */
.panels-dock *::-webkit-scrollbar,
.adobe-window-floating *::-webkit-scrollbar {
    width: 5px;
    height: 5px;
}
.panels-dock *::-webkit-scrollbar-track,
.adobe-window-floating *::-webkit-scrollbar-track {
    background: transparent;
}
.panels-dock *::-webkit-scrollbar-thumb,
.adobe-window-floating *::-webkit-scrollbar-thumb {
    background: var(--sl-control);
    border-radius: 3px;
}
.panels-dock *::-webkit-scrollbar-thumb:hover,
.adobe-window-floating *::-webkit-scrollbar-thumb:hover {
    background: var(--sl-control-hover);
}

/* ---- Floating Window Mode ---- */
.adobe-window-floating {
    position: fixed !important;
    z-index: 9500 !important;
    width: 440px;
    height: 540px;
    min-width: 300px;
    min-height: 200px;
    max-width: calc(100vw - 40px);
    max-height: calc(100vh - 40px);
    display: flex !important;
    flex-direction: column !important;
    background: var(--adobe-bg-panel) !important;
    border: 1px solid var(--sl-border-strong) !important;
    border-radius: var(--sl-r-12) !important;
    box-shadow: var(--sl-shadow-float) !important;
    overflow: hidden !important;
}
.adobe-window-floating .dock-panel-head {
    cursor: move;
    border-radius: 11px 11px 0 0;
}
.adobe-window-floating .dock-panel-body {
    border-radius: 0 0 11px 11px;
}

/* Floating Window Resize Handles */
.window-resize-handle {
    position: absolute;
    z-index: 100;
}
.window-resize-r { right: 0; top: 0; bottom: 0; width: 6px; cursor: ew-resize; }
.window-resize-b { bottom: 0; left: 0; right: 0; height: 6px; cursor: ns-resize; }
.window-resize-br { right: 0; bottom: 0; width: 10px; height: 10px; cursor: nwse-resize; }

/* ---- Panel-Specific Clean Overrides When Docked ---- */
/* GPU Panel in Dock */
.panels-dock .runpod-panel,
.adobe-window-floating .runpod-panel {
    width: 100% !important;
    min-width: 0 !important;
    max-width: none !important;
    border-left: 0 !important;
    box-shadow: none !important;
    height: 100%;
}
.panels-dock .runpod-panel .rp-resize-handle-left {
    display: none;
}

/* Asset Panel in Dock */
.panels-dock .asset-panel,
.adobe-window-floating .asset-panel {
    width: 100% !important;
    min-width: 0 !important;
    max-width: none !important;
    border-left: 0 !important;
    box-shadow: none !important;
    height: 100%;
    display: flex !important;
}
.panels-dock .asset-panel .asset-resize-handle-left {
    display: none;
}

/* Console Panel in Dock */
.panels-dock .console-panel,
.adobe-window-floating .console-panel {
    width: 100% !important;
    min-width: 0 !important;
    max-width: none !important;
    border-left: 0 !important;
    box-shadow: none !important;
    height: 100%;
    display: flex !important;
}
.panels-dock .console-panel .console-resize-handle-left {
    display: none;
}

/* Claude Chat in Dock */
.panels-dock .agc-panel,
.adobe-window-floating .agc-panel {
    position: static !important;
    top: auto !important;
    left: auto !important;
    width: 100% !important;
    max-width: none !important;
    max-height: none !important;
    height: 100% !important;
    border: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    transform: none !important;
    opacity: 1 !important;
    pointer-events: auto !important;
}

/* Remove redundant duplicate inner headers when docked or floating */
.dock-item .rp-head,
.adobe-window-floating .rp-head,
.dock-item .asset-window-header,
.adobe-window-floating .asset-window-header,
.dock-item .output-panel-header,
.adobe-window-floating .output-panel-header {
    display: none !important;
}


/* Lucide stroke for the manager's inline icons (they carry no stroke attrs). */
.dock-icon-btn svg,
.dock-panel-title svg,
.dock-chevron svg {
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}
