/* css/schedule.css
   Pillar 3 schedule page — skeleton layout (basic). Cell-level styling +
   sticky headers + status colors ship in PR-A4b_ui_render together with
   the renderMatrix DOM build.
   Plan: docs/plans/2026-05-06-korolev-schedule-plan.md §11 task A4.5. */

:root {
  --slot-completed-bg: #d8e8d0;
  --slot-cancelled-bg: #efeae5;
  --slot-no-show-bg: #fde2dc;
  --slot-replaced-bg: #f4e8cc;
  --slot-replaced-fg: #8a6d2c;
  /* Shift colour categories (hybrid: warm=hostess, cool=guide, grey=absence). */
  --shift-front-bg: #ffd9c2;   --shift-front-fg: #8a3a12;
  --shift-quiet-bg: #fbefd0;   --shift-quiet-fg: #7a5e12;
  --shift-guide-bg: #d2eae6;   --shift-guide-fg: #1e5a53;
  --shift-absence-bg: #ebebeb; --shift-absence-fg: #8a8a8a;
}

body { background: var(--color-bg); font-family: 'Inter', sans-serif; margin: 0; }

.page-header { display: flex; align-items: center; justify-content: space-between;
  padding: 16px 32px; background: #fff; border-bottom: 1px solid var(--color-border); }
.page-header h1 { font-size: 20px; margin: 0; }
.page-header .header-right { display: flex; align-items: center; gap: 16px; }
.page-header .user-name { font-size: 14px; color: var(--color-text-muted); }
.page-header a { color: var(--color-primary); text-decoration: none; font-size: 14px; }

.page-content { max-width: 1200px; margin: 24px auto; padding: 0 24px; }

.schedule-view-tabs { display: flex; gap: 4px; margin-bottom: 16px; border-bottom: 1px solid var(--color-border); }
.schedule-view-tab { background: transparent; border: 0; padding: 10px 16px; font-size: 14px; cursor: pointer;
  color: var(--color-text-muted); border-bottom: 2px solid transparent; font-family: inherit; }
.schedule-view-tab:hover { color: var(--color-primary); }
.schedule-view-tab.is-active { color: var(--color-primary); border-bottom-color: var(--color-primary); font-weight: 600; }

.schedule-controls { display: flex; align-items: center; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.schedule-controls input[type="month"] { padding: 8px 12px; border: 1px solid var(--color-border);
  border-radius: 6px; font-size: 14px; font-family: inherit; }
.schedule-page-indicator { font-size: 13px; color: var(--color-text-muted); }

.schedule-state { padding: 24px; background: #fff; border: 1px solid var(--color-border);
  border-radius: var(--radius); text-align: center; color: var(--color-text-muted); }
.schedule-state-error { color: var(--color-danger); }
.schedule-state-loading::before { content: ''; display: inline-block; width: 14px; height: 14px;
  border: 2px solid var(--color-border); border-top-color: var(--color-primary); border-radius: 50%;
  margin-right: 8px; vertical-align: middle; animation: schedule-spin 1s linear infinite; }
@keyframes schedule-spin { to { transform: rotate(360deg); } }

.schedule-matrix { background: #fff; border: 1px solid var(--color-border); border-radius: var(--radius);
  padding: 16px; overflow-x: auto; min-height: 80px; }

/* === Schedule grid (cell-level styles, A4b_ui_render R.3) === */
.schedule-grid {
  border-collapse: collapse;
  width: 100%;
  font-size: 13px;
}

.schedule-grid thead th {
  position: sticky;
  top: 0;
  background: var(--color-primary-light, #e8f0e0);
  padding: 8px 6px;
  font-weight: 600;
  border-bottom: 1px solid var(--color-border);
  z-index: 1;
}

.schedule-grid th.schedule-grid-corner,
.schedule-grid th.schedule-user-name {
  position: sticky;
  left: 0;
  background: #fff;
  z-index: 2;
  text-align: left;
  padding: 6px 12px;
  border-right: 1px solid var(--color-border);
  white-space: nowrap;
}

.schedule-grid th.schedule-grid-corner {
  z-index: 3;
  background: var(--color-primary-light, #e8f0e0);
}

.schedule-grid td {
  padding: 4px 6px;
  border-bottom: 1px solid var(--color-border);
  vertical-align: top;
  min-width: 80px;
}

.schedule-grid tbody tr:hover {
  background: rgba(45, 80, 22, 0.04);
}

.slot {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  margin-right: 2px;
}

.slot-planned   { background: #f0eee9; color: var(--color-text-muted); }
.slot-confirmed { background: var(--color-primary-light, #e8f0e0); color: var(--color-primary); }
.slot-active    { background: var(--color-primary); color: #fff; font-weight: 600; }
.slot-completed { background: var(--slot-completed-bg); color: var(--color-primary); }
.slot-cancelled { background: var(--slot-cancelled-bg); color: var(--color-text-muted); text-decoration: line-through; }
.slot-no_show   { background: var(--slot-no-show-bg); color: var(--color-danger); font-weight: 600; }
.slot-replaced  { background: var(--slot-replaced-bg); color: var(--slot-replaced-fg); }

/* Shift colour categories — single source: js/schedule-shift-colors.js (shared
   by chips, legend, filter). After .slot-<status> so the category bg/colour wins
   for normal statuses; cancelled re-asserts its treatment at higher specificity. */
.slot--cat-front   { background: var(--shift-front-bg);   color: var(--shift-front-fg); }
.slot--cat-quiet   { background: var(--shift-quiet-bg);   color: var(--shift-quiet-fg); }
.slot--cat-guide   { background: var(--shift-guide-bg);   color: var(--shift-guide-fg); }
.slot--cat-absence { background: var(--shift-absence-bg); color: var(--shift-absence-fg); opacity: .75; }
.slot.slot-cancelled { text-decoration: line-through; opacity: .5; }

/* Filter active: hide shifts whose category is not selected (grid stays intact). */
.schedule-grid.is-filtering .slot[data-cat]:not(.is-filter-match) { display: none; }

/* Legend + shift filter bar. */
.schedule-legend, .schedule-shift-filter { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 8px 0; }
.schedule-legend-item { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: var(--color-text-muted); }
.schedule-legend-swatch { width: 14px; height: 14px; border-radius: 3px; display: inline-block; }
.schedule-filter-chip { font-size: 12px; padding: 3px 10px; border-radius: 14px; border: 1px solid var(--color-border, #d8d2ca); background: #fff; color: var(--color-text, #333); cursor: pointer; }
.schedule-filter-chip.is-active { background: var(--color-primary, #4a7); color: #fff; border-color: var(--color-primary, #4a7); }
.schedule-filter-reset { font-size: 12px; padding: 3px 8px; background: none; border: none; color: var(--color-text-muted); cursor: pointer; text-decoration: underline; }
.schedule-filter-reset[hidden] { display: none; }

/* Sheets sync (js/schedule-sync.js) — preview/apply panel under the controls. */
.schedule-sync-panel {
  margin: 12px 0;
  padding: 14px 16px;
  border: 1px solid var(--color-border, #e0ddd6);
  border-radius: 8px;
  background: #fafafa;
}
.schedule-sync-status { font-size: 13px; color: var(--color-text-muted); margin-bottom: 8px; }
.schedule-sync-summary { font-size: 14px; }
.schedule-sync-summary p { margin: 4px 0; }
.schedule-sync-skipped { color: var(--color-danger, #b00020); }
/* roster_errors — config-level block (account archived / no specialization);
   harder stop than -skipped, so it reads as a warning that gates Apply. */
.schedule-sync-error {
  color: var(--color-danger, #b00020);
  font-weight: 600;
  border-left: 3px solid var(--color-danger, #b00020);
  padding-left: 8px;
}
.schedule-sync-actions { display: flex; gap: 8px; margin-top: 12px; }

/* ── DW roster panel (phase 2, js/dw-roster.js) ───────────────────────── */
/* DW-mode hides schedule chrome via a class on <main> so we never fight
   schedule-app.js's dynamic `hidden` attributes. */
.page-content.dw-mode-active > *:not(.schedule-view-tabs):not(#dw-roster-panel):not(#dw-schedule-grid-panel) { display: none !important; }
#dw-roster-panel, #dw-schedule-grid-panel { display: none; }
.page-content.dw-mode-active #dw-roster-panel,
.page-content.dw-mode-active #dw-schedule-grid-panel { display: block; }

.dw-roster-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 16px 0; flex-wrap: wrap; }
.dw-roster-head h2 { margin: 0; font-size: 1.1rem; }
.dw-roster-archtoggle { font-size: .85rem; display: inline-flex; align-items: center; gap: 6px; }
.dw-roster-msg { margin: 8px 0; font-size: .9rem; }
.dw-roster-msg.is-error { color: var(--color-danger, #b00020); }

.dw-roster-form { display: grid; grid-template-columns: 1.3fr 1.3fr 1fr 1fr auto auto; gap: 8px; align-items: end; margin: 8px 0 16px; }
/* `display:grid` (author) overrides the UA `[hidden]{display:none}` at equal
   specificity — without this the add-form is always visible. */
.dw-roster-form[hidden] { display: none; }
.dw-roster-form label { display: flex; flex-direction: column; gap: 4px; font-size: .75rem; color: #555; }
.dw-roster-form input { padding: 7px 8px; border: 1px solid #ccc; border-radius: 6px; font: inherit; }
@media (max-width: 720px) { .dw-roster-form { grid-template-columns: 1fr 1fr; } }

.dw-roster-table { width: 100%; border-collapse: collapse; }
.dw-roster-table th, .dw-roster-table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid #eee; font-size: .9rem; vertical-align: middle; }
.dw-roster-table th { font-weight: 600; color: #444; }
.dw-roster-row--archived { opacity: .5; }
.dw-contact-btn { display: inline-block; margin-right: 6px; text-decoration: none; font-size: 1.05rem; }
.dw-contact-btn.is-off { opacity: .25; pointer-events: none; }
.dw-row-actions { white-space: nowrap; }
.dw-row-actions button { margin-left: 6px; }
.dw-bot-badge { font-size: .85rem; cursor: default; }
.dw-roster-search { flex: 1 1 220px; max-width: 320px; padding: 7px 10px; border: 1px solid #ccc; border-radius: 6px; font: inherit; }

/* ── DW schedule grid (phase 1c) ──────────────────────────────────────────── */
.dw-grid-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 16px 0 8px; flex-wrap: wrap; }
.dw-grid-head h2 { margin: 0; font-size: 1.1rem; }
.dw-grid-controls { display: flex; gap: 8px; align-items: center; }
.dw-grid-select { padding: 7px 8px; border: 1px solid #ccc; border-radius: 6px; font: inherit; max-width: 320px; }
.dw-grid-newform { display: flex; gap: 8px; align-items: end; margin: 8px 0 12px; flex-wrap: wrap; }
.dw-grid-newform[hidden] { display: none; }
.dw-grid-newform label { display: flex; flex-direction: column; gap: 4px; font-size: .75rem; color: #555; }
.dw-grid-newform input { padding: 7px 8px; border: 1px solid #ccc; border-radius: 6px; font: inherit; }
.dw-grid-hint { font-size: .78rem; color: #777; margin: 4px 0 10px; }
.dw-grid-wrap { overflow-x: auto; margin-bottom: 24px; }
.dw-grid { border-collapse: collapse; font-size: .82rem; }
.dw-grid th, .dw-grid td { border: 1px solid #e3e3e3; padding: 4px 6px; text-align: center; white-space: nowrap; }
.dw-grid thead th { background: #f6f6f6; font-weight: 600; color: #444; position: sticky; top: 0; }
.dw-grid-loc, .dw-grid-corner { text-align: left; background: #fafafa; font-weight: 600; position: sticky; left: 0; z-index: 1; }
.dw-cell { min-width: 86px; vertical-align: top; }
.dw-cell--empty { background: #fcfcfc; }
.dw-cell-add { width: 22px; height: 22px; border: 1px dashed #bbb; border-radius: 6px; background: #fff; color: #888; cursor: pointer; line-height: 1; }
.dw-cell-add:hover { border-color: #4a90d9; color: #4a90d9; }
.dw-cell-time { display: block; color: #666; font-size: .72rem; }
.dw-cell-name { display: block; font-weight: 600; }
.dw-cell-btn { padding: 2px 8px; font-size: .72rem; margin-top: 2px; }
.dw-cell-x { border: none; background: transparent; color: #b00020; cursor: pointer; font-size: .8rem; margin-left: 4px; }
/* one slot inside a cell (a cell can hold several) */
.dw-slot { display: block; padding: 3px 5px; border-radius: 6px; margin-bottom: 3px; }
.dw-slot--confirmed { background: #e7f6e9; }
.dw-slot--pending { background: #fff7e0; }
.dw-slot--declined { background: #fdeaea; }
.dw-slot--cancelled { background: #f0f0f0; color: #999; text-decoration: line-through; }
.dw-slot-waiting { display: block; font-size: .7rem; color: #b8860b; margin: 1px 0; }
.dw-slot-count { display: block; font-size: .7rem; font-weight: 600; color: #2e7d32; margin: 1px 0; }

/* modal */
.dw-modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.4); display: flex; align-items: center; justify-content: center; z-index: 1000; }
.dw-modal-overlay[hidden] { display: none; }
.dw-modal { background: #fff; border-radius: 10px; padding: 20px; min-width: 280px; max-width: 92vw; box-shadow: 0 10px 40px rgba(0,0,0,.25); }
.dw-modal h3 { margin: 0 0 12px; font-size: 1rem; }
.dw-modal-row { display: flex; flex-direction: column; gap: 4px; font-size: .8rem; color: #555; margin-bottom: 10px; }
.dw-modal-row input, .dw-modal-row select { padding: 7px 8px; border: 1px solid #ccc; border-radius: 6px; font: inherit; }
/* Invite-selected picker: checkbox + name on one line (compact list). */
.dw-modal-row--pick { flex-direction: row; align-items: center; gap: 8px; margin-bottom: 6px; }
.dw-modal-row--pick input { padding: 0; border-radius: 3px; flex: none; }
.dw-modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
