/*
 * The mini CRM window: four of the CRM's screens on one demo fleet (Calendar, Cars, Chats, Today). Drawn with the
 * CRM's own colours, plate chip and bars (tinted fill, 3px edge), so what the visitor plays with is what they will get.
 */
.win {
  --day-min: 3.5rem;
  --car-col: 11rem;
  --row: 2.75rem;
  --win-h: 27rem;
  position: relative;
  display: grid;
  grid-template-columns: 3.25rem minmax(0, 1fr);
  background: var(--app-bg);
  color: var(--app-text);
  border: 1px solid var(--app-border);
  border-radius: var(--r-window);
  box-shadow: var(--shadow-window);
  overflow: hidden;
  font-size: var(--size-small);
  line-height: var(--lh-small);
}
.win button {
  font-family: inherit;
}
.win :focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

/* Which status a thing is in: one pair of colours, read by bars, chips and the card's line. */
.win [data-s="booked"], .win [data-s="hold"] { --edge: var(--status-booked); --fill: var(--status-booked-bg); }
.win [data-s="active"], .win [data-s="free"] { --edge: var(--status-active); --fill: var(--status-active-bg); }
.win [data-s="due"] { --edge: var(--status-due); --fill: var(--status-due-bg); }
.win [data-s="overdue"] { --edge: var(--status-overdue); --fill: var(--status-overdue-bg); }
.win [data-s="closed"] { --edge: var(--status-closed); --fill: var(--status-closed-bg); }
.win [data-s="service"] { --edge: var(--status-service); --fill: var(--status-service-bg); }

/* The rail of screens, as in the CRM: icons, the name on hover. */
.win-rail {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s-1);
  padding: var(--s-3) 0;
  border-right: 1px solid var(--app-border);
  background: var(--app-subtle);
}
.win-rail button {
  position: relative;
  display: grid;
  place-items: center;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  border: 0;
  border-radius: var(--r-app-control);
  background: transparent;
  color: var(--app-text-2);
  cursor: pointer;
  transition:
    background var(--duration) var(--ease),
    color var(--duration) var(--ease);
}
.win-rail button:hover {
  color: var(--app-text);
  background: var(--app-bg);
}
.win-rail button[aria-selected="true"] {
  background: var(--app-bg);
  color: var(--accent);
  box-shadow: 0 0 0 1px var(--app-border);
}
.win-rail button::after {
  content: attr(data-name);
  position: absolute;
  left: calc(100% + 0.5rem);
  z-index: 6;
  padding: var(--s-1) var(--s-2);
  border-radius: var(--r-chip);
  background: var(--app-text);
  color: var(--app-bg);
  font-size: var(--size-meta);
  line-height: var(--lh-meta);
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--duration) var(--ease);
}
.win-rail button:hover::after {
  opacity: 1;
}
.win-rail button > i {
  position: absolute;
  top: 0.25rem;
  right: 0.25rem;
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 2px var(--app-subtle);
}
.win-rail svg,
.win-icon {
  width: 1.125rem;
  height: 1.125rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.win-main {
  min-width: 0;
  height: var(--win-h);
  display: flex;
  flex-direction: column;
}
.win-view {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.win-view[hidden] {
  display: none;
}

/* On a phone the rail turns into a bar at the window's foot, as the CRM's own bar does. */
@media (width < 48rem) {
  .win {
    --day-min: 2.75rem;
    --car-col: 7.25rem;
    --win-h: 29rem;
    grid-template-columns: minmax(0, 1fr);
  }
  .win-rail {
    order: 2;
    flex-direction: row;
    justify-content: space-around;
    padding: var(--s-1) 0;
    border-right: 0;
    border-top: 1px solid var(--app-border);
  }
  .win-rail button {
    width: 3rem;
    height: 2.5rem;
  }
  .win-rail button::after {
    display: none;
  }
}

/* A screen's top row: its title, then what it needs. */
.win-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s-2) var(--s-3);
  min-height: 3.5rem;
  padding: var(--s-3) var(--s-4);
  border-bottom: 1px solid var(--app-border);
}
.win-title {
  font-weight: 600;
  font-size: var(--size-body);
}
.win-search {
  width: 12rem;
  max-width: 100%;
  height: 2rem;
  padding: 0 var(--s-3);
  border: 1px solid var(--app-border);
  border-radius: var(--r-app-control);
  background: var(--app-bg);
  color: var(--app-text);
  font: 400 var(--size-small) / 1 var(--font-text);
}
.win-search::placeholder {
  color: var(--app-text-3);
}
.win-end {
  margin-left: auto;
}
@media (width < 48rem) {
  .win-end {
    margin-left: 0;
  }
}
.win-count {
  color: var(--app-text-2);
  font-variant-numeric: tabular-nums;
}

/* Chips pressed: one of a short list. */
.win-models {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-1);
}
.win-models button,
.win-btn {
  height: 1.75rem;
  padding: 0 var(--s-3);
  border-radius: var(--r-app-control);
  border: 1px solid var(--app-border);
  background: var(--app-bg);
  color: var(--app-text-2);
  font: 500 var(--size-small) / 1 var(--font-text);
  cursor: pointer;
  transition:
    background var(--duration) var(--ease),
    color var(--duration) var(--ease);
}
.win-models button:hover,
.win-btn:hover {
  color: var(--app-text);
}
.win-models button[aria-pressed="true"] {
  background: var(--accent-bg);
  border-color: var(--accent);
  color: var(--accent-strong);
}
.win-btn-main {
  height: 2rem;
  border-color: var(--accent);
  background: var(--accent);
  color: var(--on-accent);
}
.win-btn-main:hover {
  background: var(--accent-strong);
  color: var(--on-accent);
}
.win-btn:disabled {
  opacity: 0.5;
  cursor: default;
}
.win-range {
  color: var(--app-text-2);
  font-variant-numeric: tabular-nums;
}
.win-range b {
  color: var(--app-text);
  font-weight: 600;
}
/* The answer: green when something is free, quiet when nothing is. */
.win-answer {
  display: inline-flex;
  align-items: center;
  height: 1.75rem;
  padding: 0 var(--s-3);
  border-radius: var(--r-chip);
  background: var(--status-active-bg);
  color: var(--status-active-ink);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.win-answer[data-none] {
  background: var(--status-closed-bg);
  color: var(--app-text-2);
}

/* A status as a small chip: tint and edge, words in the text colour. */
.win-chip {
  display: inline-flex;
  align-items: center;
  height: 1.375rem;
  padding: 0 var(--s-2);
  border-left: 3px solid var(--edge);
  border-radius: var(--r-chip);
  background: var(--fill);
  font-size: var(--size-meta);
  font-weight: 500;
  white-space: nowrap;
}

/* ---- Calendar ---- */
.win-scroll {
  position: relative;
  flex: 1;
  min-height: 0;
  container-type: inline-size;
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
}
.win-grid {
  /* The days fill the window; narrower than the minimum, the calendar scrolls. */
  --day: max(var(--day-min), calc((100cqw - var(--car-col)) / 14));
  position: relative;
  width: calc(var(--car-col) + var(--day) * 14);
}
.win-row {
  position: relative;
  display: flex;
  height: var(--row);
  border-bottom: 1px solid var(--app-border);
}
.win-row:last-child {
  border-bottom: 0;
}
/* Dim what a row holds, not the row: an opacity on the row would lift the band and the now line over the car column. */
.win-row[data-busy] .win-car > *,
.win-row[data-busy] .win-bar {
  opacity: 0.4;
}
.win-row[data-other] .win-car > *,
.win-row[data-other] .win-bar {
  opacity: 0.3;
}
.win-car {
  position: sticky;
  left: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 2px;
  flex: 0 0 var(--car-col);
  padding: 0 var(--s-3);
  background: var(--app-bg);
  border-right: 1px solid var(--app-border);
}
.win-car-model {
  font-size: var(--size-meta);
  line-height: var(--lh-meta);
  color: var(--app-text-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
.win-free {
  color: var(--status-active-ink);
  font-weight: 600;
}
.win-days {
  position: relative;
  flex: 1;
  display: flex;
}
.win-days > i {
  flex: 0 0 var(--day);
  border-right: 1px solid var(--app-border);
}
.win-days > i:last-child {
  border-right: 0;
}
.win-days > i[data-weekend] {
  background: var(--app-subtle);
}
.win-head {
  height: 2.75rem;
  position: sticky;
  top: 0;
  z-index: 3;
  background: var(--app-bg);
}
.win-head .win-car {
  font-size: var(--size-meta);
  color: var(--app-text-3);
}
.win-head .win-days > button {
  flex: 0 0 var(--day);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 0;
  border-right: 1px solid var(--app-border);
  background: var(--app-bg);
  color: var(--app-text-2);
  font: 400 var(--size-meta) / 1.2 var(--font-text);
  font-variant-numeric: tabular-nums;
  cursor: pointer;
}
.win-head .win-days > button:last-child {
  border-right: 0;
}
.win-head .win-days > button b {
  font-size: var(--size-small);
  font-weight: 600;
  color: var(--app-text);
}
.win-head .win-days > button[data-today],
.win-head .win-days > button[data-today] b {
  color: var(--accent);
}
.win-head .win-days > button:hover {
  background: var(--app-subtle);
}
.win-head .win-days > button[data-picked] {
  background: var(--accent-bg);
}
.win-band {
  position: absolute;
  top: 0;
  bottom: 0;
  z-index: 0;
  background: color-mix(in srgb, var(--accent-bg) 55%, transparent);
  border-inline: 1px solid var(--accent);
  pointer-events: none;
}
.win-now {
  position: absolute;
  top: 0;
  bottom: 0;
  z-index: 1;
  width: 2px;
  margin-left: -1px;
  background: var(--accent);
  pointer-events: none;
}
.win-bar {
  position: absolute;
  top: 0.4375rem;
  z-index: 1;
  height: 1.75rem;
  display: flex;
  align-items: center;
  padding: 0 var(--s-2);
  border: 0;
  border-left: 3px solid var(--edge);
  border-radius: var(--r-chip);
  background: var(--fill);
  color: var(--app-text);
  font: 500 var(--size-meta) / 1 var(--font-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
  text-align: left;
  transition: filter var(--duration) var(--ease);
}
.win-bar:hover {
  filter: brightness(0.96);
}
.win-bar[data-open] {
  box-shadow: 0 0 0 1px var(--edge);
}
.win-bar[data-s="hold"] {
  border: 1px dashed var(--edge);
  border-left: 3px dashed var(--edge);
}
.win-bar[data-s="closed"] {
  color: var(--app-text-2);
}
/* A booking just made: it draws itself in once. */
.win-bar[data-new] {
  animation: win-grow 400ms var(--ease);
  transform-origin: left;
}
@keyframes win-grow {
  from { transform: scaleX(0); }
}

/* ---- Lists (Cars, Today) ---- */
.win-list {
  flex: 1;
  min-height: 0;
  overflow: auto;
}
.win-table {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}
.win-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  height: 2.25rem;
  padding: 0 var(--s-4);
  background: var(--app-bg);
  border-bottom: 1px solid var(--app-border);
  color: var(--app-text-2);
  font-size: var(--size-meta);
  font-weight: 500;
  text-align: left;
  white-space: nowrap;
}
.win-table td {
  height: var(--row);
  padding: 0 var(--s-4);
  border-bottom: 1px solid var(--app-border);
  white-space: nowrap;
}
.win-table tbody tr {
  cursor: pointer;
}
.win-table tbody tr:hover td {
  background: var(--app-subtle);
}
.win-table tr[data-open] td {
  background: var(--accent-bg);
}
.win-table .win-2 {
  color: var(--app-text-2);
}
@media (width < 48rem) {
  .win-table .win-wide {
    display: none;
  }
  .win-table th,
  .win-table td {
    padding: 0 var(--s-3);
  }
}
.win-empty {
  padding: var(--s-8) var(--s-4);
  color: var(--app-text-2);
}

/* Today: a task is ticked done, the tick only marks it. */
.win-task {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  min-height: var(--row);
  padding: var(--s-2) var(--s-4);
  border-bottom: 1px solid var(--app-border);
  cursor: pointer;
}
.win-task:hover {
  background: var(--app-subtle);
}
.win-tick {
  flex: none;
  display: grid;
  place-items: center;
  width: 1.125rem;
  height: 1.125rem;
  padding: 0;
  border: 1.5px solid var(--app-text-3);
  border-radius: var(--r-chip);
  background: var(--app-bg);
  color: var(--on-accent);
  cursor: pointer;
}
.win-tick svg {
  width: 0.75rem;
  height: 0.75rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0;
}
.win-task[data-done] .win-tick {
  border-color: var(--accent);
  background: var(--accent);
}
.win-task[data-done] .win-tick svg {
  opacity: 1;
}
.win-task[data-done] .win-task-what {
  color: var(--app-text-3);
  text-decoration: line-through;
}
.win-task-time {
  flex: 0 0 2.75rem;
  color: var(--app-text-2);
  font-variant-numeric: tabular-nums;
}
.win-task-what {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.win-task-what b {
  font-weight: 600;
}

/* ---- Chats: the messenger's shape ---- */
.win-chats {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 13rem minmax(0, 1fr);
}
@media (width < 48rem) {
  .win-chats {
    grid-template-columns: minmax(0, 1fr);
  }
  .win-chat-list {
    display: none;
  }
}
.win-chat-list {
  overflow: auto;
  border-right: 1px solid var(--app-border);
}
.win-chat-item {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  width: 100%;
  padding: var(--s-3) var(--s-4);
  border: 0;
  border-bottom: 1px solid var(--app-border);
  background: var(--app-bg);
  color: var(--app-text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.win-chat-item:hover {
  background: var(--app-subtle);
}
.win-chat-item[aria-current="true"] {
  background: var(--accent-bg);
}
.win-chat-item > span:nth-child(2) {
  flex: 1;
  min-width: 0;
}
.win-chat-item b {
  display: block;
  font-weight: 600;
}
.win-chat-item small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--app-text-2);
  font-size: var(--size-meta);
}
.win-unread {
  flex: none;
  display: grid;
  place-items: center;
  min-width: 1.125rem;
  height: 1.125rem;
  padding: 0 0.25rem;
  border-radius: 0.5625rem;
  background: var(--accent);
  color: var(--on-accent);
  font-size: var(--size-meta);
  font-weight: 600;
}
/* A person's circle, the channel's badge on it. */
.win-face {
  position: relative;
  flex: none;
  display: grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  background: var(--app-subtle);
  color: var(--app-text-2);
  font-size: var(--size-meta);
  font-weight: 600;
}
.win-face > i {
  position: absolute;
  right: -2px;
  bottom: -2px;
  width: 0.75rem;
  height: 0.75rem;
  border-radius: 50%;
  border: 2px solid var(--app-bg);
  background: var(--channel);
}
.win-chat {
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.win-chat-head {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-3) var(--s-4);
  border-bottom: 1px solid var(--app-border);
}
.win-chat-head b {
  font-weight: 600;
}
.win-msgs {
  flex: 1;
  min-height: 0;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  padding: var(--s-4);
  background: var(--app-subtle);
}
.win-msg {
  max-width: 80%;
  padding: var(--s-2) var(--s-3);
  border-radius: var(--r-float);
  background: var(--app-bg);
  border: 1px solid var(--app-border);
  animation: win-in var(--duration) var(--ease);
}
.win-msg[data-out] {
  align-self: flex-end;
  background: var(--accent-bg);
  border-color: transparent;
}
.win-msg small {
  display: block;
  margin-top: 2px;
  color: var(--app-text-2);
  font-size: var(--size-meta);
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.win-msg-note {
  align-self: center;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s-2);
  animation: win-in var(--duration) var(--ease);
}
.win-typing {
  align-self: flex-start;
  color: var(--app-text-2);
  font-size: var(--size-meta);
}
@keyframes win-in {
  from { opacity: 0; transform: translateY(4px); }
}
/* The copilot's draft: outlined, waiting for a person to send it. */
.win-draft {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  padding: var(--s-3) var(--s-4);
  border-top: 1px solid var(--app-border);
}
.win-draft-text {
  padding: var(--s-2) var(--s-3);
  border: 1px solid var(--accent);
  border-radius: var(--r-float);
}
.win-draft-who {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  color: var(--app-text-2);
  font-size: var(--size-meta);
}
.win-draft-who i {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: var(--copilot);
}
.win-draft-actions {
  display: flex;
  gap: var(--s-2);
  justify-content: flex-end;
}

/* ---- A record pressed opens its card on the right, as in the CRM ---- */
.win-card {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 5;
  width: min(17rem, 100%);
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
  padding: var(--s-4);
  background: var(--app-bg);
  border-left: 1px solid var(--app-border);
  box-shadow: var(--shadow-float);
  transform: translateX(100%);
  visibility: hidden;
  transition:
    transform var(--duration) var(--ease),
    visibility 0s linear var(--duration);
}
.win-card[data-open] {
  transform: none;
  visibility: visible;
  transition: transform var(--duration) var(--ease);
}
.win-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--s-2);
}
.win-card-title {
  margin-bottom: var(--s-1);
  font-size: var(--size-body);
  font-weight: 600;
}
.win-card-close {
  display: grid;
  place-items: center;
  width: 1.75rem;
  height: 1.75rem;
  padding: 0;
  border: 0;
  border-radius: var(--r-app-control);
  background: transparent;
  color: var(--app-text-2);
  cursor: pointer;
}
.win-card-close:hover {
  background: var(--app-subtle);
}
.win-card-status {
  padding: var(--s-1) var(--s-2);
  border-left: 3px solid var(--edge);
  border-radius: var(--r-chip);
  background: var(--fill);
  font-weight: 500;
}
.win-card dl {
  display: grid;
  grid-template-columns: 4.5rem 1fr;
  gap: var(--s-2) var(--s-3);
  margin: 0;
}
.win-card dt {
  color: var(--app-text-2);
}
.win-card dd {
  margin: 0;
  font-variant-numeric: tabular-nums;
}

@media (prefers-reduced-motion: reduce) {
  .win-bar[data-new],
  .win-msg,
  .win-msg-note {
    animation: none;
  }
}
