/**
 * @component Workspace Viewer Pane
 * @description Collapsible viewer/editor pane for files. Same pattern as
 *   ws-ai-pane and ws-worktree-pane. Sits between worktree and module content.
 * @category Layouts
 * @darkmode true
 */

/* ============================================================
   Viewer pane flex item
   ============================================================ */

.ws-viewer-pane {
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
}

#ws-viewer-resizer {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  z-index: 1;
}

/* Initial hidden state for viewer sub-panes (toggled by JS) */
.ws-viewer-monaco,
.ws-viewer-preview,
.ws-viewer-media {
  display: none;
}

#ws-viewer-sidebar {
  position: relative;
  height: 100%;
  width: 480px;
  background: var(--bg-secondary, #161b22);
  border-right: 1px solid var(--border-default, #30363d);
  overflow: hidden;
  transition: width 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

#ws-viewer-sidebar.collapsed {
  width: 40px;
  overflow: hidden;
}

/* Short label shown when collapsed; full label shown when expanded */
#ws-viewer-sidebar .stx-shell-sidebar__title-full {
  display: none;
}

#ws-viewer-sidebar:not(.collapsed) .stx-shell-sidebar__title-full {
  display: inline;
}

#ws-viewer-sidebar:not(.collapsed) .stx-shell-sidebar__title {
  display: none;
}

/* Mode toggle embedded in title */
.ws-viewer-mode-toggle-title {
  cursor: pointer;
  transition: color 0.15s ease;
}

.ws-viewer-mode-toggle-title:hover {
  color: var(--text-primary, #d4e1e8);
}

/* Hide header actions when collapsed */
#ws-viewer-sidebar.collapsed .ws-viewer-header-actions {
  display: none;
}

/* ============================================================
   Viewer header — left-aligned tabs
   ============================================================ */

#ws-viewer-sidebar:not(.collapsed) .stx-shell-sidebar__header {
  justify-content: flex-start;
  gap: 0;
}

.ws-viewer-header-actions {
  flex: 1;
  display: flex;
  align-items: center;
  min-width: 0;
}

/* ============================================================
   Current file label (inside header)
   ============================================================ */

.ws-viewer-tabs {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  min-width: 0;
  margin-left: 8px;
}

.ws-viewer-current-file {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary, #d4e1e8);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ws-viewer-file-close {
  font-size: 0.75rem;
  opacity: 0.4;
  padding: 0 2px;
  line-height: 1;
  color: var(--text-muted, #8b949e);
  cursor: pointer;
  transition: opacity 0.15s;
  flex-shrink: 0;
}

.ws-viewer-file-close:hover {
  opacity: 1;
  color: var(--danger-color, #f85149);
}

/* ============================================================
   Keyboard shortcuts button
   ============================================================ */

.ws-viewer-shortcuts-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: var(--text-muted, #8b949e);
  font-size: 13px;
  cursor: pointer;
  padding: 4px;
  margin-left: 4px;
  flex-shrink: 0;
  opacity: 0.6;
  transition: opacity 0.15s ease;
}

.ws-viewer-shortcuts-btn:hover {
  opacity: 1;
  color: var(--text-primary, #d4e1e8);
}

/* ============================================================
   Viewer content area
   ============================================================ */

.ws-viewer-body {
  display: flex;
  flex-direction: column;
  height: calc(100% - 36px); /* minus header */
  overflow: hidden;
}

.ws-viewer-content {
  flex: 1;
  position: relative;
  overflow: hidden;
  display: flex;
}

.ws-viewer-monaco {
  width: 100%;
  height: 100%;
}

.ws-viewer-media {
  width: 100%;
  height: 100%;
  overflow: auto;
}

/* Empty state */
.ws-viewer-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  gap: 0.5rem;
  color: var(--text-muted, #8b949e);
  font-size: 0.85rem;
}

.ws-viewer-empty i {
  font-size: 1.5rem;
  opacity: 0.5;
}

/* ============================================================
   Formats info button + tooltip
   ============================================================ */

.ws-viewer-formats-info-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: var(--text-muted, #8b949e);
  font-size: 13px;
  cursor: help;
  padding: 4px;
  margin-left: 4px;
  flex-shrink: 0;
  opacity: 0.6;
  transition: opacity 0.15s ease;
  position: relative;
}

.ws-viewer-formats-info-btn:hover {
  opacity: 1;
  color: var(--text-primary, #d4e1e8);
}

.ws-viewer-formats-info-btn[data-tooltip]:hover::after {
  content: attr(data-tooltip);
  position: absolute;
  top: 100%;
  right: 0;
  z-index: 1000;
  padding: 8px 12px;
  background: var(--bg-secondary, #161b22);
  color: var(--text-primary, #d4e1e8);
  border: 1px solid var(--border-default, #30363d);
  border-radius: 6px;
  font-size: 11px;
  font-family: "JetBrains Mono", monospace;
  white-space: pre-line;
  line-height: 1.6;
  min-width: 280px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  pointer-events: none;
}

/* ============================================================
   Responsive: mobile pane switching handled by mobile.css
   (Previously hid viewer with display:none — removed because
    mobile-swipe.ts now manages pane visibility via .mobile-active)
   ============================================================ */
