/* ═══════════════════════════════════════════════════════════════════
   LiDoll Quest Web Content Editor — app.css
   Layered on top of /SADENGINE/style/main.css
   Palette tokens (mirrored from SADENGINE):
     --bg:        rgb(45,45,50)
     --panel:     rgb(55,55,60)
     --accent:    #ff96c8
     --fuchsia:   rgb(255,0,255)
     --text:      #ffc8e0
     --deep:      rgb(31,24,34)
     --sidebar:   rgba(80,35,65,1)
═══════════════════════════════════════════════════════════════════ */

/* ── Reset / base ────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

body.ldq-editor {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  padding: 0;
  margin: 0;
  font-family: mingliu, 'Segoe UI', sans-serif;
  color: #ffc8e0;
}

/* ── Header ──────────────────────────────────────────────────────── */
#editor-header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 20px;
  background: linear-gradient(90deg, rgba(80,35,65,1) 0%, rgba(45,45,50,1) 100%);
  border-bottom: 3px double #ff96c8;
}

#editor-header h1 {
  margin: 0;
  font-size: 1.4rem;
  font-family: ferrite, serif;
  color: #ff96c8;
  text-shadow: 0 0 10px rgba(255,150,200,0.5);
}

.dirty-hidden { display: none; }
.dirty-visible {
  display: inline;
  color: #ff96c8;
  font-size: 0.85rem;
  animation: pulse 1.5s infinite alternate;
}

/* ── Tab navigation ─────────────────────────────────────────────── */
#editor-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  padding: 6px 12px 0;
  background: rgba(31,24,34,0.8);
  border-bottom: 2px solid #ff96c8;
}

.tab-btn {
  padding: 6px 14px;
  background: rgba(55,55,60,0.7);
  color: #ffc8e0;
  border: 1px solid rgba(255,150,200,0.3);
  border-bottom: none;
  border-radius: 4px 4px 0 0;
  font-family: mingliu, sans-serif;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.tab-btn:hover {
  background: rgba(80,35,65,0.9);
  color: #ff96c8;
}

.tab-btn.active {
  background: rgb(45,45,50);
  color: #ff96c8;
  border-color: #ff96c8;
  border-bottom: 2px solid rgb(45,45,50); /* visually connects to panel */
  font-weight: bold;
}

.bundle-tab { color: #ffd0ff; }
.bundle-tab.active { color: #ff96c8; }

/* ── Main panel ──────────────────────────────────────────────────── */
#editor-main {
  flex: 1;
  padding: 16px 20px;
}

.tab-panel { display: block; }
.tab-panel.hidden { display: none; }

/* ── Panel toolbar ──────────────────────────────────────────────── */
.panel-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.panel-toolbar h2 {
  margin: 0;
  font-family: ferrite, serif;
  font-size: 1.2rem;
  color: #ff96c8;
}

.panel-toolbar h2 small {
  font-family: mingliu, sans-serif;
  font-size: 0.75rem;
  color: rgba(255,200,224,0.6);
}

/* ── Buttons ─────────────────────────────────────────────────────── */
button, .btn-new, .btn-primary, .btn-sm, .btn-danger {
  cursor: pointer;
  font-family: mingliu, sans-serif;
  border-radius: 4px;
  transition: background 0.15s, border-color 0.15s;
}

.btn-new {
  padding: 5px 12px;
  background: rgba(80,35,65,0.8);
  color: #ff96c8;
  border: 1px solid #ff96c8;
  font-size: 0.85rem;
}
.btn-new:hover { background: rgba(255,0,255,0.25); }

.btn-primary {
  padding: 8px 20px;
  background: linear-gradient(135deg, rgba(80,35,65,1), rgba(45,45,50,1));
  color: #ff96c8;
  border: 2px solid #ff96c8;
  font-size: 1rem;
  font-family: ferrite, serif;
  letter-spacing: 1px;
}
.btn-primary:hover { background: rgba(255,0,255,0.3); }

.btn-sm {
  padding: 3px 10px;
  background: rgba(55,55,60,0.8);
  color: #ffc8e0;
  border: 1px solid rgba(255,150,200,0.4);
  font-size: 0.8rem;
}
.btn-sm:hover { border-color: #ff96c8; color: #ff96c8; }

.btn-danger {
  padding: 3px 8px;
  background: rgba(120,30,50,0.7);
  color: #ffaaaa;
  border: 1px solid #ff6666;
  font-size: 0.8rem;
}
.btn-danger:hover { background: rgba(180,30,50,0.8); }

.btn-edit {
  padding: 3px 8px;
  background: rgba(40,60,80,0.7);
  color: #96d8ff;
  border: 1px solid #6ab0e0;
  font-size: 0.8rem;
  cursor: pointer;
  border-radius: 4px;
}
.btn-edit:hover { background: rgba(60,90,120,0.8); }

/* ── Search box ─────────────────────────────────────────────────── */
.search-box {
  padding: 4px 10px;
  background: rgba(31,24,34,0.9);
  color: #ffc8e0;
  border: 1px solid rgba(255,150,200,0.4);
  border-radius: 4px;
  font-family: mingliu, sans-serif;
  font-size: 0.85rem;
  width: 220px;
}
.search-box:focus {
  outline: none;
  border-color: #ff96c8;
  box-shadow: 0 0 6px rgba(255,150,200,0.4);
}

/* ── Split layout ────────────────────────────────────────────────── */
.split-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 12px;
  min-height: 420px;
}

/* ── Record list ─────────────────────────────────────────────────── */
.record-list {
  background: rgba(31,24,34,0.7);
  border: 1px solid rgba(255,150,200,0.3);
  border-radius: 6px;
  overflow-y: auto;
  max-height: 620px;
  padding: 4px 0;
}

.record-list-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 10px;
  border-bottom: 1px solid rgba(255,150,200,0.1);
  cursor: pointer;
  transition: background 0.1s;
  font-size: 0.85rem;
}
.record-list-item:hover  { background: rgba(80,35,65,0.4); }
.record-list-item.active { background: rgba(80,35,65,0.8); color: #ff96c8; }

.record-list-item .item-key {
  font-family: 'Courier New', monospace;
  font-size: 0.75rem;
  color: rgba(255,200,224,0.5);
  margin-right: 4px;
}

.record-actions { display: flex; gap: 4px; }

/* ── Record form ─────────────────────────────────────────────────── */
.record-form {
  background: rgba(55,55,60,0.6);
  border: 1px solid rgba(255,150,200,0.3);
  border-radius: 6px;
  padding: 16px;
  overflow-y: auto;
  max-height: 620px;
}
.record-form.hidden { display: none; }

.record-form h3 {
  font-family: ferrite, serif;
  color: #ff96c8;
  margin: 0 0 14px 0;
  font-size: 1rem;
  border-bottom: 1px solid rgba(255,150,200,0.3);
  padding-bottom: 6px;
}

/* Form fields */
.form-row {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin-bottom: 10px;
}

.form-row label {
  font-size: 0.8rem;
  color: rgba(255,200,224,0.7);
  font-family: mingliu, sans-serif;
}

.form-row input[type="text"],
.form-row input[type="number"],
.form-row select,
.form-row textarea {
  background: rgba(31,24,34,0.8);
  color: #ffc8e0;
  border: 1px solid rgba(255,150,200,0.35);
  border-radius: 4px;
  padding: 5px 8px;
  font-family: mingliu, sans-serif;
  font-size: 0.85rem;
  width: 100%;
  transition: border-color 0.15s;
}

.form-row input:focus,
.form-row select:focus,
.form-row textarea:focus {
  outline: none;
  border-color: #ff96c8;
  box-shadow: 0 0 5px rgba(255,150,200,0.3);
}

.form-row textarea { resize: vertical; min-height: 60px; }

.form-row input[type="checkbox"] {
  width: auto;
  accent-color: #ff96c8;
}

.form-section-title {
  font-family: ferrite, serif;
  font-size: 0.85rem;
  color: rgba(255,150,200,0.8);
  margin: 14px 0 6px;
  padding-bottom: 3px;
  border-bottom: 1px solid rgba(255,150,200,0.2);
}

.form-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.form-save-bar {
  display: flex;
  gap: 8px;
  margin-top: 16px;
  padding-top: 10px;
  border-top: 1px solid rgba(255,150,200,0.2);
}

/* JSON textarea sections (arrays) */
.json-array-field {
  font-family: 'Courier New', monospace;
  font-size: 0.78rem;
  min-height: 80px;
  white-space: pre;
}

/* ── Notes / info ────────────────────────────────────────────────── */
.info-note {
  font-size: 0.8rem;
  color: rgba(255,200,224,0.6);
  margin: 0 0 10px 0;
  padding: 6px 10px;
  background: rgba(31,24,34,0.5);
  border-left: 3px solid rgba(255,150,200,0.4);
  border-radius: 0 4px 4px 0;
}

.skip-note {
  font-size: 0.82rem;
  color: #ffd080;
  background: rgba(60,40,0,0.5);
  border-left: 3px solid #ffd080;
  padding: 6px 10px;
  border-radius: 0 4px 4px 0;
  margin: 8px 0;
}

/* ── Accident Dialogue bucket editor ───────────────────────────── */
.bucket-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 14px;
}

.bucket-btn {
  padding: 4px 10px;
  background: rgba(55,55,60,0.8);
  color: #ffc8e0;
  border: 1px solid rgba(255,150,200,0.35);
  border-radius: 4px;
  font-size: 0.78rem;
  cursor: pointer;
}
.bucket-btn:hover  { border-color: #ff96c8; color: #ff96c8; }
.bucket-btn.active { background: rgba(80,35,65,0.9); color: #ff96c8; border-color: #ff96c8; }

.bucket-editor {
  background: rgba(31,24,34,0.7);
  border: 1px solid rgba(255,150,200,0.3);
  border-radius: 6px;
  padding: 16px;
  min-height: 260px;
}

.bucket-editor h3 {
  font-family: ferrite, serif;
  color: #ff96c8;
  margin: 0 0 10px 0;
  font-size: 1rem;
}

.bucket-line-list { list-style: none; padding: 0; margin: 0 0 10px 0; }

.bucket-line-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 0;
  border-bottom: 1px solid rgba(255,150,200,0.1);
}

.bucket-line-input {
  flex: 1;
  background: rgba(31,24,34,0.8);
  color: #ffc8e0;
  border: 1px solid rgba(255,150,200,0.3);
  border-radius: 3px;
  padding: 4px 6px;
  font-family: mingliu, sans-serif;
  font-size: 0.85rem;
}

.bucket-line-input:focus {
  outline: none;
  border-color: #ff96c8;
}

.bucket-save-bar { display: flex; gap: 8px; margin-top: 10px; }

/* ── Narrative chunk beat editor ────────────────────────────────── */
.beat-list { margin-top: 10px; }

.beat-card {
  background: rgba(31,24,34,0.6);
  border: 1px solid rgba(255,150,200,0.2);
  border-radius: 5px;
  padding: 10px;
  margin-bottom: 8px;
}

.beat-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  font-family: ferrite, serif;
  font-size: 0.82rem;
  color: rgba(255,150,200,0.7);
}

/* ── Bundle Export UI ────────────────────────────────────────────── */
.bundle-ui {
  display: grid;
  grid-template-columns: 300px 1fr;
  grid-template-rows: auto auto;
  gap: 16px;
}

.bundle-meta-panel {
  background: rgba(31,24,34,0.7);
  border: 1px solid rgba(255,150,200,0.3);
  border-radius: 6px;
  padding: 16px;
  grid-row: 1 / 3;
}

.bundle-meta-panel h3,
.bundle-scope-panel h3 {
  font-family: ferrite, serif;
  color: #ff96c8;
  margin: 0 0 12px 0;
  font-size: 1rem;
}

.bundle-meta-panel label,
.bundle-scope-panel label {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin-bottom: 10px;
  font-size: 0.8rem;
  color: rgba(255,200,224,0.7);
}

.bundle-meta-panel input,
.bundle-meta-panel textarea {
  background: rgba(31,24,34,0.8);
  color: #ffc8e0;
  border: 1px solid rgba(255,150,200,0.35);
  border-radius: 4px;
  padding: 5px 8px;
  font-family: mingliu, sans-serif;
  font-size: 0.85rem;
  width: 100%;
}

.bundle-meta-panel input:focus,
.bundle-meta-panel textarea:focus {
  outline: none;
  border-color: #ff96c8;
}

.bundle-scope-panel {
  background: rgba(31,24,34,0.7);
  border: 1px solid rgba(255,150,200,0.3);
  border-radius: 6px;
  padding: 16px;
  overflow-y: auto;
  max-height: 420px;
}

.bundle-scope-panel details {
  margin-bottom: 6px;
}

.bundle-scope-panel summary {
  cursor: pointer;
  font-family: ferrite, serif;
  font-size: 0.88rem;
  color: #ff96c8;
  padding: 4px 6px;
  background: rgba(55,55,60,0.5);
  border-radius: 4px;
  list-style: none;
  user-select: none;
}
.bundle-scope-panel summary:hover { background: rgba(80,35,65,0.6); }
.bundle-scope-panel summary::before { content: "▶ "; font-size: 0.7rem; }
.bundle-scope-panel details[open] summary::before { content: "▼ "; }

.bundle-picker {
  padding: 6px 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-height: 120px;
  overflow-y: auto;
}

.bundle-pick-item {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.78rem;
  color: #ffc8e0;
}

.bundle-pick-item input[type="checkbox"] {
  accent-color: #ff96c8;
}

.bundle-actions {
  grid-column: 1 / 3;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.bundle-log {
  background: rgba(10,5,15,0.9);
  border: 1px solid rgba(255,150,200,0.3);
  border-radius: 5px;
  padding: 10px;
  font-family: 'Courier New', monospace;
  font-size: 0.78rem;
  color: #96ffb4;
  min-height: 80px;
  max-height: 240px;
  overflow-y: auto;
  white-space: pre-wrap;
}

/* ── Footer / status bar ─────────────────────────────────────────── */
#editor-footer {
  padding: 6px 20px;
  background: rgba(31,24,34,0.9);
  border-top: 1px solid rgba(255,150,200,0.25);
  font-size: 0.78rem;
  color: rgba(255,200,224,0.6);
}

/* ── Loading / error states ─────────────────────────────────────── */
.loading-msg {
  color: rgba(255,200,224,0.5);
  font-style: italic;
  padding: 20px;
  text-align: center;
  font-size: 0.9rem;
}

.error-msg {
  color: #ffaaaa;
  padding: 10px;
  border: 1px solid #ff4444;
  border-radius: 4px;
  background: rgba(120,0,0,0.3);
  font-size: 0.85rem;
}

/* ── Scrollbar styling ───────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: rgba(31,24,34,0.5); }
::-webkit-scrollbar-thumb { background: rgba(255,150,200,0.4); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,150,200,0.7); }

/* ── Animations (from SADENGINE palette) ────────────────────────── */
@keyframes pulse {
  from { opacity: 0.6; }
  to   { opacity: 1.0; }
}

/* ── Responsive: collapse split layout on narrow screens ─────────── */
@media (max-width: 700px) {
  .split-layout { grid-template-columns: 1fr; }
  .bundle-ui    { grid-template-columns: 1fr; }
  .bundle-meta-panel { grid-row: auto; }
}
