/* ==========================================================================
   Atelier S3-02 · Chrome Desktop Podado (Tabla §2.2 del informe)
   Superficies permanentes sobre el lienzo: ≤ 3 (Barra superior, Dock ≤ 7, HUD zoom/minimapa).
   ========================================================================== */

@layer components {
  /* #1: Toggle de idioma y fila de idioma fuera del chrome principal (vive en Cmd+K y Ajustes) */
  body[data-chrome="pruned"] #btn-lang-toggle,
  body[data-chrome="pruned"] .command-lang-row {
    display: none !important;
  }

  /* #2, #3, #4, #5, #6: La barra HUD de estudio y las coordenadas del minimapa desaparecen */
  body[data-chrome="pruned"] #studio-hud-bar,
  body[data-chrome="pruned"] #minimap-coords {
    display: none !important;
  }

  /* #6: Punto discreto de estado de sync junto al navegador espacial */
  .topbar-sync-dot {
    width: 7px;
    height: 7px;
    border-radius: 9999px;
    background: #10b981;
    display: inline-block;
    flex-shrink: 0;
    margin-left: 4px;
    box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.18);
  }

  /* #15 (flag): Ocultar Limpiar de la barra superior (sigue en Archivo y Cmd+K) */
  body[data-chrome="pruned"][data-flag-hide-clear="true"] #btn-clear {
    display: none !important;
  }

  /* #16: Consolidar Vista y Exportar en menú único + botón Exportar directo + Cmd+K */
  body[data-chrome="pruned"] #btn-view-menu,
  body[data-chrome="pruned"] #btn-export-menu {
    display: none !important;
  }

  .topbar-pruned-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    height: 30px;
    padding: 0 10px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--ui-surface-border);
    background: var(--ui-surface);
    color: var(--text-primary);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: background 120ms ease, border-color 120ms ease;
  }
  .topbar-pruned-btn:hover {
    background: var(--ui-surface-hover);
    border-color: var(--accent-primary);
  }
  .topbar-pruned-btn.active {
    background: var(--accent-tint);
    border-color: var(--accent-primary);
    color: var(--accent-primary);
  }
  .topbar-pruned-btn svg {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
  }

  /* #8, #9, #10, #11, #12: Poda del dock a ≤ 7 herramientas primarias */
  body[data-chrome="pruned"][data-flag-presentation="true"] #tool-dock .tool-btn[data-tool="nada"],
  body[data-chrome="pruned"] #tool-dock .tool-btn[data-tool="lasso"],
  body[data-chrome="pruned"] #tool-dock .tool-btn[data-tool="laser"],
  body[data-chrome="pruned"] #tool-dock .tool-btn[data-tool="marker"],
  body[data-chrome="pruned"] #tool-dock .tool-btn[data-tool="ellipse"],
  body[data-chrome="pruned"] #tool-dock .tool-btn[data-tool="diamond"],
  body[data-chrome="pruned"] #tool-dock .tool-btn[data-tool="text"],
  body[data-chrome="pruned"] #select-mode-subtray {
    display: none !important;
  }

  /* Indicador de flyout en herramientas con variantes (Pluma, Formas, Nota/Texto) */
  body[data-chrome="pruned"] #tool-dock .tool-btn.has-flyout {
    position: relative;
  }
  body[data-chrome="pruned"] #tool-dock .tool-btn.has-flyout::after {
    content: "";
    position: absolute;
    right: 4px;
    bottom: 4px;
    width: 0;
    height: 0;
    border-left: 3.5px solid transparent;
    border-right: 3.5px solid transparent;
    border-top: 4px solid currentColor;
    opacity: 0.55;
    pointer-events: none;
  }

  /* Flyout popover compacto sobre el dock */
  .dock-flyout {
    position: fixed;
    z-index: 950;
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 156px;
    padding: 5px;
    border-radius: var(--radius-md);
    border: 1px solid var(--ui-surface-border);
    background: var(--ui-surface);
    box-shadow: var(--ui-shadow-float);
    backdrop-filter: blur(14px);
  }
  .dock-flyout.hidden {
    display: none !important;
  }
  .dock-flyout-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 6px 9px;
    border: none;
    border-radius: var(--radius-xs);
    background: transparent;
    color: var(--text-primary);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    text-align: left;
  }
  .dock-flyout-item:hover,
  .dock-flyout-item.active {
    background: var(--accent-tint);
    color: var(--accent-primary);
  }
  .dock-flyout-item kbd {
    font-family: var(--font-mono);
    font-size: 10px;
    opacity: 0.65;
  }

  /* #7: Control único de zoom (%) + menú popover y minimapa colapsable */
  body[data-chrome="pruned"] #btn-zoom-out,
  body[data-chrome="pruned"] #btn-zoom-in,
  body[data-chrome="pruned"] #btn-zoom-fit {
    display: none !important;
  }
  body[data-chrome="pruned"] .spatial-hud {
    gap: 6px;
    padding: 6px;
  }
  body[data-chrome="pruned"] .spatial-hud.minimap-collapsed #minimap-container {
    display: none !important;
  }
  .minimap-toggle-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border: none;
    border-radius: var(--radius-xs);
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
  }
  .minimap-toggle-btn:hover {
    background: var(--accent-tint);
    color: var(--accent-primary);
  }

  /* #17 + #12: Inspector derecho anclado, contextual (oculto sin selección), sin pestañas ni "shapes" */
  body[data-chrome="pruned"] #inspector-panel {
    position: fixed !important;
    top: 62px !important;
    right: 12px !important;
    left: auto !important;
    bottom: 16px !important;
    width: 256px !important;
    max-height: calc(100vh - 78px);
    overflow-y: auto;
    border-radius: var(--radius-md);
  }
  body[data-chrome="pruned"][data-has-selection="false"] #inspector-panel:not(.force-open) {
    display: none !important;
  }
  body[data-chrome="pruned"] .inspector-tabs,
  body[data-chrome="pruned"] [data-insp-tab="shapes"],
  body[data-chrome="pruned"] [data-insp-panel="shapes"] {
    display: none !important;
  }
  body[data-chrome="pruned"] [data-insp-panel="style"],
  body[data-chrome="pruned"] [data-insp-panel="entity"] {
    display: block !important;
  }

  /* #13 + #14: HUD de selección podado a 5 acciones primarias */
  body[data-chrome="pruned"] #selection-hud .hud-action-btn[data-pruned-secondary="true"] {
    display: none !important;
  }
  body[data-chrome="pruned"][data-flag-merge="false"] [data-action="merge"],
  body[data-chrome="pruned"][data-flag-merge="false"] #btn-hud-merge {
    display: none !important;
  }

  /* #8: Modo presentación (oculta el chrome sobre el lienzo y activa láser) */
  body[data-presentation="true"] .top-bar,
  body[data-presentation="true"] #tool-dock,
  body[data-presentation="true"] .spatial-hud,
  body[data-presentation="true"] #inspector-panel,
  body[data-presentation="true"] #selection-hud {
    display: none !important;
  }
  .presentation-exit-pill {
    position: fixed;
    bottom: 18px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1200;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 7px 14px;
    border-radius: var(--radius-pill);
    border: 1px solid var(--ui-surface-border);
    background: var(--ui-surface);
    color: var(--text-primary);
    font-size: 12px;
    font-weight: 500;
    box-shadow: var(--ui-shadow-float);
    cursor: pointer;
  }
  .presentation-exit-pill.hidden {
    display: none !important;
  }

  /* Accesibilidad: foco visible claro en todos los controles del chrome */
  body[data-chrome="pruned"] button:focus-visible,
  body[data-chrome="pruned"] [role="menuitem"]:focus-visible {
    outline: 2px solid var(--accent-primary);
    outline-offset: 2px;
  }
}
