/* Traven Editor Demo Pages Layout & Chrome Styling */

:root {
  --bg-main: #f8fafc;
  --bg-card: #ffffff;
  --border-color: #e2e8f0;
  --text-primary: #0f172a;
  --text-secondary: #475569;

  /* Accent System - Blood Rust */
  --accent: #cc4a0a;
  --accent-hover: #a83808;
  --accent-light: #fff0e8;
  --accent-on-dark: #e8631a;

  /* Secondary Accent System - Acid Green */
  --accent-2: #8fcc00;
  --accent-2-dark: #6aaa00;
  --accent-2-light: #f0fad0;
  --accent-2-on-dark: #a8e000;

  --terminal-bg: #0f172a;
}

/* Base Styles */
body {
  font-family: 'Atkinson Hyperlegible Next', sans-serif;
  background-color: var(--bg-main);
  color: var(--text-primary);
  margin: 0;
  padding: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Premium Brand Header Navigation */
header {
  background-color: var(--bg-card);
  border-bottom: 1px solid var(--border-color);
  padding: 16px 40px 16px 5px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.02);
  width: 100%;
  box-sizing: border-box;
}

.brand-section {
  display: flex;
  align-items: center;
  gap: 0;
}

.logo-container {
  display: flex;
  align-items: center;
  justify-content: center;
  color: #64748b;
}

.logo-container svg {
  height: 25px;
  width: auto;
  display: block;
}

.logo-container svg .s1 {
  fill: var(--bg-card) !important;
}

.brand-name {
  font-family: 'Mozilla Headline', 'Outfit', sans-serif;
  font-size: 1.95em;
  font-weight: 500;
  letter-spacing: -0.02em;
  color: #64748b;
}

.nav-links {
  display: flex;
  gap: 8px;
  align-items: center;
}

.nav-btn {
  text-decoration: none;
  font-size: 0.72em;
  font-weight: 600;
  color: var(--text-secondary);
  padding: 5px 10px;
  border-radius: 6px;
  transition: all 0.2s;
}

.nav-btn:hover {
  color: var(--text-primary);
  background-color: #f1f5f9;
}

/* Common Card Styles */
.sandbox-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.card-header {
  padding: 12px 20px;
  background-color: #fafafa;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.card-title {
  font-family: 'Mozilla Headline', sans-serif;
  font-size: 0.9em;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #0f172a;
  display: flex;
  align-items: center;
  gap: 8px;
}


.editor-mount,
.raw-editor-mount {
  flex: 1;
  padding: 0;
  outline: none;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.editor-mount .cm-editor,
.raw-editor-mount .cm-editor {
  flex: 1;
  min-height: 0;
}

/* ==========================================================================
   Inline Demo Page (index.php) Styles
   ========================================================================== */
.inline-demo main {
  flex: 1;
  padding: 40px;
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.description-text {
  color: var(--text-secondary);
  font-size: 1.05em;
  max-width: 700px;
  margin: 0 0 8px 0;
  line-height: 1.6;
}

.inline-demo .sandbox-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 28px;
  align-items: stretch;
}

@media (max-width: 1024px) {
  .inline-demo .sandbox-grid {
    grid-template-columns: 1fr;
  }
}

.inline-demo .sandbox-card {
  border-radius: 16px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.03);
  resize: vertical;
  min-height: 400px;
  height: 600px;
}

@media (min-width: 1025px) {
  body.inline-demo {
    height: 100vh;
    overflow: hidden;
  }

  .inline-demo main {
    min-height: 0;
    overflow: hidden;
  }

  .inline-demo .sandbox-grid {
    flex: 1;
    min-height: 0;
  }

  .inline-demo .sandbox-card {
    height: 100%;
    min-height: 0;
    resize: none;
  }
}


.raw-editor-mount {
  background-color: #ffffff;
}

.raw-editor-mount .cm-editor {
  background-color: #ffffff !important;
  color: #1e293b !important;
  font-family: 'Fira Code', monospace !important;
  font-size: 0.88em !important;
}

.raw-editor-mount .cm-scroller {
  line-height: 1.7 !important;
  padding: 16px 20px !important;
}

.raw-editor-mount .cm-gutters {
  background-color: transparent !important;
  border-right: none !important;
  color: #94a3b8 !important;
  font-family: 'Fira Code', monospace !important;
  font-size: 0.85em !important;
  opacity: 0.7;
}

.raw-editor-mount .cm-gutterElement {
  padding: 0 16px 0 8px !important;
}

.raw-editor-mount .cm-activeLine {
  background-color: rgba(241, 245, 249, 0.6) !important;
}

.raw-editor-mount .cm-activeLineGutter {
  background-color: transparent !important;
  color: var(--accent) !important;
  font-weight: 500;
  opacity: 1;
}

.raw-editor-mount .cm-selectionBackground {
  background-color: rgba(204, 74, 10, 0.15) !important;
}

.output-label-badge {
  background-color: rgba(204, 74, 10, 0.1);
  color: var(--accent);
  font-size: 0.72em;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 6px;
}

/* ==========================================================================
   Form Demo Page (index2.php) Styles
   ========================================================================== */
.form-demo main {
  flex: 1;
  padding: 30px;
  max-width: 1440px;
  margin: 0 auto;
  width: 100%;
  box-sizing: border-box;
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 30px;
}

@media (max-width: 1024px) {
  .form-demo main {
    grid-template-columns: 1fr;
  }
}

.form-demo .form-sidebar {
  min-height: 0;
}

@media (min-width: 1025px) {
  body.form-demo {
    height: 100vh;
    overflow: hidden;
  }

  .form-demo main {
    min-height: 0;
    overflow: hidden;
  }

  .form-demo .form-sidebar {
    height: 100%;
    overflow-y: auto;
  }
}

.form-demo .sandbox-card {
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(15, 23, 42, 0.03);
}

.form-demo .card-header {
  padding: 16px 20px;
}

.form-demo .card-title {
  font-size: 0.95em;
  letter-spacing: 0.03em;
}

.form-body {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-label {
  font-size: 0.82em;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.form-input {
  font-family: inherit;
  font-size: 0.9em;
  padding: 10px 12px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  outline: none;
  transition: all 0.2s;
  background-color: #f8fafc;
}

.form-input:focus {
  border-color: var(--accent);
  background-color: #ffffff;
  box-shadow: 0 0 0 3px rgba(204, 74, 10, 0.15);
}

.terminal-container {
  flex: 1;
  padding: 16px;
  background-color: var(--terminal-bg);
  display: flex;
  flex-direction: column;
}

.terminal-titlebar {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 12px;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.dot.red {
  background-color: #ef4444;
}

.dot.yellow {
  background-color: #f59e0b;
}

.dot.green {
  background-color: #10b981;
}

.terminal-view {
  flex: 1;
  min-height: 0;
  font-family: 'Fira Code', monospace;
  font-size: 0.85em;
  color: #94a3b8;
  background-color: transparent;
  border: none;
  resize: none;
  outline: none;
  line-height: 1.5;
  width: 100%;
  height: auto;
  box-sizing: border-box;
  white-space: pre-wrap;
  overflow-wrap: break-word;
}

.editor-card {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.editor-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  margin: 20px;
  overflow: hidden;
  background-color: #ffffff;
}


.form-demo .editor-mount {
  flex: 1;
  overflow: hidden;
}

.form-demo .editor-mount .cm-editor {
  font-family: 'Atkinson Hyperlegible Next', sans-serif;
}

.form-demo .editor-mount .cm-scroller {
  outline: none;
}

@media (max-width: 1024px) {
  header {
    flex-direction: column;
    gap: 12px;
    padding: 12px 20px;
    align-items: center;
  }
  .brand-section {
    display: flex;
    justify-content: center;
    width: 100%;
  }
  .nav-links {
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    width: 100%;
  }
}

@media (max-width: 768px) {
  header {
    padding: 12px 10px;
  }
}

/* ==========================================================================
   Hybrid Demo Page Styles
   ========================================================================== */
.hybrid-demo main {
  flex: 1;
  padding: 30px;
  max-width: 1440px;
  margin: 0 auto;
  width: 100%;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  gap: 30px;
}

.hybrid-demo .top-row {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 30px;
}

.hybrid-demo .bottom-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 30px;
}

@media (max-width: 1024px) {
  .hybrid-demo .top-row,
  .hybrid-demo .bottom-row {
    grid-template-columns: 1fr;
  }
}

.hybrid-demo .sandbox-card {
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(15, 23, 42, 0.03);
}

.hybrid-demo .form-card {
  height: auto;
}

.hybrid-demo .preview-card {
  height: auto;
  display: flex;
  flex-direction: column;
}

.hybrid-demo .editor-card,
.hybrid-demo .raw-editor-card {
  height: 500px;
  min-height: 400px;
}

@media (min-width: 1025px) {
  body.hybrid-demo {
    height: 100vh;
    overflow: hidden;
  }

  .hybrid-demo main {
    min-height: 0;
    overflow: hidden;
  }

  .hybrid-demo .bottom-row {
    flex: 1;
    min-height: 0;
  }

  .hybrid-demo .editor-card,
  .hybrid-demo .raw-editor-card {
    height: 100%;
    min-height: 0;
  }
}

/* Ensure editor mounts grow to fill their cards */
.hybrid-demo .editor-mount,
.hybrid-demo .raw-editor-mount {
  flex: 1;
  overflow: hidden;
  height: 100%;
}

.hybrid-demo .editor-mount .cm-editor {
  font-family: 'Atkinson Hyperlegible Next', sans-serif;
}

.hybrid-demo .editor-mount .cm-scroller {
  outline: none;
}

/* ==========================================================================
   Unified Demo Page Styles
   ========================================================================== */
.unified-demo main {
  flex: 1;
  padding: 30px;
  max-width: 1440px;
  margin: 0 auto;
  width: 100%;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  gap: 30px;
}

.unified-demo .top-row {
  display: block; /* Full width for the metadata card */
}

.unified-demo .bottom-row {
  display: block; /* Full width for the editor card */
}

.unified-demo .sandbox-card {
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(15, 23, 42, 0.03);
}

.unified-demo .form-card {
  height: auto;
  max-width: 360px;
  transition: border-color 0.3s ease;
}

.unified-demo .form-card.is-collapsed .form-body {
  max-height: 0;
  padding-top: 0;
  padding-bottom: 0;
  opacity: 0;
  pointer-events: none;
}

.unified-demo .form-card.is-collapsed .card-header {
  border-bottom-color: transparent;
}

.unified-demo .form-card .form-body {
  max-height: 500px;
  overflow: hidden;
  transition: max-height 0.3s cubic-bezier(0.4, 0, 0.2, 1), padding 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.25s ease;
  opacity: 1;
}

/* Chevron Rotation */
.unified-demo .form-card .chevron-icon {
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  transform: rotate(0deg);
  color: var(--text-secondary);
}

.unified-demo .form-card:not(.is-collapsed) .chevron-icon {
  transform: rotate(180deg);
}

/* Accordion Header styling */
.unified-demo .form-card .card-header {
  cursor: pointer;
  user-select: none;
  transition: background-color 0.2s ease, border-color 0.3s ease;
}

.unified-demo .form-card .card-header:hover {
  background-color: #f1f5f9;
}

/* Horizontal Form Layout for Metadata */
.unified-demo .horizontal-form {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
  padding: 20px;
}

.unified-demo .horizontal-form .form-group {
  flex: 1;
  min-width: 240px;
}

/* Editor card layout */
.unified-demo .editor-card {
  height: 600px;
  min-height: 400px;
  resize: vertical;
}

@media (min-width: 1025px) {
  body.unified-demo {
    height: 100vh;
    overflow: hidden;
  }

  .unified-demo main {
    min-height: 0;
    overflow: hidden;
  }

  .unified-demo .bottom-row {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
  }

  .unified-demo .editor-card {
    height: 100%;
    min-height: 0;
    resize: none;
  }
}

.unified-demo .editor-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  margin: 0; /* Reset margins inside unified demo */
  border: none;
  border-radius: 0;
  overflow: hidden;
  background-color: #ffffff;
}

.unified-demo .editor-mount,
.unified-demo .raw-editor-mount {
  padding: 0;
  overflow: hidden;
  height: 100%;
}

/* Tab Switcher Styles */
.unified-tab-bar {
  display: flex;
  gap: 0;
  background-color: #f1f5f9;
  border-radius: 8px;
  padding: 3px;
  border: 1px solid var(--border-color);
}

.unified-tab {
  padding: 6px 16px;
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 0.85em;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: 6px;
  transition: all 0.15s ease;
}

.unified-tab.is-active {
  background-color: #ffffff;
  color: var(--text-primary);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.06);
  font-weight: 700;
}

.unified-tab:hover:not(.is-active) {
  color: var(--text-primary);
}

/* Switcher Editor Mounting Display Toggle */
.unified-demo .editor-wrapper.mode-wysiwym #editor {
  display: flex;
  flex-direction: column;
  flex: 1;
}

.unified-demo .editor-wrapper.mode-wysiwym #editor .cm-editor {
  flex: 1;
  min-height: 0;
}

.unified-demo .editor-wrapper.mode-wysiwym #raw-editor {
  display: none !important;
}

.unified-demo .editor-wrapper.mode-markdown #editor,
.unified-demo .editor-wrapper.mode-preview #editor {
  display: flex;
  flex-direction: column;
  flex: 0 0 auto;
  height: auto;
}

.unified-demo .editor-wrapper.mode-markdown #editor .cm-editor,
.unified-demo .editor-wrapper.mode-preview #editor .cm-editor {
  display: none !important;
}

.unified-demo .editor-wrapper.mode-markdown #raw-editor {
  display: flex !important;
  flex-direction: column;
  flex: 1;
  height: 100%;
}

.unified-demo .editor-wrapper.mode-markdown #raw-editor .cm-editor {
  flex: 1;
  min-height: 0;
}

.unified-demo .html-preview-mount {
  flex: 1 !important;
  height: auto !important;
  min-height: 0 !important;
}

/* Greyed-out Toolbar in Markdown Mode */
.unified-demo .traven-toolbar-container.is-disabled {
  opacity: 0.45;
  pointer-events: none;
  user-select: none;
  filter: grayscale(40%);
  transition: all 0.2s ease;
}

/* Flat Copy-to-Clipboard Button */
.copy-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  padding: 4px;
  color: #475569; /* slate-600 */
  cursor: pointer;
  transition: color 0.2s ease;
  outline: none;
}

.copy-btn:hover {
  color: #000000; /* black on hover */
}

.copy-btn.copied {
  color: #475569; /* slate-600 checkmark feedback */
}

.copy-btn svg {
  width: 16px;
  height: 16px;
}

/* Toast Notification */
.save-toast {
  position: fixed;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background-color: #1a1a1a;
  color: #fcfbf9;
  padding: 10px 20px;
  border-radius: 20px;
  font-size: 0.9em;
  font-weight: 500;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif !important;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  z-index: 10000;
  opacity: 0;
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.3s ease;
  pointer-events: none;
  display: flex;
  align-items: center;
  gap: 8px;
}

.save-toast.is-show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

.save-toast svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}