/* ================================================================
   sidebar-actions-clean.css
   Reemplaza a final-click-controls.css, final-click-controls-v2.css
   y sidebar-actions-accessibility-final.css. Una sola capa, simple.

   Objetivos:
   - Botones .tr-actions clickables siempre (pointer-events:auto).
   - SVGs internos NO interceptan el click (pointer-events:none).
   - Min 32x32 desktop / 44x44 touch.
   - Visibles al hover de la fila o cuando el sidebar es touch (siempre).
   - Z-index sano (no compite con menús contextuales).
   - Topbar buttons accesibles (sin overlay de glass por encima).
   ================================================================ */

/* Visibles SIEMPRE en touch primary (mobile/iPad), no solo en hover. */
@media (hover: none) and (pointer: coarse) {
  .tree-row .tr-actions { opacity: 1 !important; }
}

/* Botones del sidebar */
.sidebar .tree-row[data-page-id] .tr-actions,
#sidebar .tree-row[data-page-id] .tr-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  pointer-events: auto !important;
  position: relative;
  z-index: 5;
}

.sidebar .tree-row[data-page-id] .tr-actions button,
.sidebar .tree-row[data-page-id] .tr-actions .icon-btn,
#sidebar .tree-row[data-page-id] .tr-actions button,
#sidebar .tree-row[data-page-id] .tr-actions .icon-btn {
  pointer-events: auto !important;
  cursor: pointer;
  position: relative;
  z-index: 6;
  min-width: 26px;
  min-height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--text-2);
  border-radius: 4px;
  padding: 4px;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

/* SVGs e iconos internos NO atrapan el click */
.sidebar .tree-row[data-page-id] .tr-actions button > svg,
.sidebar .tree-row[data-page-id] .tr-actions button > span,
.sidebar .tree-row[data-page-id] .tr-actions .icon-btn > svg,
.sidebar .tree-row[data-page-id] .tr-actions .icon-btn > span {
  pointer-events: none;
}

/* Hover/focus visibles */
.sidebar .tree-row[data-page-id] .tr-actions button:hover,
.sidebar .tree-row[data-page-id] .tr-actions .icon-btn:hover {
  background: color-mix(in srgb, var(--text) 10%, transparent);
  color: var(--text);
}

.sidebar .tree-row[data-page-id] .tr-actions button:focus-visible,
.sidebar .tree-row[data-page-id] .tr-actions .icon-btn:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--text) 50%, transparent);
  outline-offset: 1px;
}

/* Touch sizing — 44x44 */
@media (hover: none) and (pointer: coarse) {
  .sidebar .tree-row[data-page-id] .tr-actions button,
  .sidebar .tree-row[data-page-id] .tr-actions .icon-btn,
  #sidebar .tree-row[data-page-id] .tr-actions button,
  #sidebar .tree-row[data-page-id] .tr-actions .icon-btn {
    min-width: 44px;
    min-height: 44px;
  }
  .sidebar .tree-row[data-page-id] .tr-actions { gap: 4px; padding-right: 6px; }
}

/* Topbar buttons accesibles, mínimo 40x40 en touch */
@media (hover: none) and (pointer: coarse) {
  #tb-share, #tb-comment, #tb-notifications, #tb-updates, #tb-favorite, #tb-more {
    min-width: 40px;
    min-height: 40px;
  }
}

#tb-share, #tb-comment, #tb-notifications, #tb-updates, #tb-favorite, #tb-more {
  pointer-events: auto !important;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

/* Context menu del sidebar (#context-menu) — z-index sano y portal */
#context-menu:not(.hidden) {
  position: fixed;
  z-index: 2147483600;
  pointer-events: auto !important;
  min-width: 220px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 12px 36px rgba(0,0,0,0.18);
  padding: 6px;
}

/* Liquid Glass: el menú contextual también con cristal */
html[data-visual="liquid-glass"] #context-menu:not(.hidden) {
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  -webkit-backdrop-filter: blur(20px) saturate(1.4);
  backdrop-filter: blur(20px) saturate(1.4);
  border: 1px solid color-mix(in srgb, var(--text) 12%, transparent);
}

#context-menu .cx-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
  color: var(--text);
  font-size: 14px;
  min-height: 36px;
  pointer-events: auto;
}

#context-menu .cx-item:hover {
  background: color-mix(in srgb, var(--text) 10%, transparent);
}

#context-menu .cx-item.danger { color: var(--danger, #d33); }
#context-menu .cx-item.danger:hover { background: color-mix(in srgb, var(--danger, #d33) 10%, transparent); }

#context-menu .cx-icon {
  width: 18px; height: 18px;
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

#context-menu .cx-meta {
  margin-left: auto;
  color: var(--text-2);
  font-size: 12px;
  opacity: 0.8;
}

#context-menu .cx-sep {
  height: 1px;
  margin: 4px 6px;
  background: var(--border);
}

/* Sidebar inner: scroll táctil fluido */
.sidebar-inner {
  -webkit-overflow-scrolling: touch;
}

/* Liquid Glass: overlays de glass NO deben tapar el sidebar.
   La sidebar-solid-final.css ya marca isolation. Aquí solo nos aseguramos
   de que ningún ::before/::after de capa superior bloquee pointer events
   sobre los botones reales del sidebar. */
.sidebar::before,
.sidebar::after,
.sidebar-inner::before,
.sidebar-inner::after,
#sidebar::before,
#sidebar::after,
#sidebar .sidebar-inner::before,
#sidebar .sidebar-inner::after {
  pointer-events: none !important;
}
