/* ==========================================================================
   v2AdvisorBlotter.css — book-level trade blotter

   Loads after v2AdvisorCenter.css, which defines the --v2-* tokens used here.
   The page is a fixed-height flex column so the ticket grid, not the window,
   is what scrolls: a desk reading 400 tickets should keep the group rollups
   and the action bar in view.
   ========================================================================== */

#v2-blotter {
  display: none;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

#v2-blotter.active {
  display: flex;
}

.v2-blotter-page {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  padding: 20px 24px;
  gap: 12px;
  overflow: hidden;
}

/* --------------------------------------------------------------------------
   Summary strip

   One bordered bar of figures rather than a row of cards: the grid is the
   page, and the totals should cost one line of it, not a quarter.
   -------------------------------------------------------------------------- */

.v2-blotter-stats {
  display: flex;
  flex-wrap: nowrap;
  flex-shrink: 0;
  border: 1px solid var(--v2-border-color, #E5E7EB);
  border-radius: 8px;
  background: var(--v2-bg-card, #FFFFFF);
  overflow: hidden;
}

.v2-blotter-stats:empty {
  display: none;
}

.v2-blotter-stat {
  flex: 1 1 0;
  min-width: 0;
  padding: 8px 12px;
  border-left: 1px solid var(--v2-border-color, #E5E7EB);
}

.v2-blotter-stat:first-child {
  border-left: none;
}

.v2-blotter-stat-label {
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--v2-text-muted, #6B7280);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.v2-blotter-stat-value {
  margin-top: 2px;
  font-size: 17px;
  font-weight: 700;
  line-height: 1.25;
  color: var(--v2-text-primary, #111827);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.v2-blotter-stat-sub {
  font-size: 11px;
  color: var(--v2-text-muted, #6B7280);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.v2-blotter-stat.is-sell .v2-blotter-stat-value { color: #DC2626; }
.v2-blotter-stat.is-buy .v2-blotter-stat-value { color: #059669; }
.v2-blotter-stat.is-warn .v2-blotter-stat-value { color: #D97706; }

/* --------------------------------------------------------------------------
   Warnings

   These carry the reasons a plan's tax numbers may not survive the custodian,
   so they sit above the grid rather than in a tooltip.
   -------------------------------------------------------------------------- */

.v2-blotter-warnings {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex-shrink: 0;
}

.v2-blotter-warnings:empty {
  display: none;
}

.v2-blotter-warning {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 6px;
  border-left: 3px solid #F59E0B;
  background: rgba(245, 158, 11, 0.08);
  color: var(--v2-text, #1F2937);
  font-size: 13px;
  line-height: 1.4;
}

.v2-blotter-warning i {
  color: #F59E0B;
  margin-top: 2px;
}

.v2-blotter-warning-ok {
  border-left-color: #10B981;
  background: rgba(16, 185, 129, 0.08);
}

.v2-blotter-warning-ok i {
  color: #10B981;
}

.v2-blotter-warning-upgrade {
  border-left-color: #6366F1;
  background: rgba(99, 102, 241, 0.08);
}

.v2-blotter-warning-upgrade i {
  color: #6366F1;
}

/* --------------------------------------------------------------------------
   Toolbar
   -------------------------------------------------------------------------- */

.v2-blotter-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  flex-shrink: 0;
}

.v2-blotter-toolbar-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.v2-blotter-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--v2-text-muted, #6B7280);
}

/* Group-by is a segmented control rather than a select: it is the primary
   decision on this page and worth one click, not two. */
.v2-blotter-segmented {
  display: inline-flex;
  border: 1px solid var(--v2-border, #E5E7EB);
  border-radius: 6px;
  overflow: hidden;
}

.v2-blotter-seg {
  padding: 6px 14px;
  border: none;
  background: var(--v2-surface, #FFFFFF);
  color: var(--v2-text-muted, #6B7280);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease;
}

.v2-blotter-seg + .v2-blotter-seg {
  border-left: 1px solid var(--v2-border, #E5E7EB);
}

.v2-blotter-seg:hover {
  background: var(--v2-surface-hover, #F3F4F6);
}

.v2-blotter-seg.active {
  background: var(--v2-primary, #2563EB);
  color: #FFFFFF;
}

.v2-blotter-ticker {
  width: 110px;
}

.v2-blotter-check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--v2-text-muted, #6B7280);
  white-space: nowrap;
  cursor: pointer;
}

/* --------------------------------------------------------------------------
   Body: group rollups above, tickets below

   The group panel is capped so it can never push the ticket grid off screen,
   however many households have drifted.
   -------------------------------------------------------------------------- */

.v2-blotter-body {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  gap: 16px;
}

.v2-blotter-section {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.v2-blotter-tickets {
  flex: 1;
  min-height: 0;
}

.v2-blotter-grid {
  flex: 1;
  min-height: 140px;
  width: 100%;
}

.v2-blotter-grid-tall {
  min-height: 260px;
}

/* The shared V2 theme wraps header labels, which splits short words like
   "Shares" mid-word in a dense grid. Here a label truncates instead, and each
   column carries a minimum width so it rarely has to. */
#blotter-trades-grid .ag-header-cell-label {
  white-space: nowrap;
}

#blotter-trades-grid .ag-header-cell-text {
  overflow: hidden;
  text-overflow: ellipsis;
}

#blotter-trades-grid .ag-header-cell,
#blotter-trades-grid .ag-header-group-cell {
  padding-left: 10px;
  padding-right: 10px;
}

#blotter-trades-grid .ag-cell {
  padding-left: 10px;
  padding-right: 10px;
}

#blotter-trades-grid .ag-row-group {
  font-weight: 600;
}

#blotter-trades-grid .ag-row-footer {
  font-weight: 700;
}

/* Group label: key, fund name, then what is folded underneath. The name is
   the part that gives way when the column is narrow. */
#blotter-trades-grid .ag-group-value {
  flex: 1 1 auto;
  min-width: 0;
}

.v2-blotter-group-label {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
  white-space: nowrap;
}

.v2-blotter-group-key {
  flex-shrink: 0;
  font-weight: 700;
  color: var(--v2-text-primary, #111827);
}

.v2-blotter-group-name {
  flex: 0 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 12px;
  font-weight: 400;
  color: var(--v2-text-secondary, #4B5563);
}

.v2-blotter-group-meta {
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 400;
  color: var(--v2-text-muted, #6B7280);
}

.v2-blotter-group-leaf {
  font-size: 12px;
  font-weight: 400;
  color: var(--v2-text-muted, #6B7280);
}

/* --------------------------------------------------------------------------
   Action bar

   Sits between the header and the grid so the selection count and the buttons
   that act on it are never separated by a scroll.
   -------------------------------------------------------------------------- */

.v2-blotter-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  padding: 6px 10px;
  border: 1px solid var(--v2-border, #E5E7EB);
  border-bottom: none;
  border-radius: 8px 8px 0 0;
  background: var(--v2-surface-alt, #F9FAFB);
  flex-shrink: 0;
}

.v2-blotter-actions-info {
  display: flex;
  align-items: baseline;
  gap: 12px;
  min-width: 0;
}

.v2-blotter-selection {
  font-size: 13px;
  font-weight: 600;
  color: var(--v2-text, #1F2937);
  white-space: nowrap;
}

.v2-blotter-note {
  font-size: 12px;
  color: var(--v2-text-muted, #6B7280);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.v2-blotter-action-buttons {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.v2-blotter-venue {
  max-width: 240px;
}

/* --------------------------------------------------------------------------
   Fill import modal
   -------------------------------------------------------------------------- */

.v2-blotter-modal {
  position: fixed;
  inset: 0;
  z-index: 99000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(17, 24, 39, 0.55);
  padding: 24px;
}

.v2-blotter-modal-card {
  display: flex;
  flex-direction: column;
  width: min(760px, 100%);
  max-height: 90vh;
  border-radius: 10px;
  background: var(--v2-surface, #FFFFFF);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.28);
  overflow: hidden;
}

.v2-blotter-modal-header,
.v2-blotter-modal-footer {
  display: flex;
  align-items: center;
  padding: 14px 18px;
  flex-shrink: 0;
}

.v2-blotter-modal-header {
  justify-content: space-between;
  border-bottom: 1px solid var(--v2-border, #E5E7EB);
}

.v2-blotter-modal-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}

.v2-blotter-modal-footer {
  justify-content: flex-end;
  gap: 8px;
  border-top: 1px solid var(--v2-border, #E5E7EB);
}

.v2-blotter-modal-body {
  padding: 18px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.v2-blotter-modal-body code {
  padding: 1px 5px;
  border-radius: 3px;
  background: var(--v2-surface-alt, #F3F4F6);
  font-size: 12px;
}

.v2-blotter-textarea {
  width: 100%;
  padding: 10px;
  border: 1px solid var(--v2-border, #E5E7EB);
  border-radius: 6px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  line-height: 1.5;
  resize: vertical;
}

.v2-blotter-textarea:focus {
  outline: none;
  border-color: var(--v2-primary, #2563EB);
}

/* --------------------------------------------------------------------------
   Household blotter, inside the transition overlay
   -------------------------------------------------------------------------- */

.v2-transition-blotter-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  padding: 8px 0;
}

.v2-transition-blotter-actions .v2-blotter-action-buttons {
  gap: 6px;
}

@media (max-width: 1100px) {
  .v2-blotter-toolbar {
    align-items: flex-start;
    flex-direction: column;
  }
}

/* --------------------------------------------------------------------------
   Dark theme
   -------------------------------------------------------------------------- */

.dark-theme .v2-blotter-stats {
  background: var(--v2-bg-surface, #111520) !important;
  border-color: var(--v2-border, #1e2433) !important;
}

.dark-theme .v2-blotter-stat {
  border-left-color: var(--v2-border, #1e2433) !important;
}

.dark-theme .v2-blotter-stat-value,
.dark-theme .v2-blotter-group-key {
  color: var(--v2-text-primary, #e6e8ee) !important;
}

.dark-theme .v2-blotter-stat.is-sell .v2-blotter-stat-value { color: #f87171 !important; }
.dark-theme .v2-blotter-stat.is-buy .v2-blotter-stat-value { color: #34d399 !important; }
.dark-theme .v2-blotter-stat.is-warn .v2-blotter-stat-value { color: #fbbf24 !important; }

.dark-theme .v2-blotter-group-name {
  color: var(--v2-text-secondary, #a3aab8) !important;
}

.dark-theme .v2-blotter-actions {
  background: var(--v2-bg-surface, #111520) !important;
  border-color: var(--v2-border, #1e2433) !important;
}
