/*!
 * Error Display Styles
 * Comprehensive styling for enhanced error messages and troubleshooting UI
 */

/* =================
   EXPAND/COLLAPSE ANIMATIONS (CSP-Safe)
   ================= */

.error-display__troubleshooting {
  overflow: hidden;
  transition: max-height 0.3s ease-out, opacity 0.3s ease-out;
  max-height: 2000px; /* Default expanded */
  opacity: 1;
}

.error-display__troubleshooting.collapsed {
  max-height: 0 !important;
  opacity: 0;
  padding-top: 0;
  padding-bottom: 0;
  margin-top: 0;
  margin-bottom: 0;
}

.error-display__troubleshooting.expanded {
  max-height: 2000px !important; /* Reasonable max height for content */
  opacity: 1;
}

/* Base Error Display */
.error-display {
  background: white;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
  margin: 16px 0;
  opacity: 0;
  transform: translateY(-20px);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  border-left: 4px solid var(--error-border, #dc3545);
  overflow: hidden;
  max-width: 100%;
}

.error-display.show {
  opacity: 1;
  transform: translateY(0);
}

.error-display.hide {
  opacity: 0;
  transform: translateY(-20px) scale(0.95);
}

/* Error Severity Variants */
.error-display--error {
  --error-border: #dc3545;
  --error-bg: #fff5f5;
  --error-color: #c53030;
}

.error-display--warning {
  --error-border: #f59e0b;
  --error-bg: #fffbeb;
  --error-color: #d97706;
}

.error-display--info {
  --error-border: #3b82f6;
  --error-bg: #eff6ff;
  --error-color: #2563eb;
}

.error-display--success {
  --error-border: #10b981;
  --error-bg: #f0fdf4;
  --error-color: #059669;
}

/* Content Container */
.error-display__content {
  padding: 20px;
}

/* Header Section */
.error-display__header {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 20px;
}

.error-display__icon {
  font-size: 24px;
  line-height: 1;
  flex-shrink: 0;
  margin-top: 2px;
}

.error-display__title-section {
  flex: 1;
  min-width: 0;
}

.error-display__title {
  color: var(--error-color);
  font-size: 18px;
  font-weight: 600;
  margin: 0 0 8px 0;
  line-height: 1.3;
}

.error-display__message {
  color: #4a5568;
  font-size: 14px;
  line-height: 1.5;
  margin: 0;
}

.error-display__close {
  background: none;
  border: none;
  color: #9ca3af;
  cursor: pointer;
  font-size: 24px;
  line-height: 1;
  padding: 4px;
  border-radius: 4px;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.error-display__close:hover {
  background-color: rgba(0, 0, 0, 0.05);
  color: #6b7280;
}

.error-display__close:focus {
  outline: 2px solid var(--error-color);
  outline-offset: 2px;
}

/* Actions Section */
.error-display__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 24px;
}

.error-display__btn {
  background: none;
  border: 2px solid;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  padding: 10px 16px;
  transition: all 0.2s ease;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px; /* Touch target */
}

.error-display__btn--primary {
  background-color: var(--error-color);
  border-color: var(--error-color);
  color: white;
}

.error-display__btn--primary:hover {
  background-color: var(--error-color);
  filter: brightness(1.1);
  transform: translateY(-1px);
}

.error-display__btn--primary:focus {
  outline: 2px solid var(--error-color);
  outline-offset: 2px;
}

.error-display__btn--secondary {
  background-color: transparent;
  border-color: var(--error-color);
  color: var(--error-color);
}

.error-display__btn--secondary:hover {
  background-color: var(--error-bg);
  transform: translateY(-1px);
}

.error-display__btn--secondary:focus {
  outline: 2px solid var(--error-color);
  outline-offset: 2px;
}

/* Section Styling */
.error-display__section {
  background-color: var(--error-bg);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 16px;
}

.error-display__section:last-child {
  margin-bottom: 0;
}

.error-display__section-title {
  color: var(--error-color);
  font-size: 16px;
  font-weight: 600;
  margin: 0 0 12px 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Recovery Steps */
.error-display__steps {
  list-style: none;
  margin: 0;
  padding: 0;
}

.error-display__step {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 12px;
  padding: 8px 0;
}

.error-display__step:last-child {
  margin-bottom: 0;
}

.error-display__step-number {
  background-color: var(--error-color);
  color: white;
  font-size: 12px;
  font-weight: 600;
  min-width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 2px;
}

.error-display__step-text {
  color: #374151;
  font-size: 14px;
  line-height: 1.5;
  flex: 1;
}

/* Troubleshooting Toggle */
.error-display__troubleshooting-toggle {
  background: none;
  border: none;
  color: var(--error-color);
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  padding: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  text-align: left;
  transition: all 0.2s ease;
  min-height: 44px; /* Touch target */
}

.error-display__troubleshooting-toggle:hover {
  opacity: 0.8;
}

.error-display__troubleshooting-toggle:focus {
  outline: 2px solid var(--error-color);
  outline-offset: 2px;
  border-radius: 4px;
}

.error-display__toggle-icon {
  margin-left: auto;
  transition: transform 0.2s ease;
  font-size: 12px;
}

.error-display__troubleshooting-toggle[aria-expanded="true"] .error-display__toggle-icon {
  transform: rotate(180deg);
}

/* Troubleshooting Content */
.error-display__troubleshooting {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
  margin-top: 16px;
}

.error-display__troubleshooting[aria-hidden="false"] {
  /* Height set via JavaScript */
}

.error-display__troubleshooting-item {
  border-left: 3px solid var(--error-color);
  padding-left: 16px;
  margin-bottom: 16px;
}

.error-display__troubleshooting-item:last-child {
  margin-bottom: 0;
}

.error-display__troubleshooting-step {
  color: var(--error-color);
  font-size: 14px;
  font-weight: 600;
  margin: 0 0 6px 0;
}

.error-display__troubleshooting-description {
  color: #6b7280;
  font-size: 13px;
  line-height: 1.4;
  margin: 0;
}

/* Modal Styles */
.error-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

.error-modal.show {
  opacity: 1;
  visibility: visible;
}

.error-modal.hide {
  opacity: 0;
  visibility: hidden;
}

.error-modal__backdrop {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
}

.error-modal__content {
  background: white;
  border-radius: 12px;
  box-shadow: 0 20px 64px rgba(0, 0, 0, 0.15);
  max-width: 600px;
  max-height: 80vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transform: scale(0.95);
  transition: transform 0.3s ease;
  position: relative;
}

.error-modal.show .error-modal__content {
  transform: scale(1);
}

.error-modal__header {
  padding: 24px 24px 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #e5e7eb;
  padding-bottom: 16px;
}

.error-modal__header h2 {
  color: #111827;
  font-size: 20px;
  font-weight: 600;
  margin: 0;
}

.error-modal__close {
  background: none;
  border: none;
  color: #9ca3af;
  cursor: pointer;
  font-size: 24px;
  line-height: 1;
  padding: 4px;
  border-radius: 4px;
  transition: all 0.2s ease;
}

.error-modal__close:hover {
  background-color: rgba(0, 0, 0, 0.05);
  color: #6b7280;
}

.error-modal__close:focus {
  outline: 2px solid #3b82f6;
  outline-offset: 2px;
}

.error-modal__body {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
}

.error-modal__footer {
  padding: 16px 24px 24px 24px;
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  border-top: 1px solid #e5e7eb;
}

/* Troubleshooting Modal Content */
.troubleshooting-step {
  margin-bottom: 24px;
}

.troubleshooting-step:last-child {
  margin-bottom: 0;
}

.troubleshooting-step h3 {
  color: #111827;
  font-size: 16px;
  font-weight: 600;
  margin: 0 0 8px 0;
}

.troubleshooting-step ul {
  margin: 0;
  padding-left: 20px;
}

.troubleshooting-step li {
  color: #374151;
  font-size: 14px;
  line-height: 1.5;
  margin-bottom: 4px;
}

/* Adapter Modal Content */
.adapter-category {
  margin-bottom: 24px;
}

.adapter-category:last-child {
  margin-bottom: 0;
}

.adapter-category h3 {
  color: #111827;
  font-size: 16px;
  font-weight: 600;
  margin: 0 0 12px 0;
}

.adapter-category ul {
  margin: 0;
  padding-left: 0;
  list-style: none;
}

.adapter-category li {
  background: #f9fafb;
  border-radius: 6px;
  color: #374151;
  font-size: 14px;
  line-height: 1.5;
  margin-bottom: 8px;
  padding: 12px;
}

.adapter-category li strong {
  color: #111827;
}

/* Responsive Design */
@media (max-width: 640px) {
  .error-display__content {
    padding: 16px;
  }
  
  .error-display__header {
    gap: 12px;
  }
  
  .error-display__title {
    font-size: 16px;
  }
  
  .error-display__actions {
    flex-direction: column;
  }
  
  .error-display__btn {
    justify-content: center;
  }
  
  .error-modal {
    padding: 12px;
  }
  
  .error-modal__content {
    max-height: 90vh;
  }
  
  .error-modal__header,
  .error-modal__body,
  .error-modal__footer {
    padding-left: 16px;
    padding-right: 16px;
  }
}

@media (max-width: 480px) {
  .error-display__header {
    flex-direction: column;
    align-items: stretch;
    gap: 16px;
  }
  
  .error-display__close {
    align-self: flex-end;
    margin-top: -8px;
  }
  
  .error-display__step {
    gap: 8px;
  }
  
  .error-display__step-number {
    min-width: 20px;
    height: 20px;
    font-size: 11px;
  }
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
  .error-display {
    border-width: 2px;
    border-style: solid;
  }
  
  .error-display__btn {
    border-width: 3px;
  }
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
  .error-display,
  .error-display__btn,
  .error-display__close,
  .error-display__troubleshooting-toggle,
  .error-display__toggle-icon,
  .error-display__troubleshooting,
  .error-modal,
  .error-modal__content {
    transition: none;
  }
  
  .error-display__btn:hover,
  .error-display__btn--secondary:hover {
    transform: none;
  }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
  .error-display {
    background: #1f2937;
    border-left-color: var(--error-border);
  }
  
  .error-display__title {
    color: var(--error-color);
  }
  
  .error-display__message {
    color: #d1d5db;
  }
  
  .error-display__close {
    color: #9ca3af;
  }
  
  .error-display__close:hover {
    background-color: rgba(255, 255, 255, 0.1);
    color: #f3f4f6;
  }
  
  .error-display__section {
    background-color: rgba(var(--error-bg-rgb, 0, 0, 0), 0.1);
  }
  
  .error-display__step-text {
    color: #d1d5db;
  }
  
  .error-display__troubleshooting-description {
    color: #9ca3af;
  }
  
  .error-modal__content {
    background: #1f2937;
  }
  
  .error-modal__header {
    border-bottom-color: #374151;
  }
  
  .error-modal__header h2 {
    color: #f9fafb;
  }
  
  .error-modal__footer {
    border-top-color: #374151;
  }
  
  .troubleshooting-step h3,
  .adapter-category h3 {
    color: #f9fafb;
  }
  
  .troubleshooting-step li,
  .adapter-category li {
    color: #d1d5db;
    background: #374151;
  }
  
  .adapter-category li strong {
    color: #f9fafb;
  }
}