/* Mission Control - Schedule V1 concept (DEMO data). Light mode only.
   Reuses the tokens and components of styles.css; everything here is scoped to .sched. */
.sched {
  --s-today-bg: #eef4ff;
  --s-sel-ring: #2459d6;
  --s-off-bg: #f2f4f7;
  --s-off-text: #475467;
  --s-pad: #98a2b3;
}
.sched-demo {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px; margin-top: 10px; padding: 8px 12px; max-width: 80ch;
  background: #fffaeb; border: 1px solid #fedf89; border-radius: 10px; color: #7a2e0e; font-size: 14px;
}
.sched-demo--seam { background: #f2f4f7; border-color: var(--border-strong); color: var(--text); }

/* ---------- toolbar: segmented control + filter ---------- */
.sched-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.seg {
  display: inline-grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; padding: 4px; max-width: 100%;
  background: #eceff3; border: 1px solid var(--border); border-radius: 12px;
}
.seg__btn {
  min-height: 44px; min-width: 96px; padding: 0 18px; border: 0; border-radius: 9px; background: transparent;
  color: var(--muted); font-weight: 700; cursor: pointer; transition: background 0.18s ease, color 0.18s ease, box-shadow 0.18s ease;
}
@media (hover: hover) { .seg__btn:hover { color: var(--text); } }
.seg__btn[aria-selected="true"] { background: var(--surface); color: var(--accent); box-shadow: 0 1px 3px rgba(16, 24, 40, 0.14); }
.sched-filter { display: inline-flex; align-items: center; gap: 10px; min-height: 44px; font-weight: 600; cursor: pointer; }
.sched-filter input { width: 22px; height: 22px; accent-color: var(--accent); }

.sched-pane:focus { outline: none; }
.sched-body--in { animation: sched-in 0.22s ease-out; }
@keyframes sched-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.sbtn {
  min-height: 44px; padding: 0 16px; background: var(--surface); border: 1px solid var(--border-strong); border-radius: 10px;
  font-weight: 600; cursor: pointer; transition: background 0.15s ease, border-color 0.15s ease;
}
@media (hover: hover) { .sbtn:hover { background: #f2f4f7; } }
.muted { color: var(--muted); }

/* ---------- chips & owner ---------- */
.schip {
  display: inline-block; font-size: 12px; font-weight: 700; line-height: 18px; padding: 0 8px; border-radius: 999px;
  background: #eef2ff; color: #3730a3; white-space: nowrap;
}
.schip--off { background: #eceff3; color: #344054; border: 1px dashed #667085; }
.schip--warn { background: #fef0c7; color: #7a2e0e; }
.schip--tz { background: #e0f2fe; color: #065986; }
.schip--demo { background: #fef0c7; color: #7a2e0e; }
.owner { display: inline-flex; align-items: center; gap: 6px; min-width: 0; }
.owner__n { font-size: 13px; font-weight: 600; overflow-wrap: anywhere; }
.owner--lg { gap: 10px; }
.avatar--xs { width: 24px; height: 24px; }
.avatar--sm { width: 64px; height: 64px; }

/* ---------- list rows (agent, time, date list) ---------- */
.srows { display: grid; gap: 6px; }
.srow-item { min-width: 0; }
.srow {
  display: grid; grid-template-columns: minmax(70px, 40%) minmax(0, 1fr); gap: 2px 12px; align-items: baseline; width: 100%;
  min-height: 44px; padding: 8px 12px; text-align: left; background: #fcfcfd; border: 1px solid var(--border); border-radius: 10px; cursor: pointer;
}
@media (hover: hover) { .srow:hover { border-color: var(--border-strong); background: #f6f7f9; } }
.srow__t { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--text); min-width: 0; overflow-wrap: break-word; }
.srow__n { font-weight: 600; overflow-wrap: anywhere; min-width: 0; }
.srow__meta { grid-column: 2; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.srow__d { grid-column: 2; font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.srow.is-off { background: var(--s-off-bg); border-style: dashed; color: var(--s-off-text); }
.srow.is-off .srow__n { font-style: italic; }

/* ---------- Agent & Time modes ---------- */
/* Agent mode: one full-width row per agent; identity | Daily | Weekly | Monthly share the same tracks in every row. */
.sagents { display: grid; gap: 14px; }
.sagent-item { min-width: 0; }
.sagent {
  display: grid; grid-template-columns: minmax(190px, 230px) repeat(3, minmax(0, 1fr)); gap: 16px 20px; align-items: start;
  min-height: 150px; padding: 18px 20px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
}
.sagent__none { grid-column: 2 / -1; align-self: center; }
/* Desktop: every agent row has the same outer height; a group with many jobs scrolls inside its own track. */
@media (min-width: 960px) {
  .sagent { height: 340px; min-height: 0; overflow: hidden; grid-template-rows: minmax(0, 1fr); align-items: stretch; }
  .sagent > .sagent__head { align-self: start; }
  .sagent > .sagent__none { align-self: center; }
  .sagent > .ssec { display: flex; flex-direction: column; min-height: 0; }
  .sagent .ssec__title { flex: none; }
  .sagent .empty { flex: none; }
  .srows--scroll { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 2px 4px 2px 2px; }
  .srows--scroll:focus-visible { outline: 3px solid #2e90fa; outline-offset: 1px; border-radius: 8px; }
}
.sagent > .ssec, .stime__col > .ssec { min-width: 0; }
.sagent > .ssec { margin-top: 0; padding-top: 0; border-top: 0; }
.sagent .srow, .stime .srow { grid-template-columns: minmax(0, 1fr); }
.sagent .srow__meta, .sagent .srow__d, .stime .srow__meta, .stime .srow__d { grid-column: 1; }
.sagent__head { display: flex; align-items: center; gap: 14px; min-width: 0; }
.sagent__ident { min-width: 0; }
.sagent__name { font-size: 20px; line-height: 1.25; }
.sagent__role { color: var(--muted); font-size: 14px; }
.sagent__count { color: var(--muted); font-size: 13px; }
.ssec { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--border); }
.ssec__title { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; font-size: 16px; margin-bottom: 10px; padding-left: 10px; border-left: 4px solid var(--border-strong); }
.ssec__meta { font-size: 13px; font-weight: 600; color: var(--muted); }
.ssec--daily .ssec__title { border-left-color: #2e90fa; }
.ssec--weekly .ssec__title { border-left-color: #7a5af8; }
.ssec--monthly .ssec__title { border-left-color: #12b76a; }
.empty--box { padding: 10px 12px; background: #fcfcfd; border: 1px dashed var(--border-strong); border-radius: 10px; }
.stime { display: grid; gap: 16px; grid-template-columns: repeat(3, minmax(0, 1fr)); align-items: start; }
.stime__col { min-width: 0; }
.stime__col > .ssec { margin-top: 0; padding: 18px 20px 20px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }

/* ---------- Calendar ---------- */
.cal__head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.cal__month { font-size: 24px; letter-spacing: -0.01em; }
.cal__nav { display: flex; gap: 8px; }
.cal__dow, .cal__grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.cal__dow { gap: 6px; margin-bottom: 6px; }
.cal__dow li { text-align: center; font-size: 13px; font-weight: 700; color: var(--muted); }
.cal__grid { gap: 6px; }
.cal__cell {
  position: relative; min-width: 0; min-height: 132px; padding: 6px; display: flex; flex-direction: column; gap: 4px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
}
.cal__cell.is-pad { background: #fafbfc; border-style: dashed; }
.cal__cell.is-pad .cal__num { color: var(--s-pad); }
.cal__cell.is-today { background: var(--s-today-bg); border-color: #a4bcfd; }
.cal__cell.is-selected { box-shadow: 0 0 0 2px var(--s-sel-ring); }
.cal__date {
  display: flex; align-items: center; gap: 6px; min-height: 28px; padding: 0 2px; border: 0; background: transparent; cursor: pointer; text-align: left;
}
.cal__date::after { content: ""; position: absolute; inset: 0; border-radius: inherit; }
.cal__date:focus-visible { outline: none; }
.cal__date:focus-visible::after { outline: 3px solid #2e90fa; outline-offset: 1px; }
.cal__num { font-weight: 700; font-variant-numeric: tabular-nums; }
.is-pad .cal__num { padding: 0 2px; font-weight: 500; }
.cal__today { font-size: 11px; font-weight: 700; color: var(--accent); background: #dbe7ff; border-radius: 999px; padding: 0 7px; }
.cal__count { display: none; margin-left: auto; font-size: 12px; font-weight: 700; min-width: 22px; text-align: center; border-radius: 999px; background: #eef2ff; color: #3730a3; padding: 0 6px; line-height: 20px; }
.cal__events { position: relative; z-index: 1; display: grid; gap: 3px; min-width: 0; }
.ev {
  display: flex; align-items: baseline; gap: 6px; width: 100%; min-height: 24px; padding: 2px 6px; text-align: left; cursor: pointer;
  background: #eef2ff; border: 1px solid transparent; border-radius: 6px; font-size: 12.5px; line-height: 1.3; min-width: 0;
}
@media (hover: hover) { .ev:hover { border-color: #a4bcfd; } }
.ev__t { flex: none; font-weight: 700; font-variant-numeric: tabular-nums; }
.ev__n { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ev__off { flex: none; font-size: 11px; font-weight: 700; border: 1px solid #667085; border-radius: 4px; padding: 0 4px; color: #344054; }
.ev.is-off { background: var(--s-off-bg); border: 1px dashed #98a2b3; color: var(--s-off-text); font-style: italic; }
.ev--more { background: transparent; color: var(--accent); font-weight: 700; border: 1px solid transparent; }
.cal__unsupported { margin-top: 24px; padding: 18px 20px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.cal__daysub { color: var(--muted); font-size: 14px; margin: 2px 0 12px; }

/* ---------- Detail dialog (centered on desktop, bottom sheet on phones) ---------- */
body.is-modal { overflow: hidden; }
.sched-modal { position: fixed; inset: 0; z-index: 80; display: flex; align-items: center; justify-content: center; padding: 16px; }
.smodal__backdrop { position: absolute; inset: 0; background: rgba(16, 24, 40, 0.45); animation: sched-fade 0.18s ease-out; }
.smodal__panel {
  position: relative; width: min(620px, 100%); max-height: min(86vh, 100%); overflow-y: auto; overscroll-behavior: contain;
  background: var(--surface); border-radius: 16px; padding: 20px 22px 24px; box-shadow: 0 24px 60px rgba(16, 24, 40, 0.28);
  animation: sched-in 0.2s ease-out;
}
.smodal__panel--day { width: min(680px, 100%); }
.smodal__back { margin-bottom: 10px; }
.smodal__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.smodal__title { font-size: 22px; line-height: 1.25; overflow-wrap: anywhere; }
.smodal__title:focus { outline: none; }
.smodal__chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.smodal__desc { margin: 8px 0 14px; color: #344054; }
.skv .kv__row { grid-template-columns: 150px minmax(0, 1fr); }
.raw { font: 13px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; background: #f2f4f7; border-radius: 6px; padding: 2px 8px; overflow-wrap: anywhere; }
.smodal__note { margin-top: 16px; font-size: 13px; color: var(--muted); }
@keyframes sched-fade { from { opacity: 0; } to { opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  .sched-body--in, .smodal__panel, .smodal__backdrop { animation: none; }
}

/* ---------- Phones / narrow: compact calendar (counts) + large selected-date list ---------- */
@media (max-width: 759px) {
  .cal__events { display: none; }
  .cal__cell { min-height: 56px; padding: 2px; align-items: stretch; }
  .cal__date { flex-direction: column; justify-content: center; align-items: center; gap: 2px; min-height: 52px; padding: 2px 0; }
  .cal__count { display: inline-block; margin-left: 0; }
  .cal__today { display: none; }
  .cal__grid, .cal__dow { gap: 3px; }
  .cal__dow li { font-size: 12px; }
  .cal__month { font-size: 21px; }
  .cal__nav { width: 100%; }
  .cal__nav .sbtn { flex: 1 1 0; padding: 0 8px; }
  .cal__cell.is-today .cal__num { text-decoration: underline; text-underline-offset: 3px; }
  .seg { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); width: 100%; }
  .seg__btn { min-width: 0; padding: 0 8px; }
  .sched-filter { width: 100%; }
  .cal__unsupported, .sagent { padding: 16px; }
  .stime__col > .ssec { padding: 14px 14px 16px; }
  .sagent { grid-template-columns: minmax(0, 1fr); min-height: 0; }
  .sagent__none { grid-column: 1; }
  .stime { grid-template-columns: minmax(0, 1fr); }
  .sched-modal { align-items: flex-end; padding: 0; }
  .smodal__panel { width: 100%; max-height: 88vh; max-height: 88dvh; border-radius: 18px 18px 0 0; padding-bottom: calc(24px + var(--safe-bottom)); animation-name: sched-sheet; }
  .skv .kv__row { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .srow { grid-template-columns: minmax(0, 1fr); }
  .srow__meta, .srow__d { grid-column: 1; }
}
/* Tablet-narrow (below typical browser widths): stack D/W/M instead of crushing names */
@media (min-width: 760px) and (max-width: 959px) {
  .sagent { grid-template-columns: minmax(0, 1fr); min-height: 0; }
  .sagent__none { grid-column: 1; }
  .stime { grid-template-columns: minmax(0, 1fr); }
}
@keyframes sched-sheet { from { opacity: 0; transform: translateY(24px); } to { opacity: 1; transform: none; } }
@media (max-width: 759px) and (prefers-reduced-motion: reduce) { .smodal__panel { animation: none; } }
