/* =============================================================
   Shipping Quotes Dashboard — component styles layered on
   styles.css. Halogen Systems brand theme (navy / cyan / slate),
   inheriting the same tokens so light & dark flow through.
   ============================================================= */

/* Controls bar — keep the wide quote dropdown from shoving "Get Rates". */
.controls-bar { gap: 14px; }
.controls-bar .ctrl-wide { flex: 1 1 280px; min-width: 240px; }
.controls-bar .ctrl-wide select { width: 100%; max-width: 520px; }

/* ---------- Cards ---------- */
.quote-card {
  border: 1px solid var(--line-soft);
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px 20px;
  display: flex; flex-direction: column; gap: 12px;
  position: relative;
}
.quote-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}
@media (max-width: 760px) { .quote-grid { grid-template-columns: 1fr; } }

/* ---------- Key/value meta grid ---------- */
.quote-meta {
  display: grid;
  grid-template-columns: max-content 1fr;
  column-gap: 16px;
  row-gap: 6px;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.quote-meta .k {
  color: var(--steel);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 11px;
  font-weight: 700;
  align-self: center;
}
.quote-meta .v { color: var(--navy); word-break: break-word; }
.quote-meta .v.right { text-align: right; }
.quote-meta .v a { color: var(--cyan-darker); text-decoration: none; font-weight: 600; }
.quote-meta .v a:hover { text-decoration: underline; }
.quote-meta .ship-block { white-space: pre-line; line-height: 1.45; }

/* ---------- Tables (parcels + rates) ---------- */
.tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.tbl th, .tbl td {
  text-align: left;
  padding: 9px 10px;
  border-bottom: 1px solid var(--line-soft);
}
.tbl th {
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--steel);
  font-weight: 700;
  border-bottom: 1px solid var(--line);
}
.tbl td.right, .tbl th.right { text-align: right; }
.tbl tr:last-child td { border-bottom: none; }
.tbl tr:hover td { background: var(--slate-low); }

/* Cheapest-row highlight. */
:root {
  --highlight-bg: var(--cyan-tint);
  --highlight-fg: var(--cyan-darker);
}
html[data-theme="dark"] {
  --highlight-bg: rgba(0, 168, 232, 0.16);
  --highlight-fg: var(--cyan-light);
}
.tbl tr.is-cheapest td { background: var(--highlight-bg); color: var(--term-fg); }
.tbl tr.is-cheapest td strong { color: var(--highlight-fg); }
.tbl tr.is-cheapest td:first-child::before {
  content: "★ ";
  color: var(--cyan);
  font-weight: 700;
}

.rate-wrap { min-height: 80px; }

/* ---------- Empty / error placeholders ---------- */
.rate-empty {
  padding: 16px 14px;
  color: var(--steel);
  font-size: 13px;
  text-align: center;
  border: 1px dashed var(--line);
  border-radius: var(--radius-sm);
}
.rate-empty.error {
  color: var(--err);
  border-color: rgba(186, 26, 26, 0.35);
  background: rgba(186, 26, 26, 0.04);
}
.rate-error-msg {
  font-size: 13px;
  color: var(--err);
  line-height: 1.45;
  margin-bottom: 8px;
  text-align: left;
}
.rate-error-details { text-align: left; font-size: 12px; color: var(--steel); }
.rate-error-details > summary {
  cursor: pointer;
  user-select: none;
  padding: 5px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--slate-low);
  list-style: none;
  display: inline-block;
}
.rate-error-details > summary::before { content: "▸ "; }
.rate-error-details[open] > summary::before { content: "▾ "; }
.rate-error-raw {
  margin: 8px 0 0 0;
  padding: 10px 12px;
  background: var(--slate-low);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  color: var(--navy);
  font-size: 12px;
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 220px;
  overflow: auto;
}

/* ---------- Service pills ---------- */
.svc-pill {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 2px 10px;
  border-radius: 999px;
  border: 1px solid currentColor;
  text-transform: uppercase;
}
.svc-pill.ok    { color: var(--ok);    background: rgba(27, 143, 90, 0.08); }
.svc-pill.err   { color: var(--err);   background: rgba(186, 26, 26, 0.08); }
.svc-pill.warn  { color: var(--warn);  background: rgba(180, 83, 9, 0.08); }
.svc-pill.muted { color: var(--steel); background: var(--slate-low); }

/* ---------- Settings ---------- */
.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px 18px;
  padding: 4px 0 8px;
}
.settings-grid .ctrl { width: 100%; flex-direction: column; align-items: stretch; gap: 5px; }
.settings-grid .ctrl .ctrl-label { align-self: flex-start; }
.settings-grid .ctrl input,
.settings-grid .ctrl select { flex: 1 1 auto; min-width: 60px; }
.settings-actions {
  display: flex; gap: 12px; align-items: center;
  border-top: 1px solid var(--line-soft);
  padding-top: 14px;
  flex-wrap: wrap;
}

/* ---------- Connections grid ---------- */
.conn-grid {
  display: grid;
  grid-template-columns: max-content 1fr;
  column-gap: 16px;
  row-gap: 6px;
  padding: 6px 0;
  font-size: 13px;
}
.conn-row { display: contents; }
.conn-label {
  color: var(--steel);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 11px;
  font-weight: 700;
}
.conn-value { color: var(--navy); }
.conn-value.ok    { color: var(--ok); }
.conn-value.err   { color: var(--err); }
.conn-value.muted { color: var(--steel); }

/* ---------- Report modal ---------- */
.report-card {
  background: var(--white);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  width: min(900px, 100%);
  max-height: 90vh;
  display: flex; flex-direction: column;
  gap: 12px;
  padding: 18px 20px;
}
.report-head {
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--line-soft);
  padding-bottom: 12px;
}
.report-content {
  flex: 1 1 auto;
  overflow: auto;
  font-size: 13px;
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  background: var(--slate-low);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  padding: 14px;
  white-space: pre;
  margin: 0;
}
.report-actions {
  display: flex; gap: 10px; align-items: center;
  border-top: 1px solid var(--line-soft);
  padding-top: 12px;
  flex-wrap: wrap;
}

/* Email-send block. */
.report-send-block {
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  margin: 4px 0 0;
  padding: 12px 14px 14px;
  background: var(--slate);
}
.report-send-block > legend {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--steel);
  font-weight: 700;
  padding: 0 6px;
}
.report-send-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 14px;
  margin-bottom: 10px;
}
.report-send-grid .ctrl { display: flex; flex-direction: column; gap: 4px; align-items: stretch; }
.report-send-grid .ctrl-full { grid-column: 1 / -1; }
.report-send-grid .ctrl-checkbox {
  flex-direction: row; align-items: center; gap: 8px;
  font-size: 12px; color: var(--navy);
}
.report-send-grid input[type="text"],
.report-send-grid textarea {
  font: inherit; font-size: 13px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  background: var(--white); color: var(--navy);
  border-radius: var(--radius-sm);
  width: 100%;
  resize: vertical;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.report-send-grid input:focus,
.report-send-grid textarea:focus {
  outline: none; border-color: var(--cyan); box-shadow: var(--ring-cyan);
}
.report-send-actions {
  display: flex; gap: 12px; align-items: center;
  border-top: 1px solid var(--line-soft);
  padding-top: 12px;
}

/* ---------- Parcel preset picker ---------- */
.presets-section {
  border-top: 1px solid var(--line-soft);
  padding-top: 12px;
  margin-top: 4px;
}
.presets-section:first-of-type { border-top: none; padding-top: 0; margin-top: 0; }
.presets-section-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--steel);
  font-weight: 700;
  margin-bottom: 8px;
}
.presets-section-title--row {
  display: flex; justify-content: space-between; align-items: center;
}
.presets-section-title--row input {
  font: inherit; font-size: 12px;
  padding: 5px 9px;
  border: 1px solid var(--line);
  background: var(--white); color: var(--navy);
  border-radius: var(--radius-sm);
  text-transform: none;
  letter-spacing: 0;
}
.presets-section-title--row input:focus {
  outline: none; border-color: var(--cyan); box-shadow: var(--ring-cyan);
}

.presets-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.preset-chip {
  display: inline-flex; flex-direction: column; gap: 1px;
  padding: 7px 12px;
  border: 1px solid var(--line);
  background: var(--white);
  border-radius: 999px;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  user-select: none;
  line-height: 1.3;
  text-align: left;
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
}
.preset-chip:hover { background: var(--slate-low); border-color: var(--steel); }
.preset-chip .preset-chip-name { font-weight: 600; color: var(--navy); }
.preset-chip .preset-chip-meta { color: var(--steel); font-size: 11px; }

/* Add / remove affordance. */
.preset-chip::before { content: "+ "; color: var(--steel); font-weight: 700; }
.preset-chip.selected::before { content: "✓ "; color: var(--cyan-dark); }

.preset-chip.suggested {
  border-color: var(--cyan);
  background: var(--cyan-tint);
}
.preset-chip.selected {
  border-color: var(--cyan);
  background: var(--cyan-tint);
  box-shadow: 0 1px 4px rgba(0, 168, 232, 0.20);
}
.preset-chip.selected .preset-chip-name { color: var(--cyan-darker); }
.preset-chip.suggested:not(.selected) {
  border-color: var(--cyan);
  border-style: dashed;
  background: var(--white);
}

/* Per-row remove button in the selected-parcels table. */
.parcel-remove {
  background: transparent;
  border: 1px solid transparent;
  border-radius: 999px;
  color: var(--err);
  cursor: pointer;
  padding: 2px 8px;
  font-family: inherit;
  font-size: 13px;
  line-height: 1;
}
.parcel-remove:hover { border-color: var(--err); background: rgba(186, 26, 26, 0.06); }
