/* Compatibility Calculator Page Styles */

.compatibility-calculator {
  background: white;
  border-radius: 12px;
  padding: 32px;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  margin-bottom: 24px;
}

.page-description {
  color: #666;
  margin-bottom: 24px;
  line-height: 1.6;
}

.character-selection {
  display: flex;
  flex-direction: column;
  gap: 32px;
  margin-bottom: 32px;
}

/* Section Styling */
.selection-section {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.section-caption {
  font-size: 0.85rem;
  font-weight: 600;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

/* Grid Layouts */
.selection-grid {
  display: grid;
  gap: 16px;
  width: 100%;
}

.support-grid {
  grid-template-columns: repeat(4, 1fr);
}

.legacy-grid {
  grid-template-columns: repeat(2, 1fr);
  max-width: 600px;
  margin: 0 auto;
}

/* Character Card */
.character-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 12px;
  background: #f8f9fa;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  transition: all 0.2s;
  width: 100%;
  min-width: 0; /* Prevent overflow */
  cursor: pointer;
  position: relative;
}

.character-card:hover {
  border-color: var(--main-color, #8b5cf6);
  box-shadow: 0 2px 4px rgba(139, 92, 246, 0.1);
  background: #f5f3ff;
}



.character-card.locked {
  cursor: default;
}

.character-card.locked:hover {
  border-color: #e0e0e0;
  box-shadow: none;
  background: #f0f0f0;
  transform: none;
}

.character-card.locked .character-portrait {
  cursor: default;
}

.locked-indicator {
  font-size: 0.7rem;
  color: #999;
  text-align: center;
  margin-top: 4px;
  font-weight: 500;
}

.character-portrait {
  width: 80px;
  height: 80px;
  border-radius: 6px;
  border: 2px solid #ddd;
  background: white;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
  flex-shrink: 0;
}

.character-portrait.clickable {
  cursor: pointer;
  transition: all 0.2s;
  pointer-events: auto;
}

.character-portrait.clickable:hover {
  border-color: var(--main-color, #8b5cf6);
  transform: scale(1.05);
  box-shadow: 0 2px 8px rgba(139, 92, 246, 0.2);
}

.character-card.locked .character-portrait {
  cursor: default;
  pointer-events: none;
}

.main-char-card .character-portrait {
  width: 100px;
  height: 100px;
}

.character-portrait img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
}

.empty-portrait {
  color: #999;
  font-size: 0.75rem;
  text-align: center;
  padding: 8px;
  line-height: 1.2;
}

.slot-label {
  font-size: 0.8rem;
  font-weight: 500;
  color: #555;
  text-align: center;
}

.character-select {
  width: 100%;
  padding: 6px 10px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 0.85rem;
  background: white;
  cursor: pointer;
  outline: none;
  transition: border-color 0.2s;
  pointer-events: auto; /* Allow clicking on select even when card is clickable */
}

.character-select:focus {
  border-color: var(--main-color, #8b5cf6);
  box-shadow: 0 0 0 2px rgba(139, 92, 246, 0.1);
}

.character-select:hover {
  border-color: var(--main-color, #8b5cf6);
}

/* Main Character Section */
.main-section {
  margin-top: 8px;
}

.main-char-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 24px;
  background: #f8f9fa;
  border: 2px solid #e0e0e0;
  border-radius: 12px;
}

.main-char-card {
  background: white;
  padding: 16px;
  max-width: 200px;
}

/* Affinity Results */
.affinity-results {
  background: #f8f9fa;
  border-radius: 8px;
  padding: 0;
  margin-top: 32px;
  overflow: hidden;
}

/* Collapsed Header */
.affinity-header-collapsed {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  cursor: pointer;
  background: white;
  transition: background 0.2s;
  border-bottom: 1px solid #e0e0e0;
}

.affinity-header-collapsed:hover {
  background: #f8f9fa;
}

.affinity-header-content {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
}

.affinity-label-inline {
  font-size: 0.95rem;
  color: #666;
}

.affinity-value-inline {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--main-color, #8b5cf6);
}

.status-icon-inline {
  font-size: 1.8rem;
  line-height: 1;
  font-weight: normal;
}

.affinity-toggle-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 8px;
  color: #666;
  font-size: 1rem;
  transition: transform 0.3s, color 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.affinity-toggle-btn:hover {
  color: var(--main-color, #8b5cf6);
}

.affinity-results.collapsed .toggle-icon {
  transform: rotate(-90deg);
}

.affinity-expanded-content {
  padding: 24px;
  display: block;
}

.affinity-results.collapsed .affinity-expanded-content {
  display: none;
}

/* Spark Requirements Results */
.spark-requirements-results {
  margin-top: 16px;
  padding: 0;
  background: #f8f9fa;
  border-radius: 12px;
  border: 1px solid #e0e0e0;
  overflow: hidden;
}

/* Collapsed Header */
.spark-requirements-header-collapsed {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  cursor: pointer;
  background: white;
  transition: background 0.2s;
  border-bottom: 1px solid #e0e0e0;
}

.spark-requirements-header-collapsed:hover {
  background: #f8f9fa;
}

.spark-requirements-header-content {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
}

.spark-requirements-label-inline {
  font-size: 0.95rem;
  font-weight: 600;
  color: #333;
}

.spark-requirements-toggle-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 8px;
  color: #666;
  font-size: 1rem;
  transition: transform 0.3s, color 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.spark-requirements-toggle-btn:hover {
  color: var(--main-color, #8b5cf6);
}

.spark-requirements-results.collapsed .toggle-icon {
  transform: rotate(-90deg);
}

.spark-requirements-expanded-content {
  padding: 24px;
  display: block;
}

.spark-requirements-results.collapsed .spark-requirements-expanded-content {
  display: none;
}

.spark-requirements-intro {
  font-size: 0.95rem;
  color: #666;
  margin-bottom: 20px;
  line-height: 1.6;
}

.spark-requirements-list {
  background: white;
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 16px;
}

.spark-requirement-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid #f0f0f0;
}

.spark-requirement-item:last-child {
  border-bottom: none;
}

.spark-requirement-item.spark-requirement-section {
  font-weight: 600;
  color: #333;
  padding-top: 16px;
  padding-bottom: 8px;
  border-bottom: 2px solid #eee;
}

.spark-requirement-item.spark-requirement-subitem {
  padding-left: 24px;
  font-size: 0.95rem;
}

.spark-requirement-label {
  font-size: 0.95rem;
  color: #555;
  flex: 1;
}

.spark-requirement-value {
  font-size: 1rem;
  font-weight: 600;
  color: var(--main-color, #8b5cf6);
  min-width: 120px;
  text-align: right;
}

.spark-requirement-value.requirement-ok {
  color: var(--main-color, #8b5cf6);
}

.spark-requirement-value.requirement-missing {
  color: var(--sub-color, #ef4444);
}

.spark-requirements-note {
  font-size: 0.85rem;
  color: #666;
  font-style: italic;
  padding-top: 12px;
  border-top: 1px solid #e0e0e0;
}

/* Spark Status Results */
.spark-status-results {
  margin-top: 16px;
  padding: 0;
  background: #f8f9fa;
  border-radius: 12px;
  border: 1px solid #e0e0e0;
  overflow: hidden;
}

/* Collapsed Header */
.spark-status-header-collapsed {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  cursor: pointer;
  background: white;
  transition: background 0.2s;
  border-bottom: 1px solid #e0e0e0;
}

.spark-status-header-collapsed:hover {
  background: #f8f9fa;
}

.spark-status-header-content {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
}

.spark-status-label-inline {
  font-size: 0.95rem;
  font-weight: 600;
  color: #333;
}

.spark-status-toggle-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 8px;
  color: #666;
  font-size: 1rem;
  transition: transform 0.3s, color 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.spark-status-toggle-btn:hover {
  color: var(--main-color, #8b5cf6);
}

.spark-status-results.collapsed .toggle-icon {
  transform: rotate(-90deg);
}

.spark-status-expanded-content {
  padding: 24px;
  display: block;
}

.spark-status-results.collapsed .spark-status-expanded-content {
  display: none;
}

.spark-status-intro {
  font-size: 0.95rem;
  color: #666;
  margin-bottom: 20px;
  line-height: 1.6;
}

.spark-status-list {
  background: white;
  border-radius: 8px;
  padding: 20px;
}

.spark-status-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid #f0f0f0;
}

.spark-status-item:last-child {
  border-bottom: none;
}

.spark-status-item.spark-status-section {
  font-weight: 600;
  color: #333;
  padding-top: 16px;
  padding-bottom: 8px;
  border-bottom: 2px solid #eee;
}

.spark-status-item.spark-status-subitem {
  padding-left: 24px;
  font-size: 0.95rem;
}

.spark-status-label {
  font-size: 0.95rem;
  color: #555;
  flex: 1;
}

.spark-status-value {
  font-size: 1rem;
  font-weight: 600;
  min-width: 80px;
  text-align: right;
}

.spark-status-value.fulfilled {
  color: var(--main-color, #10b981);
}

.spark-status-value.unfulfilled {
  color: var(--sub-color, #ef4444);
}

.total-affinity {
  text-align: center;
  margin-bottom: 20px;
}

.affinity-label {
  font-size: 1rem;
  color: #666;
  margin-bottom: 8px;
}

.affinity-value {
  font-size: 3rem;
  font-weight: 700;
  color: var(--main-color, #8b5cf6);
}

.affinity-status {
  text-align: center;
  margin-bottom: 24px;
  padding: 16px;
  background: white;
  border-radius: 8px;
}

.status-icon {
  font-size: 3rem;
  margin-bottom: 8px;
  line-height: 1;
  font-weight: normal;
}

.status-text {
  font-size: 1.1rem;
  font-weight: 600;
  color: #333;
  margin-bottom: 4px;
}

/* Compatibility level colors */
.affinity-status[data-level="great"] .status-icon {
  color: #10b981; /* Green for great */
}

.affinity-status[data-level="good"] .status-icon {
  color: var(--main-color, #3b82f6); /* Theme color for good */
}

.affinity-status[data-level="poor"] .status-icon {
  color: #ef4444; /* Red for poor */
}

.status-requirement {
  font-size: 0.9rem;
  color: #666;
}

.points-breakdown {
  background: white;
  border-radius: 8px;
  padding: 20px;
}

.breakdown-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: #333;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 2px solid #eee;
}

.breakdown-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid #f0f0f0;
}

.breakdown-item:last-child {
  border-bottom: none;
}

.breakdown-label {
  font-size: 0.95rem;
  color: #555;
  flex: 1;
}

.breakdown-value {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--main-color, #8b5cf6);
  min-width: 40px;
  text-align: right;
}

/* Responsive */
@media (max-width: 1024px) {
  .support-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  .compatibility-calculator {
    padding: 20px;
  }

  .support-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .legacy-grid {
    grid-template-columns: 1fr;
    max-width: 100%;
  }

  .character-card {
    padding: 10px;
  }

  .character-portrait {
    width: 70px;
    height: 70px;
  }

  .main-char-card .character-portrait {
    width: 90px;
    height: 90px;
  }

  .affinity-value {
    font-size: 2.5rem;
  }

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

  .btn {
    width: 100%;
  }
}

@media (max-width: 480px) {
  .support-grid {
    grid-template-columns: 1fr;
  }
}

/* Character Selection Modal */
.character-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1000;
}

.character-modal.active {
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
}

.modal-content {
  position: relative;
  background: white;
  border-radius: 12px;
  width: 90%;
  max-width: 900px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  z-index: 1001;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  border-bottom: 1px solid #e0e0e0;
}

.modal-title {
  font-size: 1.25rem;
  font-weight: 600;
  color: #333;
  margin: 0;
}

.modal-close {
  background: none;
  border: none;
  font-size: 2rem;
  color: #999;
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: all 0.2s;
  line-height: 1;
}

.modal-close:hover {
  background: #f0f0f0;
  color: #333;
}

.modal-search {
  padding: 16px 24px;
  border-bottom: 1px solid #e0e0e0;
}

.modal-search .search-input {
  width: 100%;
  padding: 10px 16px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s;
}

.modal-search .search-input:focus {
  border-color: var(--main-color, #8b5cf6);
  box-shadow: 0 0 0 2px rgba(139, 92, 246, 0.1);
}

.modal-characters {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 16px;
}

.modal-character-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 12px;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
  background: white;
}

.modal-character-item:hover {
  border-color: var(--main-color, #8b5cf6);
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(139, 92, 246, 0.2);
}

.modal-character-item.selected {
  border-color: var(--main-color, #8b5cf6);
  background: #f5f3ff;
}

.modal-character-portrait {
  width: 80px;
  height: 80px;
  border-radius: 6px;
  border: 2px solid #ddd;
  overflow: hidden;
  background: #f5f5f5;
  position: relative;
}

.modal-character-portrait img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
}

.modal-character-name {
  font-size: 0.8rem;
  text-align: center;
  color: #555;
  font-weight: 500;
  line-height: 1.2;
  max-width: 100px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.modal-character-affinity {
  font-size: 0.75rem;
  text-align: center;
  color: var(--main-color, #8b5cf6);
  font-weight: 600;
  margin-top: 4px;
  padding: 2px 6px;
  background: #f5f3ff;
  border-radius: 4px;
  display: inline-block;
}

@media (max-width: 768px) {
  .modal-content {
    width: 95%;
    max-height: 90vh;
  }

  .modal-characters {
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 12px;
    padding: 16px;
  }

  .modal-character-portrait {
    width: 70px;
    height: 70px;
  }

  .modal-character-name {
    font-size: 0.75rem;
    max-width: 80px;
  }
}

/* Spark Pills */
.spark-pills-container {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: center;
  width: 100%;
  margin-top: 4px;
}

.spark-pill {
  padding: 4px 12px;
  border-radius: 16px;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  border: 1px solid transparent;
  min-width: 60px;
  text-align: center;
  user-select: none;
}

.spark-pill.blue-pill {
  background: rgba(59, 130, 246, 0.15);
  color: #1e40af;
  border-color: #3b82f6;
}

.spark-pill.blue-pill:hover {
  background: rgba(59, 130, 246, 0.25);
  transform: scale(1.05);
}

.spark-pill.blue-pill.has-spark {
  background: #3b82f6;
  color: white;
  border-color: #2563eb;
}

.spark-pill.green-pill {
  background: rgba(16, 185, 129, 0.15);
  color: #065f46;
  border-color: #10b981;
}

.spark-pill.green-pill:hover {
  background: rgba(16, 185, 129, 0.25);
  transform: scale(1.05);
}

.spark-pill.green-pill.has-spark {
  background: #10b981;
  color: white;
  border-color: #059669;
}

/* Spark Selection Modal */
.spark-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 2000;
}

.spark-modal.active {
  display: flex;
  align-items: center;
  justify-content: center;
}

.spark-modal-content {
  position: relative;
  background: white;
  border-radius: 12px;
  width: 90%;
  max-width: 600px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  z-index: 2001;
}

.spark-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  border-bottom: 1px solid #e0e0e0;
}

.spark-modal-title {
  font-size: 1.25rem;
  font-weight: 600;
  color: #333;
  margin: 0;
}

.spark-modal-close {
  background: none;
  border: none;
  font-size: 2rem;
  color: #999;
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: all 0.2s;
  line-height: 1;
}

.spark-modal-close:hover {
  background: #f0f0f0;
  color: #333;
}

.spark-modal-grid {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.spark-grid-row {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}

.spark-grid-row.header-row {
  margin-bottom: 8px;
}

.spark-grid-header {
  padding: 12px 8px;
  background: #3b82f6;
  color: white;
  border-radius: 8px;
  text-align: center;
  font-size: 0.9rem;
  font-weight: 600;
}

.spark-grid-header.green-header {
  background: #10b981;
}

.spark-grid-cell {
  padding: 16px 8px;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  background: white;
  cursor: pointer;
  text-align: center;
  font-size: 0.85rem;
  font-weight: 500;
  color: #333;
  transition: all 0.2s;
}

.spark-grid-cell:hover {
  border-color: #3b82f6;
  background: rgba(59, 130, 246, 0.1);
  transform: translateY(-2px);
}

.spark-grid-cell.selected {
  border-color: #3b82f6;
  background: rgba(59, 130, 246, 0.2);
  color: #1e40af;
}

/* Green spark grid styling */
.spark-modal.green-modal .spark-grid-cell:hover {
  border-color: #10b981;
  background: rgba(16, 185, 129, 0.1);
}

.spark-modal.green-modal .spark-grid-cell.selected {
  border-color: #10b981;
  background: rgba(16, 185, 129, 0.2);
  color: #065f46;
}

.spark-grid-placeholder {
  padding: 40px;
  text-align: center;
  color: #999;
  font-style: italic;
}

.spark-modal-footer {
  padding: 16px 24px;
  border-top: 1px solid #e0e0e0;
  display: flex;
  justify-content: flex-end;
}

.spark-modal-cancel {
  padding: 10px 24px;
  background: #f0f0f0;
  color: #333;
  border: none;
  border-radius: 6px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.spark-modal-cancel:hover {
  background: #e0e0e0;
}
