/*
 * DarziOS PWA — SCR-ORD-08 Order Delivery & Final Handover styles
 * (production, Doc 7 §6.4).
 *
 * Owner rule (strict): every color, spacing value, radius, shadow and
 * duration in this file resolves to a custom property in
 * css/design-tokens.css. Zero raw color literals. Control patterns
 * (buttons, .input, .field, tags) come from css/controls.css;
 * .sample-chip and .app-bar live in css/app.css.
 */

/* ---------------------------------------------------------------- page */
.dlv {
  max-width: 1160px;
  margin: 0 auto;
  padding: var(--space-6);
  display: grid;
  gap: var(--space-4);
}

.dlv__toolbar {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
}
.dlv__titles {
  display: grid;
  gap: var(--space-1);
  min-width: 0;
}
.dlv__title {
  margin: 0;
  font-size: var(--text-2xl);
  font-weight: var(--weight-semibold);
}
.dlv__ctx {
  margin: 0;
  font-size: var(--text-sm);
  color: var(--chalk-muted);
  font-variant-numeric: tabular-nums;
}
.dlv__toolbar .sample-chip {
  margin-left: auto;
}

/* --------------------------------------- offline restriction banner
 * Doc 7 §6.4: delivery that moves money is STRICTLY BLOCKED offline.
 * Always visible on this screen (demo states what would execute). */
.dlv-offline {
  margin: 0;
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--status-warning);
  border-radius: var(--radius-md);
  background: var(--warning-faint);
  color: var(--status-warning);
  font-size: var(--text-sm);
  line-height: 1.55;
}
.dlv-offline strong {
  font-weight: var(--weight-bold);
}

/* ---------------------------------------------------------- body grid */
/* Main column (checklist / item / financials) + sticky settlement
   column (tender, credit policy, remarks, complete). Collapses to a
   single column on counter phones; the sticky side stops sticking
   below 900px so it scrolls naturally. */
.dlv__body {
  display: grid;
  grid-template-columns: 3fr 2fr;
  gap: var(--space-4);
  align-items: start;
}
.dlv-main {
  display: grid;
  gap: var(--space-4);
  min-width: 0;
}
.dlv-side {
  display: grid;
  gap: var(--space-4);
  position: sticky;
  top: var(--space-6);
  min-width: 0;
}

/* -------------------------------------------------------------- cards */
.dlv-card {
  background: var(--surface-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: var(--space-4);
  display: grid;
  gap: var(--space-3);
}
.dlv-card__title {
  margin: 0;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
}
.dlv-card__sub {
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--chalk-muted);
  background: var(--neutral-faint);
  padding: 2px var(--space-2);
  border-radius: var(--radius-full);
}
.dlv-card__foot {
  margin: 0;
  padding-top: var(--space-3);
  border-top: 1px solid var(--border-subtle);
  font-size: var(--text-sm);
  color: var(--chalk-muted);
}
.dlv-card--success {
  border-color: var(--status-success);
  background: var(--success-faint);
}

/* ------------------------------------------------------------ checklist */
.dlv-checklist {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: var(--space-2);
}
.dlv-check {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-md);
}
.dlv-check__mark {
  flex: none;
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-full);
  background: var(--neutral-faint);
  color: var(--status-neutral);
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
}
.dlv-check--done .dlv-check__mark {
  background: var(--success-faint);
  color: var(--status-success);
}

/* ------------------------------------------------------------- facts */
.dlv-facts {
  margin: 0;
  display: grid;
  gap: var(--space-3);
}
.dlv-facts__row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--space-3);
}
.dlv-facts__k {
  font-size: var(--text-sm);
  color: var(--chalk-muted);
}
.dlv-facts__v {
  margin: 0;
  font-size: var(--text-md);
  font-weight: var(--weight-semibold);
  font-variant-numeric: tabular-nums;
  text-align: right;
}
.dlv-facts__v--due {
  color: var(--status-warning);
  font-weight: var(--weight-bold);
}

/* ----------------------------------------------------- tender segment */
.dlv-seg {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-2);
}
.dlv-seg__btn {
  min-height: var(--touch-min);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: var(--surface-elevated);
  color: var(--chalk-white);
  font-family: var(--font-ui);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  cursor: pointer;
  transition:
    background-color var(--duration-fast) var(--ease-standard),
    color var(--duration-fast) var(--ease-standard),
    border-color var(--duration-fast) var(--ease-standard);
}
.dlv-seg__btn--active {
  background: var(--brand-brass);
  border-color: var(--brand-brass);
  color: var(--on-brass);
}

/* ---------------------------------------------------- collection state */
.dlv-colstatus {
  margin: 0;
  min-height: 3em;
  font-size: var(--text-sm);
  line-height: 1.55;
}
.dlv-colstatus--ok { color: var(--status-success); }
.dlv-colstatus--warn { color: var(--status-warning); }
.dlv-colstatus--err { color: var(--status-danger); }

/* -------------------------------------------------- credit policy toggle */
.dlv-toggle {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  font-size: var(--text-sm);
  line-height: 1.55;
  cursor: pointer;
}
.dlv-toggle input[type='checkbox'] {
  flex: none;
  width: 22px;
  height: 22px;
  margin-top: 2px;
  accent-color: var(--brand-brass);
  cursor: pointer;
}

/* ------------------------------------------------------ text input area */
/* .input (controls.css) provides the base; the textarea variant adds
   its own height/resize rules. */
.input--area {
  min-height: 0;
  padding: var(--space-2) var(--space-3);
  line-height: 1.55;
  resize: vertical;
}

/* ------------------------------------------------------ completion card */
.dlv-by {
  margin: 0;
  font-size: var(--text-sm);
  color: var(--chalk-muted);
}
.dlv-note {
  margin: 0;
  font-size: var(--text-sm);
  line-height: 1.55;
  color: var(--chalk-muted);
}
.dlv-done__msg {
  margin: 0;
  font-size: var(--text-md);
  line-height: 1.55;
}

/* ------------------------------------------------- post-delivery actions */
.dlv-post {
  display: grid;
  gap: var(--space-2);
}

/* --------------------------------------------------------- responsive */
@media (max-width: 900px) {
  .dlv {
    padding: var(--space-4);
  }
  .dlv__body {
    grid-template-columns: 1fr;
  }
  .dlv-side {
    position: static;
  }
}

/* -------------------------------------------------- mobile CTA bar
 * Doc 7 §16 smartphone ergonomics: the primary handover action
 * lives in a bottom-fixed, thumb-reachable bar. Hidden by default;
 * this @720 block activates it. Placed AFTER the @900 block so the
 * later declarations win where both media queries match. */
.dlv-mobilebar {
  display: none;
}

@media (max-width: 720px) {
  .dlv {
    padding-bottom: calc(
      var(--space-6) + var(--touch-min) + var(--space-3) * 2 + var(--space-4)
      + env(safe-area-inset-bottom, 0px)
    );
  }
  .dlv-mobilebar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 35;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4)
      calc(var(--space-3) + env(safe-area-inset-bottom, 0px));
    background: var(--surface-card);
    border-top: 1px solid var(--border-subtle);
    box-shadow: 0 calc(-1 * var(--space-1)) var(--space-3)
      color-mix(in oklab, var(--chalk-white) 14%, transparent);
  }
  .dlv-mobilebar__bal {
    margin: 0;
    font-size: var(--text-sm);
    font-variant-numeric: tabular-nums;
  }
  .dlv-mobilebar .btn {
    flex-shrink: 0;
  }
  /* Lift the floating theme switch above the fixed CTA bar. */
  .theme-toggle {
    bottom: calc(var(--touch-min) + var(--space-3) * 2 + var(--space-4)
      + env(safe-area-inset-bottom, 0px));
  }
}
