/*
 * race-roadbook.css — premium roadbook section + print stylesheet.
 * Re-uses the existing card / aa-card design tokens; adds a `rb-` namespace.
 */

.rb-card {
  --rb-accent: var(--race-color, #F26419);
  position: relative;
}

.rb-card .rb-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(242, 100, 25, 0.10);
  color: var(--rb-accent);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.rb-card .rb-intro {
  margin: 0 0 16px;
  color: #5b6271;
  font-size: 14px;
  line-height: 1.5;
}

/* --- form ---------------------------------------------------------------- */
.rb-form { margin: 0 0 12px; }

.rb-form__row {
  display: flex;
  flex-wrap: wrap;
  gap: 16px 24px;
  align-items: flex-end;
  padding: 14px;
  background: #f7f8fb;
  border: 1px solid #e6e8ee;
  border-radius: 10px;
}

.rb-fieldset {
  margin: 0;
  padding: 0;
  border: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.rb-fieldset legend {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #6b7280;
  margin-bottom: 4px;
}
.rb-radio {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border: 1px solid #d8dce6;
  border-radius: 999px;
  background: white;
  cursor: pointer;
  font-size: 13px;
  transition: all 0.15s;
}
.rb-radio:has(input:checked) {
  border-color: var(--rb-accent);
  background: rgba(242, 100, 25, 0.08);
  color: var(--rb-accent);
  font-weight: 600;
}
.rb-radio input { accent-color: var(--rb-accent); }

.rb-field { display: flex; flex-direction: column; gap: 4px; }
.rb-field label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #6b7280;
}
.rb-time-pair {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.rb-time-pair input,
.rb-field select {
  border: 1px solid #d8dce6;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  background: white;
}
.rb-time-pair input { width: 64px; text-align: center; }
.rb-time-sep { color: #6b7280; font-size: 13px; }

/* --- banner -------------------------------------------------------------- */
.rb-banner {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  line-height: 1.4;
}
.rb-banner[hidden] { display: none; }
.rb-banner--warn {
  background: #FFF8E1;
  color: #8a6d3b;
  border: 1px solid #f5e0a8;
}
.rb-banner i { color: #d97706; }

/* --- summary ------------------------------------------------------------- */
.rb-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin: 16px 0 8px;
}
.rb-summary__item {
  flex: 1 1 140px;
  padding: 10px 14px;
  background: #fafbfd;
  border: 1px solid #eceff5;
  border-radius: 10px;
}
.rb-summary__label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #6b7280;
  margin-bottom: 2px;
}
.rb-summary__value {
  font-size: 16px;
  font-weight: 600;
  color: #1f2937;
  font-variant-numeric: tabular-nums;
}
.rb-summary__value .rb-elapsed {
  font-weight: 400;
  color: #6b7280;
  font-size: 12px;
}

/* --- table --------------------------------------------------------------- */
.rb-table-wrap {
  margin-top: 8px;
  overflow-x: auto;
  border: 1px solid #eceff5;
  border-radius: 10px;
}
.rb-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.rb-table th, .rb-table td {
  padding: 8px 10px;
  border-bottom: 1px solid #eceff5;
  text-align: right;
  white-space: nowrap;
}
.rb-table th {
  background: #f7f8fb;
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #6b7280;
  position: sticky;
  top: 0;
  z-index: 1;
}
.rb-table tbody tr:last-child td { border-bottom: 0; }
.rb-row--start, .rb-row--finish {
  background: rgba(242, 100, 25, 0.05);
  font-weight: 600;
}
.rb-col-name { text-align: left; max-width: 220px; overflow: hidden; text-overflow: ellipsis; }
.rb-elapsed { color: #6b7280; font-weight: 400; font-size: 11px; }

.rb-pause-input,
.rb-margin-input {
  width: 56px;
  border: 1px solid #d8dce6;
  border-radius: 6px;
  padding: 4px 6px;
  font-size: 13px;
  text-align: right;
  background: white;
}
.rb-pause-input:focus,
.rb-margin-input:focus {
  outline: none;
  border-color: var(--rb-accent);
  box-shadow: 0 0 0 2px rgba(242, 100, 25, 0.18);
}
/* Inert cells (start/finish rows have no pause/departure/pace/margin). */
.rb-na { color: #cbd1da; font-weight: 400; }

.rb-margin {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 12px;
}
.rb-margin--ok   { background: rgba(22, 163, 74, 0.10); color: #166534; }
.rb-margin--warn { background: rgba(245, 158, 11, 0.10); color: #b45309; }
.rb-margin--bad  { background: rgba(220, 38, 38, 0.10); color: #b91c1c; }
.rb-margin--none { color: #9ca3af; font-weight: 400; }

/* Cumulative elevation column (D+ / D-). Compact inline pair. */
.rb-col-elevation { font-variant-numeric: tabular-nums; }
.rb-dplus  { color: #166534; font-weight: 600; }
.rb-dminus { color: #b91c1c; font-weight: 600; margin-left: 4px; }

.rb-empty { text-align: center !important; padding: 24px !important; color: #9ca3af; }

/* --- actions ------------------------------------------------------------- */
.rb-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}
.rb-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid #d8dce6;
  background: white;
  color: #1f2937;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}
.rb-btn:hover:not(:disabled) {
  border-color: var(--rb-accent);
  color: var(--rb-accent);
}
.rb-btn:disabled { opacity: 0.55; cursor: not-allowed; }
.rb-btn--primary {
  background: var(--rb-accent);
  border-color: var(--rb-accent);
  color: white;
}
.rb-btn--primary:hover:not(:disabled) { color: white; filter: brightness(1.05); }
.rb-btn--ghost { background: transparent; }
.rb-btn--busy { opacity: 0.7; }

.rb-disclaimer {
  margin-top: 12px;
  font-size: 11px;
  line-height: 1.5;
  color: #9ca3af;
}

/* --- responsive ---------------------------------------------------------- */
@media (max-width: 640px) {
  .rb-form__row { flex-direction: column; align-items: stretch; }
  .rb-table th, .rb-table td { padding: 6px 8px; font-size: 12px; }
  .rb-col-name { max-width: 120px; }
}

/* --- print --------------------------------------------------------------- */
@media print {
  /* While printing, race-roadbook.js moves #roadbookCard to <body> root and
     tags <body class="is-printing-roadbook">. We hide its (now direct)
     siblings with display:none — using display rather than visibility so
     the page flow collapses to the card only, avoiding the trailing blank
     pages the previous visibility-based rule produced. */
  body.is-printing-roadbook > *:not(#roadbookCard) { display: none !important; }
  #roadbookCard {
    box-shadow: none;
    border: 0;
    padding: 0;
  }
  .rb-actions, .rb-form, .rb-disclaimer, .rb-banner, .rb-intro { display: none !important; }
  .rb-summary { gap: 8px; margin-top: 0; }
  .rb-summary__item { flex: 1 1 30%; padding: 6px 10px; border-radius: 4px; }
  .rb-table-wrap { border: 0; overflow: visible; }
  .rb-table { font-size: 11px; }
  .rb-table th { background: white; border-bottom: 1px solid #333; color: black; }
  .rb-table td { border-bottom: 1px solid #ddd; }
  .rb-pause-input { border: 0; background: transparent; padding: 0; width: auto; }
  .rb-pause-input::-webkit-inner-spin-button,
  .rb-pause-input::-webkit-outer-spin-button { display: none; -webkit-appearance: none; }
  .rb-margin { background: none !important; color: black !important; padding: 0; font-weight: 500; }
  @page { margin: 1cm; }
}
