@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:ital,wght@0,400;0,700;1,400&family=DM+Sans:wght@300;400;500;600&display=swap');

:root {
  --gold: #C9A84C;
  --gold-light: #E8C96A;
  --cream: #FAF6EF;
  --cream-dark: #F0E8D8;
  --charcoal: #1A1A1A;
  --charcoal-soft: #2D2D2D;
  --gray: #6B6B6B;
  --gray-light: #D4D0C8;
  --white: #FFFFFF;
  --danger: #E05252;
  --success: #4CAF50;
  --shadow: 0 2px 16px rgba(0,0,0,0.07);
  --shadow-md: 0 4px 24px rgba(0,0,0,0.1);
  --radius: 10px;
  --sidebar-w: 300px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; font-family: 'DM Sans', sans-serif; background: #F5F4F1; color: var(--charcoal); }

/* ── LAYOUT ── */
.dash-layout { display: flex; min-height: 100vh; }

/* ── SIDEBAR ── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--charcoal);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 50;
  overflow-y: auto;
}

.sidebar-header {
  padding: 1.5rem 1.25rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,0.07);
}

.sidebar-logo {
  font-family: 'Playfair Display', serif;
  font-size: 1.25rem;
  color: var(--gold);
  display: block;
  margin-bottom: 0.2rem;
}

.sidebar-logo span { color: white; font-style: italic; }

.sidebar-label {
  font-size: 0.7rem;
  color: rgba(255,255,255,0.35);
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.sidebar-section-label {
  padding: 1rem 1.25rem 0.4rem;
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: rgba(255,255,255,0.25);
}

.sidebar-tree { padding: 0 0.75rem 1rem; }

.tree-node {
  position: relative;
}

.tree-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.6rem;
  border-radius: 7px;
  cursor: pointer;
  transition: background 0.15s;
  font-size: 0.875rem;
  color: rgba(255,255,255,0.6);
  user-select: none;
}

.tree-item:hover { background: rgba(255,255,255,0.06); color: var(--white); }
.tree-item.selected { background: rgba(201,168,76,0.15); color: var(--gold); }

.tree-item .icon { font-size: 0.8rem; opacity: 0.6; width: 14px; }
.tree-item .name { flex: 1; font-weight: 500; }
.tree-item .count { font-size: 0.65rem; background: rgba(255,255,255,0.1); padding: 1px 6px; border-radius: 10px; }

.tree-children { padding-left: 1.2rem; border-left: 1px solid rgba(255,255,255,0.07); margin-left: 0.8rem; }

.add-child-btn {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.6rem;
  font-size: 0.75rem;
  color: rgba(255,255,255,0.3);
  cursor: pointer;
  border-radius: 6px;
  transition: all 0.15s;
  margin-top: 2px;
}

.add-child-btn:hover { color: var(--gold); background: rgba(201,168,76,0.1); }

.sidebar-actions {
  margin-top: auto;
  padding: 1rem 0.75rem;
  border-top: 1px solid rgba(255,255,255,0.07);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.sidebar-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 0.9rem;
  border-radius: 8px;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: all 0.2s;
  text-decoration: none;
  text-align: left;
}

.btn-gold { background: var(--gold); color: var(--charcoal); }
.btn-gold:hover { background: var(--gold-light); }
.btn-outline { background: rgba(255,255,255,0.06); color: rgba(255,255,255,0.6); border: 1px solid rgba(255,255,255,0.1); }
.btn-outline:hover { background: rgba(255,255,255,0.1); color: white; }
.btn-danger { background: rgba(224,82,82,0.1); color: var(--danger); border: 1px solid rgba(224,82,82,0.2); }
.btn-danger:hover { background: rgba(224,82,82,0.2); }

/* ── MAIN CONTENT ── */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
}

/* ── TOP BAR ── */
.topbar {
  background: var(--white);
  border-bottom: 1px solid var(--cream-dark);
  padding: 0 2rem;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 30;
}

.topbar-title {
  font-family: 'Playfair Display', serif;
  font-size: 1.1rem;
  color: var(--charcoal);
}

.topbar-actions { display: flex; gap: 0.5rem; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.2s;
}

.btn-primary { background: var(--charcoal); color: white; }
.btn-primary:hover { background: var(--charcoal-soft); }
.btn-secondary { background: var(--cream-dark); color: var(--charcoal); }
.btn-secondary:hover { background: var(--gray-light); }
.btn-success { background: var(--success); color: white; }
.btn-success:hover { filter: brightness(0.9); }

/* ── CONTENT AREA ── */
.content-area { padding: 2rem; flex: 1; }

/* ── WELCOME / EMPTY ── */
.welcome-state {
  text-align: center;
  padding: 5rem 2rem;
  max-width: 480px;
  margin: 0 auto;
}

.welcome-state .big-icon { font-size: 4rem; margin-bottom: 1.5rem; }
.welcome-state h2 {
  font-family: 'Playfair Display', serif;
  font-size: 1.6rem;
  margin-bottom: 0.75rem;
}

.welcome-state p { color: var(--gray); margin-bottom: 2rem; line-height: 1.6; }

/* ── EDITOR PANEL ── */
.editor-panel {
  max-width: 780px;
}

.editor-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 1.75rem;
  box-shadow: var(--shadow);
  margin-bottom: 1.5rem;
}

.editor-card h3 {
  font-family: 'Playfair Display', serif;
  font-size: 1.1rem;
  margin-bottom: 1.25rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--cream-dark);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-grid.single { grid-template-columns: 1fr; }

.form-group { display: flex; flex-direction: column; gap: 0.4rem; }
.form-group.full { grid-column: 1 / -1; }

.form-label {
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--gray);
}

.form-input, .form-textarea, .form-select {
  padding: 0.65rem 0.9rem;
  border: 1.5px solid var(--cream-dark);
  border-radius: 8px;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.9rem;
  color: var(--charcoal);
  background: var(--cream);
  outline: none;
  transition: border-color 0.2s;
}

.form-input:focus, .form-textarea:focus, .form-select:focus {
  border-color: var(--gold);
  background: var(--white);
}

.form-textarea { resize: vertical; min-height: 80px; }

/* ── IMAGE MANAGER ── */
.image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.image-thumb {
  position: relative;
  aspect-ratio: 3/4;
  border-radius: 8px;
  overflow: hidden;
  border: 2px solid var(--cream-dark);
  background: var(--cream-dark);
}

.image-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.image-thumb .img-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 22px;
  height: 22px;
  background: var(--danger);
  color: white;
  border: none;
  border-radius: 50%;
  font-size: 0.7rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s;
}

.image-thumb:hover .img-remove { opacity: 1; }

.image-thumb .img-order {
  position: absolute;
  bottom: 4px;
  left: 4px;
  background: rgba(0,0,0,0.6);
  color: white;
  font-size: 0.65rem;
  padding: 1px 5px;
  border-radius: 4px;
}

.upload-zone {
  border: 2px dashed var(--gray-light);
  border-radius: 10px;
  padding: 1.5rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  color: var(--gray);
}

.upload-zone:hover { border-color: var(--gold); color: var(--gold); background: rgba(201,168,76,0.03); }
.upload-zone.dragover { border-color: var(--gold); background: rgba(201,168,76,0.06); }

.upload-zone .upload-icon { font-size: 1.75rem; margin-bottom: 0.5rem; }
.upload-zone p { font-size: 0.82rem; margin-bottom: 0.25rem; font-weight: 500; }
.upload-zone small { font-size: 0.72rem; opacity: 0.7; }

#image-file-input { display: none; }

/* ── URL IMAGE INPUT ── */
.url-input-row {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.url-input-row input {
  flex: 1;
  padding: 0.55rem 0.8rem;
  border: 1.5px solid var(--cream-dark);
  border-radius: 8px;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.85rem;
  outline: none;
  background: var(--cream);
}

.url-input-row input:focus { border-color: var(--gold); background: white; }
.url-input-row button {
  padding: 0.55rem 1rem;
  background: var(--charcoal);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

/* ── FLIPBOOK PREVIEW ── */
.flipbook-preview {
  width: 140px;
  aspect-ratio: 3/4;
  border-radius: 10px;
  overflow: hidden;
  border: 2px solid var(--cream-dark);
  position: relative;
  background: var(--cream-dark);
  margin-left: auto;
}

.flipbook-preview .fp-track {
  display: flex;
  height: 100%;
  transition: transform 0.5s ease;
}

.flipbook-preview .fp-slide {
  min-width: 100%;
  height: 100%;
  object-fit: cover;
}

.fp-label {
  position: absolute;
  bottom: 6px;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 0.6rem;
  color: white;
  background: rgba(0,0,0,0.5);
  padding: 2px;
}

/* ── ACTION STRIP ── */
.action-strip {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  flex-wrap: wrap;
}

.delete-zone {
  margin-top: 0.5rem;
  padding: 1rem;
  border: 1.5px solid rgba(224,82,82,0.2);
  border-radius: 10px;
  background: rgba(224,82,82,0.03);
}

.delete-zone h4 { font-size: 0.85rem; color: var(--danger); margin-bottom: 0.4rem; }
.delete-zone p { font-size: 0.78rem; color: var(--gray); margin-bottom: 0.75rem; }

/* ── SETTINGS FORM ── */
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }

/* ── TOAST ── */
.toast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  background: var(--charcoal);
  color: white;
  padding: 0.75rem 1.25rem;
  border-radius: 10px;
  font-size: 0.85rem;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  z-index: 9999;
  transform: translateY(80px);
  opacity: 0;
  transition: all 0.3s;
  border-left: 3px solid var(--gold);
  max-width: 300px;
}

.toast.show { transform: translateY(0); opacity: 1; }
.toast.error { border-left-color: var(--danger); }
.toast.success { border-left-color: var(--success); }

/* ── MODAL ── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 200;
  align-items: center;
  justify-content: center;
}

.modal-overlay.open { display: flex; }

.modal {
  background: white;
  border-radius: var(--radius);
  padding: 1.75rem;
  max-width: 440px;
  width: 90%;
  box-shadow: var(--shadow-md);
}

.modal h3 {
  font-family: 'Playfair Display', serif;
  font-size: 1.15rem;
  margin-bottom: 0.75rem;
}

.modal p { color: var(--gray); font-size: 0.9rem; margin-bottom: 1.25rem; line-height: 1.5; }
.modal-actions { display: flex; gap: 0.6rem; justify-content: flex-end; }

/* ── RESPONSIVE ── */
@media (max-width: 900px) {
  .sidebar { width: 240px; }
  :root { --sidebar-w: 240px; }
}

@media (max-width: 640px) {
  .form-grid { grid-template-columns: 1fr; }
  .settings-grid { grid-template-columns: 1fr; }
  .sidebar { transform: translateX(-100%); transition: transform 0.3s; }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .topbar { padding: 0 1rem; }
  .content-area { padding: 1rem; }
}
