/* ============================================================================
   Sync Client Styles
   ============================================================================ */

/* Nav button — sits alongside the gear/data-manager icon */
.sync-nav-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  color: var(--text-secondary);
  transition: color 0.2s, background 0.2s;
  position: relative;
}
.sync-nav-btn:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

/* Sync status dot */
.sync-nav-btn .sync-dot {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-muted);
  border: 1.5px solid var(--bg-primary);
}
.sync-nav-btn .sync-dot--synced {
  background: var(--status-success);
}
.sync-nav-btn .sync-dot--error {
  background: var(--status-error);
}
.sync-nav-btn .sync-dot--syncing {
  background: var(--status-info);
  animation: sync-pulse 1s ease-in-out infinite;
}

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

/* ============================================================================
   Sync Modal Overlay
   ============================================================================ */

.sync-overlay {
  position: fixed;
  inset: 0;
  z-index: 10001;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  padding: 16px;
}

.sync-modal {
  background: var(--bg-primary);
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  width: 100%;
  max-width: 420px;
  max-height: 90vh;
  overflow-y: auto;
  animation: sync-fade-in 0.2s ease-out;
}

@keyframes sync-fade-in {
  from { opacity: 0; transform: translateY(10px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.sync-modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 12px;
  border-bottom: 1px solid var(--border-color);
}

.sync-modal__header h2 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text-primary);
}

.sync-modal__close {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  color: var(--text-secondary);
  transition: color 0.15s, background 0.15s;
}
.sync-modal__close:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

.sync-modal__body {
  padding: 20px 24px 24px;
}

/* ============================================================================
   Auth Form (Login / Register)
   ============================================================================ */

.sync-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.sync-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sync-field label {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.sync-field input {
  padding: 10px 12px;
  border: 1.5px solid var(--border-color);
  border-radius: 8px;
  font-size: 0.95rem;
  background: var(--bg-primary);
  color: var(--text-primary);
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: none;
}
.sync-field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.sync-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 16px;
  border: none;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
}
.sync-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.sync-btn--primary {
  background: var(--accent);
  color: #fff;
}
.sync-btn--primary:hover:not(:disabled) {
  background: var(--accent-dark);
}

.sync-btn--outline {
  background: transparent;
  color: var(--text-secondary);
  border: 1.5px solid var(--border-color);
}
.sync-btn--outline:hover:not(:disabled) {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.sync-btn--danger {
  background: var(--status-error);
  color: #fff;
}
.sync-btn--danger:hover:not(:disabled) {
  background: var(--status-error-text);
}

.sync-btn--ghost {
  background: transparent;
  color: var(--accent);
  padding: 6px 4px;
}
.sync-btn--ghost:hover:not(:disabled) {
  text-decoration: underline;
}

.sync-form__toggle {
  text-align: center;
  font-size: 0.82rem;
  color: var(--text-secondary);
  margin-top: 4px;
}
.sync-form__toggle button {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font-size: inherit;
  font-weight: 500;
  padding: 0;
}
.sync-form__toggle button:hover {
  text-decoration: underline;
}

/* ============================================================================
   Sync Status View (logged in)
   ============================================================================ */

.sync-status {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.sync-user-info {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: var(--bg-secondary);
  border-radius: 10px;
}

.sync-user-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1rem;
  flex-shrink: 0;
}

.sync-user-details {
  flex: 1;
  min-width: 0;
}

.sync-user-name {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sync-user-email {
  font-size: 0.8rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sync-last-synced {
  font-size: 0.82rem;
  color: var(--text-secondary);
  text-align: center;
  padding: 4px 0;
}

.sync-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sync-message {
  text-align: center;
  font-size: 0.85rem;
  padding: 8px 12px;
  border-radius: 8px;
  animation: sync-fade-in 0.2s ease-out;
}

.sync-message--success {
  background: var(--status-success-soft);
  color: var(--status-success-text);
}

.sync-message--error {
  background: var(--status-error-soft);
  color: var(--status-error-text);
}

.sync-message--info {
  background: var(--status-info-soft);
  color: var(--status-info-text);
}

/* API URL field */
.sync-api-url {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 4px;
  padding-top: 12px;
  border-top: 1px solid var(--border-color);
}

.sync-api-url label {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.sync-api-url input {
  padding: 7px 10px;
  border: 1.5px solid var(--border-color);
  border-radius: 6px;
  font-size: 0.82rem;
  font-family: 'JetBrains Mono', monospace;
  background: var(--bg-primary);
  color: var(--text-primary);
  outline: none;
}
.sync-api-url input:focus {
  border-color: var(--accent);
}

.sync-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 4px;
  padding-top: 12px;
  border-top: 1px solid var(--border-color);
}

/* Spinner */
.sync-spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: sync-spin 0.6s linear infinite;
}
.sync-btn--outline .sync-spinner {
  border-color: var(--border-soft);
  border-top-color: var(--text-secondary);
}

@keyframes sync-spin {
  to { transform: rotate(360deg); }
}

/* ── Reduced motion ─────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .sync-nav-btn,
  .sync-modal__close,
  .sync-field input,
  .sync-btn,
  .sync-nav-btn .sync-dot--syncing,
  .sync-modal,
  .sync-message {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
