/* DoorForce Smart Sync — compact header pill + center panel (Technician) */

.df-smart-sync-chip {
  --df-ss-h: 42px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: var(--df-ss-h);
  min-height: 40px;
  max-height: 44px;
  max-width: min(220px, 42vw);
  flex: 0 1 auto;
  padding: 0 12px 0 10px;
  border: 1px solid var(--border-color, #d1d5db);
  border-radius: 999px;
  background: var(--surface, #fff);
  color: var(--text-primary, #111827);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
  text-align: left;
  box-sizing: border-box;
  vertical-align: middle;
  transition: border-color 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease;
}

.df-smart-sync-chip:hover {
  border-color: var(--navy, #0a2342);
}

.df-smart-sync-chip:focus {
  outline: none;
}

.df-smart-sync-chip:focus-visible {
  outline: 2px solid var(--navy, #0a2342);
  outline-offset: 2px;
  box-shadow: 0 0 0 3px rgba(10, 35, 66, 0.18);
}

.df-smart-sync-chip .df-ss-icon {
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--navy, #0a2342);
}

.df-smart-sync-chip .df-ss-icon svg {
  width: 20px;
  height: 20px;
  display: block;
}

.df-smart-sync-chip .df-ss-copy {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.df-smart-sync-chip .df-ss-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 14px;
  font-weight: 600;
}

.df-smart-sync-chip .df-ss-badge-count {
  flex: 0 0 auto;
  min-width: 1.35rem;
  height: 1.35rem;
  padding: 0 6px;
  border-radius: 999px;
  border: 1px solid currentColor;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.35rem;
  text-align: center;
  color: var(--navy, #0a2342);
  background: rgba(10, 35, 66, 0.06);
}

/* Status accents — always paired with icon + text (never color alone) */
.df-smart-sync-chip[data-status="synced"] .df-ss-icon { color: #065f46; }
.df-smart-sync-chip[data-status="syncing"] .df-ss-icon { color: #1d4ed8; }
.df-smart-sync-chip[data-status="offline-ready"] .df-ss-icon,
.df-smart-sync-chip[data-status="saved-offline"] .df-ss-icon { color: #92400e; }
.df-smart-sync-chip[data-status="uploads-pending"] .df-ss-icon { color: #1d4ed8; }
.df-smart-sync-chip[data-status="failed"] .df-ss-icon,
.df-smart-sync-chip[data-status="conflict"] .df-ss-icon { color: #991b1b; }

.df-smart-sync-chip[data-status="failed"],
.df-smart-sync-chip[data-status="conflict"] {
  border-color: #fecaca;
  background: #fef2f2;
}

.df-smart-sync-chip[data-status="saved-offline"],
.df-smart-sync-chip[data-status="offline-ready"] {
  border-color: #fde68a;
  background: #fffbeb;
}

.df-ss-spin {
  transform-origin: center;
  animation: df-ss-rotate 1.1s linear infinite;
}

@keyframes df-ss-rotate {
  to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
  .df-ss-spin { animation: none; }
}

/* Legacy banner removed from UI — hide if any residual markup remains */
.df-smart-sync-banner,
.df-smart-sync-banner.is-visible {
  display: none !important;
  margin: 0 !important;
  padding: 0 !important;
  border: 0 !important;
  height: 0 !important;
  overflow: hidden !important;
}

/* Temporary notices */
.df-ss-toast-host {
  position: fixed;
  left: 50%;
  bottom: 88px;
  transform: translateX(-50%);
  z-index: 13000;
  width: min(420px, calc(100vw - 24px));
  pointer-events: none;
}

.df-ss-toast {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--border-color, #e5e7eb);
  background: var(--surface, #fff);
  color: var(--text-primary, #111827);
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.16);
  font-size: 14px;
  line-height: 1.35;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.df-ss-toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.df-ss-toast.tone-success { border-color: #a7f3d0; background: #ecfdf5; }
.df-ss-toast.tone-info { border-color: #bfdbfe; background: #eff6ff; }
.df-ss-toast.tone-danger { border-color: #fecaca; background: #fef2f2; }

.df-ss-toast-msg { flex: 1; min-width: 0; }

.df-ss-toast-ack {
  flex: 0 0 auto;
  border: 1px solid var(--border-color, #d1d5db);
  background: var(--surface, #fff);
  border-radius: 8px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  color: var(--navy, #0a2342);
}

.df-ss-toast-ack:focus-visible {
  outline: 2px solid var(--navy, #0a2342);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  .df-ss-toast { transition: none; }
}

/* Per-item badges on job cards (unchanged role) */
.df-ss-badge {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 4px;
  border: 1px solid currentColor;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.df-ss-badge[data-state="pending"] { color: #92400e; }
.df-ss-badge[data-state="uploading"],
.df-ss-badge[data-state="syncing"] { color: #1d4ed8; }
.df-ss-badge[data-state="synced"] { color: #065f46; }
.df-ss-badge[data-state="failed"] { color: #991b1b; }

.df-smart-sync-panel {
  position: fixed;
  inset: 0;
  z-index: 12000;
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 48px 16px 24px;
  background: rgba(15, 23, 42, 0.45);
}

.df-smart-sync-panel.is-open { display: flex; }

.df-smart-sync-card {
  width: min(560px, 100%);
  max-height: calc(100vh - 72px);
  overflow: auto;
  background: var(--surface, #fff);
  color: var(--text-primary, #111827);
  border-radius: 12px;
  border: 1px solid var(--border-color, #e5e7eb);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.18);
  padding: 18px 18px 14px;
}

.df-smart-sync-card h2 {
  margin: 0 0 4px;
  font-size: 1.15rem;
  color: var(--navy, #0a2342);
}

.df-smart-sync-card .df-ss-sub {
  margin: 0 0 14px;
  color: var(--text-muted, #6b7280);
  font-size: 13px;
}

.df-ss-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 14px;
}

.df-ss-grid div {
  border: 1px solid var(--border-color, #e5e7eb);
  border-radius: 8px;
  padding: 10px;
}

.df-ss-grid span {
  display: block;
  font-size: 11px;
  color: var(--text-muted, #6b7280);
  margin-bottom: 4px;
}

.df-ss-grid strong {
  font-size: 16px;
}

.df-ss-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.df-ss-pending-list {
  border-top: 1px solid var(--border-color, #e5e7eb);
  padding-top: 10px;
  max-height: 220px;
  overflow: auto;
  font-size: 12px;
  margin: 0;
  padding-left: 0;
}

.df-ss-pending-list li {
  list-style: none;
  margin: 0 0 8px;
  padding: 8px;
  border: 1px solid var(--border-color, #e5e7eb);
  border-radius: 6px;
}

.df-ss-close {
  float: right;
}

.df-ss-warning {
  font-size: 12px;
  color: #92400e;
  margin: 0 0 8px;
}

.df-ss-conflict-box {
  margin-top: 10px;
  border: 1px solid #991b1b;
  border-radius: 8px;
  padding: 10px;
  font-size: 13px;
}

.df-ss-conflict-box p {
  font-size: 12px;
  margin: 6px 0;
}

.df-ss-conflict-item {
  margin-top: 8px;
}

/* Keep theme control clear of the pill */
.top-nav-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.top-nav-actions .df-theme-picker {
  flex: 0 0 auto;
}

@media (max-width: 640px) {
  .df-ss-grid { grid-template-columns: 1fr; }
  .df-smart-sync-chip {
    max-width: min(148px, 38vw);
    padding: 0 10px 0 8px;
    font-size: 13px;
  }
  .df-smart-sync-chip .df-ss-text { font-size: 13px; }
  .df-ss-toast-host { bottom: 76px; }
}

@media (max-width: 420px) {
  .df-smart-sync-chip {
    max-width: 118px;
  }
}
