/**
 * ============================================================================
 * PANEL SYSTEM STYLES - VS Code-style Resizable Layout
 * ============================================================================
 *
 * ARCHITECTURE OVERVIEW:
 * ┌─────────────────────────────────────────────────────────────────────────┐
 * │                        .dashboard-bento (grid)                          │
 * ├─────────────────────────────────────────────────────────────────────────┤
 * │  .bento-chyron-row (header/toolbar)                                     │
 * ├──────────────┬───┬──────────────────────────┬───┬───────────────────────┤
 * │ .collapsible │ R │      .panel-center       │ R │    .collapsible       │
 * │ -panel--left │ E │   (WritingWorkspace)     │ E │    -panel--right      │
 * │              │ S │                          │ S │                       │
 * │ (Timberframe)│ I │  Internal layout:        │ I │   (Publishing)        │
 * │              │ Z │  ┌──────┬──────┬──────┐  │ Z │                       │
 * │  Collapsible │ E │  │Guide │Editor│Preview│ │ E │   Collapsible         │
 * │              │   │  │Panel │      │Panel  │ │   │                       │
 * │  flex: 1     │ H │  └──────┴──────┴──────┘  │ H │   flex: 1             │
 * │  min: 200px  │ A │       flex: 1            │ A │   min: 240px          │
 * │              │ N │       min: 400px         │ N │                       │
 * │              │ D │                          │ D │                       │
 * │              │ L │                          │ L │                       │
 * │              │ E │                          │ E │                       │
 * └──────────────┴───┴──────────────────────────┴───┴───────────────────────┘
 *
 * KEY BEHAVIORS:
 * - All 3 panels flex to fill available space (VS Code style)
 * - 6px gap between panels for visual separation of focus rings
 * - Collapsed panels shrink to 32px icon bar
 * - Resize handles appear between expanded panels
 * - Keyboard: Ctrl+B (left), Ctrl+Shift+B (right), Ctrl+\ (reset)
 *
 * COMPONENTS STYLED:
 * - .panel-container - Main flex container (gap: 6px)
 * - .panel-center - Priority center panel (flex: 1)
 * - .collapsible-panel - Left/right panels (flex: 1, collapsible)
 * - .resize-handle - Draggable dividers (6px width)
 *
 * RELATED FILES:
 * - Pulse/components/layout/PanelContainer.jsx - Orchestrator component
 * - Pulse/components/layout/CollapsiblePanel.jsx - Panel wrapper
 * - Pulse/components/layout/ResizeHandle.jsx - Drag handles
 * - Pulse/components/layout/panelConfig.js - Constraints & config
 * - Pulse/hooks/usePanelSizes.js - State management + localStorage
 * - Pulse/components/writing/editor.css - Center panel internal layout
 */

/* ============================================================================
   PANEL CONTAINER - Main Layout
   ============================================================================ */

.panel-container {
  display: flex;
  flex-direction: row;
  width: 100%;
  height: 100%;
  min-height: 0;
  overflow: hidden;
  gap: 6px; /* 8pt grid - provides visual separation between panel focus rings */
  padding: 0 6px; /* Match gap on outer edges */
}

/* ============================================================================
   CENTER PANEL - Priority Content Area
   ============================================================================ */

.panel-center {
  flex: 1 1 0; /* Allow shrinking below content size */
  min-width: 300px; /* Reduced to allow more space for side panels */
  display: flex;
  flex-direction: column;
  overflow: hidden;

  /* Match sibling panel styling for visual consistency */
  background: rgb(var(--gt-midnight-rgb, 15, 23, 42), var(--opacity-light, 0.8));

  /* Higher opacity (0.5) so accent colors like Mustang GT red are bold, not faded */
  border: 1px solid rgb(var(--gt-focus-blue-rgb, 56, 189, 248), 0.5);
  border-radius: 12px;

  /* Internal padding to match sibling panels */
  padding: 8px;
}

/* Writing Workspace inside center panel - full height, no extra constraints */
.panel-center > .writing-workspace,
.panel-center > .loading-placeholder {
  width: 100%;
  height: 100%;
}

/* Ultrawide: sidebars expand naturally since they flex with no maxWidth constraint */

/* ============================================================================
   COLLAPSIBLE PANEL - Sidebars
   ============================================================================ */

.collapsible-panel {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition:
    width 200ms ease,
    min-width 200ms ease,
    flex 200ms ease;
  background: rgb(var(--gt-midnight-rgb, 15, 23, 42), var(--opacity-light, 0.8));

  /* Higher opacity (0.5) so accent colors like Mustang GT red are bold, not faded */
  border: 1px solid rgb(var(--gt-focus-blue-rgb, 56, 189, 248), 0.5);

  /* Allow flexible growth to fill space - VS Code style */
  flex: 1 1 auto;
}

/* Expanded state */
.collapsible-panel--expanded {
  position: relative;
  flex-direction: row;
}

.collapsible-panel--expanded .collapsible-panel__content {
  flex: 1;
  overflow: auto;
  min-height: 0;
}

/* Left panel styling - full border ring */
.collapsible-panel--left {
  border-radius: 12px;
}

/* Right panel styling - full border ring */
.collapsible-panel--right {
  border-radius: 12px;
}

/* Collapsed state - slim bar, no flex grow */
.collapsible-panel--collapsed {
  flex: 0 0 auto !important; /* Override flex grow when collapsed */
  background: rgb(var(--gt-midnight-rgb, 15, 23, 42), 0.95);
  align-items: center;
  justify-content: center;
}

/* ============================================================================
   RESIZE HANDLE - VS Code-style draggable divider
   ============================================================================ */

.collapsible-panel__resize-handle {
  position: relative;
  width: 6px;
  min-width: 6px;
  height: 100%;
  cursor: col-resize;
  flex-shrink: 0;
  z-index: 10;
  transition: background-color 0.1s ease;
}

/* Left panel: handle on RIGHT edge */
.collapsible-panel--left .collapsible-panel__resize-handle {
  order: 2; /* After content */
}

/* Right panel: handle on LEFT edge */
.collapsible-panel--right .collapsible-panel__resize-handle {
  order: -1; /* Before content */
}

/* Visual line in the center of the handle */
.collapsible-panel__resize-line {
  position: absolute;
  left: 50%;
  top: 0;
  bottom: 0;
  width: 1px;
  transform: translateX(-50%);
  background: var(--color-border-primary, #475569);
  transition: background-color 0.15s ease, opacity 0.15s ease;
  opacity: 0;
}

/* Hover state - show the line */
.collapsible-panel__resize-handle:hover {
  background: var(--color-bg-tertiary, rgba(255, 255, 255, 0.05));
}

.collapsible-panel__resize-handle:hover .collapsible-panel__resize-line {
  opacity: 1;
  background: var(--color-accent-primary, #3b82f6);
}

/* Active/dragging state */
.collapsible-panel__resize-handle:active,
body.resizing-horizontal .collapsible-panel__resize-handle {
  background: var(--color-bg-tertiary, rgba(255, 255, 255, 0.08));
}

.collapsible-panel__resize-handle:active .collapsible-panel__resize-line,
body.resizing-horizontal .collapsible-panel__resize-handle .collapsible-panel__resize-line {
  opacity: 1;
  background: var(--color-accent-primary, #3b82f6);
  box-shadow: 0 0 4px var(--color-accent-primary, #3b82f6);
}

/* Focus ring for accessibility */
.collapsible-panel__resize-handle:focus-visible {
  outline: 2px solid var(--color-accent-primary, #3b82f6);
  outline-offset: -2px;
}

.collapsible-panel__resize-handle:focus-visible .collapsible-panel__resize-line {
  opacity: 1;
}

.resize-handle__dots {
  color: var(--color-text-tertiary, #64748b);
  font-size: 14px;
  font-weight: bold;
  line-height: 1;
}

/* Focus state for keyboard accessibility */
.resize-handle:focus-visible {
  outline: 2px solid var(--color-accent-primary, #3b82f6);
  outline-offset: -2px;
  background: rgb(var(--gt-focus-blue-rgb, 56, 189, 248), 0.2);
}

/* ============================================================================
   RESPONSIVE BREAKPOINTS
   ============================================================================ */

/* Medium screens - suggest collapse */
@media (width <= 1440px) {
  .panel-container[data-auto-collapse='true']
    .collapsible-panel--right:not(.collapsible-panel--collapsed) {
    opacity: 0.9;
  }
}

/* Smaller screens - enforce collapse */
@media (width <= 1280px) {
  .panel-center {
    min-width: 250px;
  }
}

/* Mobile - stack layout not resize */
@media (width <= 768px) {
  .panel-container {
    flex-direction: column;
  }

  .panel-center {
    min-width: 100%;
  }

  .collapsible-panel--collapsed {
    width: 100% !important;
    min-width: 100% !important;
    flex-direction: row;
    height: 40px;
    padding: 0 8px;
  }

  .collapsible-panel--left,
  .collapsible-panel--right {
    border-radius: 0;
  }

  .resize-handle {
    display: none;
  }
}
