/* ==========================================================================
   SHARED WIDGET POPUP COMPONENT

   JS-positioned fixed popup with hover/touch activation. Used by the vector
   widget, portfolio heatmap, and info tooltips.

   Usage:
     1. Add class `has-popup` to the trigger element
     2. Inside the trigger, place a .widget-popup element with a direction modifier:
          .widget-popup--top    (popup appears above the trigger)
          .widget-popup--bottom (popup appears below the trigger)
          .widget-popup--left   (popup appears to the left of the trigger)
          .widget-popup--right  (popup appears to the right of the trigger)
     3. Add .widget-popup--compact for small inline tooltips (e.g. info icons)
     4. Popup shows on :hover or when the trigger has class .active (touch/tap)
     5. JS in app.js positions the popup as position:fixed on mouseenter so it
        always renders on top, even inside overflow:hidden containers.
   ========================================================================== */

/* --- Trigger base --- */
.has-popup {
  position: relative;
}

/* --- Base --- */
.widget-popup {
  position: fixed;
  top: -9999px;
  left: -9999px;
  min-width: min(260px, calc(100vw - 32px));
  max-width: min(300px, calc(100vw - 32px));
  background: linear-gradient(135deg, #1e2545 0%, #2a3153 100%);
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.1);
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms ease;
  z-index: 9999;
  backdrop-filter: blur(10px);
  text-align: left;
  cursor: default;
}

/* --- Show when JS adds .is-visible (popup is appended to document.body) --- */
.widget-popup.is-visible {
  opacity: 1;
  pointer-events: auto;
}

/* --- Direction modifier classes are read by JS to determine placement --- */
/* .widget-popup--top | --bottom | --left | --right */

/* ==========================================================================
   POPUP CONTENT STRUCTURE
   ========================================================================== */

.widget-popup-header {
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  padding-bottom: 12px;
  margin-bottom: 12px;
}

.widget-popup-title {
  font-size: var(--text-base);
  font-weight: bold;
  display: block;
  margin-bottom: 4px;
  color: #fff;
}

.widget-popup-subtitle {
  font-size: var(--text-xs);
  color: var(--color-on-dark-secondary, rgba(255, 255, 255, 0.7));
  display: block;
}

.widget-popup-body {
  font-size: var(--text-sm);
  line-height: 1.6;
  color: #fff;
}

.widget-popup-section {
  margin-bottom: 12px;
}

.widget-popup-section:last-child {
  margin-bottom: 0;
}

.widget-popup-label {
  font-size: var(--text-xs);
  color: var(--color-on-dark-muted, rgba(255, 255, 255, 0.6));
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
}

.widget-popup-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.widget-popup-list li {
  padding-left: 16px;
  position: relative;
  margin-bottom: 4px;
  color: rgba(255, 255, 255, 0.9);
}

.widget-popup-list li::before {
  content: "•";
  position: absolute;
  left: 0;
  color: #4cd7a5;
}

.widget-popup-insight {
  background: rgba(76, 215, 165, 0.1);
  border-left: 3px solid #4cd7a5;
  padding: 8px 12px;
  border-radius: 4px;
  font-size: var(--text-xs);
  margin-top: 10px;
}

.widget-popup-insight::before {
  content: "💡 ";
}

.widget-popup-warning {
  background: rgba(255, 171, 0, 0.1);
  border-left: 3px solid #FFAB00;
  color: #FFAB00;
}

.widget-popup-warning::before {
  content: "⚠️ ";
}

.widget-popup-more {
  font-size: var(--text-xs);
  color: rgba(255, 255, 255, 0.5);
  font-style: italic;
  margin-top: 0.5rem;
  padding-left: 1rem;
}

/* Key-value rows — used by the heatmap cell popup */
.widget-popup-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
  font-size: var(--text-sm);
}

.widget-popup-row:last-child {
  margin-bottom: 0;
}

.widget-popup-row-label {
  color: rgba(255, 255, 255, 0.65);
}

.widget-popup-row-value {
  color: #fff;
  font-weight: 600;
  text-align: right;
  margin-left: 1rem;
}

.widget-popup-row-value.positive {
  color: var(--color-positive, #36E0A0);
}

.widget-popup-row-value.negative {
  color: var(--color-negative, #EF4444);
}

/* --- Compact modifier: smaller tooltip style for inline info icons --- */
.widget-popup--compact {
  min-width: min(200px, calc(100vw - 32px));
  max-width: min(260px, calc(100vw - 32px));
  padding: 10px 12px;
  border-radius: 8px;
  font-size: var(--text-xs);
  font-weight: 400;
  line-height: 1.45;
  color: rgba(255, 255, 255, 0.9);
}

.widget-popup--compact .widget-popup-body {
  font-size: var(--text-xs);
  line-height: 1.45;
  color: rgba(255, 255, 255, 0.9);
}

/* --- Info-tip trigger: inline icon that opens a compact tooltip --- */
.info-tip {
  display: inline-flex;
  align-items: center;
  cursor: help;
  color: var(--bs-secondary);
  font-size: var(--text-xs);
  margin-left: 0.35rem;
  vertical-align: middle;
}
