/* Dispatch Board Styles - Operations Hub */

/* Top toolbar */
.dispatch-toolbar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.dispatch-date-nav {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.dispatch-date-nav .btn {
  padding: 0.35rem 0.6rem;
  font-size: 0.85rem;
}

.dispatch-date-label {
  font-weight: 600;
  font-size: 1rem;
  min-width: 160px;
  text-align: center;
}

.dispatch-search {
  flex: 1;
  min-width: 150px;
  max-width: 250px;
  padding: 0.4rem 0.6rem;
  background: var(--bg-input);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.85rem;
}

.dispatch-search::placeholder {
  color: var(--text-muted);
}

/* Board container */
.dispatch-board {
  display: flex;
  gap: 0.75rem;
  overflow-x: auto;
  padding-bottom: 1rem;
  min-height: calc(100vh - 200px);
  align-items: flex-start;
}

/* Columns */
.dispatch-col {
  min-width: 280px;
  max-width: 320px;
  flex-shrink: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
}

.dispatch-col.drag-over {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(237, 139, 104, 0.3);
}

.dispatch-col-header {
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  position: sticky;
  top: 0;
  background: var(--bg-card);
  border-radius: var(--radius) var(--radius) 0 0;
  z-index: 1;
}

.dispatch-col-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.dispatch-col-name {
  font-weight: 600;
  font-size: 0.9rem;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dispatch-col-count {
  font-size: 0.75rem;
  color: var(--text-muted);
  background: var(--bg-input);
  padding: 0.1rem 0.4rem;
  border-radius: 10px;
  flex-shrink: 0;
}

.dispatch-col-gps {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  opacity: 0.7;
}

.dispatch-col-gps.active {
  background: var(--success);
  animation: gps-pulse 2s infinite;
  opacity: 1;
}

.dispatch-col-gps.inactive {
  background: var(--text-muted);
}

@keyframes gps-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.dispatch-col-body {
  padding: 0.5rem;
  flex: 1;
  min-height: 80px;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.dispatch-col-body.empty-state {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-style: italic;
}

/* "Book in Schedule" link in column header */
.dispatch-col-book-link {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
  text-decoration: none;
  padding: 0.15rem 0.4rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  flex-shrink: 0;
  transition: all 0.15s;
}

.dispatch-col-book-link:hover {
  border-color: var(--primary);
  color: var(--primary);
}

/* Appointment cards */
.dispatch-card {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.6rem;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s, opacity 0.15s;
  position: relative;
}

.dispatch-card:hover {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  transform: translateY(-1px);
}

.dispatch-card.dragging {
  opacity: 0.4;
}

.dispatch-card-time {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--primary);
  margin-bottom: 0.25rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.dispatch-card-duration {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-weight: 400;
}

.dispatch-card-customer {
  font-size: 0.85rem;
  font-weight: 500;
  margin-bottom: 0.2rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dispatch-card-type {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 0.15rem;
}

.dispatch-card-address {
  font-size: 0.75rem;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dispatch-card-status {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 600;
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  margin-top: 0.3rem;
  text-transform: capitalize;
}

.dispatch-card-status.status-scheduled {
  background: rgba(30, 136, 229, 0.15);
  color: #42a5f5;
}

.dispatch-card-status.status-on_the_way {
  background: rgba(251, 140, 0, 0.15);
  color: #ffa726;
}

.dispatch-card-status.status-in_progress {
  background: rgba(67, 160, 71, 0.15);
  color: #66bb6a;
}

.dispatch-card-status.status-completed {
  background: rgba(154, 154, 146, 0.15);
  color: var(--text-muted);
}

.dispatch-card-status.status-pending {
  background: rgba(245, 158, 11, 0.15);
  color: #f59e0b;
}

.dispatch-card-status.status-no_show_pending,
.dispatch-card-status.status-no_show {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
}

/* Drop placeholder */
.dispatch-drop-indicator {
  height: 3px;
  background: var(--primary);
  border-radius: 2px;
  margin: 0.25rem 0;
  transition: opacity 0.2s;
}

/* Detail panel (slide-in from right) */
.dispatch-panel-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 5000;
  opacity: 0;
  transition: opacity 0.25s;
}

.dispatch-panel-overlay.visible {
  opacity: 1;
}

.dispatch-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 400px;
  max-width: 100vw;
  background: var(--bg-card);
  border-left: 1px solid var(--border);
  z-index: 5001;
  transform: translateX(100%);
  transition: transform 0.25s ease;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.dispatch-panel.visible {
  transform: translateX(0);
}

.dispatch-panel-header {
  padding: 1rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.dispatch-panel-header h3 {
  font-size: 1rem;
  font-weight: 600;
}

.dispatch-panel-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.4rem;
  cursor: pointer;
  padding: 0 0.3rem;
  line-height: 1;
}

.dispatch-panel-body {
  padding: 1rem;
  flex: 1;
}

.dispatch-panel-row {
  margin-bottom: 0.75rem;
}

.dispatch-panel-label {
  font-family: var(--font-utility);
  font-size: 0.6rem;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  margin-bottom: 0.15rem;
}

.dispatch-panel-value {
  font-size: 0.9rem;
}

.dispatch-panel-actions {
  padding: 1rem;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.dispatch-panel-actions .btn {
  width: 100%;
  justify-content: center;
  margin-left: 0;
  min-height: 44px;
  font-size: 0.9rem;
}

/* Panel form elements */
.dispatch-panel-select {
  width: 100%;
  background: var(--bg-input);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.6rem 0.75rem;
  font-family: var(--font-body);
  font-size: 0.9rem;
  min-height: 44px;
}

.dispatch-panel-select:focus {
  border-color: var(--primary);
  outline: none;
  box-shadow: 0 0 0 2px rgba(237, 139, 104, 0.2);
}

.dispatch-panel-notes {
  font-size: 0.85rem;
  white-space: pre-wrap;
  line-height: 1.65;
}

/* Pin modal */
.dispatch-pin-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 6000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.dispatch-pin-modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  max-width: 360px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
}

.dispatch-pin-modal h3 {
  margin-bottom: 0.75rem;
  font-size: 1rem;
}

.dispatch-pin-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0;
  cursor: pointer;
  font-size: 0.9rem;
}

.dispatch-pin-item input[type="checkbox"] {
  accent-color: var(--primary);
}

/* Quick-assign modal (mobile reassign) */
.dispatch-assign-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 6000;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.dispatch-assign-modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 1rem;
  width: 100%;
  max-width: 500px;
  max-height: 70vh;
  overflow-y: auto;
}

.dispatch-assign-modal h3 {
  margin-bottom: 0.75rem;
  font-size: 1rem;
}

.dispatch-assign-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.6rem 0.4rem;
  cursor: pointer;
  border-radius: 6px;
  transition: background 0.15s;
}

.dispatch-assign-item:hover {
  background: var(--bg-input);
}

.dispatch-assign-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.dispatch-assign-name {
  flex: 1;
  font-size: 0.9rem;
}

.dispatch-assign-count {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.dispatch-assign-distance {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Suggest tech button */
.dispatch-suggest-btn {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.75rem;
  padding: 0.3rem 0.5rem;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 4px;
  cursor: pointer;
  margin-top: 0.3rem;
}

.dispatch-suggest-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}

/* Mobile layout */
@media (max-width: 767px) {
  .dispatch-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .dispatch-toolbar-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
  }

  .dispatch-date-nav {
    justify-content: center;
    width: 100%;
  }

  .dispatch-search {
    max-width: none;
  }

  /* Hide desktop board on mobile (including week grid) */
  .dispatch-board,
  .dispatch-board.dispatch-week-grid {
    display: none !important;
  }

  /* Mobile tab bar */
  .dispatch-mobile-tabs {
    display: flex;
    overflow-x: auto;
    gap: 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: 0.75rem;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .dispatch-mobile-tabs::-webkit-scrollbar {
    display: none;
  }

  .dispatch-mobile-tab {
    flex-shrink: 0;
    padding: 0.5rem 0.75rem;
    font-size: 0.8rem;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-muted);
    cursor: pointer;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 0.35rem;
    transition: color 0.15s, border-color 0.15s;
  }

  .dispatch-mobile-tab.active {
    color: var(--text);
    font-weight: 600;
  }

  .dispatch-mobile-tab-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
  }

  .dispatch-mobile-tab-count {
    font-size: 0.7rem;
    background: var(--bg-input);
    padding: 0 0.3rem;
    border-radius: 8px;
    color: var(--text-muted);
  }

  /* Mobile card list */
  .dispatch-mobile-cards {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding-bottom: 1rem;
  }

  .dispatch-card {
    position: relative;
    overflow: hidden;
  }

  /* Swipe action */
  .dispatch-card-swipe-action {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 80px;
    background: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 0.75rem;
    font-weight: 600;
    transform: translateX(100%);
    transition: transform 0.2s;
  }

  .dispatch-card.swiped .dispatch-card-swipe-action {
    transform: translateX(0);
  }

  /* Mobile detail panel as bottom sheet */
  .dispatch-panel {
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    max-width: 100%;
    max-height: 85vh;
    transform: translateY(100%);
    border-left: none;
    border-top: 1px solid var(--border);
    border-radius: var(--radius) var(--radius) 0 0;
  }

  .dispatch-panel.visible {
    transform: translateY(0);
  }

  .dispatch-actions-row {
    flex-wrap: wrap;
    gap: 0.4rem;
  }

  .dispatch-view-toggle .btn {
    padding: 0.3rem 0.6rem;
    font-size: 0.8rem;
  }

  .dispatch-search {
    order: 10;
    flex: 1 1 100%;
  }

  .dispatch-day-header {
    position: sticky;
    top: 0;
    z-index: 1;
  }
}

/* Desktop-only: show board, hide mobile elements */
@media (min-width: 768px) {
  .dispatch-mobile-tabs,
  .dispatch-mobile-cards {
    display: none;
  }
}

/* Unassigned column special styling */
.dispatch-col.unassigned {
  border-color: var(--warning);
  border-style: dashed;
}

.dispatch-col.unassigned .dispatch-col-header {
  background: rgba(245, 158, 11, 0.05);
}

/* Actions row */
.dispatch-actions-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

/* View toggle */
.dispatch-view-toggle {
  display: flex;
  gap: 0.2rem;
}

.dispatch-view-toggle .btn {
  padding: 0.25rem 0.5rem;
  font-size: 0.8rem;
}

/* Week day sections within tech columns */
.dispatch-day-section {
  margin-bottom: 0.5rem;
}

.dispatch-day-section.dimmed {
  opacity: 0.45;
}

.dispatch-day-header {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  padding: 0.3rem 0.5rem;
  background: var(--bg-input);
  border-radius: 4px;
  margin-bottom: 0.3rem;
  position: sticky;
  top: 40px;
  z-index: 1;
}

.dispatch-day-header.is-today {
  color: var(--primary);
  border-left: 3px solid var(--primary);
}

.dispatch-day-empty {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-align: center;
  padding: 0.2rem;
  font-style: italic;
}

/* Tech position badges (in column header) */
.dispatch-tech-pos {
  font-size: 0.6rem;
  font-weight: 600;
  padding: 0.1rem 0.3rem;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  flex-shrink: 0;
  white-space: nowrap;
}

.dispatch-tech-pos.en-route {
  background: rgba(251, 140, 0, 0.15);
  color: #ffa726;
}

.dispatch-tech-pos.at-location {
  background: rgba(67, 160, 71, 0.15);
  color: #66bb6a;
}

.dispatch-tech-pos.at-office {
  background: rgba(30, 136, 229, 0.15);
  color: #42a5f5;
}

.dispatch-tech-pos.day-complete {
  background: rgba(154, 154, 146, 0.15);
  color: var(--text-muted);
}

/* Position badges on appointment cards */
.dispatch-pos-badge {
  font-size: 0.6rem;
  font-weight: 600;
  padding: 0.1rem 0.3rem;
  border-radius: 4px;
  margin-left: auto;
  text-transform: uppercase;
}

.dispatch-pos-badge.en-route {
  background: rgba(251, 140, 0, 0.15);
  color: #ffa726;
}

.dispatch-pos-badge.at-location {
  background: rgba(67, 160, 71, 0.15);
  color: #66bb6a;
}

/* Highlight cards that tech is currently at or heading to */
.dispatch-card.dispatch-card-active-appt {
  border-left: 3px solid var(--success);
}

.dispatch-card.dispatch-card-enroute {
  border-left: 3px solid #ffa726;
}

/* Week view grid layout */
.dispatch-board.dispatch-week-grid {
  display: grid;
  align-items: start;
  gap: 0.4rem 0.5rem;
}

.dispatch-wg-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 0.75rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  position: sticky;
  top: 0;
  z-index: 2;
}

.dispatch-wg-header.unassigned {
  border-color: var(--warning);
  border-style: dashed;
  background: rgba(245, 158, 11, 0.05);
}

.dispatch-wg-cell {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.4rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  min-height: 50px;
}

.dispatch-wg-cell .dispatch-day-header {
  position: static;
}

.dispatch-wg-cell.dimmed {
  opacity: 0.45;
}

.dispatch-wg-cell.drag-over,
.dispatch-wg-header.drag-over {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(237, 139, 104, 0.3);
}

/* Multi-slot continuation marker */
.dispatch-slot-continuation {
  padding: 0.1rem 0.5rem;
}

.dispatch-cont-marker {
  height: 3px;
  background: var(--primary);
  border-radius: 2px;
  opacity: 0.4;
}

/* ---- UX Guide Styles ---- */

/* Page title - Barlow Condensed per vol5 */
.dispatch-page-title {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

/* Empty board state (Title + body + CTA per vol5 empty state rules) */
.dispatch-board-empty {
  padding: 3rem 1.5rem;
  text-align: center;
  width: 100%;
  background: var(--bg-card);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}

.dispatch-board-empty-title {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  margin-bottom: 0.5rem;
}

.dispatch-board-empty-body {
  color: var(--text-muted);
  font-size: 0.9rem;
  line-height: 1.65;
  max-width: 320px;
  margin: 0 auto 1.25rem;
}

.dispatch-board-empty-cta {
  display: inline-block;
  padding: 0.6rem 1.25rem;
  background: var(--primary);
  color: #111827;
  font-family: var(--font-display);
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-decoration: none;
  border-radius: 4px;
  border: none;
  cursor: pointer;
  min-height: 44px;
  transition: background 0.15s;
}

.dispatch-board-empty-cta:hover {
  background: #c77a5a;
}

.dispatch-board-empty-secondary {
  display: block;
  margin-top: 0.75rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.dispatch-board-empty-secondary a {
  color: var(--primary);
  text-decoration: underline;
}

/* Column empty state */
.dispatch-col-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-style: italic;
  padding: 1rem 0.5rem;
  min-height: 80px;
}

/* Modal subtitle / description text */
.dispatch-modal-subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
  line-height: 1.5;
}

.dispatch-modal-description {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
  line-height: 1.5;
}

/* Reassign row spacing */
.dispatch-panel-row.mt {
  margin-top: 1rem;
}

/* Skeleton loading */
.dispatch-skeleton-col {
  min-width: 280px;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.dispatch-skeleton {
  background: var(--bg-input);
  border-radius: var(--radius);
  animation: skeleton-pulse 1.5s ease-in-out infinite;
}

.dispatch-skeleton-header {
  height: 48px;
}

.dispatch-skeleton-card {
  height: 80px;
}

@keyframes skeleton-pulse {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 0.3; }
}
