/* ==========================================================================
   Right-hand Information card (Project + Purchase Order show pages)
   projects/_project_info.html.erb, deals/_additional_info.html.erb,
   shared/_related_record_link.html.erb.
   Colours come from Bootstrap variables that dark_theme.css re-points
   (--bs-border-color, --bs-secondary-color, --bs-*-text-emphasis), so no
   parallel dark rule set.
   ========================================================================== */

/* Show-page layout: the main column takes all remaining space and the sidebar
   gets a capped width instead of a third of the row, so wide screens don't
   stretch the Information card. min-width: 0 stops wide tab content (tables,
   timelines) from pushing the flex item past the row. */
.row > .cp-show-main {
  min-width: 0;
}

@media (min-width: 992px) {
  .row > .cp-show-sidebar {
    width: clamp(320px, 28%, 420px);
  }
}

.cp-info-card .card-body {
  padding: 0;
}

.cp-info-section {
  padding: 1rem 1.25rem;
}

.cp-info-section + .cp-info-section {
  border-top: 1px solid var(--bs-border-color);
}

/* Opportunity Mark as Won / Lost (opportunities/_info_card): two equal buttons. */
.cp-info-close {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}

.cp-info-close .btn {
  padding-inline: 0.5rem;
  white-space: nowrap;
}

.cp-info-section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.625rem;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--bs-secondary-color);
}

/* Navigation tiles to the linked Project(s) / Purchase Order(s) */
.cp-related-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.625rem 0.75rem;
  border: 1px solid var(--bs-border-color);
  border-radius: 0.5rem;
  color: inherit;
  text-decoration: none;
  transition: border-color 0.15s, background-color 0.15s, box-shadow 0.15s;
}

.cp-related-link + .cp-related-link {
  margin-top: 0.5rem;
}

a.cp-related-link:hover,
a.cp-related-link:focus-visible {
  color: inherit;
  border-color: rgba(var(--cp-header-accent-rgb), 0.55);
  background-color: rgba(var(--cp-header-accent-rgb), 0.05);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
}

a.cp-related-link:hover .cp-related-chevron {
  color: var(--cp-header-accent);
  transform: translateX(2px);
}

.cp-related-link.is-archived {
  opacity: 0.7;
}

.cp-related-icon {
  flex: 0 0 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 0.5rem;
  background-color: rgba(var(--cp-header-accent-rgb), 0.1);
  color: var(--cp-header-accent);
  font-size: 1rem;
}

.cp-related-body {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.cp-related-title,
.cp-related-meta-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cp-related-title {
  font-size: 0.875rem;
  font-weight: 600;
}

/* Status badge + period/code on one line under the title, so the title keeps
   the full tile width on the narrow sidebar. */
.cp-related-meta {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  min-width: 0;
  margin-top: 0.125rem;
  font-size: 0.75rem;
  color: var(--bs-secondary-color);
}

.cp-related-meta .badge {
  flex-shrink: 0;
  font-size: 0.6875rem;
}

.cp-related-chevron {
  flex-shrink: 0;
  color: var(--bs-secondary-color);
  transition: transform 0.15s, color 0.15s;
}

/* Call-to-action tile in place of a linked record ("Create Project from PO"):
   same shape as the navigation tiles, dashed until hovered so it reads as an
   empty slot to fill rather than an existing record. */
.cp-related-action {
  width: 100%;
  border-style: dashed;
  background-color: transparent;
  text-align: left;
  cursor: pointer;
}

.cp-related-action:hover,
.cp-related-action:focus-visible {
  border-style: solid;
  border-color: rgba(var(--cp-header-accent-rgb), 0.55);
  background-color: rgba(var(--cp-header-accent-rgb), 0.05);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
}

.cp-related-action:focus-visible {
  outline: 2px solid rgba(var(--cp-header-accent-rgb), 0.5);
  outline-offset: 2px;
}

.cp-related-action:hover .cp-related-chevron,
.cp-related-action:focus-visible .cp-related-chevron {
  color: var(--cp-header-accent);
  transform: translateX(2px);
}

.cp-related-empty {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.625rem 0.75rem;
  border: 1px dashed var(--bs-border-color);
  border-radius: 0.5rem;
  font-size: 0.8125rem;
  color: var(--bs-secondary-color);
}

/* Status header — the card's header (shared/_info_status), tinted in the
   record's status colour with an accent bar on top; the tone class picks the
   Bootstrap colour. Not a .card-header on purpose: dark_theme.css forces every
   .card-header background with !important, which would flatten the tint. */
.cp-info-status {
  --cp-status-rgb: var(--bs-secondary-rgb);
  --cp-status-text: var(--bs-secondary-text-emphasis);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.875rem 1.25rem;
  border-top: 4px solid rgb(var(--cp-status-rgb));
  border-bottom: 1px solid rgba(var(--cp-status-rgb), 0.2);
  border-radius: var(--bs-card-inner-border-radius) var(--bs-card-inner-border-radius) 0 0;
  background-color: rgba(var(--cp-status-rgb), 0.12);
}

.cp-info-status--primary   { --cp-status-rgb: var(--bs-primary-rgb);   --cp-status-text: var(--bs-primary-text-emphasis); }
.cp-info-status--success   { --cp-status-rgb: var(--bs-success-rgb);   --cp-status-text: var(--bs-success-text-emphasis); }
.cp-info-status--info      { --cp-status-rgb: var(--bs-info-rgb);      --cp-status-text: var(--bs-info-text-emphasis); }
.cp-info-status--warning   { --cp-status-rgb: var(--bs-warning-rgb);   --cp-status-text: var(--bs-warning-text-emphasis); }
.cp-info-status--danger    { --cp-status-rgb: var(--bs-danger-rgb);    --cp-status-text: var(--bs-danger-text-emphasis); }

.cp-info-status-dot {
  flex: 0 0 10px;
  height: 10px;
  border-radius: 50%;
  background-color: rgb(var(--cp-status-rgb));
  box-shadow: 0 0 0 4px rgba(var(--cp-status-rgb), 0.2);
}

/* Subtle variant, mirroring a "-subtle" status badge (e.g. On Hold vs the
   solid Cancelled): lighter tint and edge, hollow dot. */
.cp-info-status.is-subtle {
  border-top-color: rgba(var(--cp-status-rgb), 0.45);
  background-color: rgba(var(--cp-status-rgb), 0.06);
}

.cp-info-status.is-subtle .cp-info-status-dot {
  background-color: transparent;
  box-shadow: inset 0 0 0 2px rgb(var(--cp-status-rgb));
}

.cp-info-status-body {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.cp-info-status-caption {
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--bs-secondary-color);
}

.cp-info-status-value {
  font-size: 1.0625rem;
  font-weight: 700;
  line-height: 1.25;
  color: var(--cp-status-text);
}

/* Label / value rows — stacked: small caption, value directly underneath, so
   the value sits next to its label instead of at the far edge. */
.cp-info-rows {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  margin: 0;
}

.cp-info-row {
  min-width: 0;
  font-size: 0.875rem;
}

.cp-info-row dt {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  margin-bottom: 0.25rem;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--bs-secondary-color);
}

.cp-info-row dt .bi {
  font-size: 0.75rem;
}

.cp-info-row dd {
  min-width: 0;
  margin: 0;
  font-weight: 500;
  overflow-wrap: anywhere;
}

/* Two short rows side by side (Created / Last updated); they stack when the
   sidebar is too narrow for both. */
.cp-info-row-pair {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(7.5rem, 1fr));
  gap: 1.25rem 0.875rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--bs-border-color);
}

/* Customer row (shared/_info_customer): a larger logo beside the name, the
   homepage under the name so both lines share one left edge. */
.cp-info-customer {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.cp-info-customer-body {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.cp-info-customer-name {
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.3;
}

.cp-info-customer-url {
  display: inline-flex;
  align-items: center;
  gap: 0.3125rem;
  min-width: 0;
  font-size: 0.8125rem;
  font-weight: 400;
  text-decoration: none;
}

.cp-info-customer-url span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cp-info-customer-url .bi {
  flex-shrink: 0;
  font-size: 0.75rem;
}

a.cp-info-customer-url:hover {
  text-decoration: underline;
}

/* Stage focus note (opportunities/_stage_panel): a quiet tinted box. */
.cp-stage-focus {
  display: flex;
  gap: 0.5rem;
  padding: 0.625rem 0.75rem;
  border-radius: 0.5rem;
  font-size: 0.8125rem;
  color: var(--bs-info-text-emphasis);
  background-color: var(--bs-info-bg-subtle);
}

/* Header metric chips that wrap (opportunities/_header): dividers between the
   chips of a row, and a top divider on the second row when they wrap two by two. */
.cp-header-chips > .col {
  border-right: 1px solid var(--bs-border-color);
}

@media (max-width: 1199.98px) {
  .cp-header-chips > .col:nth-child(2n) {
    border-right: 0;
  }

  .cp-header-chips > .col:nth-child(n + 3) {
    border-top: 1px solid var(--bs-border-color);
  }
}

@media (min-width: 1200px) {
  .cp-header-chips > .col:last-child {
    border-right: 0;
  }
}

/* Opportunity Information card: the stage row (opportunities/_info_card) — stage name,
   a segmented bar through the open stages and "Stage n of m · days in stage". */
.cp-info-stage-name {
  display: block;
  font-size: 1.0625rem;
  font-weight: 600;
  line-height: 1.3;
  color: var(--bs-primary-text-emphasis);
}

.cp-info-stage-bar {
  display: flex;
  gap: 3px;
  margin: 0.5rem 0 0.375rem;
}

.cp-info-stage-bar > span {
  flex: 1 1 0;
  height: 6px;
  border-radius: 3px;
  background-color: var(--bs-tertiary-bg);
}

.cp-info-stage-bar > .is-done {
  background-color: rgba(var(--bs-primary-rgb), 0.45);
}

.cp-info-stage-bar > .is-current {
  background-color: var(--bs-primary);
}

.cp-info-stage-meta {
  display: block;
  font-size: 0.8125rem;
  font-weight: 400;
  color: var(--bs-secondary-color);
}
