/* Campaign Testbed Styles
 *
 * The preview panel below mimics the real reading pane (dm-reading-pane.css)
 * so an author sees what their JSON will actually look like at the table -
 * re-themed to the app's current "aged leather" palette (see
 * UPSTREAM_CHANGES.md "Design system, pass 1"/"pass 2"). Previously mimicked
 * an earlier navy+gold (#1a1a2e/#d4af37) version of that design, superseded
 * in the app itself but never updated here - a real, if harmless, drift
 * between what this preview showed and what the app actually renders.
 * .monster-placeholder* below was already accurate (that component kept its
 * own dedicated blood-red identity through the leather repaint) and is
 * left as-is apart from one gradient stop.
 */

/* style.css's global `p { color: var(--premium-text) }` is a direct
   declaration on every <p> tag, including the ones inside the mock
   readAloud/dmNotes HTML this file renders (scene.readAloud's own JSON
   string already contains "<p>...</p>" markup) - a direct declaration
   always wins over an inherited value no matter how specific the
   ancestor's own selector is, so without this override every rendered <p>
   silently ignored .read-aloud-box-preview .text's dark parchment-ink
   color and rendered light premium-text instead - on the light parchment
   background that's light-on-light, nearly invisible. Found via a real
   screenshot, not caught by reading the CSS alone. */
.preview-container p {
  color: inherit;
}

/* Override main layout for testbed */
.testbed-layout {
  display: flex;
  gap: 20px;
  max-width: none;
  padding: 20px;
}

/* Input Panel (Left) */
.input-panel {
  flex: 0 0 45%;
  background: var(--premium-card);
  border: 1px solid var(--premium-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 220px);
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px 20px;
  background: var(--premium-darker);
  border-bottom: 1px solid var(--premium-border);
  border-radius: var(--radius-md) var(--radius-md) 0 0;
}

.panel-header h3 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 600;
  color: var(--premium-gold);
}

.panel-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.btn-small {
  padding: 6px 12px;
  font-size: 13px;
  border: 1px solid var(--premium-border);
  background: var(--premium-card);
  color: var(--premium-text);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s;
}

.btn-small:hover {
  background: var(--premium-bg);
  border-color: var(--premium-gold);
}

.btn-small.btn-primary {
  background: var(--premium-gold);
  color: var(--premium-darker);
  border-color: var(--premium-gold);
  font-weight: 600;
}

.btn-small.btn-primary:hover {
  background: #e0bf47;
}

.example-select {
  padding: 6px 10px;
  font-size: 13px;
  border: 1px solid var(--premium-border);
  border-radius: var(--radius-md);
  background: var(--premium-card);
  color: var(--premium-text);
  cursor: pointer;
}

.example-select:focus {
  outline: none;
  border-color: var(--premium-gold);
}

/* JSON Input */
.json-input-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 15px;
  min-height: 300px;
}

#campaignJsonInput {
  flex: 1;
  width: 100%;
  min-height: 250px;
  padding: 15px;
  font-family: 'Courier New', Courier, monospace;
  font-size: 13px;
  line-height: 1.5;
  border: 1px solid var(--premium-border);
  border-radius: var(--radius-md);
  resize: vertical;
  background: var(--premium-darker);
  color: #d8cdb8;
}

#campaignJsonInput:focus {
  outline: none;
  border-color: var(--premium-gold);
  box-shadow: 0 0 0 2px rgba(201, 162, 75, 0.2);
}

.validation-message {
  margin-top: 10px;
  padding: 10px;
  border-radius: var(--radius-md);
  font-size: 13px;
  display: none;
}

.validation-message.error {
  display: block;
  background: var(--accent-danger-bg);
  color: #e69a97;
  border: 1px solid var(--accent-danger);
}

.validation-message.success {
  display: block;
  background: var(--accent-success-bg);
  color: #8fd6a3;
  border: 1px solid var(--accent-success);
}

/* Placeholder Reference */
.placeholder-reference {
  padding: 15px;
  background: var(--premium-bg);
  border-top: 1px solid var(--premium-border);
}

.placeholder-reference h4 {
  margin: 0 0 8px 0;
  font-family: var(--font-display);
  font-size: 14px;
  color: var(--premium-gold);
}

.reference-note {
  font-size: 12px;
  color: var(--premium-text-dim);
  margin-bottom: 10px;
}

.reference-table {
  width: 100%;
  font-size: 12px;
  border-collapse: collapse;
}

.reference-table td {
  padding: 4px 8px;
  border: none;
  border-bottom: 1px solid var(--premium-border);
  color: var(--premium-text);
}

.reference-table td:first-child {
  font-family: 'Courier New', monospace;
  color: var(--premium-gold);
  background: var(--premium-darker);
  width: 45%;
}

.reference-table td:last-child {
  color: var(--premium-text-dim);
  font-weight: 500;
}

.reference-section-header {
  background: var(--premium-darker);
  color: var(--premium-gold);
  font-weight: 600;
  font-family: var(--font-display);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 6px 8px !important;
}

.reference-section-header.danger {
  color: #e69a97;
}

.danger-text {
  color: #e69a97 !important;
}

/* Preview Panel (Right) */
.preview-panel {
  flex: 0 0 55%;
  background: var(--premium-card);
  border: 1px solid var(--premium-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 220px);
}

.scene-label {
  font-size: 12px;
  color: var(--premium-text-dim);
  background: var(--premium-darker);
  border: 1px solid var(--premium-border);
  padding: 4px 10px;
  border-radius: 12px;
}

/* Preview Container (DM Toolkit Mimic) */
.preview-container {
  flex: 1;
  display: flex;
  overflow: hidden;
  background: var(--premium-dark);
  border-radius: 0 0 var(--radius-md) var(--radius-md);
}

/* DM Reading Pane (Left side of preview) */
.dm-reading-pane {
  flex: 1 1 65%;
  display: flex;
  flex-direction: column;
  background: var(--premium-bg);
  border-right: 1px solid var(--premium-border);
}

.breadcrumb-preview {
  padding: 12px 16px;
  background: var(--premium-darker);
  border-bottom: 1px solid var(--premium-border);
  font-size: 13px;
  color: var(--premium-text-dim);
}

.breadcrumb-preview .separator {
  margin: 0 8px;
  color: var(--premium-gold);
}

.content-area-preview {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  color: var(--premium-text);
}

.content-area-preview::-webkit-scrollbar {
  width: 8px;
}

.content-area-preview::-webkit-scrollbar-track {
  background: var(--premium-darker);
}

.content-area-preview::-webkit-scrollbar-thumb {
  background: var(--premium-border);
  border-radius: 4px;
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--premium-text-dim);
}

.empty-icon {
  font-size: 48px;
  margin-bottom: 16px;
}

.empty-state h3 {
  font-family: var(--font-display);
  color: var(--premium-gold);
  margin-bottom: 12px;
  font-weight: 600;
}

.empty-state p {
  margin-bottom: 8px;
  line-height: 1.6;
}

.empty-state .hint {
  font-size: 13px;
  color: var(--premium-text-dim);
  opacity: 0.7;
}

/* Scene Content */
.scene-content {
  animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

.scene-title {
  font-family: var(--font-display);
  font-size: 1.4em;
  font-weight: 600;
  color: var(--premium-gold);
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.scene-title .icon {
  font-size: 1.2em;
}

/* Inline placeholder resolution markers - never styled at all before this
   pass (found while re-theming this file, not part of the original ask,
   but a one-line gap directly in the same code path). Mirrors the real
   app's own .npc-name-link treatment for the resolved case. */
.placeholder-resolved {
  color: var(--premium-gold);
  text-decoration: underline dotted;
  cursor: help;
}

.placeholder-unknown {
  color: #e69a97;
  border-bottom: 1px dashed #e69a97;
  cursor: help;
}

/* Read Aloud Box - the real thing: a light parchment card in EB Garamond
   italic (dm-reading-pane.css's .opening-crawl/.read-aloud-box), not a
   generic dark panel - this is the single most load-bearing visual in the
   whole preview, since it's what an author is most directly checking. */
.read-aloud-box-preview {
  background: var(--parchment-bg);
  border: 1px solid var(--parchment-border);
  border-radius: var(--radius-md);
  padding: 20px;
  margin: 16px 0;
  box-shadow: var(--shadow-sm);
}

.read-aloud-box-preview h4 {
  color: var(--parchment-ink-dim);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  margin-bottom: 12px;
  font-weight: 600;
}

.read-aloud-box-preview .text {
  font-family: var(--font-body-serif);
  font-style: italic;
  line-height: 1.8;
  color: var(--parchment-ink);
  font-size: 1.1em;
}

/* DM Notes Box - kept the teal identity dm-reading-pane.css's own
   --dm-notes-bg/--dm-notes-border tokens still use (untouched by the
   leather repaint), just re-pointed at those exact values instead of
   arbitrary ones. */
.dm-notes-box-preview {
  background: #1e3a3a;
  border: 1px solid #2e5a5a;
  padding: 16px;
  margin: 16px 0;
  border-radius: var(--radius-md);
}

.dm-notes-box-preview h4 {
  color: var(--premium-gold);
  margin-bottom: 8px;
  font-size: 14px;
}

.dm-notes-box-preview .text {
  color: var(--premium-text);
  line-height: 1.6;
}

/* Structured DM Notes Content */
.dm-notes-content {
  color: var(--premium-text);
  line-height: 1.6;
}

.dm-notes-content p {
  margin: 0 0 12px 0;
}

.dm-notes-content p:last-child {
  margin-bottom: 0;
}

.dm-note-section {
  margin-bottom: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid #2e5a5a;
}

.dm-note-section:last-child {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
}

.dm-note-section .section-label {
  display: block;
  color: var(--premium-gold);
  font-size: 13px;
  margin-bottom: 8px;
}

.dm-note-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.dm-note-list li {
  padding: 6px 0 6px 20px;
  position: relative;
  border-bottom: 1px solid rgba(46, 90, 90, 0.5);
  color: var(--premium-text);
}

.dm-note-list li:last-child {
  border-bottom: none;
}

.dm-note-list li::before {
  content: "•";
  color: var(--accent-info);
  position: absolute;
  left: 4px;
}

/* If Asked Section */
.if-asked-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.if-asked-item {
  background: #1a2e2e;
  border-radius: var(--radius-md);
  padding: 12px;
  border-left: 3px solid var(--accent-info);
}

.if-asked-topic {
  color: #7fc4e8;
  font-weight: 600;
  font-size: 13px;
  margin-bottom: 6px;
  text-transform: capitalize;
}

.if-asked-response {
  color: var(--premium-text-dim);
  font-size: 13px;
  line-height: 1.6;
  font-style: italic;
}

/* Skill Checks */
.skill-checks-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.skill-check-item {
  background: var(--premium-darker);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  border-left: 3px solid var(--premium-gold);
}

.skill-name {
  color: var(--premium-text);
  font-weight: 600;
  text-transform: capitalize;
}

.skill-dc {
  color: var(--premium-gold);
  font-weight: 700;
  margin-left: 8px;
  padding: 2px 6px;
  background: rgba(201, 162, 75, 0.15);
  border-radius: var(--radius-sm);
  font-size: 12px;
}

.skill-result {
  color: #a0c0a0;
  font-size: 13px;
  margin-top: 6px;
  line-height: 1.5;
}

/* Enemies */
.enemies-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.enemy-block {
  background: #2a1a1a;
  border: 1px solid #4a2a2a;
  border-radius: var(--radius-md);
  padding: 12px;
}

.enemy-header {
  color: #e69a97;
  font-weight: 700;
  font-size: 14px;
  margin-bottom: 6px;
}

.enemy-stats {
  display: flex;
  gap: 16px;
  color: var(--premium-text-dim);
  font-size: 13px;
  margin-bottom: 6px;
}

.enemy-stats span {
  background: var(--accent-danger-bg);
  padding: 2px 8px;
  border-radius: var(--radius-sm);
}

.enemy-extra {
  color: var(--premium-text-dim);
  font-size: 12px;
  margin-bottom: 6px;
}

.enemy-tactics {
  color: var(--premium-text-dim);
  font-size: 13px;
  font-style: italic;
  border-top: 1px solid #4a2a2a;
  padding-top: 8px;
  margin-top: 8px;
}

/* Locations */
.locations-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.location-item {
  background: var(--premium-darker);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  border-left: 3px solid var(--accent-success);
}

.location-name {
  color: #8fd6a3;
  font-weight: 600;
  margin-bottom: 4px;
}

.location-clues,
.location-npc {
  color: var(--premium-text-dim);
  font-size: 12px;
  margin-top: 4px;
}

/* Development Notes - special styling */
.development-notes {
  background: var(--accent-info-bg);
  border: 1px dashed var(--accent-info);
  border-radius: var(--radius-md);
  padding: 12px;
  margin-top: 16px;
}

.development-notes .section-label {
  color: #7fc4e8;
}

/* JSON Fallback */
.json-fallback {
  background: var(--premium-darker);
  padding: 12px;
  border-radius: var(--radius-md);
  font-size: 11px;
  overflow-x: auto;
  color: var(--premium-text-dim);
  white-space: pre-wrap;
  word-break: break-word;
}

/* Monster Placeholder - already matches the real app's own
   .monster-placeholder (dm-reading-pane.css) apart from this one gradient
   stop, which used the old navy dark instead of the current --premium-dark
   - left otherwise untouched, this component kept its own dedicated
   blood-red identity through the leather repaint, by design. */
.monster-placeholder {
  display: inline-block;
  background: linear-gradient(135deg, #2a1a1a 0%, #1c1611 100%);
  border: 2px solid #8b0000;
  border-radius: 8px;
  padding: 12px 16px;
  margin: 8px 0;
  min-width: 200px;
  max-width: 300px;
  box-shadow: 0 4px 12px rgba(139, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.monster-placeholder-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid #4a2a2a;
}

.monster-icon {
  font-size: 1.4em;
}

.monster-name {
  color: #ff6b6b;
  font-weight: 700;
  font-size: 1.1em;
  flex: 1;
}

.monster-count {
  background: #8b0000;
  color: #fff;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
}

.monster-variant {
  background: #4a2a6a;
  color: #d4a5ff;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.monster-placeholder-info {
  margin-bottom: 10px;
}

.compendium-note {
  color: var(--premium-text-dim);
  font-size: 11px;
}

.compendium-note strong {
  color: var(--premium-gold);
}

.monster-placeholder-preview {
  display: flex;
  gap: 12px;
  background: rgba(0, 0, 0, 0.3);
  padding: 8px 12px;
  border-radius: var(--radius-md);
  margin-bottom: 8px;
}

.stat-preview-row {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.stat-preview-row .stat-label {
  color: #888;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.stat-preview-row .stat-value {
  color: #999;
  font-size: 14px;
  font-weight: 600;
}

.monster-placeholder-footer {
  color: #777;
  font-size: 10px;
  text-align: center;
  font-style: italic;
}

/* Dungeon Placeholder (preview) - mirrors dm-reading-pane.css's real
   .dungeon-placeholder/.btn-open-dungeon (gold pill button), same reason
   the monster placeholder above matches: authors should see the literal
   button their {dungeon:id} reference will render as. */
.dungeon-placeholder-preview {
  display: inline-block;
  margin: 8px 0;
}

.btn-open-dungeon-preview {
  display: inline-block;
  background: var(--premium-gold);
  color: var(--premium-darker);
  border: none;
  border-radius: var(--radius-sm);
  padding: 8px 16px;
  font-size: 0.95em;
  font-weight: 600;
}

/* Navigation Preview */
.navigation-preview {
  display: flex;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--premium-darker);
  border-top: 1px solid var(--premium-border);
}

.nav-btn {
  padding: 8px 16px;
  border: 1px solid var(--premium-border);
  background: var(--premium-card);
  color: var(--premium-text);
  border-radius: var(--radius-md);
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s;
}

.nav-btn:hover:not(:disabled) {
  background: var(--premium-accent);
  border-color: var(--premium-accent);
  color: white;
}

.nav-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.nav-btn.btn-primary {
  background: var(--premium-gold);
  color: var(--premium-darker);
  border-color: var(--premium-gold);
  font-weight: 600;
}

.nav-btn.btn-primary:hover:not(:disabled) {
  background: #e0bf47;
  color: var(--premium-darker);
}

/* DM Side Panel (Right side of preview) */
.dm-side-panel {
  flex: 0 0 35%;
  background: var(--premium-darker);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.side-section {
  border-bottom: 1px solid var(--premium-border);
}

.side-header {
  padding: 10px 14px;
  background: var(--premium-bg);
  color: var(--premium-gold);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  margin: 0;
}

.side-content {
  padding: 14px;
}

.progress-item {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
  font-size: 13px;
}

.progress-item .label {
  color: var(--premium-text-dim);
}

.progress-item .value {
  color: var(--premium-gold);
  font-weight: 600;
}

.progress-bar-container {
  background: var(--premium-darker);
  height: 6px;
  border-radius: 3px;
  overflow: hidden;
  margin-top: 8px;
}

.progress-bar {
  background: linear-gradient(90deg, var(--premium-accent), var(--premium-gold));
  height: 100%;
  transition: width 0.3s ease;
}

/* Choices */
.choice-btn {
  width: 100%;
  background: var(--premium-bg);
  border: 1px solid var(--premium-border);
  color: var(--premium-text);
  padding: 12px;
  margin-bottom: 8px;
  border-radius: var(--radius-md);
  cursor: pointer;
  text-align: left;
  font-size: 13px;
  line-height: 1.4;
  transition: all 0.2s;
}

.choice-btn:hover {
  background: var(--premium-accent);
  border-color: var(--premium-accent);
  color: white;
  transform: translateX(4px);
}

.choice-btn:last-child {
  margin-bottom: 0;
}

.empty-hint {
  font-size: 12px;
  color: var(--premium-text-dim);
  text-align: center;
  padding: 10px;
}

/* Scene Info */
.scene-info-item {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  font-size: 12px;
  border-bottom: 1px solid var(--premium-border);
}

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

.scene-info-item .label {
  color: var(--premium-text-dim);
}

.scene-info-item .value {
  color: var(--premium-text);
}

/* Validation Results */
.validation-item {
  padding: 8px 0;
  font-size: 12px;
  border-bottom: 1px solid var(--premium-border);
}

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

.validation-item.success {
  color: #8fd6a3;
}

.validation-item.warning {
  color: #e0bf47;
}

.validation-item.error {
  color: #e69a97;
}

.validation-item .icon {
  margin-right: 6px;
}

/* Footer Override */
.testbed-footer {
  margin-left: 240px;
}

/* Responsive */
@media (max-width: 1400px) {
  .testbed-layout {
    flex-direction: column;
  }

  .input-panel,
  .preview-panel {
    flex: none;
    max-height: none;
  }

  .preview-container {
    min-height: 500px;
  }
}
