/* =========================================================================
   Prompt Studio — Editor Workspace Styles (Stage 38.3)
   Adaptive Preview Monitor Layout & Tool Bands
   Scoped strictly under #view-editor and #playerMountEditor inside @layer.
   ========================================================================= */

@layer editor-workspace {
  /* 1. Responsive Viewport Optimization (< 900px vertical height budget) */
  @media (max-height: 899px) {
    #view-editor:has(#editorContent:not([hidden])) .ed-capcut-header,
    #view-editor.view-capcut:has(#editorContent:not([hidden])) .ed-capcut-header {
      display: none !important;
    }
    #view-editor.view-capcut:not([hidden]),
    #view-editor:not([hidden]) {
      padding-top: 4px !important;
      padding-bottom: 4px !important;
    }
    #view-editor.view-capcut:not([hidden]) #editorContent,
    #view-editor:not([hidden]) #editorContent {
      height: calc(100vh - 62px) !important;
    }
  }

  /* 2. Monitor Box Full-Width & Elimination of Decorative Clutter */
  #playerBlock[data-mount="editor"] {
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    box-shadow: none;
    background: #07080c;
  }

  #playerBlock[data-mount="editor"] .player-stage {
    padding: 0;
    margin: 0;
    background: #050608;
    position: relative;
    overflow: hidden;
  }

  /* 3. Dual-Mode Tool Bands (Top Bar vs Side Rail) */
  .ed-monitor-top-band {
    display: none;
    height: 34px;
    align-items: center;
    justify-content: space-between;
    padding: 0 10px;
    background: rgba(14, 16, 22, 0.95);
    border-bottom: 1px solid rgba(255, 255, 255, 0.07);
    z-index: 5;
    flex-shrink: 0;
  }

  .ed-monitor-side-rail {
    display: none;
    position: absolute;
    left: 10px;
    top: 10px;
    z-index: 10;
    flex-direction: column;
    gap: 6px;
    background: rgba(14, 16, 22, 0.88);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 8px;
    padding: 5px;
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
  }

  .ed-monitor-info-chip {
    display: none;
    position: absolute;
    right: 10px;
    top: 10px;
    z-index: 10;
    flex-direction: column;
    gap: 3px;
    background: rgba(14, 16, 22, 0.88);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 8px;
    padding: 6px 10px;
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
    pointer-events: none;
    user-select: none;
  }

  /* data-band="top" state: top bar active, side rail hidden */
  #playerBlock[data-mount="editor"][data-band="top"] .ed-monitor-top-band {
    display: flex;
  }

  #playerBlock[data-mount="editor"][data-band="top"] .ed-monitor-side-rail {
    display: none;
  }

  #playerBlock[data-mount="editor"][data-band="top"] .ed-monitor-info-chip {
    display: none;
  }

  /* data-band="side" state: NO top bar! Full vertical space for video */
  #playerBlock[data-mount="editor"][data-band="side"] .ed-monitor-top-band {
    display: none;
  }

  #playerBlock[data-mount="editor"][data-band="side"] .ed-monitor-side-rail {
    display: flex;
  }

  #playerBlock[data-mount="editor"][data-band="side"] .ed-monitor-info-chip {
    display: flex;
  }

  /* 4. Tool Controls & Popover Menus */
  .ed-band-group {
    display: flex;
    align-items: center;
    gap: 6px;
  }

  .ed-band-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 26px;
    padding: 0 8px;
    font-size: 12px;
    font-weight: 500;
    color: #c9ccd6;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.10);
    border-radius: 5px;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
    user-select: none;
  }

  .ed-band-btn:hover {
    background: rgba(255, 255, 255, 0.12);
    color: #ffffff;
    border-color: rgba(255, 255, 255, 0.22);
  }

  .ed-band-btn.is-active,
  .ed-band-btn[aria-pressed="true"] {
    background: rgba(0, 229, 255, 0.18);
    color: #00e5ff;
    border-color: rgba(0, 229, 255, 0.45);
  }

  .ed-band-btn-icon {
    width: 26px;
    padding: 0;
  }

  .ed-band-btn-icon svg {
    width: 14px;
    height: 14px;
    stroke: currentColor;
  }

  /* Popovers */
  .ed-popover-menu {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    z-index: 30;
    background: #0f1118;
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 8px;
    padding: 8px 10px;
    box-shadow: 0 12px 36px rgba(0, 0, 0, 0.75);
    min-width: 190px;
    display: flex;
    flex-direction: column;
    gap: 6px;
  }

  .ed-popover-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: #d1d5db;
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 4px;
    user-select: none;
    transition: background 0.12s;
  }

  .ed-popover-item:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #ffffff;
  }

  .ed-popover-item input[type="checkbox"] {
    accent-color: #00e5ff;
    cursor: pointer;
  }

  /* 5. Ghost Preview (in Fill Mode) */
  .ed-ghost-box {
    position: absolute;
    pointer-events: none;
    z-index: 1;
    border: 1px dashed rgba(0, 229, 255, 0.50);
    border-radius: 4px;
    box-sizing: border-box;
    overflow: hidden;
  }

  .ed-ghost-canvas {
    width: 100%;
    height: 100%;
    opacity: 0.25;
    display: block;
    object-fit: fill;
  }

  .ed-ghost-label {
    position: absolute;
    bottom: 4px;
    left: 6px;
    font-family: monospace;
    font-size: 10px;
    color: #00e5ff;
    background: rgba(0, 0, 0, 0.75);
    padding: 2px 6px;
    border-radius: 3px;
    letter-spacing: 0.05em;
  }

  /* 6. Vertical Safe Zones (TikTok/Reels/Shorts UI Clutter) */
  .ed-safe-vertical {
    position: absolute;
    inset: 0;
    pointer-events: none;
  }

  .ed-safe-vert-top {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 12%;
    border-bottom: 1px dashed rgba(244, 63, 94, 0.75);
    background: rgba(244, 63, 94, 0.08);
  }

  .ed-safe-vert-bottom {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 22%;
    border-top: 1px dashed rgba(244, 63, 94, 0.75);
    background: rgba(244, 63, 94, 0.08);
  }

  .ed-safe-vert-right {
    position: absolute;
    top: 12%;
    bottom: 22%;
    right: 0;
    width: 16%;
    border-left: 1px dashed rgba(244, 63, 94, 0.75);
    background: rgba(244, 63, 94, 0.08);
  }

  .ed-safe-vert-label {
    position: absolute;
    font-size: 9px;
    font-family: monospace;
    color: #fda4af;
    background: rgba(0, 0, 0, 0.75);
    padding: 1px 4px;
    border-radius: 2px;
    line-height: 1.2;
  }

  /* 7. Clean View Mode */
  #playerBlock[data-mount="editor"].is-clean-view .ed-monitor-top-band,
  #playerBlock[data-mount="editor"].is-clean-view .ed-monitor-side-rail,
  #playerBlock[data-mount="editor"].is-clean-view .ed-monitor-info-chip,
  #playerBlock[data-mount="editor"].is-clean-view .ed-monitor-guides,
  #playerBlock[data-mount="editor"].is-clean-view .ed-compare-overlay,
  #playerBlock[data-mount="editor"].is-clean-view .ed-ghost-box {
    display: none !important;
  }

  /* Clean view button active state */
  .ed-btn-clean-active {
    background: rgba(0, 229, 255, 0.25) !important;
    color: #00e5ff !important;
  }

  /* 8. Inspector Canvas Tab Clean separation */
  .ed-inspector .ed-canvas-current-label {
    font-size: 12px;
    font-family: monospace;
    color: #00e5ff;
    padding: 4px 8px;
    background: rgba(0, 229, 255, 0.08);
    border-radius: 4px;
    display: inline-block;
    margin-bottom: 6px;
  }
}
