/**
 * @file
 * Styles for HTTP Client components (loading states, error messages, etc.)
 */

/* Loading spinner */
.loading-spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid #f3f3f3;
  border-top: 2px solid #3498db;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-left: 8px;
  vertical-align: middle;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Loading state for elements */
.loading {
  position: relative;
  opacity: 0.7;
  pointer-events: none;
}

/* Loading state for buttons */
button.loading,
input[type="button"].loading,
input[type="submit"].loading {
  opacity: 0.7;
  cursor: not-allowed;
}

/* HTTP Client error messages */
.http-client-error-message {
  background-color: #f8d7da;
  color: #721c24;
  border: 1px solid #f5c6cb;
  border-radius: 4px;
  padding: 12px 16px;
  margin: 8px 0;
  font-size: 14px;
  line-height: 1.4;
  display: block;
  animation: slideDown 0.3s ease-out;
}

.http-client-error-message::before {
  content: "⚠️ ";
  margin-right: 8px;
}

/* Success messages */
.http-client-success-message {
  background-color: #d4edda;
  color: #155724;
  border: 1px solid #c3e6cb;
  border-radius: 4px;
  padding: 12px 16px;
  margin: 8px 0;
  font-size: 14px;
  line-height: 1.4;
  display: block;
  animation: slideDown 0.3s ease-out;
}

.http-client-success-message::before {
  content: "✓ ";
  margin-right: 8px;
}

/* Warning messages */
.http-client-warning-message {
  background-color: #fff3cd;
  color: #856404;
  border: 1px solid #ffeaa7;
  border-radius: 4px;
  padding: 12px 16px;
  margin: 8px 0;
  font-size: 14px;
  line-height: 1.4;
  display: block;
  animation: slideDown 0.3s ease-out;
}

.http-client-warning-message::before {
  content: "⚠️ ";
  margin-right: 8px;
}

/* Animation for messages */
@keyframes slideDown {
  0% {
    opacity: 0;
    transform: translateY(-10px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Fade out animation */
.http-client-message-fade-out {
  animation: fadeOut 0.3s ease-out forwards;
}

@keyframes fadeOut {
  0% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translateY(-10px);
  }
}

/* Account Plan specific styles */
.account-plan__message {
  background-color: #f8f9fa;
  border-radius: 4px;
  padding: 12px 16px;
  margin: 16px 0;
  font-size: 14px;
  line-height: 1.4;
  border-left: 4px solid #6c757d;
  animation: slideDown 0.3s ease-out;
}

.account-plan__message--success {
  background-color: #d4edda;
  color: #155724;
  border-left-color: #28a745;
}

.account-plan__message--success::before {
  content: "✓ ";
  margin-right: 8px;
  font-weight: bold;
}

.account-plan__message--error {
  background-color: #f8d7da;
  color: #721c24;
  border-left-color: #dc3545;
}

.account-plan__message--error::before {
  content: "✕ ";
  margin-right: 8px;
  font-weight: bold;
}

.account-plan__message--warning {
  background-color: #fff3cd;
  color: #856404;
  border-left-color: #ffc107;
}

.account-plan__message--warning::before {
  content: "⚠️ ";
  margin-right: 8px;
}

/* Account plan button loading states */
.account-plan__submit--loading {
  opacity: 0.7;
  cursor: not-allowed;
  position: relative;
}

.account-plan__submit--loading::after {
  content: "";
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  border: 2px solid transparent;
  border-top: 2px solid currentColor;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

/* Header account info processing state */
.header__account-info--processing {
  opacity: 0.7;
  pointer-events: none;
  position: relative;
}

.header__account-info--processing::after {
  content: "";
  position: absolute;
  top: 50%;
  right: 8px;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  border: 2px solid #f3f3f3;
  border-top: 2px solid #3498db;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .http-client-error-message,
  .http-client-success-message,
  .http-client-warning-message,
  .account-plan__message {
    margin: 12px 0;
    padding: 10px 12px;
    font-size: 13px;
  }

  .loading-spinner {
    width: 14px;
    height: 14px;
  }
}

/* Focus states for accessibility */
.http-client-error-message:focus,
.http-client-success-message:focus,
.http-client-warning-message:focus,
.account-plan__message:focus {
  outline: 2px solid #0056b3;
  outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  .http-client-error-message {
    border-width: 2px;
    font-weight: bold;
  }
  
  .http-client-success-message {
    border-width: 2px;
    font-weight: bold;
  }
  
  .http-client-warning-message {
    border-width: 2px;
    font-weight: bold;
  }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  .loading-spinner,
  .account-plan__submit--loading::after,
  .header__account-info--processing::after {
    animation: none;
  }
  
  .http-client-error-message,
  .http-client-success-message,
  .http-client-warning-message,
  .account-plan__message {
    animation: none;
  }
}
