/* Окно встречи v2 — shell layout and .a-* components (P1–P3, P19–P20, P33–P40). Owner: agent D.
   The publisher wraps index.html in a skeleton that pads :root by the vertical safe-area insets;
   the app fills html/body with height:100% (not 100vh) so that padding is respected. */

html, body { height: 100%; }
body { min-height: 0; overflow: hidden; }

/* ---------- frame ---------- */
.a-app {
  height: 100%;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto auto auto auto minmax(0, 1fr) auto;
  grid-template-areas: "top" "days" "answer" "banner" "main" "bar";
  background: var(--surface);
  color: var(--ink);
}
.a-top     { grid-area: top; }
.a-days    { grid-area: days; }
.a-answer  { grid-area: answer; }
.a-banner  { grid-area: banner; }
.a-main    { grid-area: main; }
.a-bar     { grid-area: bar; }
.a-panel   { grid-area: panel; display: none; }
#sheets { position: fixed; top: 0; left: 0; width: 0; height: 0; z-index: var(--z-sheet); }

.a-main {
  position: relative;
  min-height: calc(var(--g-row-h) * 4);
  display: flex;
  flex-direction: column;
  border-top: 1px solid var(--grid-line);
}
#grid { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.a-stub { margin: auto; padding: var(--sp-5); color: var(--ink-2); font-size: var(--fs-meta); text-align: center; }

/* ---------- row 1: day switcher, "Встреча" (drawer, ≥ 900 px), "⋯" ---------- */
.a-top {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: var(--sp-1);
  padding: 6px var(--sp-3) 2px;
}
.a-top .a-dayctl { justify-self: start; }
.a-panel-toggle { display: none; }
.a-panel-toggle.is-on { background: var(--surface-2); }

/* ---------- row 2: narrow search (widens while typing), "+", city strip, "Скрыть" ---------- */
.a-quick { position: relative; flex: 0 1 15rem; min-width: 8.5rem; transition: flex-basis var(--t-fast) var(--ease); }
.a-quick:focus-within { flex-basis: 22rem; }
.a-days.is-folded .a-quick { flex: 1 1 auto; max-width: 32rem; }
/* the whole row is 32 px high like the city chips; hit areas stay 44 px (::before) */
.a-days .a-quick__input { min-height: 2rem; height: 2rem; padding-block: 0; }
.a-days .a-quick__clear, .a-days__add { width: 2rem; height: 2rem; min-width: 2rem; min-height: 2rem; }
.a-days__add { position: relative; flex: 0 0 auto; }
.a-pick-toggle { position: relative; flex: 0 0 auto; gap: 4px; min-height: 2rem; padding-block: 0; padding-inline: var(--sp-2); font-size: var(--fs-meta); }
.a-days__add::before, .a-pick-toggle::before { content: ""; position: absolute; inset: -6px 0; }
.a-pick-toggle__open, .a-days.is-folded .a-pick-toggle__close { display: none; }
.a-days.is-folded .a-pick-toggle__open { display: inline; }
.a-days.is-folded .a-pick-toggle svg { transform: rotate(180deg); }
@media (max-width: 599px) {
  /* phone: the strip gives way while the field is in use; the toggle is icon-only */
  .a-days:has(.a-quick:focus-within) .a-pickwrap { display: none; }
  .a-days:has(.a-quick:focus-within) .a-quick { flex: 1 1 auto; }
  .a-quick { flex-basis: 6.5rem; min-width: 6.5rem; }
  .a-days__add { display: none; } /* the field adds cities too ("Лиссабон" → "+ Добавить") */
  .a-pick-toggle span:not([class]) { display: none; }
  .a-pick-toggle__open, .a-pick-toggle__close { display: none !important; }
}
.a-quick__input { padding-right: calc(var(--tap) + 2px); background: var(--surface-2); }
.a-quick__clear { position: absolute; top: 50%; right: 0; transform: translateY(-50%); color: var(--ink-2); }

.a-menu {
  position: absolute;
  top: calc(100% - 2px);
  right: var(--sp-3);
  z-index: var(--z-menu);
  width: min(300px, calc(100vw - 24px));
  display: grid;
  gap: var(--sp-3);
  padding: var(--sp-2);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-ctl);
  box-shadow: 0 8px 24px rgb(0 0 0 / .18);
}
.a-menu[hidden] { display: none; }
.a-menu__item {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  min-height: var(--tap);
  padding: 0 var(--sp-3);
  border-radius: var(--r-ctl);
  font-weight: var(--fw-medium);
}
.a-menu__item:hover { background: var(--surface-2); }
.a-menu__item > svg { font-size: 1.25rem; color: var(--ink-2); }
.a-menu__group { display: grid; gap: var(--sp-1); padding: 0 var(--sp-1); }
.a-menu__label { font: var(--fw-semibold) var(--fs-meta)/var(--lh-tight) var(--f-ui); color: var(--ink-2); }
.a-seg { display: flex; flex-wrap: wrap; gap: var(--sp-1); }
.a-seg .chip { font-size: var(--fs-meta); padding-inline: var(--sp-3); }
.a-menu__select { min-height: 2.25rem; padding-block: 0; font-size: var(--fs-meta); }
.a-menu__hint { font-size: var(--fs-caption); color: var(--ink-2); font-variant-numeric: tabular-nums; }

/* ---------- answer card (P20) ---------- */
.a-answer {
  margin-inline: var(--sp-3);
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: var(--sp-1);
  margin-top: var(--sp-1);
  padding: var(--sp-2) 0 var(--sp-2) var(--sp-3);
  border: 1px solid var(--line);
  border-radius: var(--r-ctl);
  background: var(--surface);
}
.a-answer.is-error { border-color: var(--danger); box-shadow: inset 3px 0 0 var(--danger); }
.a-answer__body { display: grid; gap: var(--sp-1); min-width: 0; padding-top: 2px; }
.a-answer__lead { font-size: var(--fs-body); line-height: var(--lh-body); }
.a-answer__lead b { font: var(--fw-bold) var(--fs-readout)/1 var(--f-time); font-variant-numeric: tabular-nums; }
.a-answer__others { font-size: var(--fs-meta); color: var(--ink-2); font-family: var(--f-ui); }
.a-answer__add { justify-self: start; margin-top: var(--sp-1); font-size: var(--fs-meta); }
.a-answer__close { color: var(--ink-2); }

/* ---------- day strip (P33, P34) ---------- */
.a-days {
  display: flex;
  align-items: center;
  gap: var(--sp-1);
  min-width: 0;
  padding: var(--sp-1) var(--sp-3);
}
.a-days__scroll {
  display: flex;
  gap: var(--sp-1);
  flex: 1 1 auto;
  min-width: 0;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scroll-snap-type: x proximity;
  scrollbar-width: none;
  padding: 3px; /* room for the focus ring */
  margin: -3px;
}
.a-days__scroll::-webkit-scrollbar { display: none; }
/* strip scrolling: round ‹ › over faded edges, shown only when there is more to see */
.a-pickwrap { position: relative; display: flex; flex: 1 1 auto; min-width: 0; }
.a-pickwrap.is-left .a-days__scroll { -webkit-mask-image: linear-gradient(to right, transparent 0, #000 48px); mask-image: linear-gradient(to right, transparent 0, #000 48px); }
.a-pickwrap.is-right .a-days__scroll { -webkit-mask-image: linear-gradient(to left, transparent 0, #000 48px); mask-image: linear-gradient(to left, transparent 0, #000 48px); }
.a-pickwrap.is-left.is-right .a-days__scroll {
  -webkit-mask-image: linear-gradient(to right, transparent 0, #000 48px, #000 calc(100% - 48px), transparent 100%);
  mask-image: linear-gradient(to right, transparent 0, #000 48px, #000 calc(100% - 48px), transparent 100%);
}
.a-pickwrap.is-dragging .a-days__scroll { cursor: grabbing; scroll-snap-type: none; }
.a-pickbtn {
  position: absolute;
  top: 50%;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: 1px solid var(--grid-line);
  border-radius: var(--r-pill);
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 2px 8px rgb(0 0 0 / .12);
  transform: translateY(-50%);
  cursor: pointer;
}
.a-pickbtn:hover { background: var(--surface-2); }
.a-pickbtn--left { left: 0; }
.a-pickbtn--right { right: 0; }
.a-pickbtn::before { content: ""; position: absolute; inset: -6px; } /* 44 px hit area */
/* quick-pick cities: "+ Киев / Украина"; an added city is filled with ✓ (home with ⌂) */
.a-pick { display: flex; gap: var(--sp-1); }
/* compact chip: flag + city, 32 px high (the hit area is taller, see ::before) */
.a-pick__chip {
  position: relative;
  flex: 0 0 auto;
  gap: 6px;
  min-height: 2rem;
  padding: 0 var(--sp-3) 0 var(--sp-2);
  scroll-snap-align: start;
  border-color: var(--grid-line);
}
.a-pick__chip::before { content: ""; position: absolute; inset: -6px 0; }
.a-pick__name { font-size: var(--fs-meta); font-weight: var(--fw-semibold); white-space: nowrap; }
/* every quick city is in the grid: a note (text from app.js, in the interface language) */
.a-pick__empty {
  align-self: center;
  font-size: var(--fs-meta);
  color: var(--ink-2);
  white-space: nowrap;
}

/* day switcher: ‹ Сегодня › */
.a-dayctl {
  display: flex;
  align-items: center;
  gap: 2px;
  flex: 0 0 auto;
}
.a-dayctl__label {
  gap: 6px;
  padding-inline: var(--sp-2);
  font-size: var(--fs-meta);
  font-weight: var(--fw-semibold);
  white-space: nowrap;
}
.a-dayctl__label.is-weekend #day-label { color: var(--ink-2); }
.a-last { flex: 0 0 auto; font-size: var(--fs-meta); border-style: dashed; }
.a-days__now { flex: 0 0 auto; padding-inline: var(--sp-3); font-size: var(--fs-meta); }
.a-cal { position: relative; flex: 0 0 auto; }

/* calendar popover (Marketing CRM CalendarPanel): 264 px, round 32 px days, today ringed, chosen day filled */
.a-calpop {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: var(--z-menu);
  width: 16.5rem;
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  padding: var(--sp-3);
  background: var(--surface);
  border: 1px solid var(--line-soft, var(--line));
  border-radius: 14px;
  box-shadow: var(--shadow-pop, 0 8px 24px rgb(0 0 0 / .12));
}
.a-calpop__head { display: flex; align-items: center; justify-content: space-between; }
.a-calpop__title { font-weight: var(--fw-semibold); font-size: var(--fs-body); }
.a-calpop__nav, .a-calpop__day {
  display: grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: 1px solid transparent;
  border-radius: var(--r-pill);
  background: transparent;
  color: var(--ink);
  cursor: pointer;
}
.a-calpop__nav:hover, .a-calpop__day:hover { background: var(--surface-2); }
.a-calpop__wd, .a-calpop__grid { display: grid; grid-template-columns: repeat(7, 1fr); justify-items: center; }
.a-calpop__wd { font-size: var(--fs-meta); color: var(--ink-2); }
.a-calpop__wd span { padding-block: 4px; }
.a-calpop__grid { row-gap: 2px; }
.a-calpop__day { font-size: var(--fs-meta); font-variant-numeric: tabular-nums; }
.a-calpop__day.is-out { color: var(--ink-3, var(--ink-2)); opacity: .55; }
.a-calpop__day.is-today { border-color: var(--line); }
.a-calpop__day.is-sel, .a-calpop__day.is-sel:hover { background: var(--sel-line); border-color: var(--sel-line); color: var(--surface); font-weight: var(--fw-semibold); opacity: 1; }
.a-calpop__foot { padding-top: var(--sp-2); border-top: 1px solid var(--line-soft, var(--line)); }
.a-calpop__today {
  padding: 4px;
  border: 0;
  background: transparent;
  color: var(--sel-line);
  font-size: var(--fs-meta);
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}
.a-calpop__today:hover { color: var(--ink); }

/* city autocomplete under the search field */
.a-ac {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: var(--z-menu);
  width: max(100%, 19rem);
  max-height: 21rem;
  overflow: auto;
  margin: 0;
  padding: 4px;
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--line-soft, var(--line));
  border-radius: 12px;
  box-shadow: var(--shadow-pop, 0 8px 24px rgb(0 0 0 / .12));
}
.a-ac__item {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: var(--tap);
  padding: 6px 10px;
  border-radius: 8px;
  cursor: pointer;
}
.a-ac__item:hover, .a-ac__item[aria-selected="true"] { background: var(--surface-2); }
.a-ac__txt { display: flex; flex-direction: column; min-width: 0; }
.a-ac__name { font-weight: var(--fw-semibold); font-size: var(--fs-body); }
.a-ac__sub { font-size: var(--fs-caption); color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.a-ac__in { display: inline-flex; align-items: center; gap: 4px; margin-left: auto; font-size: var(--fs-caption); color: var(--st-ok); white-space: nowrap; }

/* ---------- DST banner (P38) ---------- */
.a-banner {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  min-height: 40px;
  margin: 0 var(--sp-3) var(--sp-2);
  padding-left: var(--sp-3);
  border-radius: var(--r-ctl);
  background: var(--warn-bg);
  color: var(--ink);
}
.a-banner[hidden] { display: none; }
.a-banner__icon { color: var(--warn); font-size: 1.125rem; display: grid; }
.a-banner__text { flex: 1; min-width: 0; font-size: var(--fs-meta); line-height: var(--lh-tight); padding-block: var(--sp-1); }
.a-banner .icon-btn { color: var(--ink-2); }
.a-banner .icon-btn:hover { background: rgb(0 0 0 / .06); }

/* ---------- onboarding card and coachmark (P40) ---------- */
.a-onboard {
  display: grid;
  gap: var(--sp-2);
  margin: 0 var(--sp-3) var(--sp-2);
  padding: var(--sp-3) var(--sp-1) var(--sp-3) var(--sp-4);
  border: 1px solid var(--line);
  border-radius: var(--r-sheet);
  background: var(--surface);
}
.a-onboard[hidden] { display: none; }
.a-onboard__head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); margin-block: -10px -6px; }
.a-onboard__chips {
  display: flex;
  gap: var(--sp-2);
  overflow-x: auto;
  scrollbar-width: none;
  padding: 3px var(--sp-3) 3px 3px; /* focus ring room */
  margin: -3px 0 -3px -3px;
}
.a-onboard__chips::-webkit-scrollbar { display: none; }
.a-onboard__chips .chip { flex: 0 0 auto; }
.a-onboard__chips .chip > svg { color: var(--ink-2); }

.a-coach {
  position: absolute;
  z-index: calc(var(--z-handle) + 2);
  top: calc(var(--g-head-h) + var(--sp-2));
  left: calc(var(--g-rail-w) + var(--g-fit-w) + var(--sp-2));
  right: var(--sp-2);
  max-width: 340px;
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-2) var(--sp-2) var(--sp-3);
  border-radius: var(--r-ctl);
  background: var(--toast-bg);
  color: var(--toast-ink);
  box-shadow: var(--shadow-handle);
  font-size: var(--fs-meta);
  line-height: var(--lh-tight);
}
.a-coach[hidden] { display: none; }
.a-coach p { flex: 1; }
.a-coach__ok, .a-coach__ok:hover, .a-coach__ok:active { background: transparent; color: var(--toast-link); filter: none; }

/* ---------- bottom bar (P36) ---------- */
.a-bar {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  min-height: var(--a-bar-h);
  padding: var(--sp-2) var(--sp-3);
  border-top: 1px solid var(--grid-line);
  background: var(--surface);
  z-index: var(--z-bar);
}
.a-verdict {
  flex: 1 1 auto;
  min-width: 0;
  min-height: var(--tap);
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  /* even padding around icon and text on hover; the negative margin keeps the icon on the grid's left edge */
  padding: 0 var(--sp-3);
  margin-left: calc(-1 * var(--sp-3));
  border-radius: var(--r-pill);
  font-weight: var(--fw-semibold);
}
.a-verdict:hover { background: var(--surface-2); }
.a-bar .btn { flex: 0 0 auto; min-width: 7.5rem; padding-inline: var(--sp-4); }

/* ---------- toast fallback (only while sheets.js is missing) ---------- */
.a-toast-fallback {
  position: fixed;
  left: 50%;
  bottom: calc(var(--a-bar-h) + var(--sp-3));
  transform: translateX(-50%);
  z-index: var(--z-toast);
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  min-height: 48px;
  max-width: calc(100vw - 24px);
  padding: var(--sp-1) var(--sp-2) var(--sp-1) var(--sp-4);
  border-radius: var(--r-ctl);
  background: var(--toast-bg);
  color: var(--toast-ink);
  box-shadow: var(--shadow-sheet);
}
.a-toast-fallback[hidden] { display: none; }
.a-toast-fallback .btn { background: transparent; color: var(--toast-link); }

/* ---------- large root font (P45) ---------- */
@media (max-width: 599px) {
  .a-bar .btn { min-width: 6.75rem; padding-inline: var(--sp-3); } /* fits "Назначить", so both are one width */
}

/* ---------- responsive frame (kept last so it overrides the component rules above) ---------- */
/* 600–899: one centred column (P3) */
@media (min-width: 600px) {
  .a-app { max-width: 720px; margin-inline: auto; box-shadow: 0 0 0 1px var(--grid-line); }
}

/* ≥ 900: grid left, permanent "Встреча" panel right (P2) */
@media (min-width: 900px) {
  body { overflow: auto; }
  .a-app {
    max-width: 1320px;
    padding: var(--sp-5);
    column-gap: var(--sp-5);
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto auto auto auto minmax(0, 1fr) auto;
    grid-template-areas: "top" "days" "answer" "banner" "main" "bar";
    background: transparent;
    box-shadow: none;
  }
  /* the meeting drawer: closed by default, the grid takes the whole width */
  .a-app.is-panel-open {
    grid-template-columns: minmax(0, 1fr) 380px;
    grid-template-areas: "top panel" "days panel" "answer panel" "banner panel" "main panel" "bar panel";
  }
  .a-panel-toggle { display: inline-grid; }
  .a-bar { border-top: 0; padding-inline: 0; background: transparent; }
  .a-answer { margin-inline: 0; }
  .a-panel { display: none; }
  .a-app.is-panel-open .a-panel {
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
    background: var(--surface);
    border: 1px solid var(--grid-line);
    border-radius: var(--r-sheet);
  }
  .a-panel:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
  .a-main {
    background: var(--surface);
    border: 1px solid var(--grid-line);
    border-radius: var(--r-sheet);
    overflow: hidden;
  }
  .a-top { padding-inline: 0; padding-top: 0; }
  .a-days { padding-inline: 0; }
  .a-banner { margin-inline: 0; }
}
