/* =============================================================
   PR226 — Mobile Schedule UX Styles
   TradeRail Field Service Platform
   All rules scoped to ≤767px except the crew sheet (which uses
   a class guard so it never appears on desktop).
   ============================================================= */

/* ── Mobile root container ────────────────────────────────── */
#p226MobileRoot {
  display: none; /* hidden by default — JS shows it on mobile */
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0 0 80px 0; /* bottom pad for safe area */
  width: 100%;
}

@media (max-width: 767px) {
  #p226MobileRoot {
    display: flex;
  }

  /* Hide ALL desktop board elements on mobile */
  #p226Root .p226-body,
  #p226Root .p226-board-wrap,
  #p226Root #p226WorkerDrawer,
  #p226Root #p226WorkerDrawerBtn,
  #p226Root .p226-req-drawer,
  #p226Root .p226-controls-bar {
    display: none !important;
  }
}

/* Desktop controls bar is fully hidden on mobile — replaced by .msch-controls */

/* ── Mobile controls row ─────────────────────────────────── */
.msch-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px 6px;
  background: var(--navy, #1A1A2E);
  flex-wrap: wrap;
}

.msch-view-toggle {
  display: flex;
  gap: 0;
  background: rgba(255,255,255,0.08);
  border-radius: 8px;
  padding: 2px;
  flex-shrink: 0;
}

.msch-view-btn {
  background: none;
  border: none;
  color: rgba(255,255,255,0.6);
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  padding: 5px 14px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.msch-view-btn-on {
  background: #FF6B00;
  color: #fff;
}

.msch-nav-btns {
  display: flex;
  gap: 6px;
  margin-left: auto;
}

.msch-nav-btn {
  background: rgba(255,255,255,0.10);
  border: 1px solid rgba(255,255,255,0.15);
  color: rgba(255,255,255,0.85);
  font-size: 12px;
  font-weight: 700;
  font-family: 'Barlow Condensed', sans-serif;
  padding: 5px 12px;
  border-radius: 8px;
  cursor: pointer;
  letter-spacing: 0.3px;
}

.msch-nav-btn:active { background: rgba(255,255,255,0.18); }

.msch-today-btn {
  background: rgba(255, 107, 0, 0.18);
  border: 1px solid #FF6B00;
  color: #FF6B00;
  font-size: 12px;
  font-weight: 700;
  font-family: 'Barlow Condensed', sans-serif;
  padding: 5px 12px;
  border-radius: 8px;
  cursor: pointer;
  width: 100%;
  text-align: center;
}

/* ── Day stack ───────────────────────────────────────────── */
.msch-day-stack {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 10px 10px 0;
  background: #f4f6f8;
}

/* ── Day card ───────────────────────────────────────────── */
.msch-day-card {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  margin-bottom: 10px;
  overflow: hidden;
  box-shadow: 0 1px 4px rgba(20,19,16,0.06);
  transition: box-shadow 0.12s;
}

.msch-day-card-today {
  border-color: #FF6B00;
  box-shadow: 0 0 0 2px rgba(255,107,0,0.12), 0 2px 8px rgba(20,19,16,0.10);
}

/* ── Day card header ────────────────────────────────────── */
.msch-day-hdr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  cursor: pointer;
  user-select: none;
  background: #fff;
  border-radius: 14px;
  -webkit-tap-highlight-color: rgba(255,107,0,0.08);
  transition: background 0.12s;
  min-height: 52px;
  gap: 8px;
}

.msch-day-hdr:active {
  background: #fef6f0;
}

.msch-day-hdr-today {
  background: linear-gradient(135deg, #1A1A2E 0%, #0f3460 100%);
}

.msch-day-hdr-today .msch-day-label,
.msch-day-hdr-today .msch-day-job-count,
.msch-day-hdr-today .msch-chevron {
  color: rgba(255,255,255,0.9);
}

.msch-day-hdr-today.msch-day-hdr-open {
  border-radius: 14px 14px 0 0;
}

.msch-day-hdr-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1;
}

.msch-day-hdr-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.msch-today-pill {
  background: #FF6B00;
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  font-family: 'Barlow Condensed', sans-serif;
  letter-spacing: 0.8px;
  padding: 2px 8px;
  border-radius: 6px;
  text-transform: uppercase;
  flex-shrink: 0;
}

.msch-day-label {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 16px;
  font-weight: 700;
  color: #1A1A2E;
  letter-spacing: 0.2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.msch-day-job-count {
  font-size: 11px;
  color: #64748b;
  font-family: 'Barlow', sans-serif;
  white-space: nowrap;
}

.msch-staff-tag {
  font-size: 10px;
  font-weight: 700;
  font-family: 'Barlow Condensed', sans-serif;
  padding: 2px 8px;
  border-radius: 6px;
  white-space: nowrap;
  letter-spacing: 0.3px;
}

.msch-staff-full    { background: #d1fae5; color: #065f46; }
.msch-staff-partial { background: #fff3cd; color: #856404; }
.msch-staff-none    { background: #fee2e2; color: #991b1b; }

.msch-chevron {
  font-size: 10px;
  color: #94a3b8;
  flex-shrink: 0;
}

/* ── Day body ────────────────────────────────────────────── */
.msch-day-body {
  padding: 0 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #f8fafc;
  border-top: 1px solid #e2e8f0;
}

.msch-no-jobs {
  text-align: center;
  padding: 20px 0 10px;
  color: #64748b;
  font-size: 13px;
  font-family: 'Barlow', sans-serif;
}

.msch-add-job-inline {
  background: none;
  border: none;
  color: #FF6B00;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  padding: 0 4px;
  text-decoration: underline;
}

.msch-add-job-btn {
  background: #fff;
  border: 1.5px dashed #cbd5e1;
  border-radius: 10px;
  color: #64748b;
  font-size: 13px;
  font-weight: 700;
  font-family: 'Barlow Condensed', sans-serif;
  padding: 10px;
  cursor: pointer;
  text-align: center;
  width: 100%;
  letter-spacing: 0.3px;
  transition: border-color 0.12s, color 0.12s;
  margin-top: 2px;
}

.msch-add-job-btn:active {
  border-color: #FF6B00;
  color: #FF6B00;
}

/* ── Job card ────────────────────────────────────────────── */
.msch-job-card {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 12px 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  box-shadow: 0 1px 3px rgba(20,19,16,0.05);
  margin-top: 10px;
}

.msch-job-card-top {
  display: flex;
  align-items: center;
  gap: 7px;
}

.msch-type-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.msch-job-title {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 16px;
  font-weight: 700;
  color: #1A1A2E;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.msch-badge {
  font-size: 10px;
  font-weight: 700;
  font-family: 'Barlow Condensed', sans-serif;
  padding: 2px 7px;
  border-radius: 5px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  flex-shrink: 0;
}

.msch-badge-ok      { background: #d1fae5; color: #065f46; }
.msch-badge-pending { background: #fff3cd; color: #856404; }
.msch-badge-gray    { background: #f1f5f9; color: #64748b; }

.msch-job-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.msch-job-time {
  font-size: 13px;
  font-weight: 600;
  color: #1A1A2E;
  font-family: 'Barlow', sans-serif;
}

.msch-job-stage {
  font-size: 11px;
  background: #f0f4f8;
  color: #475569;
  padding: 2px 8px;
  border-radius: 5px;
  font-family: 'Barlow', sans-serif;
  font-weight: 600;
}

.msch-job-multiday {
  font-size: 11px;
  background: rgba(255,107,0,0.10);
  color: #c45000;
  padding: 2px 8px;
  border-radius: 5px;
  font-weight: 700;
  font-family: 'Barlow Condensed', sans-serif;
}

.msch-job-address {
  font-size: 11px;
  color: #64748b;
  font-family: 'Barlow', sans-serif;
  display: flex;
  align-items: center;
  gap: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.msch-job-address svg {
  flex-shrink: 0;
}

/* ── Crew row ────────────────────────────────────────────── */
.msch-crew-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding-top: 4px;
  border-top: 1px solid #f1f5f9;
  margin-top: 2px;
}

.msch-crew-label {
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: #94a3b8;
  font-family: 'Barlow Condensed', sans-serif;
  flex-shrink: 0;
}

.msch-crew-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  align-items: center;
  flex: 1;
}

.msch-crew-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #1A1A2E;
  color: #fff;
  border-radius: 20px;
  padding: 4px 8px 4px 5px;
  font-size: 12px;
  font-family: 'Barlow', sans-serif;
  font-weight: 600;
  cursor: pointer;
  -webkit-tap-highlight-color: rgba(255,107,0,0.15);
  transition: background 0.12s;
  max-width: 130px;
}

.msch-crew-chip:active { background: #e63946; }

.msch-crew-chip-av {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #FF6B00;
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.msch-crew-chip-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 60px;
}

.msch-crew-chip-x {
  font-size: 14px;
  color: rgba(255,255,255,0.55);
  line-height: 1;
  flex-shrink: 0;
}

.msch-add-crew-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #fff;
  border: 1.5px solid #FF6B00;
  color: #FF6B00;
  border-radius: 20px;
  padding: 4px 12px;
  font-size: 12px;
  font-weight: 700;
  font-family: 'Barlow Condensed', sans-serif;
  cursor: pointer;
  letter-spacing: 0.3px;
  transition: background 0.12s;
  -webkit-tap-highlight-color: rgba(255,107,0,0.10);
}

.msch-add-crew-btn:active {
  background: #fff4ec;
}

/* ── Crew bottom sheet ───────────────────────────────────── */
.msch-sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(20,19,16,0.50);
  z-index: 800;
  display: none;
  -webkit-tap-highlight-color: transparent;
}

.msch-crew-sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 801;
  background: #fff;
  border-radius: 20px 20px 0 0;
  max-height: 75vh;
  display: none;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 -8px 32px rgba(20,19,16,0.20);
  transform: translateY(100%);
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.msch-crew-sheet-open {
  display: flex;
  transform: translateY(0);
}

.msch-sheet-backdrop {
  /* backdrop shown when sheet open */
}

/* Show backdrop when sheet is open */
.msch-crew-sheet-open ~ * .msch-sheet-backdrop,
.msch-sheet-backdrop:not([style*="display:none"]) {
  display: block;
}

/* Actually wire backdrop display via the element directly */
#mschSheetBackdrop:not([style*="display:none"]) {
  display: block;
}

.msch-sheet-drag-handle {
  width: 36px;
  height: 4px;
  background: #e2e8f0;
  border-radius: 2px;
  margin: 10px auto 0;
  flex-shrink: 0;
}

.msch-sheet-body {
  overflow-y: auto;
  overflow-x: hidden;
  flex: 1;
  -webkit-overflow-scrolling: touch;
  padding-bottom: env(safe-area-inset-bottom, 16px);
}

.msch-sheet-hdr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px 8px;
  border-bottom: 1px solid #f1f5f9;
  flex-shrink: 0;
}

.msch-sheet-title {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 16px;
  font-weight: 700;
  color: #1A1A2E;
  letter-spacing: 0.2px;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.msch-sheet-close {
  background: #f1f5f9;
  border: none;
  border-radius: 50%;
  width: 30px;
  height: 30px;
  font-size: 18px;
  color: #64748b;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.msch-sheet-day-label {
  padding: 6px 16px 10px;
  font-size: 12px;
  color: #64748b;
  font-family: 'Barlow', sans-serif;
}

.msch-sheet-section-hdr {
  padding: 8px 16px 4px;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: #94a3b8;
  font-family: 'Barlow Condensed', sans-serif;
  background: #f8fafc;
  border-top: 1px solid #f1f5f9;
}

.msch-sheet-section-free  { color: #065f46; background: #f0fdf4; }
.msch-sheet-section-busy  { color: #856404; background: #fefce8; }
.msch-sheet-section-off   { color: #991b1b; background: #fff1f2; }

.msch-sheet-current {
  padding-bottom: 4px;
}

.msch-sheet-empty {
  padding: 20px 16px;
  color: #94a3b8;
  font-size: 13px;
  text-align: center;
  font-family: 'Barlow', sans-serif;
}

/* ── Worker rows in sheet ───────────────────────────────── */
.msch-worker-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid #f8fafc;
  cursor: pointer;
  -webkit-tap-highlight-color: rgba(255,107,0,0.08);
  transition: background 0.10s;
  min-height: 52px;
}

.msch-worker-row:active {
  background: #fef6f0;
}

.msch-wr-busy   { opacity: 0.85; }
.msch-wr-off    { opacity: 0.55; cursor: default; }
.msch-wr-on-job { background: #f0fdf4; cursor: default; }

.msch-wr-av {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #1A1A2E;
  color: #fff;
  font-size: 13px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-family: 'Barlow Condensed', sans-serif;
}

.msch-wr-av-on {
  background: #2a9d8f;
}

.msch-wr-info {
  flex: 1;
  min-width: 0;
}

.msch-wr-name {
  font-size: 14px;
  font-weight: 700;
  color: #1A1A2E;
  font-family: 'Barlow', sans-serif;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.msch-wr-role {
  font-size: 11px;
  color: #64748b;
  font-family: 'Barlow', sans-serif;
}

.msch-wr-free-tag {
  background: #d1fae5;
  color: #065f46;
  font-size: 10px;
  font-weight: 700;
  font-family: 'Barlow Condensed', sans-serif;
  padding: 2px 8px;
  border-radius: 6px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  flex-shrink: 0;
}

.msch-wr-assigned-tag {
  background: #d1fae5;
  color: #065f46;
}

.msch-wr-where {
  background: #fef9c3;
  color: #713f12;
  font-size: 10px;
  font-weight: 700;
  font-family: 'Barlow', sans-serif;
  padding: 3px 8px;
  border-radius: 6px;
  max-width: 110px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex-shrink: 0;
}

.msch-wr-off-tag {
  background: #fee2e2;
  color: #991b1b;
  font-size: 10px;
  font-weight: 700;
  font-family: 'Barlow Condensed', sans-serif;
  padding: 2px 8px;
  border-radius: 6px;
  text-transform: uppercase;
  flex-shrink: 0;
}

.msch-wr-add-icon {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: #FF6B00;
  color: #fff;
  font-size: 18px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  line-height: 1;
}

.msch-wr-remove {
  background: #fee2e2;
  border: none;
  border-radius: 8px;
  color: #991b1b;
  font-size: 11px;
  font-weight: 700;
  font-family: 'Barlow Condensed', sans-serif;
  padding: 5px 10px;
  cursor: pointer;
  flex-shrink: 0;
  letter-spacing: 0.2px;
}

.msch-wr-remove:active {
  background: #fecaca;
}

/* ── Toast notification ──────────────────────────────────── */
.msch-toast {
  position: fixed;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 24px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  background: #1A1A2E;
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  font-family: 'Barlow', sans-serif;
  padding: 10px 20px;
  border-radius: 20px;
  box-shadow: 0 4px 16px rgba(20,19,16,0.25);
  white-space: nowrap;
  pointer-events: none;
  animation: mschToastIn 0.2s ease;
}

@keyframes mschToastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(10px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ── Scheduling Queue section ────────────────────────────── */
.msch-queue-section {
  border: 1.5px solid #e2e8f0;
  border-radius: 12px;
  overflow: hidden;
  margin-top: 4px;
}

.msch-queue-hdr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: #1A1A2E;
}

.msch-queue-hdr-label {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: rgba(255,255,255,0.85);
}

.msch-queue-hdr-count {
  background: #FF6B00;
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  font-family: 'Barlow Condensed', sans-serif;
  padding: 2px 8px;
  border-radius: 10px;
  letter-spacing: 0.3px;
}

.msch-queue-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 12px;
  background: #fff;
  border-top: 1px solid #f1f5f9;
}

.msch-queue-item:first-of-type {
  border-top: none;
}

.msch-queue-item-left {
  flex: 1;
  min-width: 0;
}

.msch-queue-name {
  font-size: 14px;
  font-weight: 700;
  color: #1A1A2E;
  font-family: 'Barlow Condensed', sans-serif;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.msch-queue-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 2px;
  flex-wrap: wrap;
}

.msch-queue-meta span {
  font-size: 11px;
  color: #64748b;
  font-family: 'Barlow', sans-serif;
}

.msch-queue-window {
  background: #fef9c3;
  color: #713f12 !important;
  padding: 1px 6px;
  border-radius: 4px;
  font-weight: 600 !important;
  font-size: 10px !important;
}

.msch-queue-notes {
  font-size: 11px;
  color: #94a3b8;
  font-family: 'Barlow', sans-serif;
  margin-top: 3px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.msch-queue-place-btn {
  background: #FF6B00;
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 8px 14px;
  font-size: 12px;
  font-weight: 700;
  font-family: 'Barlow Condensed', sans-serif;
  cursor: pointer;
  letter-spacing: 0.4px;
  white-space: nowrap;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.12s;
}

.msch-queue-place-btn:active {
  background: #c45000;
}
