/* Character Refresh Controller Styles - Task 6 Implementation */

/* Refresh Button Container */
.character-refresh-container {
  margin-bottom: 1rem;
}

.character-refresh-container .modern-card {
  background: var(--bg-card, rgba(255, 255, 255, 0.05));
  border: 1px solid var(--border-primary, rgba(255, 255, 255, 0.1));
  border-radius: var(--radius-lg, 15px);
  transition: var(--transition-normal, 0.3s ease);
}

.character-refresh-container .modern-card:hover {
  background: var(--bg-card-hover, rgba(255, 255, 255, 0.08));
  transform: translateY(-1px);
}

/* Refresh Button Styles */
.refresh-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  background: linear-gradient(
    45deg,
    var(--accent-primary, #4ecdc4),
    var(--accent-tertiary, #45b7d1)
  );
  color: white;
  border: none;
  border-radius: var(--radius-md, 10px);
  font-weight: 600;
  font-size: var(--font-size-base, 1rem);
  cursor: pointer;
  transition: var(--transition-normal, 0.3s ease);
  text-decoration: none;
  user-select: none;
  position: relative;
  overflow: hidden;
}

.refresh-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(78, 205, 196, 0.3);
}

.refresh-btn:active:not(:disabled) {
  transform: translateY(0);
}

.refresh-btn:disabled {
  background: var(--gradient-disabled, linear-gradient(45deg, #666, #888));
  cursor: not-allowed;
  opacity: 0.6;
}

.refresh-btn.disabled {
  background: var(--gradient-disabled, linear-gradient(45deg, #666, #888));
  cursor: not-allowed;
  opacity: 0.6;
}

/* Refresh Icon Animation */
.refresh-icon {
  transition: transform 0.3s ease;
}

.refresh-icon.fa-spin {
  animation: spin 1s linear infinite;
}

@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

/* Refresh Status Display */
.character-refresh-status-container {
  text-align: center;
}

.refresh-status {
  font-size: var(--font-size-small, 0.9rem);
  font-weight: 500;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm, 5px);
  transition: var(--transition-fast, 0.2s ease);
  min-height: 1.5rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto;
}

.refresh-status.status-loading {
  color: var(--accent-tertiary, #45b7d1);
  background: rgba(69, 183, 209, 0.1);
  border: 1px solid rgba(69, 183, 209, 0.3);
}

.refresh-status.status-success {
  color: var(--accent-primary, #4ecdc4);
  background: rgba(78, 205, 196, 0.1);
  border: 1px solid rgba(78, 205, 196, 0.3);
}

.refresh-status.status-error {
  color: var(--accent-secondary, #ff6b6b);
  background: rgba(255, 107, 107, 0.1);
  border: 1px solid rgba(255, 107, 107, 0.3);
}

.refresh-status.status-warning {
  color: var(--accent-warning, #ffc107);
  background: rgba(255, 193, 7, 0.1);
  border: 1px solid rgba(255, 193, 7, 0.3);
}

/* Character Card Loading States */
.character-card.refreshing {
  position: relative;
  opacity: 0.7;
}

.refresh-loading-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: inherit;
  z-index: 10;
}

.refresh-loading-spinner {
  color: var(--accent-primary, #4ecdc4);
  font-size: 1.5rem;
}

.refresh-loading-spinner i {
  animation: spin 1s linear infinite;
}

/* Character Card Updated State */
.character-card.recently-updated {
  animation: cardUpdated 2s ease-out;
}

@keyframes cardUpdated {
  0% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(78, 205, 196, 0.7);
  }
  50% {
    transform: scale(1.02);
    box-shadow: 0 0 0 10px rgba(78, 205, 196, 0.3);
  }
  100% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(78, 205, 196, 0);
  }
}

/* Character Image Update Animations */
.character-image.image-loading {
  opacity: 0.5;
  filter: blur(2px);
  transition: all 0.3s ease;
}

.character-image.image-updated {
  animation: imageUpdated 1s ease-out;
}

@keyframes imageUpdated {
  0% {
    opacity: 0;
    transform: scale(0.95);
  }
  50% {
    opacity: 1;
    transform: scale(1.05);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

/* Field Update Highlight Animation */
.field-updated {
  animation: fieldHighlight 1.5s ease-out;
  position: relative;
}

@keyframes fieldHighlight {
  0% {
    background-color: rgba(78, 205, 196, 0.3);
    color: var(--accent-primary, #4ecdc4);
  }
  50% {
    background-color: rgba(78, 205, 196, 0.2);
  }
  100% {
    background-color: transparent;
    color: inherit;
  }
}

/* Cache Status Update Styles */
.cache-status-info {
  font-size: var(--font-size-small, 0.85rem);
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-sm, 5px);
  display: inline-block;
  transition: all 0.3s ease;
}

.cache-status-info.cache-fresh {
  background: rgba(78, 205, 196, 0.15);
  color: var(--accent-primary, #4ecdc4);
  border: 1px solid rgba(78, 205, 196, 0.3);
}

.cache-status-info.cache-valid {
  background: rgba(69, 183, 209, 0.15);
  color: var(--accent-tertiary, #45b7d1);
  border: 1px solid rgba(69, 183, 209, 0.3);
}

.cache-status-info.cache-stale {
  background: rgba(255, 193, 7, 0.15);
  color: var(--accent-warning, #ffc107);
  border: 1px solid rgba(255, 193, 7, 0.3);
}

/* Toast Notification Styles */
.refresh-toast {
  position: fixed;
  top: 20px;
  right: 20px;
  max-width: 400px;
  background: var(--bg-card, rgba(255, 255, 255, 0.05));
  backdrop-filter: blur(10px);
  border: 1px solid var(--border-primary, rgba(255, 255, 255, 0.1));
  border-radius: var(--radius-lg, 15px);
  padding: 1rem;
  z-index: var(--z-notification, 1000);
  transform: translateX(100%);
  opacity: 0;
  transition: all 0.3s ease;
}

.refresh-toast.show {
  transform: translateX(0);
  opacity: 1;
}

.refresh-toast.toast-success {
  border-left: 4px solid var(--accent-primary, #4ecdc4);
}

.refresh-toast.toast-error {
  border-left: 4px solid var(--accent-secondary, #ff6b6b);
}

.refresh-toast.toast-warning {
  border-left: 4px solid var(--accent-warning, #ffc107);
}

.toast-content {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  min-height: 40px;
}

.toast-icon {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: bold;
  flex-shrink: 0;
}

.toast-success .toast-icon {
  background: var(--accent-primary, #4ecdc4);
  color: white;
}

/* Removed duplicate ::before pseudo-element - using FontAwesome icons instead */

.toast-error .toast-icon {
  background: var(--accent-secondary, #ff6b6b);
  color: white;
}

/* Removed duplicate ::before pseudo-element - using FontAwesome icons instead */

.toast-warning .toast-icon {
  background: var(--accent-warning, #ffc107);
  color: black;
}

/* Removed duplicate ::before pseudo-element - using FontAwesome icons instead */

.toast-message {
  flex: 1;
  color: #ffffff !important;
  font-size: 1rem !important;
  font-weight: bold !important;
  line-height: 1.4;
  white-space: pre-line;
}

/* Toast Actions Container */
.toast-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

/* Toast Retry Button - Task 15 (Requirement 6.4) */
.toast-retry {
  background: var(--accent-primary, #4ecdc4);
  border: none;
  color: white;
  cursor: pointer;
  padding: 0.4rem 0.8rem;
  border-radius: var(--radius-sm, 5px);
  font-size: var(--font-size-small, 0.85rem);
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  transition: var(--transition-fast, 0.2s ease);
  white-space: nowrap;
}

.toast-retry:hover {
  background: var(--accent-primary-hover, #45b8af);
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(78, 205, 196, 0.3);
}

.toast-retry:active {
  transform: translateY(0);
}

.toast-retry i {
  font-size: 0.9rem;
}

/* Toast Close Button */
.toast-close {
  background: none;
  border: none;
  color: var(--secondary-text, #b0b0b0);
  cursor: pointer;
  padding: 0;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: var(--transition-fast, 0.2s ease);
  flex-shrink: 0;
}

.toast-close:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--primary-text, #e0e0e0);
}

/* Responsive Design */
@media (max-width: 768px) {
  .character-refresh-container .flex {
    flex-direction: column;
    gap: 1rem;
    align-items: stretch;
  }

  .refresh-btn {
    width: 100%;
    justify-content: center;
  }

  .refresh-status {
    text-align: center;
  }

  .refresh-toast {
    right: 10px;
    left: 10px;
    max-width: none;
  }
}

@media (max-width: 480px) {
  .character-refresh-container .modern-card {
    padding: 1rem;
  }

  .refresh-btn {
    padding: 0.5rem 1rem;
    font-size: var(--font-size-small, 0.9rem);
  }

  .toast-content {
    gap: 0.5rem;
  }

  .toast-message {
    font-size: 0.8rem;
  }
}

/* Section Header with Button Layout */
.section-header-with-button {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--spacing-lg, 20px);
  gap: var(--spacing-md, 15px);
}

.section-header-with-button h2 {
  margin: 0;
  /* Use same styling as other h2 elements for consistency */
  font-size: 2rem;
  font-weight: 600;
  line-height: 1.2;
  color: inherit;
}

/* Legacy support for character-selection-header (deprecated) */
.character-selection-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--spacing-lg, 20px);
  gap: var(--spacing-md, 15px);
}

.character-selection-header h2 {
  margin: 0;
  font-size: 2rem;
  font-weight: 600;
  line-height: 1.2;
  color: inherit;
}

/* Refresh Button in Header */
.section-header-with-button .refresh-btn,
.character-selection-header .refresh-btn {
  flex-shrink: 0;
  min-width: 120px;
}

/* Responsive Header Layout */
@media (max-width: 768px) {
  .section-header-with-button,
  .character-selection-header {
    flex-direction: column;
    align-items: stretch;
    gap: var(--spacing-sm, 10px);
  }

  .section-header-with-button h2,
  .character-selection-header h2 {
    text-align: center;
    justify-content: center;
  }

  .section-header-with-button .refresh-btn,
  .character-selection-header .refresh-btn {
    width: 100%;
    min-width: auto;
  }
}

@media (max-width: 480px) {
  .section-header-with-button,
  .character-selection-header {
    gap: var(--spacing-xs, 5px);
  }

  .section-header-with-button h2,
  .character-selection-header h2 {
    font-size: 1.5rem; /* Slightly smaller but still consistent */
  }

  .section-header-with-button .refresh-btn,
  .character-selection-header .refresh-btn {
    padding: 0.5rem 1rem;
    font-size: var(--font-size-small, 0.9rem);
  }
}

/* Enhanced Button Styling for Header Integration */
.section-header-with-button .refresh-btn,
.character-selection-header .refresh-btn {
  /* Let modern-btn-primary handle the main styling */
  flex-shrink: 0;
  min-width: 120px;
}

/* Specific overrides for refresh button in header */
.section-header-with-button .refresh-btn.modern-btn-primary:disabled,
.character-selection-header .refresh-btn.modern-btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: var(--shadow-sm);
}

/* Refresh icon animation enhancement */
.section-header-with-button .refresh-btn .refresh-icon,
.character-selection-header .refresh-btn .refresh-icon {
  transition: transform 0.3s ease;
}

.section-header-with-button .refresh-btn .refresh-icon.fa-spin,
.character-selection-header .refresh-btn .refresh-icon.fa-spin {
  animation: spin 1s linear infinite;
}

/* Utility Classes */
.flex {
  display: flex;
}

.justify-between {
  justify-content: space-between;
}

.items-center {
  align-items: center;
}

.space-x-4 > * + * {
  margin-left: 1rem;
}

.mb-4 {
  margin-bottom: 1rem;
}

.p-4 {
  padding: 1rem;
}

.text-lg {
  font-size: var(--font-size-large, 1.1rem);
}

.font-medium {
  font-weight: 500;
}

/* Animation for button state changes */
.refresh-btn .refresh-text {
  transition: all 0.2s ease;
}

.refresh-btn:disabled .refresh-text,
.refresh-btn.disabled .refresh-text {
  opacity: 0.7;
}

/* Focus styles for accessibility */
.refresh-btn:focus {
  outline: 2px solid var(--accent-primary, #4ecdc4);
  outline-offset: 2px;
}

.toast-close:focus {
  outline: 2px solid var(--accent-primary, #4ecdc4);
  outline-offset: 1px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  .refresh-btn {
    border: 2px solid currentColor;
  }

  .refresh-status {
    border-width: 2px;
  }

  .refresh-toast {
    border-width: 2px;
  }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  .refresh-icon.fa-spin {
    animation: none;
  }

  .refresh-loading-spinner i {
    animation: none;
  }

  .character-card.recently-updated {
    animation: none;
  }

  .refresh-toast {
    transition: opacity 0.3s ease;
  }
}
