/* Background transfer manager — floating FAB + panel, shown on every page.
   Mirrors the DocSync toast look: #2563eb blue, white cards, rounded, soft shadow.
   z-index sits below the reminder toast stack (99999). */

#ds-tm-fab {
  position: fixed;
  right: 22px;
  bottom: 22px;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: #2563eb;
  color: #fff;
  border: none;
  box-shadow: 0 6px 18px rgba(37, 99, 235, .35);
  display: none;                 /* shown by JS only when transfers exist */
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 9990;
  transition: transform .12s ease, background .12s ease;
}
#ds-tm-fab:hover { transform: translateY(-2px); background: #1d4ed8; }
#ds-tm-fab i { font-size: 22px; line-height: 1; }

#ds-tm-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: 10px;
  background: #ef4444;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 20px;
  text-align: center;
  display: none;
}

#ds-tm-panel {
  position: fixed;
  right: 22px;
  bottom: 84px;
  width: 360px;
  max-width: calc(100vw - 32px);
  max-height: 60vh;
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 12px 34px rgba(15, 23, 42, .22);
  border: 1px solid #e5e7eb;
  display: none;
  flex-direction: column;
  overflow: hidden;
  z-index: 9991;
}
#ds-tm-panel.open { display: flex; }

#ds-tm-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  background: #2563eb;
  color: #fff;
  font-weight: 600;
  font-size: 14px;
}
#ds-tm-head .ds-tm-close {
  background: transparent;
  border: none;
  color: #fff;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  opacity: .85;
}
#ds-tm-head .ds-tm-close:hover { opacity: 1; }

#ds-tm-list {
  overflow-y: auto;
  padding: 8px;
  flex: 1 1 auto;
}
#ds-tm-empty { padding: 22px 12px; text-align: center; color: #94a3b8; font-size: 13px; }

.ds-tm-item {
  border: 1px solid #eef0f3;
  border-radius: 10px;
  padding: 9px 10px;
  margin-bottom: 8px;
  background: #fff;
}
.ds-tm-item:last-child { margin-bottom: 0; }
.ds-tm-item-top {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}
.ds-tm-icon { flex: 0 0 auto; font-size: 16px; color: #64748b; }
.ds-tm-name {
  flex: 1 1 auto;
  font-size: 13px;
  font-weight: 600;
  color: #1e293b;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ds-tm-actions { flex: 0 0 auto; display: flex; gap: 4px; }
.ds-tm-actions button {
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
  color: #64748b;
  padding: 2px 4px;
  border-radius: 6px;
}
.ds-tm-actions button:hover { background: #f1f5f9; color: #1e293b; }

.ds-tm-bar {
  height: 6px;
  border-radius: 4px;
  background: #eef2f7;
  overflow: hidden;
}
.ds-tm-bar > span {
  display: block;
  height: 100%;
  width: 0%;
  background: #2563eb;
  transition: width .15s ease;
}
.ds-tm-meta {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: #94a3b8;
  margin-top: 4px;
}

.ds-tm-item.done .ds-tm-bar > span { background: #16a34a; }
.ds-tm-item.done .ds-tm-icon { color: #16a34a; }
.ds-tm-item.failed .ds-tm-bar > span { background: #ef4444; }
.ds-tm-item.failed .ds-tm-icon { color: #ef4444; }
.ds-tm-status { font-weight: 600; }
.ds-tm-item.done .ds-tm-status { color: #16a34a; }
.ds-tm-item.failed .ds-tm-status { color: #ef4444; }

#ds-tm-foot {
  padding: 8px 12px;
  border-top: 1px solid #eef0f3;
  text-align: right;
}
#ds-tm-foot button {
  border: none;
  background: transparent;
  color: #2563eb;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
#ds-tm-foot button:hover { text-decoration: underline; }

/* Inline toast used for start/success/error messages. */
#ds-tm-toasts {
  position: fixed;
  right: 22px;
  bottom: 84px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 9992;
  pointer-events: none;
}
.ds-tm-toast {
  background: #1f2937;
  color: #fff;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 13px;
  box-shadow: 0 8px 22px rgba(15, 23, 42, .28);
  border-left: 4px solid #2563eb;
  max-width: 320px;
  pointer-events: auto;
  animation: ds-tm-slidein .18s ease;
}
.ds-tm-toast.success { border-left-color: #16a34a; }
.ds-tm-toast.error { border-left-color: #ef4444; }
@keyframes ds-tm-slidein {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}

@media (max-width: 576px) {
  #ds-tm-panel { right: 8px; left: 8px; width: auto; bottom: 78px; }
  #ds-tm-toasts { right: 8px; left: 8px; }
  .ds-tm-toast { max-width: none; }
}
