/**
 * Sticky Save Button for Django Admin Changelist Views
 *
 * Shows a floating save button at the bottom of the viewport when
 * the original save button is scrolled out of view.
 */

/* Container for sticky save button */
#sticky-save-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 9998;  /* Just below toast-container */
  display: none;  /* Hidden by default, shown via JS */
  flex-direction: row;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(0, 0, 0, 0.05);
  transition: opacity 0.2s ease, transform 0.2s ease;
  opacity: 0;
  transform: translateY(10px);
}

#sticky-save-container.visible {
  display: flex;
  opacity: 1;
  transform: translateY(0);
}

/* Animation for showing/hiding */
#sticky-save-container.fade-in {
  animation: stickySaveSlideIn 0.2s ease forwards;
}

#sticky-save-container.fade-out {
  animation: stickySaveSlideOut 0.2s ease forwards;
}

@keyframes stickySaveSlideIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes stickySaveSlideOut {
  from {
    opacity: 1;
    transform: translateY(0);
  }
  to {
    opacity: 0;
    transform: translateY(10px);
  }
}

/* Info text */
#sticky-save-container .sticky-save-info {
  color: #666;
  font-size: 12px;
  margin-right: 4px;
}

/* Button styling - match Django admin default button */
#sticky-save-container .sticky-save-btn {
  background: var(--default-button-bg, #205067);
  color: var(--default-button-fg, #fff);
  border: none;
  border-radius: 4px;
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease;
  display: flex;
  align-items: center;
  gap: 8px;
}

#sticky-save-container .sticky-save-btn:hover {
  background: var(--default-button-hover-bg, #417690);
}

#sticky-save-container .sticky-save-btn:active {
  transform: scale(0.98);
}

#sticky-save-container .sticky-save-btn:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

/* Secondary buttons (Save and continue, Save and add another) - match Django's button style */
#sticky-save-container .sticky-save-btn.secondary {
  background: var(--button-bg, #417690);
  color: var(--button-fg, #fff);
}

#sticky-save-container .sticky-save-btn.secondary:hover {
  background: var(--button-hover-bg, #205067);
}

/* Spinner inside button */
#sticky-save-container .sticky-save-btn .spinner {
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top: 2px solid #fff;
  width: 14px;
  height: 14px;
}


/* Keyboard shortcut hint */
#sticky-save-container .sticky-save-shortcut {
  font-size: 11px;
  color: #999;
  background: #f0f0f0;
  padding: 2px 6px;
  border-radius: 3px;
  margin-left: 4px;
}

/* Responsive - on mobile, full width at bottom */
@media (max-width: 767px) {
  #sticky-save-container {
    left: 10px;
    right: 10px;
    bottom: 10px;
    justify-content: center;
  }

  #sticky-save-container .sticky-save-info {
    display: none;
  }
}

/* Dark mode support (Django 4.1+) */
@media (prefers-color-scheme: dark) {
  #sticky-save-container {
    background: #2a2a2a;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(255, 255, 255, 0.1);
  }

  #sticky-save-container .sticky-save-info {
    color: #aaa;
  }

  #sticky-save-container .sticky-save-shortcut {
    background: #404040;
    color: #bbb;
  }
}
