/*
  Connected demo operations: native drag/drop lanes, accessible status/reorder
  controls, live feedback and the scoped demo reset panel.

  Unlayered on purpose: these are scoped overrides/companions for the existing
  admin_draft.css presentation and must win over its layered defaults.
*/

#demo-operations {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm, 0.75rem);
  min-width: 0;
}

#demo-operations[aria-busy="true"] {
  cursor: progress;
}

.demo-ops-feedback {
  padding: 0.75rem 0.9rem;
  border: 1px solid var(--floral-line);
  border-left: 3px solid var(--floral-ink);
  border-radius: var(--floral-control-radius, 0.375rem);
  background: var(--floral-sage-paper);
  color: var(--floral-ink);
  font-size: 0.8rem;
  line-height: 1.6;
}

.demo-ops-feedback[hidden] {
  display: none;
}

.demo-ops-feedback--error {
  border-color: var(--floral-danger-line);
  border-left-color: var(--floral-danger);
  background: var(--floral-rose-paper);
  color: var(--floral-danger);
}

/* Lanes and cards --------------------------------------------------------- */

#demo-operations .demo-ops-lane {
  transition: background-color 150ms ease, border-color 150ms ease, box-shadow 150ms ease;
}

#demo-operations .demo-ops-lane.is-dragover {
  border-color: var(--floral-rose-line);
  background: var(--floral-blush);
  box-shadow: inset 0 0 0 2px var(--floral-rose-line);
}

#demo-operations .demo-ops-lane-body {
  display: flex;
  flex-direction: column;
  min-height: 3rem;
}

#demo-operations .demo-ops-card {
  cursor: grab;
  transition: opacity 150ms ease, border-color 150ms ease, box-shadow 150ms ease;
}

#demo-operations .demo-ops-card[draggable="false"] {
  cursor: default;
}

#demo-operations .demo-ops-card.is-dragging {
  opacity: 0.45;
  border-color: var(--floral-rose-line);
}

#demo-operations .demo-ops-card:focus-within {
  border-color: var(--floral-rose-line);
}

.demo-ops-lane-empty {
  margin: 0 !important;
  padding: 0.85rem;
  border: 1px dashed var(--floral-line);
  border-radius: var(--floral-control-radius, 0.375rem);
  color: var(--floral-muted);
  font-size: 0.75rem;
  text-align: center;
}

.demo-ops-lane-empty[hidden] {
  display: none;
}

.demo-ops-card-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.6rem;
}

.demo-ops-balance {
  color: var(--floral-muted);
  font-size: 0.72rem;
  font-variant-numeric: tabular-nums;
}

/* Controls ---------------------------------------------------------------- */

#demo-operations .demo-ops-controls,
.demo-ops-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.demo-ops-control {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-width: 0;
  color: var(--floral-muted);
  font-size: 0.65rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.demo-ops-control select {
  min-height: 2.75rem;
  max-width: 100%;
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--floral-line);
  border-radius: var(--floral-control-radius, 0.375rem);
  background: var(--floral-paper);
  color: var(--floral-ink);
  font-size: 1rem;
  line-height: 1.2;
}

.demo-ops-reorder {
  display: flex;
  gap: 0.375rem;
}

.demo-ops-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.75rem;
  min-height: 2.75rem;
  padding: 0.6rem 0.85rem;
  border: 1px solid var(--floral-line);
  border-radius: var(--floral-control-radius, 0.375rem);
  background: var(--floral-paper);
  color: var(--floral-ink);
  font-size: 0.8rem;
  line-height: 1.2;
  text-align: center;
  cursor: pointer;
}

.demo-ops-button:hover:not(:disabled) {
  background: var(--floral-leaf);
}

.demo-ops-button:disabled {
  opacity: 0.55;
  cursor: default;
}

.demo-ops-button--primary {
  border-color: var(--floral-ink);
  background: var(--floral-ink);
  color: var(--floral-paper);
}

.demo-ops-button--primary:hover:not(:disabled) {
  background: var(--floral-olive-hover);
}

.demo-ops-button--danger {
  border-color: var(--floral-danger-line);
  background: var(--floral-rose-paper);
  color: var(--floral-danger);
}

.demo-ops-button--danger:hover:not(:disabled) {
  background: var(--floral-blush);
}

.demo-ops-reorder-button {
  padding-inline: 0.5rem;
  font-size: 1rem;
}

#demo-operations .demo-ops-controls :focus-visible,
.demo-ops-button:focus-visible,
.demo-ops-control select:focus-visible,
.demo-ops-reset summary:focus-visible {
  outline: 2px solid var(--floral-rose);
  outline-offset: 3px;
}

/* Detail actions and rows ------------------------------------------------ */

.demo-ops-actions-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.demo-ops-next-step {
  margin-top: 0.5rem !important;
  color: var(--floral-muted);
  font-size: 0.8rem;
  line-height: 1.7;
}

.demo-ops-items {
  margin: 1.1rem 0 0;
  padding: 0;
  list-style: none;
  border-top: 1px solid var(--floral-line);
}

.demo-ops-items li {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.7rem 0;
  border-bottom: 1px solid var(--floral-line);
  font-size: 0.8rem;
}

.demo-ops-items li span {
  display: grid;
  gap: 0.15rem;
  min-width: 0;
}

.demo-ops-items li small {
  color: var(--floral-muted);
  font-size: 0.7rem;
}

.demo-ops-items li > strong {
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.demo-ops-row-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.4rem;
}

.demo-ops-queues {
  align-items: start;
}

.demo-ops-history {
  margin-top: 1rem;
}

/* Protected reset --------------------------------------------------------- */

.demo-ops-reset-wrap {
  margin-top: 1rem;
}

.demo-ops-reset {
  padding: 0.75rem 1rem;
  border: 1px solid var(--floral-rose-line);
  border-radius: var(--floral-control-radius, 0.375rem);
  background: var(--floral-rose-paper);
}

.demo-ops-reset summary {
  display: flex;
  align-items: center;
  min-height: 2.75rem;
  color: var(--floral-danger);
  font-size: 0.8rem;
  cursor: pointer;
}

.demo-ops-reset p {
  margin-top: 0.6rem !important;
  color: var(--floral-muted);
  font-size: 0.78rem;
  line-height: 1.7;
}

.demo-ops-reset-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

/* New-order guidance ------------------------------------------------------ */

.demo-ops-new > h2 {
  margin-top: 0.5rem;
}

.demo-ops-new-list {
  margin: 1rem 0 0;
  padding-left: 1.1rem;
  color: var(--floral-muted);
  font-size: 0.8rem;
  line-height: 1.8;
}

.demo-ops-new-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
  margin-top: 1.25rem;
}

.demo-ops-recent {
  margin: 1rem 0 0;
  padding: 0;
  list-style: none;
}

.demo-ops-recent li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 0;
  border-bottom: 1px solid var(--floral-line);
}

.demo-ops-recent li span:first-child {
  display: grid;
  gap: 0.15rem;
  min-width: 0;
}

.demo-ops-recent small {
  color: var(--floral-muted);
  font-size: 0.72rem;
}

@media (max-width: 900px) {
  #demo-operations .demo-ops-board {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 600px) {
  .ad-delivery-row.demo-ops-row {
    flex-wrap: wrap;
    gap: 0.75rem;
    padding: 1.1rem;
  }

  .demo-ops-row-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .demo-ops-row-actions .demo-ops-button {
    flex: 1 1 auto;
  }

  .demo-ops-controls {
    align-items: stretch;
  }

  .demo-ops-control {
    flex: 1 1 8rem;
  }

  .demo-ops-reorder {
    flex: 0 0 auto;
  }

  .demo-ops-recent li {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .demo-ops-recent li > .ad-text-link {
    grid-column: 1 / -1;
  }
}

@media (prefers-reduced-motion: reduce) {
  #demo-operations .demo-ops-lane,
  #demo-operations .demo-ops-card {
    transition: none;
  }
}

/* --- Atelier branch context --------------------------------------------- */
/* A quiet boutique header, not a technical parameter: the selected branch and
   its demo address are the first thing an operator reads on every view. */
body.demo-operations-page .ops-branch-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
  min-width: 0;
  padding: var(--space-sm) var(--space-md);
  border: 1px solid var(--floral-line);
  border-left: 3px solid var(--floral-rose-line);
  border-radius: 8px;
  background: var(--floral-sage-paper);
}

body.demo-operations-page .ops-branch-bar__context {
  display: grid;
  gap: 0.15rem;
  min-width: 0;
}

body.demo-operations-page .ops-branch-bar__label {
  margin: 0;
  color: var(--floral-muted);
  font-family: var(--floral-sans);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

body.demo-operations-page .ops-branch-bar__name {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0;
  color: var(--floral-ink);
  font-family: var(--floral-serif);
  font-size: clamp(1.1rem, 1.6vw, 1.35rem);
  line-height: 1.2;
  overflow-wrap: anywhere;
}

body.demo-operations-page .ops-branch-bar__dot {
  width: 0.5rem;
  height: 0.5rem;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--floral-rose);
}

body.demo-operations-page .ops-branch-bar__meta {
  margin: 0;
  color: var(--floral-muted);
  font-family: var(--floral-sans);
  font-size: 0.8rem;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

body.demo-operations-page .ops-branch-form {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.5rem 0.75rem;
  min-width: 0;
  margin: 0;
}

body.demo-operations-page .ops-branch-form__label {
  width: 100%;
  color: var(--floral-muted);
  font-family: var(--floral-sans);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  line-height: 1.4;
  text-transform: uppercase;
}

body.demo-operations-page .ops-branch-form__controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
}

body.demo-operations-page .ops-branch-form__select {
  min-height: 44px;
  min-width: 12rem;
  max-width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--floral-line);
  border-radius: var(--floral-control-radius);
  background: var(--floral-paper);
  color: var(--floral-ink);
  font-family: var(--floral-sans);
  font-size: 1rem;
  line-height: 1.3;
}

body.demo-operations-page .ops-branch-form__button {
  min-height: 44px;
  padding: 0.55rem 1.1rem;
  border: 1px solid var(--floral-ink);
  border-radius: var(--floral-control-radius);
  background: var(--floral-ink);
  color: var(--floral-paper);
  font-family: var(--floral-sans);
  font-size: 0.9rem;
  cursor: pointer;
}

body.demo-operations-page .ops-branch-form__button:hover {
  background: var(--floral-olive-hover);
}

body.demo-operations-page .ops-branch-form__select:focus-visible,
body.demo-operations-page .ops-branch-form__button:focus-visible {
  outline: 2px solid var(--floral-rose);
  outline-offset: 2px;
}

/* The order's own branch, shown on tables, cards and delivery rows. */
body.demo-operations-page .ops-branch-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin: 0;
  color: var(--floral-rose);
  font-family: var(--floral-sans);
  font-size: 0.72rem;
  line-height: 1.5;
}

body.demo-operations-page .ops-branch-chip::before {
  content: "✳";
  font-size: 0.85em;
  line-height: 1;
}

@media (max-width: 600px) {
  body.demo-operations-page .ops-branch-bar {
    align-items: stretch;
    flex-direction: column;
    padding: var(--space-sm);
  }

  body.demo-operations-page .ops-branch-form,
  body.demo-operations-page .ops-branch-form__controls,
  body.demo-operations-page .ops-branch-form__select {
    width: 100%;
  }

  body.demo-operations-page .ops-branch-form__button {
    flex: 1 1 auto;
  }
}
