/* ════════════════════════════════════════════════════════════
   Scheduling Calendar — Shared Component Styles
   Used by: manager-hub (manager mode), service-ops-hub (director mode)
   Dark theme, Case IH branding, FullCalendar v6.1.15 overrides
   HBS terminology: RO, Condition (C/W/I), Description/Cause/Fix/Internal Notes
   ════════════════════════════════════════════════════════════ */

/* ── Layout ── */
.schedule-container {
  display: flex;
  gap: 0;
  height: calc(100vh - 120px);
  background: var(--bg-dark, #0a0a0a);
  position: relative;
}

/* ── Sidebar ── */
.schedule-sidebar {
  width: 280px;
  min-width: 280px;
  border-right: 1px solid var(--border-color, #333);
  background: var(--bg-surface, #111);
  overflow-y: auto;
  transition: width 0.25s ease, min-width 0.25s ease, padding 0.25s ease;
  display: flex;
  flex-direction: column;
}
.schedule-sidebar.collapsed {
  width: 0;
  min-width: 0;
  padding: 0;
  overflow: hidden;
  border-right: none;
}
.schedule-sidebar.collapsed .sidebar-inner { opacity: 0; }
.sidebar-inner {
  padding: 12px;
  transition: opacity 0.15s ease;
  opacity: 1;
}

/* Toggle Button */
.sidebar-toggle {
  position: absolute;
  left: 280px;
  top: 12px;
  z-index: 10;
  width: 24px;
  height: 40px;
  background: var(--bg-card, #1a1a1a);
  border: 1px solid var(--border-color, #333);
  border-left: none;
  border-radius: 0 6px 6px 0;
  color: var(--text-muted, #999);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  transition: left 0.25s ease;
}
.sidebar-toggle:hover { color: var(--text-primary, #fff); background: var(--bg-input, #252525); }
.schedule-sidebar.collapsed ~ .sidebar-toggle { left: 0; }

/* Sidebar Section Tabs */
.sidebar-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 12px;
  background: var(--bg-card, #1a1a1a);
  border-radius: 8px;
  padding: 3px;
}
.sidebar-tab {
  flex: 1;
  padding: 6px 8px;
  border: none;
  background: transparent;
  color: var(--text-muted, #999);
  font-size: 11px;
  font-weight: 600;
  font-family: inherit;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
  text-align: center;
}
.sidebar-tab:hover { color: var(--text-secondary, #ccc); }
.sidebar-tab.active {
  background: var(--case-ih-red, #c8102e);
  color: #fff;
}

/* Sidebar Header */
.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.sidebar-title {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted, #999);
}

/* Store Filter (director mode) */
.schedule-store-filter {
  width: 100%;
  padding: 8px 10px;
  background: var(--bg-input, #252525);
  border: 1px solid var(--border-color, #333);
  border-radius: 8px;
  color: var(--text-primary, #fff);
  font-size: 13px;
  font-family: inherit;
  margin-bottom: 12px;
  cursor: pointer;
}
.schedule-store-filter:focus { outline: none; border-color: var(--case-ih-red, #c8102e); }

/* Store Groups */
.store-group { margin-bottom: 8px; }
.store-group-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: var(--bg-card, #1a1a1a);
  border: 1px solid var(--border-color, #333);
  border-radius: 8px;
  cursor: pointer;
  user-select: none;
  transition: background 0.15s;
}
.store-group-header:hover { background: var(--bg-input, #252525); }
.store-group-chevron {
  font-size: 10px;
  color: var(--text-muted, #999);
  transition: transform 0.2s;
  width: 12px;
}
.store-group.collapsed .store-group-chevron { transform: rotate(-90deg); }
.store-group-name {
  flex: 1;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary, #fff);
}
.job-count-badge {
  background: var(--case-ih-red, #c8102e);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 10px;
  min-width: 22px;
  text-align: center;
}
.store-group-techs {
  padding: 4px 0 0 12px;
  overflow: hidden;
  transition: max-height 0.25s ease;
}
.store-group.collapsed .store-group-techs { max-height: 0 !important; padding-top: 0; }

/* ── Unassigned ROs Section (Draggable) ── */
.unassigned-section {
  padding: 10px 12px;
  margin-bottom: 10px;
  background: rgba(107, 114, 128, 0.1);
  border: 1px dashed var(--border-color, #333);
  border-radius: 8px;
}
.unassigned-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted, #999);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.unassigned-count {
  font-size: 18px;
  font-weight: 800;
  color: #6b7280;
  margin-top: 2px;
}
.unassigned-ro-list {
  margin-top: 8px;
  max-height: 300px;
  overflow-y: auto;
}

/* Draggable RO Card */
.draggable-ro {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 8px 10px;
  background: var(--bg-card, #1a1a1a);
  border: 1px solid var(--border-color, #333);
  border-left: 3px solid #6b7280;
  border-radius: 6px;
  margin-bottom: 6px;
  cursor: grab;
  transition: all 0.15s;
  user-select: none;
}
.draggable-ro:hover {
  background: var(--bg-input, #252525);
  border-color: var(--text-muted, #999);
}
.draggable-ro:active { cursor: grabbing; }
.draggable-ro.priority-down { border-left-color: #ef4444; }
.draggable-ro.priority-high { border-left-color: #f59e0b; }
.draggable-ro.priority-routine { border-left-color: #3b82f6; }
.draggable-ro .ro-drag-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary, #fff);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.draggable-ro .ro-drag-sub {
  font-size: 11px;
  color: var(--text-muted, #999);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.draggable-ro .ro-drag-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
}

/* Drag ghost */
.fc-event-dragging .draggable-ro,
.draggable-ro.fc-event-mirror {
  opacity: 0.7;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

/* Condition Code Badges */
.condition-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 4px;
  letter-spacing: 0.3px;
  line-height: 1.4;
}
.condition-badge.cond-c { background: rgba(59, 130, 246, 0.2); color: #60a5fa; }
.condition-badge.cond-w { background: rgba(34, 197, 94, 0.2); color: #4ade80; }
.condition-badge.cond-i { background: rgba(168, 85, 247, 0.2); color: #c084fc; }
.condition-badge.cond-wc { background: rgba(245, 158, 11, 0.2); color: #fbbf24; }

/* Status Badge */
.status-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.status-scheduled { background: rgba(59, 130, 246, 0.15); color: #60a5fa; }
.status-en-route { background: rgba(245, 158, 11, 0.15); color: #fbbf24; }
.status-on-site { background: rgba(34, 197, 94, 0.15); color: #4ade80; }
.status-in-progress { background: rgba(139, 92, 246, 0.15); color: #a78bfa; }
.status-waiting-parts { background: rgba(239, 68, 68, 0.15); color: #f87171; }
.status-parts-ready { background: rgba(6, 182, 212, 0.15); color: #22d3ee; }
.status-completed { background: rgba(34, 197, 94, 0.25); color: #4ade80; }

/* Tech Items */
.sidebar-tech {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s;
  margin-bottom: 2px;
}
.sidebar-tech:hover { background: var(--bg-input, #252525); }
.sidebar-tech.active { background: rgba(200, 16, 46, 0.15); border-left: 3px solid var(--case-ih-red, #c8102e); }
.tech-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #6b7280;
  flex-shrink: 0;
}
.tech-dot.available { background: var(--success, #22c55e); }
.tech-dot.busy { background: var(--warning, #f59e0b); }
.tech-name {
  flex: 1;
  font-size: 13px;
  color: var(--text-secondary, #ccc);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-tech.active .tech-name { color: var(--text-primary, #fff); font-weight: 600; }
.tech-jobs {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted, #999);
  background: var(--bg-input, #252525);
  padding: 2px 6px;
  border-radius: 8px;
  min-width: 20px;
  text-align: center;
}

/* ── Calendar Area ── */
.schedule-calendar {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 16px;
  overflow-y: auto;
  min-width: 0;
}

/* Filter Chips — 2 rows: Priority + Condition */
.schedule-filter-bar {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}
.schedule-filter-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.filter-row-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted, #999);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  min-width: 70px;
}
.schedule-chip {
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid var(--border-color, #333);
  background: var(--bg-card, #1a1a1a);
  color: var(--text-secondary, #ccc);
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.schedule-chip:hover { border-color: var(--text-muted, #999); }
.schedule-chip.active {
  background: var(--case-ih-red, #c8102e);
  border-color: var(--case-ih-red, #c8102e);
  color: #fff;
}
.schedule-chip .chip-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 5px;
}

/* ── FullCalendar Dark Theme Overrides ── */
.schedule-calendar .fc {
  --fc-border-color: var(--border-color, #333);
  --fc-page-bg-color: transparent;
  --fc-neutral-bg-color: var(--bg-input, #252525);
  --fc-today-bg-color: rgba(200, 16, 46, 0.08);
  --fc-highlight-color: rgba(200, 16, 46, 0.12);
  --fc-non-business-color: transparent;
  font-family: inherit;
}
.schedule-calendar .fc .fc-toolbar-title {
  color: var(--text-primary, #fff);
  font-size: 1.1rem;
  font-weight: 600;
}
.schedule-calendar .fc .fc-button {
  background: var(--bg-input, #252525);
  border: 1px solid var(--border-color, #333);
  color: var(--text-secondary, #ccc);
  font-size: 13px;
  font-weight: 500;
  padding: 6px 12px;
  transition: all 0.15s;
}
.schedule-calendar .fc .fc-button:hover {
  background: var(--bg-card, #1a1a1a);
  color: var(--text-primary, #fff);
}
.schedule-calendar .fc .fc-button-active,
.schedule-calendar .fc .fc-button:active {
  background: var(--case-ih-red, #c8102e) !important;
  border-color: var(--case-ih-red, #c8102e) !important;
  color: #fff !important;
}
.schedule-calendar .fc .fc-col-header-cell {
  background: var(--bg-input, #252525);
}
.schedule-calendar .fc .fc-col-header-cell-cushion {
  color: var(--text-muted, #999);
  text-transform: uppercase;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.5px;
  padding: 8px 4px;
}
.schedule-calendar .fc .fc-daygrid-day-number {
  color: var(--text-secondary, #ccc);
  font-size: 13px;
  padding: 6px 8px;
}
.schedule-calendar .fc .fc-daygrid-day.fc-day-today .fc-daygrid-day-number {
  color: var(--case-ih-red, #c8102e);
  font-weight: 700;
}
.schedule-calendar .fc .fc-daygrid-day:hover {
  background: rgba(255, 255, 255, 0.02);
}

/* Calendar event pills */
.schedule-calendar .fc .fc-event {
  border: none;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  padding: 2px 6px;
  margin-bottom: 1px;
}
.schedule-calendar .fc .fc-event:hover { filter: brightness(1.15); }
.schedule-calendar .fc .fc-event .fc-event-title {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.schedule-calendar .fc .fc-daygrid-more-link {
  color: var(--case-ih-red, #c8102e);
  font-weight: 600;
  font-size: 11px;
}
.schedule-calendar .fc .fc-popover {
  background: var(--bg-surface, #111);
  border: 1px solid var(--border-color, #333);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}
.schedule-calendar .fc .fc-popover-header {
  background: var(--bg-card, #1a1a1a);
  color: var(--text-primary, #fff);
  font-size: 13px;
  font-weight: 600;
  padding: 8px 12px;
}
.schedule-calendar .fc .fc-scrollgrid {
  border-color: var(--border-color, #333);
}

/* Event sub-label (tech name / store) */
.fc-event-sub-label {
  font-size: 10px;
  opacity: 0.75;
  display: block;
  margin-top: 1px;
}

/* Drag-over highlight on calendar cells */
.schedule-calendar .fc .fc-daygrid-day.fc-highlight {
  background: rgba(200, 16, 46, 0.15) !important;
}

/* ── Job Detail Slide-Out ── */
.schedule-slideout-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}
.schedule-slideout-overlay.open { opacity: 1; pointer-events: all; }

.schedule-slideout {
  position: fixed;
  top: 0;
  right: -420px;
  width: 400px;
  max-width: 90vw;
  height: 100vh;
  background: var(--bg-surface, #111);
  border-left: 1px solid var(--border-color, #333);
  z-index: 101;
  display: flex;
  flex-direction: column;
  transition: right 0.25s ease;
  box-shadow: -4px 0 24px rgba(0, 0, 0, 0.4);
}
.schedule-slideout.open { right: 0; }

.slideout-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  border-bottom: 1px solid var(--border-color, #333);
}
.slideout-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary, #fff);
}
.slideout-close {
  width: 32px;
  height: 32px;
  border: none;
  background: var(--bg-input, #252525);
  color: var(--text-muted, #999);
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}
.slideout-close:hover { background: var(--bg-card, #1a1a1a); color: var(--text-primary, #fff); }

.slideout-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

.slideout-section { margin-bottom: 16px; }
.slideout-section-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted, #999);
  margin-bottom: 8px;
}

.slideout-card {
  background: var(--bg-card, #1a1a1a);
  border: 1px solid var(--border-color, #333);
  border-radius: 10px;
  padding: 12px;
}

.slideout-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
}
.slideout-row + .slideout-row { border-top: 1px solid rgba(255, 255, 255, 0.05); }
.slideout-label { font-size: 13px; color: var(--text-muted, #999); }
.slideout-value { font-size: 13px; font-weight: 600; color: var(--text-primary, #fff); }

.slideout-priority {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.priority-dot { width: 10px; height: 10px; border-radius: 50%; }

/* HBS Condition Information fields block */
.three-cs-block {
  font-size: 13px;
  color: var(--text-secondary, #ccc);
  line-height: 1.6;
}
.three-cs-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  margin-bottom: 2px;
}
.three-cs-label.description-label { color: #f87171; }
.three-cs-label.ext-desc-label { color: #fb923c; }
.three-cs-label.cause-label { color: #fbbf24; }
.three-cs-label.fix-label { color: #4ade80; }
.three-cs-label.notes-label { color: #a78bfa; }
.three-cs-text {
  font-size: 13px;
  color: var(--text-secondary, #ccc);
  margin-bottom: 10px;
  padding-left: 10px;
  border-left: 2px solid var(--border-color, #333);
}

.slideout-actions {
  display: flex;
  gap: 8px;
  padding: 16px;
  border-top: 1px solid var(--border-color, #333);
}
.slideout-btn {
  flex: 1;
  padding: 10px 12px;
  border: 1px solid var(--border-color, #333);
  border-radius: 8px;
  background: var(--bg-card, #1a1a1a);
  color: var(--text-secondary, #ccc);
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  text-align: center;
  transition: all 0.15s;
}
.slideout-btn:hover { background: var(--bg-input, #252525); color: var(--text-primary, #fff); }
.slideout-btn.primary {
  background: var(--case-ih-red, #c8102e);
  border-color: var(--case-ih-red, #c8102e);
  color: #fff;
}
.slideout-btn.primary:hover { background: var(--case-ih-red-dark, #a60d25); }

/* ── Quick Schedule Modal ── */
.schedule-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: center;
}
.schedule-modal-overlay.open { display: flex; }

.schedule-modal {
  width: 420px;
  max-width: 92vw;
  max-height: 80vh;
  background: var(--bg-surface, #111);
  border: 1px solid var(--border-color, #333);
  border-radius: 14px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.6);
  display: flex;
  flex-direction: column;
}
.schedule-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  border-bottom: 1px solid var(--border-color, #333);
}
.schedule-modal-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary, #fff);
}
.schedule-modal-body { padding: 16px; overflow-y: auto; }
.schedule-modal-footer {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--border-color, #333);
}

/* Modal Form */
.sched-form-group { margin-bottom: 14px; }
.sched-form-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  color: var(--text-muted, #999);
  margin-bottom: 6px;
}
.sched-form-input,
.sched-form-select,
.sched-form-textarea {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg-input, #252525);
  border: 1px solid var(--border-color, #333);
  border-radius: 8px;
  color: var(--text-primary, #fff);
  font-size: 14px;
  font-family: inherit;
}
.sched-form-input:focus,
.sched-form-select:focus,
.sched-form-textarea:focus {
  outline: none;
  border-color: var(--case-ih-red, #c8102e);
}
.sched-form-textarea { min-height: 60px; resize: vertical; }

/* Job search dropdown */
.sched-job-search-results {
  background: var(--bg-card, #1a1a1a);
  border: 1px solid var(--border-color, #333);
  border-radius: 8px;
  margin-top: 4px;
  max-height: 160px;
  overflow-y: auto;
  display: none;
}
.sched-job-search-results.open { display: block; }
.sched-job-option {
  padding: 8px 12px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-secondary, #ccc);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}
.sched-job-option:hover { background: var(--bg-input, #252525); }
.sched-job-option:last-child { border-bottom: none; }
.sched-job-option .job-opt-ro { font-weight: 600; color: var(--text-primary, #fff); }
.sched-job-option .job-opt-customer { color: var(--text-muted, #999); margin-left: 8px; }

/* ── Responsive ── */
@media (max-width: 1024px) {
  .schedule-sidebar { width: 250px; min-width: 250px; }
  .sidebar-toggle { left: 250px; }
  .schedule-sidebar.collapsed ~ .sidebar-toggle { left: 0; }
}
@media (max-width: 768px) {
  .schedule-sidebar { width: 0; min-width: 0; overflow: hidden; border-right: none; }
  .schedule-sidebar:not(.collapsed) { width: 280px; min-width: 280px; position: absolute; z-index: 20; height: 100%; border-right: 1px solid var(--border-color, #333); }
  .sidebar-toggle { left: 0; }
  .schedule-sidebar:not(.collapsed) ~ .sidebar-toggle { left: 280px; }
  .schedule-slideout { width: 100vw; max-width: 100vw; }
}
