/* Unified detail panel styles */
.panel-summary,
.panel-summary-info {
  display: flex;
  gap: 12px;
  align-items: center;
  width: 100%;
}

.panel-summary {
  justify-content: space-between;
  margin-bottom: 0;
}

.panel-summary-info {
  gap: 10px;
  align-items: flex-start;
  min-width: 0;
}

.panel-summary-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.panel-summary-text h3 {
  font-size: 16px;
  font-weight: 500;
  white-space: normal;
  word-break: break-word;
}

.panel-color {
  width: 50px;
  height: 50px;
  border: 1px solid #333;
  border-radius: 6px;
  flex-shrink: 0;
}

.panel-body {
  flex: 1 1 auto;
}

.panel-controls {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-shrink: 0;
}

.panel-controls button {
  padding: 6px 10px;
  border: 1px solid #4a9eff;
  background: rgba(74, 158, 255, 0.08);
  color: #b0d4ff;
  cursor: pointer;
  font-family: inherit;
  font-size: 12px;
  transition: all 0.15s ease;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.panel-controls button:hover:not(:disabled) {
  border-color: #64c8ff;
  background: rgba(100, 200, 255, 0.15);
  box-shadow: 0 0 12px rgba(100, 200, 255, 0.2);
}

.panel-controls button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Visual state when the detail panel represents a spell the player cannot afford.
   Muted / desaturated panel, but keep the create button visible and styled red to
   indicate an error/requirement. */
.detail-panel.unaffordable-panel {
  filter: grayscale(70%) contrast(0.85) brightness(0.8);
  opacity: 0.85;
  transition: all 0.18s ease;
}

/* The Create button when unaffordable: look visually disabled but red-accented.
   We avoid using the element's disabled attribute styling alone so the red color
   remains vivid while matching the "disabled due to error" wording. */
.fusion-preview-create.unaffordable {
  background: linear-gradient(180deg, rgba(80, 20, 20, 0.08), rgba(120, 10, 10, 0.06));
  border-color: rgba(200, 70, 70, 0.95);
  color: #ffb8b8;
  box-shadow: 0 0 8px rgba(255, 80, 80, 0.18);
  cursor: not-allowed;
  opacity: 1; /* keep full opacity so the red reads clearly */
  pointer-events: none; /* prevent clicks */
}

/* Slight stronger emphasis on hover shouldn't apply, but guard against accidental hover styles */
.fusion-preview-create.unaffordable:hover {
  transform: none;
  box-shadow: 0 0 10px rgba(255, 80, 80, 0.22);
}

/* If the panel contains both unaffordable state and other controls, ensure property badges
   and other icons get slightly dimmed to match fusion-slot inactive style */
.detail-panel.unaffordable-panel .property-badge,
.detail-panel.unaffordable-panel .properties-empty,
.detail-panel.unaffordable-panel .panel-summary-text h3 {
  opacity: 0.8;
  filter: grayscale(40%);
}

/* Keep the panel-color border subdued when unaffordable */
.detail-panel.unaffordable-panel .panel-color {
  border-color: rgba(50,50,50,0.6);
}

/* Notice shown in fusion preview when spell will use spiral movement */
.fusion-spiral-note {
  background: linear-gradient(90deg, rgba(120, 80, 200, 0.12), rgba(100, 160, 255, 0.06));
  border: 1px solid rgba(122, 80, 200, 0.18);
  color: #dcd7ff;
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 8px;
  display: inline-block;
}

/* Responsive */
@media (max-width: 768px) {
  .panel-summary {
    /* Removed flex-wrap to keep controls on the same row with summary */
    gap: 8px;
    justify-content: flex-start;
    align-items: flex-start;
  }

  .panel-summary-info {
    flex-direction: column; /* Stack color and text vertically */
    align-items: flex-start;
    gap: 4px;
    flex: 1 1 0%; /* Allow info block to take available space */
  }

  .panel-summary-text {
    width: 100%; /* Ensure text container utilizes full width of panel-summary-info */
  }

  .panel-color {
    width: 40px;
    height: 40px;
  }

  .panel-summary-text h3 {
    font-size: 14px;
  }

  /* Ensure panel-controls prefer stacking vertically on mobile so multiple buttons
     don't force the summary to reflow horizontally. */
  .panel-controls {
    flex-direction: column;
    align-items: flex-end;
    gap: 8px;
  }

  .panel-controls button {
    width: auto;
    white-space: nowrap;
  }
}

@media (max-width: 480px) {
  .panel-summary {
    gap: 6px;
  }
}