/* ================== COMPACT TRIP CARDS ================== */
.trip-summary-card {
    margin-top: 20px;
}

.compact-trip-card {
  margin-bottom: 1rem;
  border: 1px solid #dee2e6;
  margin-left: auto;
  margin-right: auto;
}

.compact-trip-card .card-header {
  padding: 0.375rem 0.75rem;
  font-size: 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.compact-trip-card .card-body {
  padding: 1.6rem 0.75rem 0.75rem;
  font-size: 1rem;
  line-height: 1.2;
  position: relative;
  overflow: hidden;
}

.trip-number {
  position: absolute;
  top: 0.45rem;
  right: 0.75rem;
  z-index: 1;
  font-weight: bold;
  background-color: #e0d8c8;
  color: var(--text-secondary);
  padding: 3px 10px;
  border-radius: 6px;
  border: 1px solid var(--border-color);
  font-size: 0.85rem;
  width: auto;
}

.trip-legs-container {
  display: flex;
  gap: 1rem;
  margin-bottom: 0.5rem;
}

.trip-horizontal-container {
  display: grid;
  grid-template-columns: 1fr 1fr minmax(90px,130px) minmax(90px,130px) minmax(90px,130px);
  gap: 0.75rem;
  align-items: center;
}

.leg-header {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  margin-bottom: 0.25rem;
  flex-wrap: wrap;
  gap: 0.25rem;
}

.leg-actions {
  display: flex;
  gap: 0.25rem;
  margin-left: 0.5rem;
}

.leg-details {
  font-size: 1rem;
  line-height: 1.2;
}

.trip-summary {
  display: flex;
  gap: 1rem;
  font-weight: bold;
  margin-bottom: 0.5rem;
}

.trip-summary span {
  flex: 1;
}

.trip-summary-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  font-weight: bold;
  width: auto;
  min-width: 80px;
}

.summary-horizontal-container {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 1rem;
  align-items: flex-start;
}

.summary-horizontal-container .trip-summary-item {
  width: auto;
}

.trip-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.25rem;
}

.trip-actions .btn {
  font-size: 0.875rem;
  padding: 0.2rem 0.4rem;
}

.info-field {
  flex: 0 1 10rem;
  display: flex;
  align-items: center;
}

.info-field strong {
  margin-right: 0.25rem;
  min-width: 2.5rem;
}

.compact-trip-card .btn-sm {
  padding: 0.1rem 0.2rem;
  font-size: 0.75rem;
  border-width: 1px;
}

/* ================== CARDS (modern overrides) ================== */
.card {
  border: 1px solid var(--border-color);
  border-radius: var(--card-radius);
  box-shadow: var(--shadow-light);
  background-color: var(--card-bg);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.card:hover {
  box-shadow: var(--shadow-hover);
}

.card-header {
  background-color: var(--card-bg);
  border-bottom: 1px solid var(--border-color);
  font-weight: 600;
  color: var(--text-primary);
  border-radius: var(--card-radius) var(--card-radius) 0 0 !important;
}

.compact-trip-card {
  border-radius: var(--card-radius);
  box-shadow: var(--shadow-light);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.compact-trip-card:hover {
  box-shadow: var(--shadow-hover);
  background-color: rgba(13, 110, 253, 0.03);
}

.trip-number {
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

.leg-details {
  font-size: 0.95rem;
  line-height: 1.4;
  color: var(--text-secondary);
}

/* Summary cards */
.trip-summary-card .card {
  border-radius: var(--card-radius);
  box-shadow: var(--shadow-light);
  background-color: var(--card-bg);
}

.trip-summary-card .card-body h6 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
}

.trip-summary-card .card-body p {
  font-size: 0.95rem;
  color: var(--text-secondary);
}

/* ================== ALERTS ================== */
.alert {
  border-radius: var(--card-radius);
  border-left: 6px solid;
  font-size: 0.95rem;
  line-height: 1.4;
}

.alert-warning {
  background-color: #fff0c2;
  border-left-color: #e6a000;
  color: #5a3a00;
  border-left-width: 5px;
}

.alert-warning strong {
  color: #3d2600;
}

/* ================== CARD-WITHIN-CARD (leg boxes) ================== */
.trip-horizontal-container .trip-leg {
  background-color: rgba(0,0,0,0.03);
  border-radius: 8px;
  padding: 0.5rem 0.75rem;
  border: 1px solid rgba(0,0,0,0.07);
  text-align: left;
  width: fit-content;
  min-width: 160px;
  justify-self: center;
}

.trip-summary-item {
  background-color: rgba(0,0,0,0.03);
  border-radius: 8px;
  padding: 0.5rem 0.625rem;
  border: 1px solid rgba(0,0,0,0.07);
  text-align: center;
  justify-content: center;
}

.trip-summary-item > div:not(:first-child) {
  word-break: break-word;
  overflow-wrap: break-word;
  white-space: normal;
}

.trip-summary-item > div:first-child {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  opacity: 0.75;
  margin-bottom: 0.15rem;
}

/* ================== LAYOVER BETWEEN LEGS ================== */
.trip-layover-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  text-align: center;
  font-size: 0.95rem;
  background-color: rgba(0,0,0,0.03);
  border-radius: 8px;
  padding: 0.5rem 0.625rem;
  border: 1px solid rgba(0,0,0,0.07);
  min-width: 90px;
  align-self: center;
}

.trip-layover-item > div:first-child {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  opacity: 0.75;
  margin-bottom: 0.15rem;
}

/* ================== TRIP GRID TEMPLATES ================== */

/* 2-leg paired: Leg | Layover | Leg | Total | Meals */
.trip-horizontal-container.two-leg-paired {
  grid-template-columns: 1fr 90px 1fr minmax(90px,130px) minmax(90px,130px);
}

/* 3-leg: Leg | Lay1 | Leg | Lay2 | Leg | Total | Meals */
.trip-horizontal-container.three-leg {
  grid-template-columns: 1fr 100px 1fr 100px 1fr minmax(90px,130px) minmax(90px,130px);
}

/* Turn trip (home→home, no inbound): Leg | Total | Meals */
.trip-horizontal-container.two-leg-turn {
  grid-template-columns: 1fr minmax(90px,130px) minmax(90px,130px);
}

/* Single-leg incomplete trip */
.compact-trip-card.incomplete-trip .trip-horizontal-container:not(.two-leg-incomplete) {
  grid-template-columns: 1fr 90px 1fr minmax(90px,130px) minmax(90px,130px) !important;
}

/* 2-leg incomplete */
.trip-horizontal-container.two-leg-incomplete {
  grid-template-columns: 1fr 90px 1fr 90px 1fr minmax(90px,130px) minmax(90px,130px);
}

/* Trip summary items row — on desktop, acts as a CSS grid "pass-through" */
.trip-summary-items-row {
  display: contents;
}

/* ================== GHOST PLACEHOLDER LEG ================== */
.trip-leg-ghost {
    border: 2px dashed #6c757d !important;
    background: repeating-linear-gradient(
        45deg,
        transparent,
        transparent 6px,
        rgba(108, 117, 125, 0.06) 6px,
        rgba(108, 117, 125, 0.06) 12px
    ) !important;
    opacity: 0.72;
    min-width: 140px;
}

.trip-leg-ghost .leg-header strong {
    color: #6c757d !important;
}

.trip-leg-ghost .leg-details {
    color: #6c757d !important;
    font-style: italic;
    font-size: 0.82rem;
}

/* ================== TRIP EXTRA DATA COLLAPSE ================== */

/* The "Details ▾" toggle link */
.trip-extra-toggle {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--primary-blue, #0d6efd);
    text-decoration: none;
    cursor: pointer;
    margin-top: 0.35rem;
    letter-spacing: 0.01em;
    transition: opacity 0.15s ease;
}

.trip-extra-toggle:hover {
    opacity: 0.75;
    text-decoration: underline;
}

/* Rotate the ▾ chevron when expanded */
.trip-extra-toggle[aria-expanded="true"] {
    opacity: 0.85;
}

/* The collapsed panel container */
.trip-extra-panel {
    margin-top: 0.35rem;
}

/* The inner body (groups wrapper) */
.trip-extra-panel-body {
    border-top: 1px solid var(--border-color, #dee2e6);
    padding-top: 0.4rem;
    margin-top: 0.15rem;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

/* Each grouped section (Timing, Operational, etc.) */
.trip-extra-group {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
}

.trip-extra-group-label {
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-secondary, #6c757d);
    opacity: 0.85;
}

.trip-extra-group-fields {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem 0.6rem;
}

/* Individual field chip */
.trip-extra-field {
    display: inline-flex;
    align-items: baseline;
    gap: 0.25em;
    font-size: 0.8rem;
    background-color: rgba(0, 0, 0, 0.04);
    border-radius: 5px;
    padding: 0.1rem 0.4rem;
    border: 1px solid rgba(0, 0, 0, 0.06);
}

.trip-extra-field-label {
    color: var(--text-secondary, #6c757d);
    font-size: 0.75rem;
}

.trip-extra-field-value {
    color: var(--text-primary, #333);
}

/* ================== INCOMPLETE TRIPS — LIGHT/DARK MODE TEXT CONTRAST ================== */
.compact-trip-card.incomplete-trip .leg-details,
.compact-trip-card.incomplete-trip .leg-header strong,
.compact-trip-card.incomplete-trip .trip-number,
.compact-trip-card.incomplete-trip .trip-summary-item {
    color: inherit !important;
}

/* ================== TRIP CONNECTOR SVG LINES ================== */

/* Make the grid container the SVG coordinate root */
.trip-horizontal-container {
  position: relative;
}

/* The injected SVG overlay — sits behind card content, never blocks clicks */
.trip-connector-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: visible;
  z-index: 0;
}

/* Straight-line paths */
.trip-connector-path {
  fill: none;
  stroke: rgba(100, 116, 139, 0.32);
  stroke-width: 1.5;
  stroke-linecap: round;
  animation: connector-fadein 0.55s ease-out forwards;
}

/* Arrowhead polygon — inherits colour from CSS custom property via fill */
.trip-connector-arrow-head {
  fill: rgba(100, 116, 139, 0.40);
  stroke: none;
}

@keyframes connector-fadein {
  from { opacity: 0; stroke-dashoffset: 1; }
  to   { opacity: 1; stroke-dashoffset: 0; }
}

/* Ensure leg cards and layover items sit above the SVG layer */
.trip-horizontal-container .trip-leg,
.trip-horizontal-container .trip-layover-item,
.trip-horizontal-container .trip-summary-items-row {
  position: relative;
  z-index: 1;
}

/* Hide connectors entirely on mobile (cards stack vertically) */
@media (max-width: 999px) {
  .trip-connector-svg {
    display: none;
  }
}

/* ================== HIGHLIGHT FLASH (scroll-back after edit) ================== */
@keyframes highlight-flash {
    0%   { box-shadow: 0 0 0 4px rgba(13, 110, 253, 0.75); }
    60%  { box-shadow: 0 0 0 7px rgba(13, 110, 253, 0.30); }
    100% { box-shadow: 0 0 0 0px rgba(13, 110, 253, 0.00); }
}

.highlight-flash {
    animation: highlight-flash 2s ease-out forwards;
}

/* ================== ROUND TRIP PREVIEW CARD ================== */
#round_trip_preview_container .preview-outer-card {
    border: 2px solid #198754 !important;
}

#round_trip_preview_container .preview-outer-card > .card-header {
    background-color: rgba(25, 135, 84, 0.08) !important;
    color: #198754 !important;
    border-bottom-color: rgba(25, 135, 84, 0.2) !important;
}

/* Edit preview card (amber/yellow) */
#round_trip_preview_container .preview-edit-card {
    border: 2px solid #ffc107 !important;
}

#round_trip_preview_container .preview-edit-card > .card-header {
    background-color: rgba(255, 193, 7, 0.10) !important;
    color: #856404 !important;
    border-bottom-color: rgba(255, 193, 7, 0.3) !important;
}

/* ================== TRIP SEARCH FILTER ================== */
#trips_search_container .input-group-text {
    background-color: var(--card-bg);
    border-color: var(--border-color);
    color: var(--text-secondary);
}

#trips_search_info {
    min-height: 1.2em;
}

