/* detail.css */

/* =========================
   Header layout
   ========================= */
.detail-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
  margin-top: 20px;
  margin-bottom: 20px;
}
.detail-header-general {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
  margin-top: 20px;
}
.detail-header-left h2 { margin: 0 0 4px 0; }
.detail-header-left .meta { font-size: 12px; color: var(--muted); }

.detail-section .section-header {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  position: relative;
}
.detail-section .meta { font-size: 12px; color: var(--muted); }

/* =========================
   Percent labels above stacked bar
   ========================= */
.bar-percentages {
  display: flex;
  width: 100%;
  margin-bottom: 4px;
}
.bar-percentages .pct {
  text-align: center;
}
.bar-percentages .pct span {
  display: block;
  font-size: 10px;
  line-height: 1;
  color: #ffffff;
  opacity: 0;
  transition: opacity 0.3s ease;
}
.bar-percentages.show-labels .pct span {
  opacity: 0.95;
}

/* =========================
   Rectangular stacked bar
   ========================= */
.stacked-bar {
  display: flex;
  width: 100%;
  height: 15px;
  overflow: hidden;
  background: rgba(255,255,255,0.06);
  box-shadow: inset 0 0 3px rgba(0,0,0,0.3);
  border: none;
  border-radius: 0;
}
.stacked-bar--compact { margin-bottom: 10px; }

.stacked-bar .seg { height: 100%; }
.seg-green { background: #1f7a34; }
.seg-gray  { background: #e6eaef; }
.seg-red   { background: #b91c1c; }

/* =========================
   Chip row layout
   ========================= */
.detail-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
  position: relative;
}
.detail-chip-row .conviction-label,
.detail-chip-row .perf-link {
  display: inline-flex;
  justify-content: center;
  align-items: center;
}

/* Conviction cluster */
.conviction-wrap {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  position: relative;
}

/* =========================
   Info button + popover
   ========================= */
.info-btn {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.6);
  background: transparent;
  color: #fff;
  font-size: 12px;
  line-height: 18px;
  text-align: center;
  cursor: pointer;
}
.info-btn:hover { background: rgba(255,255,255,0.08); }

.info-popover {
  position: absolute;
  top: calc(100% + 8px);
  left: auto;
  right: 0;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 12px;
  line-height: 1.4;
  width: 320px;
  max-width: 80vw;
  box-shadow: 0 16px 32px rgba(0,0,0,0.35);
  display: none;
  z-index: 5;
}
.info-popover.open { display: block; }

/* =========================
   Overview heading above signal bar
   ========================= */
.overview-heading {
  margin-bottom: 8px;
}

.detail-signal-row .section-heading-with-info {
  margin-bottom: 8px;
}

/* =========================
   Detail sections
   ========================= */
.detail-section {
  margin: 20px 0px 20px 0px;
}

.detail-section h3 {
  margin: 0px 0px 10px 0px;
}

.section-heading-with-info {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  position: relative;
  margin-bottom: 10px;
}

.section-heading-with-info h3 {
  margin: 0;
}

.section-heading-with-info .info-popover {
  top: calc(100% + 8px);
  left: 0;
  right: auto;
}

/* =========================
   Layout tweaks
   ========================= */
.container--wide {
  max-width: 1120px;
}

.back-row--detail {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

/* Signal row positioning */
.detail-signal-row {
  margin: 18px 0 18px;
}

.detail-signal-row-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

/* =========================
   Expanders
   ========================= */
.ae-expander {
  margin: 10px 0 0;
}

.ae-expander summary.label {
  list-style: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  user-select: none;
  font-weight: 700;
  margin-bottom: 0;
}

.ae-expander summary::-webkit-details-marker {
  display: none;
}

.ae-expander .kmd-label::after {
  content: "▾";
  display: inline-block;
  margin-left: 8px;
  opacity: 0.9;
  font-size: 1.15em;
  line-height: 1;
  transform: translateY(-1px);
}

.ae-expander[open] .kmd-label::after {
  content: "▴";
}

.rationale-body {
  margin-top: 10px;
  line-height: 1.6;
}

.rationale-expander .rationale-body {
  max-height: 140px;
  overflow: hidden;
  position: relative;
}

.rationale-expander .rationale-body::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 36px;
  background: linear-gradient(to bottom, rgba(0,0,0,0), var(--card));
  pointer-events: none;
}

.rationale-expander[open] .rationale-body {
  max-height: none;
  overflow: visible;
}

.rationale-expander[open] .rationale-body::after {
  display: none;
}

/* Top Signals expander inside cards */
.news-expander--signals .news-list {
  margin-top: 8px;
  max-height: 96px;
  overflow: hidden;
  position: relative;
}

.news-expander--signals .news-list::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 34px;
  background: linear-gradient(to bottom, rgba(0,0,0,0), var(--card));
  pointer-events: none;
}

.news-expander--signals[open] .news-list {
  max-height: none;
  overflow: visible;
}

.news-expander--signals[open] .news-list::after {
  display: none;
}

/* =========================
   Asset cards
   ========================= */
.card {
  height: auto;
  min-height: unset;
  display: flex;
  flex-direction: column;
}

.card .card-actions {
  margin-top: auto;
}

/* =========================
   Responsive tweaks
   ========================= */
@media (max-width: 820px) {
  .back-row--detail {
    flex-direction: column;
    align-items: stretch;
  }
}

/* =========================
   Top-of-page signal bar sizing
   ========================= */
.signal-bar-wrap {
  flex: 0 0 100%;
  margin-bottom: 10px;
  margin-top: 10px;
}

.signal-bar-inner {
  width: 360px;
  max-width: 100%;
}

.stacked-bar--narrow {
  width: 100%;
}

/* Responsive SVG handling for any SVG placed within the signal bar area */
.signal-bar-wrap svg {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
}

/* Compact HR inside cards */
.hr--compact {
  margin: 10px 0;
  opacity: 0.7;
}

/* =========================
   Tabs
   ========================= */
.mi-tabs--center {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 14px;
  margin: 18px 0 10px;
  flex-wrap: wrap;
}

.mi-tab--btn {
  text-decoration: none;
}

/* Tab colorways */
.mi-tabs--center .btn-intel {
  background: rgba(70, 130, 255, 0.18) !important;
  border: 1px solid rgba(70, 130, 255, 0.35) !important;
  padding: 20px;
}

.mi-tabs--center .btn-quant {
  background: rgba(140, 90, 255, 0.18) !important;
  border: 1px solid rgba(140, 90, 255, 0.35) !important;
  padding: 20px;
}

/* Active tab underline */
.mi-tab--btn.active {
  text-decoration: underline;
  text-underline-offset: 6px;
  text-decoration-thickness: 2px;
}

/* Hover interaction (non-active) */
.mi-tab--btn:not(.active):hover {
  transform: translateY(-1px);
}

/* =========================
   Market Direction Rationale
   ========================= */
.rationale-expander {
  padding-top: 10px;
}

.rationale-expander summary.label {
  font-size: 15px;
}

.rationale-expander .kmd-label {
  font-weight: 800;
}

/* =========================
   Card internals
   ========================= */
.card-header {
  margin-bottom: 8px;
}

.asset-name-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.confidence-wrap {
  margin-top: 2px;
}

.card-actions {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}

.card-actions--single {
  justify-content: flex-start;
}

/* =========================
   Evidence button styling
   ========================= */
.asset-class-grid .btn-evidence {
  background: rgba(245, 158, 11, 0.16);
  border: 1px solid rgba(245, 158, 11, 0.38);
}

.asset-class-grid .btn-evidence:hover {
  background: rgba(245, 158, 11, 0.24);
  border-color: rgba(245, 158, 11, 0.55);
  transform: translateY(-1px);
}


/* =========================
   Mobile adjustments
   ========================= */
@media (max-width: 720px) {
  .detail-header { flex-direction: column; align-items: flex-start; }
  .bar-percentages { width: 100%; }
  .stacked-bar { width: 100%; }

  /* Use full available width on small screens */
  .signal-bar-inner {
    width: 100%;
  }
}
