/* ===================================
   ANALYSIS RESULTS - MODERN UI
   =================================== */

/* Results Container */
.results-wrapper {
  max-width: 1400px;
  margin: 0 auto;
  padding: 2rem;
  animation: fadeInUp 0.6s ease-out;
}

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

/* Header Section */
.results-page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--color-border);
}

.results-title-section h1 {
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  background: linear-gradient(135deg, var(--color-primary), var(--color-accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.results-subtitle {
  color: var(--color-text-muted);
  font-size: 0.95rem;
}

.results-actions {
  display: flex;
  gap: 0.75rem;
}

/* Patient Information Card */
.patient-info-card {
  background: var(--color-card);
  border-radius: 16px;
  padding: 2rem;
  margin-bottom: 2rem;
  border: 1px solid var(--color-border);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.patient-info-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
}

.patient-info-header {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--color-border);
}

.patient-info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1.5rem;
}

.patient-info-item {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.patient-info-label {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.patient-info-value {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--color-text);
}

/* Summary Card */
.summary-card {
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.05), rgba(139, 92, 246, 0.05));
  border-radius: 16px;
  padding: 2rem;
  padding-bottom: 2.5rem;
  margin-bottom: 7rem;
  border: 1px solid var(--color-border);
  border-left: 4px solid var(--color-primary);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
  position: relative;
  overflow: visible;
  z-index: 1;
  isolation: isolate;
}

.summary-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, transparent, rgba(255, 255, 255, 0.05));
  pointer-events: none;
}

.summary-card.severity-critical {
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.05), rgba(220, 38, 38, 0.05));
  border-left-color: var(--color-destructive);
}

.summary-card.severity-warning {
  background: linear-gradient(135deg, rgba(251, 191, 36, 0.05), rgba(245, 158, 11, 0.05));
  border-left-color: var(--color-warning);
}

.summary-card.severity-normal {
  background: linear-gradient(135deg, rgba(34, 197, 94, 0.05), rgba(22, 163, 74, 0.05));
  border-left-color: var(--color-success);
}

.summary-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1rem;
}

.summary-title {
  font-size: 1.35rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
}

.summary-text {
  color: var(--color-text-muted);
  line-height: 1.7;
  font-size: 1rem;
}

.summary-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2rem;
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid rgba(0, 0, 0, 0.05);
  position: relative;
  z-index: 1;
}

.stat-box {
  text-align: center;
  padding: 1rem;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.5);
  backdrop-filter: blur(10px);
  transition: transform 0.2s ease;
  position: relative;
  z-index: 1;
}

.stat-box:hover {
  transform: scale(1.05);
  z-index: 2;
}

.stat-number {
  font-size: 2.5rem;
  font-weight: 700;
  line-height: 1;
  margin-bottom: 0.5rem;
}

.stat-number.critical {
  color: var(--color-destructive);
}

.stat-number.warning {
  color: var(--color-warning);
}

.stat-number.info {
  color: var(--color-primary);
}

.stat-label {
  font-size: 0.9rem;
  color: var(--color-text-muted);
  font-weight: 500;
}

/* Severity Badge */
.severity-badge {
  padding: 0.5rem 1.25rem;
  border-radius: 50px;
  font-weight: 600;
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.severity-badge.critical {
  background: var(--color-destructive);
  color: white;
}

.severity-badge.warning {
  background: var(--color-warning);
  color: white;
}

.severity-badge.normal {
  background: var(--color-success);
  color: white;
}

.severity-badge.info {
  background: var(--color-primary);
  color: white;
}

/* Results Section - All Collapsible */
.results-section {
  margin-bottom: 2rem;
  animation: slideIn 0.5s ease-out;
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
  position: relative;
  z-index: 2;
  clear: both;
  isolation: isolate;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateX(-20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.section-header {
  padding: 1.5rem 2rem;
  color: white;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
  transition: opacity 0.2s ease;
}

.section-header:hover {
  opacity: 0.9;
}

.section-header.critical {
  background: linear-gradient(135deg, #ef4444, #dc2626);
}

.section-header.warning {
  background: linear-gradient(135deg, #f59e0b, #d97706);
}

.section-header.info {
  background: linear-gradient(135deg, #3b82f6, #2563eb);
}

.section-header.success {
  background: linear-gradient(135deg, #22c55e, #16a34a);
}

.section-title {
  font-size: 1.35rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.section-count {
  background: rgba(255, 255, 255, 0.2);
  padding: 0.25rem 0.75rem;
  border-radius: 50px;
  font-size: 0.9rem;
}

.section-subtitle {
  font-size: 0.9rem;
  opacity: 0.9;
  margin-top: 0.25rem;
}

.section-toggle-icon {
  transition: transform 0.3s ease;
  color: white;
  flex-shrink: 0;
}

.section-toggle-icon.expanded {
  transform: rotate(180deg);
}

.section-content {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.4s ease, padding 0.4s ease;
  background: var(--color-card);
}

.section-content.expanded {
  max-height: 10000px;
  padding: 2rem;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

/* Test Result Card */
.test-result-card {
  background: var(--color-background);
  border-radius: 12px;
  padding: 1.5rem;
  margin-bottom: 1rem;
  border-left: 4px solid transparent;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

.test-result-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  transition: width 0.3s ease;
}

.test-result-card:hover {
  transform: translateX(4px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.test-result-card.critical {
  border-left-color: var(--color-destructive);
  background: linear-gradient(to right, rgba(239, 68, 68, 0.03), transparent);
}

.test-result-card.critical::before {
  background: var(--color-destructive);
}

.test-result-card.warning {
  border-left-color: var(--color-warning);
  background: linear-gradient(to right, rgba(251, 191, 36, 0.03), transparent);
}

.test-result-card.warning::before {
  background: var(--color-warning);
}

.test-result-card.info {
  border-left-color: var(--color-primary);
  background: linear-gradient(to right, rgba(59, 130, 246, 0.03), transparent);
}

.test-result-card.info::before {
  background: var(--color-primary);
}

.test-result-card.normal {
  border-left-color: var(--color-success);
  background: linear-gradient(to right, rgba(34, 197, 94, 0.03), transparent);
}

.test-result-card.normal::before {
  background: var(--color-success);
}

.test-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.test-name {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--color-text);
}

.test-value {
  font-size: 1.5rem;
  font-weight: 700;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.test-value.critical {
  color: var(--color-destructive);
  background: rgba(239, 68, 68, 0.1);
}

.test-value.warning {
  color: var(--color-warning);
  background: rgba(251, 191, 36, 0.1);
}

.test-value.info {
  color: var(--color-primary);
  background: rgba(59, 130, 246, 0.1);
}

.test-value.normal {
  color: var(--color-success);
  background: rgba(34, 197, 94, 0.1);
}

.test-reference {
  font-size: 0.9rem;
  color: var(--color-text-muted);
  margin-bottom: 1rem;
}

.test-reasoning {
  background: rgba(59, 130, 246, 0.05);
  border-left: 3px solid var(--color-primary);
  padding: 1rem;
  margin-top: 1rem;
  border-radius: 8px;
}

.test-reasoning-title {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--color-primary);
  margin-bottom: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.test-reasoning-text {
  font-size: 0.95rem;
  line-height: 1.6;
  color: var(--color-text);
}

.test-guidelines {
  background: rgba(139, 92, 246, 0.05);
  border-left: 3px solid var(--color-accent);
  padding: 1rem;
  margin-top: 0.75rem;
  border-radius: 8px;
}

.test-guidelines-title {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--color-accent);
  margin-bottom: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.test-guidelines-text {
  font-size: 0.95rem;
  line-height: 1.6;
  color: var(--color-text-muted);
}

.immediate-attention-badge {
  background: linear-gradient(135deg, #ef4444, #dc2626);
  color: white;
  padding: 1rem;
  margin-top: 1rem;
  border-radius: 8px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

.immediate-attention-icon {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
}

/* Collapsible Section */
.collapsible-section {
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: 16px;
  overflow: hidden;
  margin-bottom: 2rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.collapsible-header {
  padding: 1.5rem 2rem;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: background 0.2s ease;
  user-select: none;
}

.collapsible-header:hover {
  background: rgba(0, 0, 0, 0.02);
}

.collapsible-title {
  font-size: 1.25rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--color-text);
}

.collapsible-icon {
  transition: transform 0.3s ease;
  color: var(--color-text-muted);
}

.collapsible-icon.expanded {
  transform: rotate(180deg);
}

.collapsible-content {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.4s ease, padding 0.4s ease;
}

.collapsible-content.expanded {
  max-height: 5000px;
  padding: 2rem;
  border-top: 1px solid var(--color-border);
}

.normal-results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1rem;
}

/* Action Footer */
.results-actions-footer {
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: 16px;
  padding: 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 2rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.action-buttons {
  display: flex;
  gap: 1rem;
}

/* Print Styles */
@media print {
  .results-actions,
  .results-actions-footer,
  .collapsible-icon {
    display: none !important;
  }

  .collapsible-content {
    max-height: none !important;
    padding: 2rem !important;
  }

  .test-result-card {
    page-break-inside: avoid;
  }
}

/* Responsive */
@media (max-width: 768px) {
  .results-wrapper {
    padding: 1rem;
  }

  .results-page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
  }

  .patient-info-grid {
    grid-template-columns: 1fr;
  }

  .summary-stats {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .test-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
  }

  .normal-results-grid {
    grid-template-columns: 1fr;
  }

  .results-actions-footer {
    flex-direction: column;
    gap: 1rem;
  }

  .action-buttons {
    width: 100%;
    flex-direction: column;
  }
}

