/**
 * Universal Context Menu for Account Dashboard
 * Right-click context menu system for jobs, invoices, customers, etc.
 */

/* ============================================
   CONTEXT MENU CONTAINER
   ============================================ */
.context-menu {
  position: fixed;
  z-index: 99999;
  min-width: 180px;
  max-width: 280px;
  background: rgba(26, 26, 46, 0.98);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5),
              0 0 0 1px rgba(255, 255, 255, 0.05);
  padding: 6px 0;
  opacity: 0;
  visibility: hidden;
  transform: scale(0.95) translateY(-5px);
  transform-origin: top left;
  transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s ease;
  overflow: hidden;
}

.context-menu.visible {
  opacity: 1;
  visibility: visible;
  transform: scale(1) translateY(0);
}

/* Adjust origin when menu opens from right side */
.context-menu.origin-right {
  transform-origin: top right;
}

.context-menu.origin-bottom {
  transform-origin: bottom left;
}

.context-menu.origin-bottom-right {
  transform-origin: bottom right;
}

/* ============================================
   MENU HEADER (Optional)
   ============================================ */
.context-menu-header {
  padding: 10px 14px 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  margin-bottom: 4px;
}

.context-menu-header .title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: rgba(255, 255, 255, 0.4);
}

.context-menu-header .subtitle {
  font-size: 13px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.9);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ============================================
   MENU ITEMS
   ============================================ */
.context-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  color: rgba(255, 255, 255, 0.9);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.1s ease;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}

.context-menu-item:hover {
  background: rgba(255, 255, 255, 0.08);
}

.context-menu-item:active {
  background: rgba(255, 255, 255, 0.12);
}

.context-menu-item svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  opacity: 0.7;
}

.context-menu-item:hover svg {
  opacity: 1;
}

.context-menu-item .shortcut {
  margin-left: auto;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.35);
  font-weight: 400;
}

/* ============================================
   MENU ITEM VARIANTS
   ============================================ */

/* Primary action (gold) */
.context-menu-item.primary {
  color: #f9cb00;
}

.context-menu-item.primary svg {
  color: #f9cb00;
}

/* Success action (green) */
.context-menu-item.success {
  color: #22c55e;
}

.context-menu-item.success svg {
  color: #22c55e;
}

/* Warning action (orange) */
.context-menu-item.warning {
  color: #f59e0b;
}

.context-menu-item.warning svg {
  color: #f59e0b;
}

/* Danger action (red) */
.context-menu-item.danger {
  color: #ef4444;
}

.context-menu-item.danger svg {
  color: #ef4444;
}

.context-menu-item.danger:hover {
  background: rgba(239, 68, 68, 0.15);
}

/* Disabled state */
.context-menu-item.disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

/* ============================================
   MENU DIVIDER
   ============================================ */
.context-menu-divider {
  height: 1px;
  background: rgba(255, 255, 255, 0.08);
  margin: 6px 0;
}

/* ============================================
   SUBMENU INDICATOR
   ============================================ */
.context-menu-item.has-submenu::after {
  content: '';
  margin-left: auto;
  width: 0;
  height: 0;
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  border-left: 5px solid rgba(255, 255, 255, 0.4);
}

/* ============================================
   STATUS SUBMENU
   ============================================ */
.context-submenu {
  position: absolute;
  left: 100%;
  top: 0;
  min-width: 160px;
  background: rgba(26, 26, 46, 0.98);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
  padding: 6px 0;
  opacity: 0;
  visibility: hidden;
  transform: translateX(-10px);
  transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s ease;
}

.context-menu-item:hover .context-submenu {
  opacity: 1;
  visibility: visible;
  transform: translateX(4px);
}

/* ============================================
   STATUS INDICATORS
   ============================================ */
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.status-dot.new { background: #f59e0b; }
.status-dot.reviewing { background: #f59e0b; }
.status-dot.material_ordered { background: #06b6d4; }
.status-dot.material_received { background: #06b6d4; }
.status-dot.assigned { background: #3b82f6; }
.status-dot.scheduled { background: #3b82f6; }
.status-dot.measured { background: #8b5cf6; }
.status-dot.in_production { background: #8b5cf6; }
.status-dot.ready { background: #10b981; }
.status-dot.installing { background: #10b981; }
.status-dot.completed { background: #22c55e; }
.status-dot.on_hold { background: #6b7280; }
.status-dot.cancelled { background: #ef4444; }
.status-dot.archived { background: #4b5563; }

/* Invoice statuses */
.status-dot.draft { background: #6b7280; }
.status-dot.sent { background: #3b82f6; }
.status-dot.open { background: #3b82f6; }
.status-dot.paid { background: #22c55e; }
.status-dot.void { background: #ef4444; }
.status-dot.overdue { background: #ef4444; }

/* Lead statuses */
.status-dot.contacted { background: #3b82f6; }
.status-dot.qualified { background: #8b5cf6; }
.status-dot.quoted { background: #06b6d4; }
.status-dot.won { background: #22c55e; }
.status-dot.lost { background: #ef4444; }

/* ============================================
   CONTEXT MENU OVERLAY (for mobile)
   ============================================ */
.context-menu-overlay {
  position: fixed;
  inset: 0;
  z-index: 99998;
  background: transparent;
}

/* ============================================
   ANIMATIONS
   ============================================ */
@keyframes contextMenuIn {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* ============================================
   TOUCH DEVICE ADJUSTMENTS
   ============================================ */
@media (pointer: coarse) {
  .context-menu-item {
    padding: 14px 16px;
    font-size: 15px;
  }

  .context-menu {
    min-width: 220px;
  }
}

/* ============================================
   HIGHLIGHT ROW ON RIGHT-CLICK
   ============================================ */
[data-context-menu].context-active {
  background: rgba(249, 203, 0, 0.08) !important;
  outline: 1px solid rgba(249, 203, 0, 0.2);
  outline-offset: -1px;
}
