/*
  DiviMetrics — Report layout v2
  Wyśrodkowana kolumna treści (~1000px) + rail; boczne marginesy na szerokich ekranach.
  Loaded after _app_redesign.css.
*/

/* Page scroll and layout reset — zachowaj offset pod fixed top bar */
body.report-open {
  padding-top: var(--header-height) !important;
}

body.report-open .app-shell {
  height: auto !important;
  min-height: 100vh !important;
  max-height: none !important;
  overflow: visible !important;
  padding: 0 !important;
}
body.report-open .app-main {
  height: auto !important;
  min-height: auto !important;
  overflow: visible !important;
  display: block !important;
  padding: 0 !important;
}
body.report-open .results-container {
  min-height: auto !important;
  overflow: visible !important;
  display: block !important;
  width: 100% !important;
  padding: 0 !important;
  max-width: none !important;
}

/* Report strip — pełna szerokość bez „ramki” panelu (hero ma własny border) */
.report-panel {
  width: 100% !important;
  max-width: 100% !important;
  margin: 0 !important;
  padding: 0 !important;
  background: transparent !important;
  border: none !important;
  border-top: none !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  height: auto !important;
  max-height: none !important;
  overflow: visible !important;
}

.report-layout,
.report-layout.report-layout-wide,
.report-layout.report-layout-3col,
.report-area {
  width: 100%;
  max-width: var(--report-layout-max);
  margin-inline: auto;
  min-height: calc(100vh - var(--header-height) - 120px);
  display: grid;
  grid-template-columns: var(--report-rail-width) minmax(0, 1fr);
  gap: var(--space-6);
  background: var(--bg);
  padding: var(--space-5) var(--report-gutter-inline) var(--space-8);
  box-sizing: border-box;
}

/* Left rail — część tła (SWS-style), bez osobnej „klatki” */
.report-rail,
.report-nav {
  position: sticky;
  top: var(--header-height);
  align-self: start;
  width: var(--report-rail-width);
  min-width: 0;
  height: auto;
  max-height: none;
  background: transparent;
  border: none;
  border-radius: 0;
  box-shadow: none;
  display: flex;
  flex-direction: column;
  padding: var(--space-4) 0 var(--space-5);
  overflow: visible;
  overflow-x: hidden;
  z-index: 50;
}

.stock-rail {
  display: none;
}
.stock-rail-ticker { font-size: var(--fs-2xl); font-weight: var(--fw-bold); color: var(--text-bright); letter-spacing: -0.02em; }
.stock-rail-name { font-size: var(--fs-sm); color: var(--text-dim); }
.stock-rail-price { font-size: var(--fs-xl); font-family: var(--mono); color: var(--text-bright); margin-top: var(--space-2); }
.stock-rail-change { font-size: var(--fs-sm); font-family: var(--mono); }
.stock-rail-signal { display: flex; align-items: center; gap: var(--space-2); font-size: var(--fs-sm); font-weight: var(--fw-semibold); color: var(--text-bright); margin-top: var(--space-2); }
.signal-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); display: inline-block; }
.stock-rail-confidence { font-size: var(--fs-xs); color: var(--text-dim); }

.report-nav-group { display: flex; flex-direction: column; gap: 0; }
.report-nav-item,
.report-rail a,
.report-rail .report-nav-item {
  display: flex;
  align-items: center;
  padding: 6px 0;
  font-size: var(--fs-sm);
  color: var(--text-dim);
  text-decoration: none;
  border: none;
  border-radius: 0;
  transition: color var(--transition-base);
}
.report-nav-item:hover {
  color: var(--text-bright);
  background: transparent;
  padding-left: 0;
}
.report-nav-item.active {
  color: var(--text-bright);
  font-weight: var(--fw-semibold);
  background: transparent;
  box-shadow: none;
}
.report-nav-item.active .report-nav-num { color: var(--accent-light); }

/* Main area — węższa kolumna czytania */
.report-main {
  counter-reset: report-chapter;
  padding: var(--space-2) var(--space-4) 0;
  min-width: 0;
  max-width: var(--report-content-max);
  width: 100%;
}

/* Tabele — naturalna szerokość, bez sztucznego rozciągania pustych kolumn */
.report-main .table-wrapper {
  width: fit-content;
  max-width: 100%;
}
.report-main .table-wrapper table {
  width: auto;
  min-width: min(100%, 480px);
}
.report-main .table-wrapper:has(.peer-comparison-table),
.report-main .table-wrapper:has(.backtest-table),
.report-main .table-wrapper:has(.research-calendar-table),
.report-main .table-wrapper.insider-table-desktop {
  width: 100%;
}
.report-main .table-wrapper table.peer-comparison-table,
.report-main .table-wrapper table.backtest-table,
.report-main .table-wrapper table.research-calendar-table,
.report-main .table-wrapper.insider-table-desktop table,
.report-main .table-card .table--wide,
.report-main .earnings-table,
.report-main .analyst-table {
  width: 100%;
  min-width: 100%;
}

/* Hero */
.report-hero {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: var(--stack-gap);
  padding: var(--section-pad);
  background: var(--bg-panel);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  margin-bottom: var(--section-gap);
}
.hero-left {
  display: flex;
  gap: var(--space-5);
  flex: 1;
}
.hero-copy {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
  gap: var(--space-3);
}
.hero-top {
  display: flex;
  gap: var(--space-5);
  align-items: flex-start;
}
.hero-logo {
  width: 64px; height: 64px;
  border-radius: var(--radius-md);
  background: var(--bg-inset);
  border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: var(--fs-xl); font-weight: var(--fw-bold); color: var(--text-bright);
  flex-shrink: 0;
}
.hero-identity h2 { font-size: var(--fs-2xl); margin: 0; color: var(--text-bright); }
.hero-identity p { color: var(--text-dim); margin: var(--space-1) 0; }
.hero-price-block { margin-top: var(--space-3); }
.hero-price { font-size: var(--fs-2xl); font-family: var(--mono); color: var(--text-bright); }
.hero-change { font-family: var(--mono); font-size: var(--fs-sm); }
.hero-actions { display: flex; gap: var(--space-2); margin-top: var(--space-3); }
.btn {
  padding: 8px 14px;
  background: var(--bg-inset);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  font-size: var(--fs-sm);
  cursor: pointer;
}

/* Hero snapshot */
.hero-snapshot,
.report-snapshot {
  width: 220px;
  background: var(--bg-rail);
  border: 1px solid var(--border);
  border-left: 2px solid var(--accent);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  flex-shrink: 0;
}
.snap-title { font-size: var(--fs-xs); color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.08em; }
.snap-score { font-size: var(--fs-2xl); font-weight: var(--fw-bold); color: var(--text-bright); }
.snap-signal { display: flex; align-items: center; gap: var(--space-2); font-size: var(--fs-sm); font-weight: var(--fw-semibold); color: var(--text-bright); }
.snap-kv { display: flex; justify-content: space-between; font-size: var(--fs-sm); }
.snap-kv-label { color: var(--text-dim); }
.snap-kv-value { font-family: var(--mono); color: var(--text-bright); }
.snap-kv-value.value-gold,
.value-gold { color: var(--accent-light) !important; }
.snap-divider { height: 1px; background: var(--border); margin: var(--space-1) 0; }
.snap-signals-title { font-size: var(--fs-xs); color: var(--text-dim); }
.snap-signal-item { font-size: var(--fs-xs); color: var(--text); display: flex; align-items: center; gap: var(--space-1); }
.sentiment-dot { width: 6px; height: 6px; border-radius: 50%; display: inline-block; }
.sentiment-dot.positive,
.sentiment-dot.pos { background: var(--green); }
.sentiment-dot.negative,
.sentiment-dot.neg { background: var(--red); }

/* Virtual pages */
.report-page,
.report-main > .report-section,
.report-main > .collapsible {
  counter-increment: report-chapter;
  margin-bottom: var(--section-gap);
  padding-bottom: var(--section-pad);
  border-bottom: 1px solid var(--border-strong);
  background: transparent;
  border-top: none;
  border-left: none;
  border-right: none;
  border-radius: 0;
}
.report-page:last-of-type,
.report-main > .report-section:last-of-type,
.report-main > .collapsible:last-of-type {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
}
.report-page-header,
.report-main > .report-section > .report-section-divider,
.report-main > .collapsible > .report-section-divider,
.report-main > .collapsible > .collapsible-header > .collapsible-title,
.report-main > .collapsible > .collapsible-header {
  font-size: var(--fs-2xl);
  font-weight: var(--fw-bold);
  color: var(--text-bright);
  margin-bottom: var(--stack-gap);
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  background: transparent;
  border: none;
  padding: 0;
  cursor: default;
  pointer-events: none;
}
.report-page-header::before,
.report-main > .report-section > .report-section-divider > .report-section-divider-label::before,
.report-main > .collapsible > .report-section-divider > .report-section-divider-label::before,
.report-main > .collapsible > .collapsible-header > .collapsible-title::before {
  content: counter(report-chapter, decimal-leading-zero);
  color: var(--accent);
  font-family: var(--mono);
  font-weight: var(--fw-normal);
  opacity: 0.9;
}

.report-page-body,
.report-section-body,
.collapsible-body-inner {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: var(--stack-gap);
  width: 100%;
}
.report-page-body > *,
.report-section-body > *,
.collapsible-body-inner > * {
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-5);
}
.report-page-body > .table-card,
.report-page-body > table,
.report-page-body > .research-hub,
.report-page-body > .report-cards-grid,
.report-page-body > .data-rows,
.report-page-body > .smart-money-section,
.report-page-body > .report-chart-section,
.report-section-body > .table-card,
.report-section-body > table,
.collapsible-body-inner > .table-card,
.collapsible-body-inner > table {
  background: transparent;
  border: none;
  padding: 0;
  border-radius: 0;
}

/* Data cards */
.data-card,
.report-section-body .data-card,
.collapsible-body-inner .data-card {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-5);
}
.data-card-label { font-size: var(--fs-xs); color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.05em; }
.data-card-value { font-size: var(--fs-xl); font-family: var(--mono); color: var(--text-bright); margin-top: var(--space-2); }
.data-card-value.pos,
.data-card-value.positive { color: var(--green); }
.data-card-value.neg,
.data-card-value.negative { color: var(--red); }
.data-card-value.value-gold { color: var(--accent); }
.data-card-desc { font-size: var(--fs-sm); color: var(--text-dim); margin-top: var(--space-2); }

.table-card,
.report-section-body .table-card,
.collapsible-body-inner .table-card {
  width: 100%;
  max-width: none;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-5);
}
.data-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-3);
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.data-row:last-child { border-bottom: none; }
.data-row-label,
.data-row .data-label { color: var(--text-dim); font-size: var(--fs-sm); }
.data-row-value,
.data-row .data-value { font-family: var(--mono); color: var(--text-bright); }
.data-row-value.value-gold,
.data-row .data-value.value-gold { color: var(--accent); }
.data-row-value.pos,
.data-row-value.positive,
.data-row .data-value.pos,
.data-row .data-value.positive { color: var(--green); }
.data-row-value.neg,
.data-row-value.negative,
.data-row .data-value.neg,
.data-row .data-value.negative { color: var(--red); }
.data-row .data-desc { color: var(--text-dim); font-size: var(--fs-sm); flex: 1; }
.data-row .data-badge {
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  background: var(--bg-inset);
  color: var(--text-dim);
}
.data-row .data-badge.good { background: rgba(0,200,83,0.15); color: var(--green); }
.data-row .data-badge.ok { background: rgba(255,171,0,0.15); color: var(--amber); }
.data-row .data-badge.bad { background: rgba(255,82,82,0.15); color: var(--red); }
.data-row .data-badge.na { background: var(--bg-inset); color: var(--text-dim); }
.data-row .data-value.gap {
  font-size: var(--fs-sm);
  margin-left: var(--space-2);
  opacity: 0.85;
}

/* Hide old collapsible chrome */
.report-main > .collapsible .collapsible-chevron,
.report-main > .collapsible .collapsible-summary { display: none; }
.report-main > .collapsible .collapsible-body,
.report-main > .collapsible .collapsible-body-inner {
  display: block;
  max-height: none;
  opacity: 1;
  padding: 0;
}

.report-page-body > .report-chart-section,
.report-section-body > .report-chart-section,
.collapsible-body-inner > .report-chart-section {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  width: 100%;
  background: transparent;
  border: none;
  padding: 0;
}
.report-chart-section .chart-section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-3);
}
.report-chart-section #chartArea {
  width: 100%;
  height: 300px;
  min-height: 280px !important;
  max-height: 360px;
  background: var(--bg-inset);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

/* Responsive */
@media (max-width: 1023px) {
  .report-area { grid-template-columns: 1fr; }
  .report-rail,
  .report-nav { position: static; height: auto; border-right: none; border-bottom: 1px solid var(--border-strong); }
  .report-main { max-width: 100%; padding: var(--space-5); }
  .report-hero { flex-direction: column; }
  .hero-snapshot { width: 100%; }
}
