/**
 * Scenario Modal Styles
 * Styling for individual ethical scenario modals with radar chart integration
 * Based on hero-demo.css but adapted for modal context
 */

/* Modal Backdrop */
.scenario-modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  z-index: 1050;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.scenario-modal-backdrop.show {
  opacity: 1;
}

/* Modal Container */
.scenario-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1055;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 1rem;
  padding-top: 2rem;
  opacity: 0;
  transform: scale(0.9) translateY(-2rem);
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  overflow-y: auto;
}

/* Modal Dialog - this is the actual modal content */
.scenario-modal-dialog {
  display: flex;
  flex-direction: column;
  max-width: 1200px;
  max-height: calc(100vh - 4rem);
  width: 100%;
  margin: auto;
  background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
  border-radius: 24px;
  box-shadow:
    0 25px 50px -12px rgba(0, 0, 0, 0.25),
    0 8px 32px rgba(0, 0, 0, 0.12),
    inset 0 1px 0 rgba(255, 255, 255, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.8);
  overflow: hidden;
  position: relative;
}

.scenario-modal.show {
  opacity: 1;
  transform: scale(1) translateY(0);
}

/* Modal Header */
.scenario-modal-dialog .scenario-modal-header {
  padding: 2rem 2.5rem 1rem 2.5rem;
  border-bottom: 1px solid rgba(229, 231, 235, 0.6);
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  position: relative;
  flex-shrink: 0;
}

.scenario-modal-header::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(
    90deg,
    #667eea 0%,
    #764ba2 25%,
    #f093fb 50%,
    #f5576c 75%,
    #4facfe 100%
  );
}

.scenario-title-section {
  margin-bottom: 0.5rem;
}

.scenario-category {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.8);
  margin-bottom: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.scenario-title {
  font-size: 1.75rem;
  font-weight: 800;
  margin: 0;
  color: white;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  letter-spacing: -0.025em;
}

.close-button {
  position: absolute;
  top: 1.5rem;
  right: 2rem;
  background: rgba(255, 255, 255, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: white;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1.5rem;
  line-height: 1;
  transition: all 0.2s ease;
  backdrop-filter: blur(10px);
}

.close-button:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: scale(1.1);
}

.close-button:focus {
  outline: 2px solid rgba(255, 255, 255, 0.5);
  outline-offset: 2px;
}

/* Scenario Content - this is the main body area within scenario modals */
.scenario-modal .scenario-content,
.modal-dialog .scenario-content,
.scenario-modal-dialog .scenario-content {
  display: grid !important;
  grid-template-columns: 2fr 1fr !important;
  grid-template-areas: 'main sidebar' !important;
  gap: 3rem;
  align-items: start;
  padding: 2.5rem;
  flex: 1;
  overflow-y: auto;
  width: 100%;
  box-sizing: border-box;
  min-height: 0; /* Allow flex shrinking */
}

@media (max-width: 968px) {
  .scenario-modal .scenario-content,
  .modal-dialog .scenario-content,
  .scenario-modal-dialog .scenario-content {
    grid-template-columns: 1fr !important;
    grid-template-areas:
      'main'
      'sidebar' !important;
    gap: 2rem;
    padding: 1.5rem;
  }
}

/* Scenario Main Content Area */
.scenario-main {
  background: white;
  border-radius: 16px;
  padding: 2rem;
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.08);
  border: 1px solid rgba(229, 231, 235, 0.6);
  height: fit-content;
  grid-area: main !important;
}

/* Scenario Sidebar - Radar Chart Area */
.scenario-sidebar {
  background: white;
  border-radius: 16px;
  padding: 1rem;
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.08);
  border: 1px solid rgba(229, 231, 235, 0.6);
  height: fit-content;
  position: sticky;
  top: 2rem;
  grid-area: sidebar !important;
  /* Ensure enough space for radar chart with labels */
  min-width: 400px;
  max-width: 450px;
  overflow: visible;
  /* Ensure the sidebar provides enough space for chart labels */
  box-sizing: border-box;
}

.scenario-description {
  margin-bottom: 2rem;
}

.dilemma-section,
.ethical-question-section {
  margin-bottom: 1.5rem;
}

.dilemma-section h3,
.ethical-question-section h3,
.options-section h3 {
  font-size: 1.1rem;
  font-weight: 600;
  color: #374151;
  margin: 0 0 1rem 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.dilemma-section h3::before {
  content: '⚠️';
  font-size: 1.25rem;
  opacity: 0.8;
}

.ethical-question-section h3::before {
  content: '❓';
  font-size: 1.25rem;
  opacity: 0.8;
}

.options-section h3::before {
  content: '🎯';
  font-size: 1.25rem;
  opacity: 0.8;
}

.dilemma-text {
  font-size: 1.2rem;
  color: #1a202c;
  line-height: 1.8;
  margin: 0;
  font-weight: 600;
  background: linear-gradient(
    135deg,
    rgba(245, 158, 11, 0.1) 0%,
    rgba(251, 191, 36, 0.05) 100%
  );
  padding: 2rem;
  border-radius: 16px;
  border-left: 6px solid #f59e0b;
  border-top: 1px solid rgba(245, 158, 11, 0.2);
  border-right: 1px solid rgba(245, 158, 11, 0.2);
  border-bottom: 1px solid rgba(245, 158, 11, 0.2);
  box-shadow:
    0 4px 12px rgba(245, 158, 11, 0.15),
    inset 0 1px 0 rgba(255, 255, 255, 0.8);
  position: relative;
  font-style: italic;
}

.ethical-question {
  font-size: 1.15rem;
  color: #2d3748;
  line-height: 1.6;
  margin: 0;
  font-weight: 600;
  background: linear-gradient(
    135deg,
    rgba(102, 126, 234, 0.08) 0%,
    rgba(118, 75, 162, 0.04) 100%
  );
  padding: 1.75rem;
  border-radius: 12px;
  border: 2px solid rgba(102, 126, 234, 0.15);
  box-shadow: 0 2px 8px rgba(102, 126, 234, 0.1);
  position: relative;
}

/* Options Container */
.options-container {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  position: relative;
}

/* Option Cards - matching the actual HTML structure */
.option-card {
  display: block;
  width: 100%;
  padding: 1.25rem 1.5rem;
  background: white;
  border: 2px solid #e5e7eb;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.3s ease;
  text-align: left;
  font-size: 1rem;
  line-height: 1.5;
  position: relative;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.option-card:hover {
  border-color: #667eea;
  background: rgba(102, 126, 234, 0.03);
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(102, 126, 234, 0.15);
}

.option-card:focus {
  outline: none;
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.2);
}

.option-card.selected {
  border-color: #667eea;
  background: linear-gradient(
    135deg,
    rgba(102, 126, 234, 0.1) 0%,
    rgba(118, 75, 162, 0.05) 100%
  );
  transform: none;
  box-shadow: 0 4px 20px rgba(102, 126, 234, 0.2);
}

/* Enhanced hover state for selected option cards */
.option-card.selected:hover {
  border-color: #5a67d8;
  background: linear-gradient(
    135deg,
    rgba(90, 103, 216, 0.15) 0%,
    rgba(107, 70, 193, 0.08) 100%
  );
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(90, 103, 216, 0.25);
  cursor: pointer;
}

.option-card.selected:hover .option-title {
  color: #5a67d8;
  transition: color 0.2s ease;
}

.option-card.selected:hover .option-description {
  color: #6b46c1;
  transition: color 0.2s ease;
}

/* Add a subtle visual indicator for deselection */
.option-card.selected::after {
  content: '';
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  width: 20px;
  height: 20px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-radius: 50%;
  opacity: 0.8;
  transition: all 0.2s ease;
}

.option-card.selected:hover::after {
  background: linear-gradient(135deg, #5a67d8 0%, #6b46c1 100%);
  transform: scale(1.1);
  opacity: 1;
}

/* Add a subtle visual indicator for deselection */
.option-card.selected::before {
  content: '✓';
  position: absolute;
  top: 0.85rem;
  right: 0.85rem;
  width: 10px;
  height: 10px;
  color: white;
  font-size: 0.7rem;
  font-weight: bold;
  z-index: 1;
  transition: all 0.2s ease;
}

.option-card.selected:hover::before {
  content: '✓';
  font-size: 0.8rem;
  top: 0.8rem;
  right: 0.8rem;
}

.option-header {
  margin-bottom: 0.5rem;
}

.option-title {
  color: #374151;
  font-weight: 600;
  font-size: 1rem;
  margin: 0;
}

.option-description {
  color: #6b7280;
  font-size: 0.9rem;
  line-height: 1.4;
  margin: 0;
}

.option-details {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid rgba(229, 231, 235, 0.6);
}

/* Pros/Cons Popover */
.pros-cons-popover {
  position: absolute;
  top: -1rem;
  left: 50%;
  transform: translateX(-50%) translateY(-100%);
  background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
  border: 1px solid rgba(102, 126, 234, 0.15);
  border-radius: 20px;
  padding: 2rem;
  box-shadow:
    0 25px 50px rgba(0, 0, 0, 0.15),
    0 10px 25px rgba(102, 126, 234, 0.1),
    inset 0 1px 0 rgba(255, 255, 255, 0.8);
  z-index: 1000;
  min-width: 500px;
  max-width: 650px;
  opacity: 0;
  visibility: hidden;
  transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  pointer-events: none;
  backdrop-filter: blur(12px);
}

.pros-cons-popover.visible {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateX(-50%) translateY(-100%) translateY(-1rem) scale(1);
}

/* Popover Arrow */
.pros-cons-popover::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 12px solid transparent;
  border-top-color: #ffffff;
  z-index: 1001;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
}

.pros-cons-popover::before {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 13px solid transparent;
  border-top-color: rgba(102, 126, 234, 0.15);
  z-index: 1000;
}

.pros-cons-content .option-description {
  margin-bottom: 2rem;
  text-align: center;
}

.pros-cons-content .option-description h6 {
  font-size: 1.25rem;
  font-weight: 700;
  color: #1a202c;
  margin: 0 0 0.75rem 0;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.pros-cons-content .option-description p {
  color: #4a5568;
  line-height: 1.6;
  margin: 0;
  font-size: 1rem;
}

.pros-cons-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
}

.pros-section,
.cons-section {
  background: rgba(255, 255, 255, 0.7);
  padding: 1.5rem;
  border-radius: 12px;
  border: 1px solid rgba(229, 231, 235, 0.5);
}

.pros-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: #059669;
  margin: 0 0 1rem 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.cons-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: #dc2626;
  margin: 0 0 1rem 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.pros-list,
.cons-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.pros-list li,
.cons-list li {
  margin-bottom: 0.75rem;
  padding-left: 1.5rem;
  position: relative;
  color: #374151;
  line-height: 1.5;
  font-size: 0.95rem;
}

.pros-list li::before {
  content: '•';
  position: absolute;
  left: 0;
  color: #059669;
  font-weight: bold;
  font-size: 1.2rem;
}

.cons-list li::before {
  content: '•';
  position: absolute;
  left: 0;
  color: #dc2626;
  font-weight: bold;
  font-size: 1.2rem;
}

/* Radar Chart Container - matching actual HTML structure - override radar-chart.css */
/* Radar Chart - Direct styling without redundant container */
.scenario-modal #scenario-radar-chart {
  text-align: center;
  position: static !important;
  width: 100% !important;
  max-width: 420px !important; /* Increased max-width for larger chart */
  margin: 1rem auto !important;
  padding: 0.5rem !important; /* Reduce padding to give more space to chart */
  background: none !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  border: none !important;
  backdrop-filter: none !important;
  /* Force grid placement */
  grid-area: auto;
  /* Ensure proper sizing for chart - increased min-height for labels */
  min-height: 450px;
  overflow: visible !important;
  /* Ensure container can accommodate chart labels */
  display: flex !important;
  flex-direction: column;
  justify-content: center;
  /* Ensure visibility and proper sizing */
  visibility: visible !important;
  /* Prevent any text content from showing */
  position: relative;
}

/* Remove the old radar-chart-container h3 styling and apply directly if needed */
.scenario-modal .chart-legend h3 {
  font-size: 1.25rem;
  font-weight: 700;
  color: #1a202c;
  margin: 0 0 1.5rem 0;
  text-align: center;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}



/* Ensure no unwanted text content displays in the radar chart */
.scenario-modal #scenario-radar-chart:empty::before {
  content: '';
  display: none;
}

.scenario-modal #scenario-radar-chart:empty::after {
  content: '';
  display: none;
}

/* Canvas specific styling for the radar chart */
.scenario-modal #scenario-radar-chart canvas {
  max-width: 100% !important;
  width: 400px !important; /* Increased width for chart */
  height: 400px !important; /* Increased height for chart */
  display: block !important;
  margin: 0 auto !important;
  /* Prevent clipping - ensure Chart.js has space for labels */
  transform: none !important;
  overflow: visible !important;
  /* Remove padding to give more space to the chart itself */
  padding: 0;
  box-sizing: border-box;
}

.scenario-modal .chart-legend {
  margin-top: 1.5rem;
}

.scenario-modal .chart-legend p {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 0;
  padding: 1rem;
  background: rgba(102, 126, 234, 0.05);
  border-radius: 10px;
  font-size: 0.9rem;
  color: #4a5568;
  border: 1px solid rgba(102, 126, 234, 0.1);
}

/* Modal Footer */
.scenario-modal-dialog .scenario-modal-footer {
  padding: 1rem 2rem 1.25rem 2rem;
  background: rgba(248, 250, 252, 0.8);
  border-top: 1px solid rgba(229, 231, 235, 0.6);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-shrink: 0;
}

.scenario-modal-footer .btn {
  padding: 0.75rem 2rem;
  font-size: 1rem;
  font-weight: 600;
  border-radius: 8px;
  transition: all 0.2s ease;
  border: none;
  cursor: pointer;
}

.scenario-modal-footer .btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
}

.scenario-modal-footer .btn-secondary {
  background: white;
  color: #6b7280;
  border: 2px solid #e5e7eb;
}

.scenario-modal-footer .btn-secondary:hover:not(:disabled) {
  background: #f9fafb;
  border-color: #d1d5db;
  transform: translateY(-1px);
}

.scenario-modal-footer .btn-primary {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.scenario-modal-footer .btn-primary:hover:not(:disabled) {
  box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
  transform: translateY(-2px);
}

/* Feedback Close Button */
.feedback-close {
  position: absolute;
  top: 1.5rem;
  right: 1.5rem;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(102, 126, 234, 0.2);
  cursor: pointer;
  padding: 0.5rem;
  border-radius: 50%;
  color: #6b7280;
  font-size: 1.25rem;
  line-height: 1;
  transition: all 0.2s ease;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.feedback-close:hover {
  background: rgba(239, 68, 68, 0.1);
  border-color: rgba(239, 68, 68, 0.3);
  color: #ef4444;
  transform: scale(1.1);
}

.feedback-close:focus {
  outline: 2px solid #667eea;
  outline-offset: 2px;
}

/* Typewriter Effect Styles */
.typewriter-cursor {
  display: inline-block;
  background-color: currentColor;
  margin-left: 2px;
  width: 2px;
  animation: typewriter-blink 1s infinite;
}

@keyframes typewriter-blink {
  0%, 50% { opacity: 1; }
  51%, 100% { opacity: 0; }
}

/* Ensure typewriter text elements have proper spacing */
.dilemma-text,
.ethical-question {
  min-height: 1.5em;
  line-height: 1.6;
}

/* Additional typewriter styles for better visual experience */
.scenario-description .dilemma-section,
.scenario-description .ethical-question-section {
  margin-bottom: 2rem;
}

.scenario-description h3 {
  margin-bottom: 1rem;
  opacity: 1;
  transition: opacity 0.3s ease;
}

/* Ensure smooth rendering during typewriter effect */
.dilemma-text,
.ethical-question {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  letter-spacing: 0.01em;
  word-spacing: 0.02em;
}

/* Hide text initially if typewriter is enabled */
.typewriter-ready .dilemma-text,
.typewriter-ready .ethical-question {
  opacity: 0;
  transition: opacity 0.3s ease;
}

.typewriter-active .dilemma-text,
.typewriter-active .ethical-question {
  opacity: 1;
}

/* Responsive Design */
@media (max-width: 768px) {
  .scenario-modal {
    padding: 0.5rem;
    padding-top: 1rem;
  }

  .scenario-modal-dialog {
    max-height: calc(100vh - 2rem);
  }

  .scenario-modal-dialog .scenario-modal-header {
    padding: 1.5rem 1.5rem 1rem 1.5rem;
  }

  .scenario-title {
    font-size: 1.5rem;
  }

  .close-button {
    top: 1rem;
    right: 1rem;
    width: 36px;
    height: 36px;
  }

  .scenario-modal .scenario-content,
  .modal-dialog .scenario-content,
  .scenario-modal-dialog .scenario-content {
    padding: 1.5rem;
  }

  .scenario-main,
  .scenario-sidebar {
    padding: 1.5rem;
    min-width: auto; /* Remove min-width on mobile */
  }

  /* Mobile radar chart adjustments */
  .scenario-modal #scenario-radar-chart {
    min-height: 350px;
    padding: 0.25rem !important;
    max-width: 320px !important; /* Increased from 300px */
  }

  .scenario-modal #scenario-radar-chart canvas {
    width: 320px !important; /* Increased from 300px */
    height: 320px !important; /* Increased from 300px */
    padding: 10px; /* Reduced padding */
  }

  .pros-cons-grid {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }

  .pros-cons-popover {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    min-width: auto;
    max-width: 90vw;
    max-height: 80vh;
    overflow-y: auto;
    margin: 0;
  }

  .pros-cons-popover.visible {
    transform: translate(-50%, -50%) scale(1);
  }

  .pros-cons-popover::after,
  .pros-cons-popover::before {
    display: none;
  }

  .scenario-modal-footer {
    padding: 1rem 1.5rem;
    flex-direction: column;
    gap: 0.75rem;
  }

  .scenario-modal-footer .btn {
    width: 100%;
    justify-content: center;
  }
}

@media (max-width: 480px) {
  .scenario-modal {
    padding: 0.25rem;
    padding-top: 0.5rem;
  }

  .scenario-modal-dialog {
    max-height: calc(100vh - 1rem);
  }

  .scenario-title {
    font-size: 1.25rem;
  }

  .ethical-question {
    font-size: 1rem;
  }

  .option-card {
    padding: 1rem;
    font-size: 0.95rem;
  }

  .pros-cons-popover {
    padding: 1.5rem;
    max-width: 95vw;
  }
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
  .option-btn {
    border-width: 3px;
  }

  .option-btn:focus {
    box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.5);
  }

  .pros-cons-popover {
    border-width: 2px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
  }
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
  .scenario-modal,
  .scenario-modal-backdrop,
  .option-btn,
  .pros-cons-popover,
  .feedback-close {
    transition: none;
    animation: none;
  }

  .option-btn:hover {
    transform: none;
  }

  .scenario-modal.show {
    transform: none;
  }

  .pros-cons-popover.visible {
    transform: translateX(-50%) translateY(-100%) translateY(-1rem);
  }

  @media (max-width: 768px) {
    .pros-cons-popover.visible {
      transform: translate(-50%, -50%);
    }
  }
}
