/* css/schedule-edit.css
   Pillar 3 schedule edit drawer — mobile-first bottom-sheet on phones,
   centered modal on tablet/desktop (≥768px). Surfaced by click delegation
   in js/schedule-app.js, populated by js/schedule-edit-drawer.js.
   Design ref: docs/plans/2026-05-14-pillar3-edit-ui-design.md §6.6 + §6.7.
   Variables reuse css/style.css palette (--color-primary, --color-border, ...).
*/

/* Backdrop — fades in/out, covers full viewport behind drawer. */
.schedule-edit-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 100;
  opacity: 0;
  transition: opacity 0.2s ease;
}
.schedule-edit-backdrop:not([hidden]) { opacity: 1; }

/* Drawer container — bottom-sheet on mobile, slides up from bottom. */
.schedule-edit-drawer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  max-height: 85vh;
  overflow-y: auto;
  background: #fff;
  border-radius: 16px 16px 0 0;
  z-index: 101;
  transform: translateY(100%);
  transition: transform 0.25s ease;
  box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.2);
  display: flex;
  flex-direction: column;
}
.schedule-edit-drawer:not([hidden]) { transform: translateY(0); }
/* `display: flex` above overrides UA `[hidden] { display: none }` — restore
   so the closed drawer doesn't intercept clicks over its (invisible) bounding
   box. Caught in prod 2026-05-15 when matrix clicks under the centered desktop
   modal silently no-op'd. */
.schedule-edit-drawer[hidden] { display: none; }

/* Header — sticky at top of scroll container, holds title + close. */
.schedule-edit-drawer__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px;
  border-bottom: 1px solid var(--color-border);
  position: sticky;
  top: 0;
  background: inherit;
  z-index: 1;
}
.schedule-edit-drawer__header h2 {
  font-size: 16px;
  margin: 0;
  color: var(--color-primary);
}
.schedule-edit-drawer__close {
  background: none;
  border: 0;
  font-size: 24px;
  cursor: pointer;
  width: 44px;
  height: 44px;
  color: var(--color-text-muted);
  font-family: inherit;
}
.schedule-edit-drawer__close:hover { color: var(--color-primary); }

/* Form grid — vertical stack with consistent gap + label/control pairs. */
.schedule-edit-form {
  padding: 16px;
  display: grid;
  gap: 12px;
}
.schedule-edit-form label {
  display: grid;
  gap: 4px;
  font-size: 14px;
  color: var(--color-text-muted);
}
.schedule-edit-form input,
.schedule-edit-form select,
.schedule-edit-form textarea {
  font: inherit;
  font-family: 'Inter', sans-serif;
  padding: 10px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: #fff;
  color: #222;
}
.schedule-edit-form input:focus,
.schedule-edit-form select:focus,
.schedule-edit-form textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 2px var(--color-primary-light);
}
.schedule-edit-form input[disabled],
.schedule-edit-form select[disabled],
.schedule-edit-form textarea[disabled] {
  background: #f5f3f0;
  color: var(--color-text-muted);
  cursor: not-allowed;
}

/* Days row — multi-day weekday checkboxes for bulk mode. */
.schedule-edit-form .days-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.schedule-edit-form .days-row label {
  flex-direction: row;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  color: #222;
  padding: 6px 10px;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  min-height: 36px;
}
.schedule-edit-form .days-row input[type="checkbox"] {
  width: auto;
  margin: 0;
}

/* Inline field-level error message (per-input validation). */
.schedule-edit-form .field-error {
  font-size: 12px;
  color: var(--color-danger);
  margin-top: 2px;
}

/* Result list — per-day rows from bulk-create Promise.allSettled. */
.schedule-edit-drawer__result {
  padding: 16px;
  display: grid;
  gap: 4px;
}
.schedule-edit-drawer__result .row {
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 14px;
}
.schedule-edit-drawer__result .row.ok {
  background: #e8f5e9;
  color: #2d5016;
}
.schedule-edit-drawer__result .row.fail {
  background: #ffe6e6;
  color: var(--color-danger);
}

/* Footer — sticky at bottom of scroll container, holds action buttons. */
.schedule-edit-drawer__footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 16px;
  border-top: 1px solid var(--color-border);
  position: sticky;
  bottom: 0;
  background: inherit;
  z-index: 1;
}

/* Buttons — all at least 44px tall for thumb tap targets (mobile). */
.btn {
  padding: 10px 18px;
  border-radius: 8px;
  border: 0;
  cursor: pointer;
  min-height: 44px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
}
.btn[disabled] { opacity: 0.5; cursor: wait; }
.btn--primary {
  background: var(--color-primary);
  color: #fff;
}
.btn--primary:hover:not([disabled]) { background: #244012; }
.btn--secondary {
  background: transparent;
  border: 1px solid var(--color-border);
  color: var(--color-text-muted);
}
.btn--secondary:hover:not([disabled]) { color: var(--color-primary); border-color: var(--color-primary); }
.btn--danger {
  background: var(--color-danger);
  color: #fff;
}
.btn--danger:hover:not([disabled]) { background: #962a1e; }

/* Pill click hint — matrix cells become interactive once drawer is mounted. */
.slot { cursor: pointer; }
/* Absence overlay variant — gold/amber to distinguish from shift statuses. */
.slot.slot-absence {
  background: #fff3cd;
  color: #856404;
  border: 1px solid #ffe7a0;
}
td[data-empty="1"] {
  cursor: pointer;
  position: relative;
}
td[data-empty="1"]::after {
  content: "+";
  opacity: 0.25;
  transition: opacity 0.15s ease;
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  font-size: 18px;
  font-weight: 600;
  color: var(--color-text-muted);
  pointer-events: none;
}
td[data-empty="1"]:hover::after { opacity: 0.8; }

/* Toast — fixed top notification for transient errors / success messages.
   Dismissed automatically after a few seconds OR replaced by a newer toast. */
.schedule-toast {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  background: #333;
  color: #fff;
  padding: 12px 20px;
  border-radius: 8px;
  z-index: 200;
  display: flex;
  gap: 12px;
  align-items: center;
  max-width: 90vw;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  font-size: 14px;
}
.schedule-toast .btn {
  padding: 4px 10px;
  font-size: 13px;
  min-height: 32px;
}

/* Desktop: drawer transforms into centered modal. */
@media (min-width: 768px) {
  .schedule-edit-drawer {
    left: 50%;
    right: auto;
    bottom: auto;
    top: 50%;
    transform: translate(-50%, -50%) scale(0.95);
    max-width: 480px;
    width: 90%;
    border-radius: 12px;
    max-height: 80vh;
    opacity: 0;
  }
  .schedule-edit-drawer:not([hidden]) {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
  }
}
