@import url("../assets/app.css");

/* =========================================================================
   Interactive prototype additions: auth, dialogs, charts, helpers.
   ========================================================================= */

/* --- Auth ---------------------------------------------------------------- */

.auth {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--paper);
}

.auth-card {
  width: min(400px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow-2);
  padding: 28px;
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 22px;
}

.auth-brand svg {
  width: 42px;
  height: 42px;
  color: var(--ink);
}

.auth-brand b {
  display: block;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.auth-brand span {
  display: block;
  font-size: 12px;
  color: var(--ink-3);
}

.auth h1 {
  margin: 0 0 4px;
  font-family: var(--font-display);
  font-size: 30px;
  font-weight: 600;
  line-height: 1.05;
}

.auth p.auth-lede {
  margin: 0 0 20px;
  font-size: 12.5px;
  color: var(--ink-3);
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.auth-error {
  display: none;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--madder-soft);
  color: var(--madder);
  font-size: 12.5px;
  font-weight: 500;
}

.auth-error.is-on {
  display: block;
}

.auth-hint {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--line-soft);
  font-size: 11.5px;
  color: var(--ink-3);
  line-height: 1.5;
}

.auth-hint code {
  font-size: 11px;
}

.auth-foot {
  margin-top: 18px;
  text-align: center;
  font-size: 11px;
  color: var(--ink-3);
}

.mfa-boxes {
  display: flex;
  gap: 8px;
  margin: 4px 0 6px;
}

.mfa-boxes input {
  width: 100%;
  height: 52px;
  text-align: center;
  font-size: 22px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-2);
}

.mfa-boxes input:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 1px;
  background: var(--surface);
}

/* --- Dialogs and sheets -------------------------------------------------- */

.dialog {
  position: fixed;
  z-index: 52;
  left: 50%;
  top: 50%;
  translate: -50% -50%;
  width: min(620px, calc(100vw - 40px));
  max-height: min(760px, calc(100dvh - 64px));
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow-2);
  visibility: hidden;
  opacity: 0;
  scale: 0.98;
  transition: opacity 0.16s var(--ease), scale 0.16s var(--ease),
    visibility 0s linear 0.16s;
}

.dialog[data-open="true"] {
  visibility: visible;
  opacity: 1;
  scale: 1;
  transition: opacity 0.16s var(--ease), scale 0.16s var(--ease), visibility 0s;
}

.side-sheet {
  position: fixed;
  z-index: 52;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(440px, 100vw);
  background: var(--surface);
  border-left: 1px solid var(--line);
  box-shadow: var(--shadow-2);
  display: flex;
  flex-direction: column;
  transform: translateX(101%);
  transition: transform 0.22s var(--ease);
  overscroll-behavior: contain;
}

.side-sheet[data-open="true"] {
  transform: none;
}

.sheet-body {
  padding: 14px 16px;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.sheet-foot {
  padding: 10px 16px calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.sheet-head {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--line-soft);
}

.sheet-head h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
}

.sheet-head p {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--ink-3);
}

.sheet-head .icon-btn {
  margin-left: auto;
  flex: none;
}

@media (max-width: 820px) {
  .dialog {
    top: auto;
    bottom: 0;
    translate: -50% 0;
    width: 100vw;
    max-height: 90dvh;
    border-radius: 18px 18px 0 0;
    border-left: 0;
    border-right: 0;
    border-bottom: 0;
    scale: 1;
    padding-bottom: env(safe-area-inset-bottom);
  }
  .side-sheet {
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    width: auto;
    height: auto;
    max-height: 88dvh;
    border-left: 0;
    border-top: 1px solid var(--line);
    border-radius: 18px 18px 0 0;
    transform: translateY(101%);
  }
  .side-sheet[data-open="true"] {
    transform: none;
  }
}

/* --- App-specific layout ------------------------------------------------- */

.page {
  width: min(100%, 1560px);
}

.main > .page {
  padding-bottom: 48px;
}

.workspace.has-selection .pane--detail {
  display: flex;
}

@media (max-width: 820px) {
  .workspace.has-selection .pane--list {
    display: none;
  }
  .workspace.has-selection .pane--detail {
    display: flex;
    position: static;
    inset: auto;
  }
  .workspace {
    height: calc(100dvh - 0px);
  }
  .detail-back {
    display: flex;
  }
}

/* --- Analytics ----------------------------------------------------------- */

.bars {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  height: 120px;
  margin-top: 10px;
}

.bars span {
  flex: 1;
  min-width: 3px;
  background: var(--woad);
  opacity: 0.35;
  border-radius: 2px 2px 0 0;
}

.bars span.big {
  opacity: 0.8;
}

.chart-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

@media (max-width: 820px) {
  .chart-grid {
    grid-template-columns: 1fr;
  }
}

/* --- Small helpers ------------------------------------------------------- */

.muted {
  color: var(--ink-3);
}

.small {
  font-size: 12px;
}

.nowrap {
  white-space: nowrap;
}

.mt-8 {
  margin-top: 8px;
}
.mt-12 {
  margin-top: 12px;
}
.mt-16 {
  margin-top: 16px;
}

.row-between {
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: space-between;
}

.stack-12 {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

@media (max-width: 820px) {
  .grid-2,
  .grid-3 {
    grid-template-columns: 1fr;
  }
}

.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 8px;
}

.photo-grid .swatch {
  height: 130px;
  aspect-ratio: auto;
}

.check-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.check-list .check-row {
  min-height: 40px;
  padding: 0 6px;
  border-radius: 6px;
}

.check-list .check-row:hover {
  background: var(--surface-2);
}

.kpi-inline {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
}

.kpi-inline > div {
  min-width: 120px;
}

.kpi-inline b {
  display: block;
  font-size: 20px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.kpi-inline span {
  font-size: 11.5px;
  color: var(--ink-3);
}

.timeline {
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-size: 12.5px;
}

.timeline > div {
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr);
  gap: 10px;
}

.timeline time {
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}

.hint-list {
  margin: 0;
  padding-left: 18px;
  font-size: 12px;
  color: var(--ink-3);
}

.hint-list li + li {
  margin-top: 3px;
}

/* Role badge in the user sheet */
.role-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.role-option {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 10px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.role-option:hover {
  background: var(--surface-2);
}

.role-option[aria-current="true"] {
  border-color: var(--woad-line);
  background: var(--woad-soft);
}

.role-option b {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
}

.role-option span {
  display: block;
  font-size: 11.5px;
  color: var(--ink-3);
}

@media (max-width: 820px) {
  /* The sticky head must not trap the fixed action bar in its stacking
     context, or the bottom nav paints over it. */
  .detail-head {
    z-index: auto;
  }
}

@media (max-width: 820px) {
  /* A detail push owns the screen: the tab bar steps aside for the action bar. */
  body.has-detail .mobile-nav {
    display: none;
  }
  body.has-detail .detail-body {
    padding-bottom: 104px;
  }
}

.inspect-scrim {
  position: fixed;
  inset: 0;
  z-index: 41;
  background: rgba(14, 18, 19, 0.42);
}

.more-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  height: 52px;
  padding: 0 14px;
  border: 0;
  border-bottom: 1px solid var(--line-soft);
  background: transparent;
  color: var(--ink);
  font-family: inherit;
  font-size: 13.5px;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}

.more-row:last-child {
  border-bottom: 0;
}

.more-row > svg {
  width: 18px;
  height: 18px;
  color: var(--ink-3);
  flex: none;
}

.palette-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 6px;
  color: var(--ink);
  font-size: 13px;
  text-decoration: none;
}

.palette-row:hover {
  background: var(--surface-2);
}

.palette-row small {
  margin-left: auto;
  color: var(--ink-3);
  font-size: 11.5px;
}

.palette-row b {
  color: var(--ink-3);
  font-size: 12px;
  font-weight: 500;
}

/* =========================================================================
   Custom select (shadcn Select pattern, not the native popup)
   ========================================================================= */

.cs {
  position: relative;
  width: 100%;
}

.cs-native {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  opacity: 0;
  pointer-events: none;
}

.cs-trigger {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 36px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: var(--r-1);
  background: var(--surface);
  color: var(--ink);
  font-size: 13px;
  text-align: left;
  cursor: pointer;
}

.cs-trigger:hover {
  border-color: var(--woad-line);
}

.cs-trigger[aria-expanded="true"] {
  border-color: var(--woad);
  outline: 2px solid color-mix(in oklab, var(--woad) 25%, transparent);
}

.cs-trigger span {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cs-trigger svg {
  width: 15px;
  height: 15px;
  flex: none;
  color: var(--ink-3);
  transform: rotate(90deg);
  transition: transform 0.16s var(--ease);
}

.cs-trigger[aria-expanded="true"] svg {
  transform: rotate(-90deg);
}

.cs-menu {
  position: absolute;
  z-index: 70;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  max-height: 280px;
  overflow-y: auto;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: var(--r-1);
  background: var(--surface);
  box-shadow: var(--shadow-2);
  overscroll-behavior: contain;
}

.cs-menu[hidden] {
  display: none !important;
}

.cs-option {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 34px;
  padding: 7px 8px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--ink);
  font-size: 13px;
  text-align: left;
  cursor: pointer;
}

.cs-option:hover,
.cs-option.is-active {
  background: var(--surface-2);
}

.cs-option[aria-selected="true"] {
  background: var(--woad-soft);
  color: var(--woad);
  font-weight: 600;
}

.cs-option svg {
  width: 14px;
  height: 14px;
  margin-left: auto;
}

/* =========================================================================
   New order: constrained two-column form with a sticky summary
   ========================================================================= */

.page--narrow {
  width: min(100%, 1180px);
}

.order-new {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 20px;
  align-items: start;
}

.order-main {
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-width: 0;
}

.order-side {
  position: sticky;
  top: calc(var(--topbar) + 18px);
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.customer-card {
  display: flex;
  align-items: center;
  gap: 12px;
}

.customer-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.customer-main a {
  font-weight: 600;
  color: var(--ink);
  text-decoration: none;
}

.customer-main a:hover {
  text-decoration: underline;
}

.customer-main span {
  font-size: 12px;
  color: var(--ink-3);
}

.qty {
  display: inline-flex;
  align-items: center;
  gap: 2px;
}

.qty .icon-btn {
  width: 30px;
  height: 30px;
}

.qty b {
  min-width: 22px;
  text-align: center;
  font-size: 13px;
}

.oline {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) auto 88px 32px;
  gap: 12px;
  align-items: center;
  padding: 10px 14px;
  border-top: 1px solid var(--line-soft);
}

.oline:first-child {
  border-top: 0;
}

.oline .icon-btn {
  width: 32px;
  height: 32px;
}

.oline .o-sum {
  text-align: right;
  white-space: nowrap;
}

.order-bar {
  display: none;
}

@media (max-width: 1080px) {
  .order-new {
    grid-template-columns: 1fr;
  }
  .order-side {
    position: static;
  }
}

@media (max-width: 820px) {
  .order-side {
    display: none;
  }
  .order-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 35;
    padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
    background: var(--surface);
    border-top: 1px solid var(--line);
  }
  .order-bar > div {
    display: flex;
    align-items: baseline;
    gap: 6px;
  }
  .order-bar .btn {
    height: 44px;
  }
  .page--narrow {
    padding-bottom: 96px;
  }
  .oline {
    grid-template-columns: 36px minmax(0, 1fr) auto;
    grid-template-areas:
      "img main sum"
      "img qty remove";
    row-gap: 6px;
    column-gap: 10px;
  }
  .oline .o-img {
    grid-area: img;
    align-self: center;
  }
  .oline .o-main {
    grid-area: main;
  }
  .oline .o-qty {
    grid-area: qty;
  }
  .oline .o-sum {
    grid-area: sum;
    justify-self: end;
  }
  .oline .o-remove {
    grid-area: remove;
    justify-self: end;
  }
}

.form-narrow {
  width: min(100%, 920px);
}
