/* Error Handling and States */

/* Global Error Styles */
.error-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  text-align: center;
  color: var(--muted);
  background: rgba(220, 53, 69, 0.05);
  border: 1px solid rgba(220, 53, 69, 0.2);
  border-radius: 8px;
  margin: 1rem 0;
}

.error-state.compact {
  padding: 1rem;
  margin: 0.5rem 0;
}

.error-icon {
  font-size: 2.5rem;
  color: #dc3545;
  margin-bottom: 1rem;
}

.error-icon.small {
  font-size: 1.5rem;
  margin-bottom: 0.5rem;
}

.error-title {
  font-size: 1.25rem;
  font-weight: 600;
  color: #721c24;
  margin-bottom: 0.5rem;
}

.error-message {
  color: #856404;
  margin-bottom: 1rem;
  line-height: 1.5;
}

.error-actions {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  justify-content: center;
}

/* Specific Error States */
.network-error {
  border-color: rgba(255, 193, 7, 0.3);
  background: rgba(255, 193, 7, 0.05);
}

.network-error .error-icon {
  color: #ffc107;
}

.validation-error {
  border-color: rgba(220, 53, 69, 0.3);
  background: rgba(220, 53, 69, 0.05);
}

.timeout-error {
  border-color: rgba(108, 117, 125, 0.3);
  background: rgba(108, 117, 125, 0.05);
}

.timeout-error .error-icon {
  color: #6c757d;
}

/* Form Field Errors */
.form-field {
  position: relative;
  margin-bottom: 1rem;
}

.form-field.error input,
.form-field.error textarea,
.form-field.error select {
  border-color: #dc3545;
  box-shadow: 0 0 0 0.2rem rgba(220, 53, 69, 0.25);
}

.form-field.error .field-error {
  display: block;
}

.field-error {
  display: none;
  color: #dc3545;
  font-size: 0.875rem;
  margin-top: 0.25rem;
  position: absolute;
  left: 0;
  top: 100%;
}

.field-success {
  color: #28a745;
  font-size: 0.875rem;
  margin-top: 0.25rem;
}

/* Inline Error Messages */
.inline-error {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: #dc3545;
  font-size: 0.9rem;
  padding: 0.5rem 1rem;
  background: rgba(220, 53, 69, 0.1);
  border-radius: 4px;
  margin: 0.5rem 0;
}

.inline-success {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: #28a745;
  font-size: 0.9rem;
  padding: 0.5rem 1rem;
  background: rgba(40, 167, 69, 0.1);
  border-radius: 4px;
  margin: 0.5rem 0;
}

.inline-warning {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: #856404;
  font-size: 0.9rem;
  padding: 0.5rem 1rem;
  background: rgba(255, 193, 7, 0.1);
  border-radius: 4px;
  margin: 0.5rem 0;
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 10000;
  max-width: 350px;
}

.toast {
  background: white;
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  margin-bottom: 10px;
  padding: 1rem;
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  transform: translateX(100%);
  transition: transform 0.3s ease;
  border-left: 4px solid #6c757d;
}

.toast.show {
  transform: translateX(0);
}

.toast.error {
  border-left-color: #dc3545;
}

.toast.success {
  border-left-color: #28a745;
}

.toast.warning {
  border-left-color: #ffc107;
}

.toast.info {
  border-left-color: #17a2b8;
}

.toast-icon {
  font-size: 1.2rem;
  margin-top: 0.1rem;
}

.toast-content {
  flex: 1;
}

.toast-title {
  font-weight: 600;
  margin-bottom: 0.25rem;
  color: var(--text);
}

.toast-message {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.4;
}

.toast-close {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 0;
  margin-left: auto;
  font-size: 1.2rem;
}

.toast-close:hover {
  color: var(--text);
}

/* Page-level Error States */
.page-error {
  min-height: 400px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 2rem;
}

.page-error-content {
  max-width: 500px;
}

.page-error .error-icon {
  font-size: 4rem;
  margin-bottom: 2rem;
}

/* LinkedIn Jobs Error States */
.linkedin-jobs-error {
  padding: 2rem;
  text-align: center;
  background: rgba(255, 193, 7, 0.05);
  border: 1px solid rgba(255, 193, 7, 0.2);
  border-radius: 8px;
  margin: 1rem 0;
}

.linkedin-jobs-error .error-icon {
  color: #ffc107;
  font-size: 2rem;
  margin-bottom: 1rem;
}

.linkedin-jobs-error h3 {
  color: #856404;
  margin-bottom: 0.5rem;
}

.linkedin-jobs-error p {
  color: #6c757d;
  margin-bottom: 1.5rem;
}

/* Service Loading Errors */
.service-card.error {
  border-color: rgba(220, 53, 69, 0.3);
  background: rgba(220, 53, 69, 0.02);
}

.service-card.error .service-content {
  opacity: 0.7;
}

.service-error-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.95);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: inherit;
}

/* Retry Mechanisms */
.retry-button {
  background: var(--brand-primary);
  color: white;
  border: none;
  padding: 0.5rem 1rem;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: background-color 0.3s ease;
}

.retry-button:hover {
  background: var(--brand-dark);
}

.retry-button:disabled {
  background: #6c757d;
  cursor: not-allowed;
}

/* Offline State */
.offline-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background: #856404;
  color: white;
  text-align: center;
  padding: 0.5rem;
  z-index: 10001;
  transform: translateY(-100%);
  transition: transform 0.3s ease;
}

.offline-banner.show {
  transform: translateY(0);
}

/* Accessibility - Screen reader optimized */
.error-state[role="alert"] {
  /* Properly announced to screen readers with built-in styling */
  position: relative;
}

/* Responsive Error States */
@media (max-width: 768px) {
  .toast-container {
    right: 10px;
    left: 10px;
    max-width: none;
  }
  
  .toast {
    margin-bottom: 8px;
  }
  
  .error-actions {
    flex-direction: column;
    align-items: center;
  }
  
  .page-error {
    padding: 1rem;
    min-height: 300px;
  }
  
  .page-error .error-icon {
    font-size: 3rem;
    margin-bottom: 1.5rem;
  }
}

/* Dark Mode Error States */
@media (prefers-color-scheme: dark) {
  .error-state {
    background: rgba(220, 53, 69, 0.1);
    border-color: rgba(220, 53, 69, 0.3);
  }
  
  .toast {
    background: var(--surface);
    color: var(--text);
  }
  
  .toast-title {
    color: var(--text);
  }
  
  .service-error-overlay {
    background: rgba(30, 30, 30, 0.95);
  }
}

/* Animation for Error States */
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}

.shake {
  animation: shake 0.5s ease-in-out;
}

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

.error-state {
  animation: fadeInError 0.3s ease-out;
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
  .shake {
    animation: none;
  }
  
  .error-state {
    animation: none;
  }
  
  .toast {
    transition: none;
  }
}