/**
 * Split Pane Styles
 * @countermeasure/web-components
 *
 * Resizable split layout with horizontal/vertical orientation.
 */

/* ============================================================================
   SPLIT CONTAINER
   ============================================================================ */
.cmm-split {
  display: flex;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.cmm-split--horizontal {
  flex-direction: row;
}

.cmm-split--vertical {
  flex-direction: column;
}

/* ============================================================================
   SPLIT PANE
   ============================================================================ */
.cmm-split__pane {
  overflow: auto;
  min-width: 0;
  min-height: 0;
}

.cmm-split__pane--collapsed {
  flex: 0 0 0 !important;
  overflow: hidden;
  min-width: 0;
  min-height: 0;
}

/* ============================================================================
   GUTTER (RESIZER)
   ============================================================================ */
.cmm-split__gutter {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: hsl(var(--border));
  transition: background-color var(--transition-fast, 150ms);
  user-select: none;
  touch-action: none;
}

/* Horizontal gutter (vertical divider line) */
.cmm-split--horizontal > .cmm-split__gutter {
  width: 6px;
  cursor: col-resize;
}

/* Vertical gutter (horizontal divider line) */
.cmm-split--vertical > .cmm-split__gutter {
  height: 6px;
  cursor: row-resize;
}

/* Hover state */
.cmm-split__gutter:hover {
  background-color: hsl(var(--info) / 0.4);
}

/* Active / dragging state */
.cmm-split__gutter--active,
.cmm-split__gutter:active {
  background-color: hsl(var(--info) / 0.6);
}

/* Gutter handle indicator (dots/lines) */
.cmm-split__gutter-handle {
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
}

.cmm-split--horizontal > .cmm-split__gutter > .cmm-split__gutter-handle {
  width: 2px;
  height: 24px;
  background-color: hsl(var(--muted-foreground) / 0.4);
}

.cmm-split--vertical > .cmm-split__gutter > .cmm-split__gutter-handle {
  width: 24px;
  height: 2px;
  background-color: hsl(var(--muted-foreground) / 0.4);
}

.cmm-split__gutter:hover > .cmm-split__gutter-handle {
  background-color: hsl(var(--muted-foreground) / 0.7);
}

/* ============================================================================
   DRAGGING STATE (applied to body during resize)
   ============================================================================ */
.cmm-split--dragging {
  cursor: col-resize;
  user-select: none;
}

.cmm-split--dragging.cmm-split--vertical {
  cursor: row-resize;
}

.cmm-split--dragging .cmm-split__pane {
  pointer-events: none;
}

/* ============================================================================
   COLLAPSE TOGGLE
   ============================================================================ */
.cmm-split__collapse-toggle {
  position: absolute;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.25rem;
  height: 1.25rem;
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius-sm);
  background-color: hsl(var(--card));
  color: hsl(var(--muted-foreground));
  cursor: pointer;
  z-index: 1;
  opacity: 0;
  transition: opacity var(--transition-fast, 150ms),
              background-color var(--transition-fast, 150ms),
              color var(--transition-fast, 150ms);
}

.cmm-split__gutter:hover .cmm-split__collapse-toggle,
.cmm-split__collapse-toggle:focus-visible {
  opacity: 1;
}

.cmm-split__collapse-toggle:hover {
  background-color: hsl(var(--accent));
  color: hsl(var(--accent-foreground));
}

.cmm-split__collapse-toggle svg {
  width: 0.75rem;
  height: 0.75rem;
}

/* ============================================================================
   RESPONSIVE
   ============================================================================ */
@media (max-width: 768px) {
  .cmm-split--responsive {
    flex-direction: column;
  }

  .cmm-split--responsive > .cmm-split__gutter {
    width: 100%;
    height: 6px;
    cursor: row-resize;
  }

  .cmm-split--responsive > .cmm-split__gutter > .cmm-split__gutter-handle {
    width: 24px;
    height: 2px;
  }
}
