/**
 * Unified Menu Styles
 *
 * Styles for all menus: header dropdowns, context menus, and floating menus.
 * Uses Floating UI for positioning.
 */

/* ============================================================================
   Base Menu Container
   ============================================================================ */

.floating-menu {
  position: absolute;
  z-index: 1000;
  min-width: 180px;
  max-width: 320px;
  padding: 4px 0;
  background: #ffffff;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  outline: none;

  /* Animation */
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.floating-menu:not(.hidden) {
  opacity: 1;
  transform: translateY(0);
}

.floating-menu.hidden {
  display: none !important;
}

/* Context menu uses fixed positioning */
.floating-menu.context-menu {
  position: fixed;
}

/* ============================================================================
   Menu Items
   ============================================================================ */

.menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  margin: 0 4px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
  color: #1f2937;
  user-select: none;
  outline: none;
  transition: background-color 0.1s ease;
}

.menu-item:hover,
.menu-item.focused {
  background-color: #f3f4f6;
}

.menu-item:active {
  background-color: #e5e7eb;
}

/* Disabled state */
.menu-item[data-disabled="true"] {
  color: #9ca3af;
  cursor: not-allowed;
  pointer-events: none;
}

/* Checked state (for toggle items) */
.menu-item.checked::before {
  content: "\2713"; /* Checkmark */
  display: inline-block;
  width: 16px;
  margin-right: 4px;
  color: #2563eb;
  font-weight: bold;
}

/* ============================================================================
   Menu Item Parts
   ============================================================================ */

.menu-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  font-size: 14px;
  flex-shrink: 0;
}

.menu-label {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.menu-shortcut {
  margin-left: auto;
  padding-left: 16px;
  font-size: 11px;
  color: #6b7280;
  white-space: nowrap;
}

/* ============================================================================
   Separator
   ============================================================================ */

.menu-separator {
  height: 1px;
  margin: 4px 8px;
  background-color: #e5e7eb;
}

/* ============================================================================
   Section Headers
   ============================================================================ */

.menu-section-header {
  padding: 6px 12px 4px;
  font-size: 11px;
  font-weight: 600;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ============================================================================
   Submenus
   ============================================================================ */

.menu-item.has-submenu::after {
  content: "\25B6"; /* Right arrow */
  margin-left: auto;
  font-size: 10px;
  color: #9ca3af;
}

/* ============================================================================
   Context Menu Specific
   ============================================================================ */

#textarea-context-menu {
  min-width: 200px;
  max-height: calc(100vh - 16px);
  overflow-y: auto;
}

/* ============================================================================
   Dark Mode (future)
   ============================================================================ */

@media (prefers-color-scheme: dark) {
  .floating-menu {
    background: #1f2937;
    border-color: #374151;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  }

  .menu-item {
    color: #f3f4f6;
  }

  .menu-item:hover,
  .menu-item.focused {
    background-color: #374151;
  }

  .menu-item:active {
    background-color: #4b5563;
  }

  .menu-item[data-disabled="true"] {
    color: #6b7280;
  }

  .menu-separator {
    background-color: #374151;
  }

  .menu-shortcut {
    color: #9ca3af;
  }
}

/* ============================================================================
   Header Menu Integration
   ============================================================================ */

/* Override for header dropdown menus to work with existing structure */
.menu-bar .floating-menu {
  position: absolute;
  top: 100%;
  left: 0;
}

/* Ensure dropdown buttons show active state */
.menu-bar button.active {
  background-color: #e5e7eb;
}
