/* Portfolio page: the tabbed positions table (General, Holdings, Dividends, ...).
   Builds on /css/portfolio-detail.css and its --pd-* light/dark palette. */

/* ---------- Tabs ---------- */
.pw-tabs {
  display: flex;
  gap: 4px;
  padding: 10px 14px 0;
  border-bottom: 1px solid var(--pd-line);
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.pw-tabs::-webkit-scrollbar { display: none; }
.pw-tab {
  flex: 0 0 auto;
  appearance: none;
  background: transparent;
  border: 0;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  padding: 8px 14px 10px;
  font-size: .88rem;
  font-weight: 600;
  color: var(--pd-muted);
  cursor: pointer;
  white-space: nowrap;
  border-radius: 8px 8px 0 0;
}
.pw-tab:hover { color: var(--pd-text); background: var(--pd-soft); }
.pw-tab:focus-visible { outline: 2px solid var(--pd-accent); outline-offset: -2px; }
.pw-tab.is-active {
  color: var(--pd-accent);
  border-bottom-color: var(--pd-accent);
}

/* ---------- Table ---------- */
.pw-table { min-width: 0; }
.pw-table thead th {
  white-space: normal !important;
  line-height: 1.25;
  vertical-align: bottom !important;
  min-width: 78px;
}
.pw-table thead th.pd-num { text-align: right; }
.pw-table thead th.pw-sym { min-width: 0; }
.pw-sort {
  appearance: none;
  background: none;
  border: 0;
  padding: 0;
  margin: 0;
  font: inherit;
  color: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
  text-align: inherit;
  cursor: pointer;
}
.pw-sort:hover { color: var(--pd-text); }
.pw-sort:focus-visible { outline: 2px solid var(--pd-accent); outline-offset: 2px; border-radius: 3px; }
th[aria-sort="ascending"] .pw-sort::after { content: " \25B2"; font-size: .8em; }
th[aria-sort="descending"] .pw-sort::after { content: " \25BC"; font-size: .8em; }
th[aria-sort="ascending"] .pw-sort,
th[aria-sort="descending"] .pw-sort { color: var(--pd-accent); }

/* Compact rows (2026-12-01): ticker and company name on one line, less padding, so a typical
   portfolio fits on one screen (rows were about 57 px, now about 33). */
.pw-table td { padding-top: 5px !important; padding-bottom: 5px !important; }
.pw-table thead th { padding-top: 7px !important; padding-bottom: 7px !important; }
.pw-table .pd-stock { flex-direction: row; flex-wrap: nowrap; align-items: baseline; column-gap: 8px; row-gap: 0; min-width: 0; }
.pw-table .pd-name { max-width: 150px; }
.pw-table .pd-stock:has(.pd-note) { flex-wrap: wrap; }   /* only a row with a note takes two lines */
.pw-table .pd-note { flex-basis: 100%; max-width: 230px; }   /* a watchlist note on its own line */
.pw-ticker { text-decoration: none; color: var(--pd-accent) !important; }
.pw-ticker:hover { text-decoration: underline; }
.pw-up { color: var(--pd-up) !important; }
.pw-down { color: var(--pd-down) !important; }
/* The stop was reached (StopAlertService). */
.pw-stop-hit { display: inline-block; margin-left: 6px; padding: 0 6px; font-size: .72rem; font-weight: 700; line-height: 1.5;
  color: var(--pd-down); border: 1px solid color-mix(in srgb, var(--pd-down) 45%, transparent); border-radius: 999px; white-space: nowrap; }
.pw-none { color: var(--pd-muted); opacity: .75; }

/* The symbol column stays in view while the table scrolls sideways. */
.pw-table th.pw-sym,
.pw-table td.pw-sym {
  position: sticky;
  left: 0;
  z-index: 1;
  background: var(--pd-card) !important;
  box-shadow: 1px 0 0 var(--pd-line);
}
.pw-table thead th.pw-sym { background: var(--pd-head) !important; z-index: 2; }
.pw-table tbody tr:hover td.pw-sym { background: var(--pd-hover) !important; }

/* A long position list scrolls inside the card, so both scroll bars stay on screen; the header
   row stays at the top of it, and the Action column (Edit, Remove) at its right edge. */
.pw-panel > .pd-scroll {
  /* As tall as the window below the sticky navbar: once the page is scrolled to the table,
     the whole box, its sideways scroll bar included, is on screen. */
  max-height: max(360px, calc(100vh - 90px));
  overflow: auto;
}
.pw-panel .pw-table thead th { position: sticky; top: 0; z-index: 2; }
.pw-panel .pw-table thead th.pw-sym { z-index: 4; }
.pw-table th.pd-actions,
.pw-table td.pd-actions {
  position: sticky;
  right: 0;
  z-index: 1;
  background: var(--pd-card) !important;
  box-shadow: -1px 0 0 var(--pd-line);
}
.pw-table thead th.pd-actions { background: var(--pd-head) !important; z-index: 4; }
.pw-table tbody tr:hover td.pd-actions { background: var(--pd-hover) !important; }

.pw-foot {
  margin: 0;
  padding: 10px 20px 14px;
  font-size: .8rem;
  color: var(--pd-muted);
  border-top: 1px solid var(--pd-row-line);
}

/* Pages for big portfolios (2026-12-01): built by portfolio-watchlist.js when there are more than 20. */
.pw-table tbody tr[hidden] { display: none; }
.pw-pager {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  padding: 10px 20px;
  font-size: .84rem;
  color: var(--pd-muted);
  border-top: 1px solid var(--pd-line);
}
.pw-pager-nav { display: flex; align-items: center; gap: 10px; }
.pw-pager-nav[hidden] { display: none; }
.pw-pager-page { color: var(--pd-text); font-weight: 600; white-space: nowrap; }
.pw-page-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 12px;
  font-size: .82rem;
  font-weight: 600;
  color: var(--pd-text);
  background: transparent;
  border: 1px solid var(--pd-line);
  border-radius: 8px;
}
.pw-page-btn:hover:not(:disabled), .pw-page-btn:focus-visible { color: var(--pd-accent); border-color: var(--pd-accent); }
.pw-page-btn:disabled { opacity: .45; cursor: default; }
.pw-pager-size { display: inline-flex; align-items: center; gap: 6px; margin: 0; }
.pw-pager-size select {
  padding: 3px 6px;
  font-size: .82rem;
  color: var(--pd-text);
  background: var(--pd-card);
  border: 1px solid var(--pd-line);
  border-radius: 6px;
}

@media (max-width: 767.98px) {
  .pw-tabs { padding: 8px 8px 0; }
  .pw-tab { padding: 8px 10px 10px; font-size: .84rem; }
  .pw-table th, .pw-table td { padding-left: 10px !important; padding-right: 10px !important; }
  .pw-table .pd-stock { min-width: 84px; }
  .pw-table .pd-name { max-width: 110px; }
}
