/* screenplayEditor.css */
/* Styles for the Lína Document-Style Screenplay Editor */
/* Additive — does not override existing screenplay viewer styles */

/* =====================================================
   DOCUMENT EDITOR SURFACE
   ===================================================== */

/* Paper grows with content in edit mode (no fixed height / absolute positioning) */
.screenplay-paper-editing {
  min-height: 11in;
  height: auto;
}

.screenplay-doc-editor {
  /* Same typography as .screenplay-paper-content but flow-based, not absolute */
  font-family: "Courier Prime", "Courier New", Courier, monospace;
  font-size: 12pt;
  line-height: 12pt;

  /* Same margins as the viewer's content area */
  padding: 1in 1in 1in 1.5in;

  outline: none;
  cursor: text;
  min-height: calc(11in - 2in);
}

/* All paragraphs: reset vertical margins, preserve horizontal (set by element type classes) */
.screenplay-doc-editor p {
  margin-top: 0;
  margin-bottom: 0;
  padding-bottom: 11.2pt;  /* Match viewer's .sp-block spacing */
  min-height: 12pt;
  outline: none;
  line-height: 12pt;
}

/*
 * In the viewer, dialogue lines and parentheticals live inside an sp-dialogue
 * container div that provides margin-left: 1in. In the editor's flat DOM,
 * we apply absolute margins directly.
 *
 * Standard screenplay margins within the content area (6in wide):
 *   Character cue:    ~2.2in from left
 *   Dialogue:         ~1in from left, ~3.6in wide
 *   Parenthetical:    ~1.5in from left, ~2.1in wide
 *   Transition:       right-aligned
 */

/* Dialogue lines — absolute margin */
.screenplay-doc-editor p.sp-dialogue-line {
  margin-left: 1in;
  width: 3.6in;
  padding-bottom: 0;
}

/* Parenthetical — absolute margin */
.screenplay-doc-editor p.sp-parenthetical {
  margin-left: 1.5in;
  width: 2.1in;
  padding-bottom: 0;
}

/* Character cue: tight to dialogue below */
.screenplay-doc-editor p.sp-character {
  padding-bottom: 0;
}

/* Last dialogue/paren line in a run needs bottom spacing */
.screenplay-doc-editor p.sp-dialogue-line:last-child,
.screenplay-doc-editor p.sp-parenthetical:last-child {
  padding-bottom: 11.2pt;
}

.screenplay-doc-editor p.sp-dialogue-line:has(+ p:not(.sp-dialogue-line):not(.sp-parenthetical)),
.screenplay-doc-editor p.sp-parenthetical:has(+ p:not(.sp-dialogue-line):not(.sp-parenthetical)) {
  padding-bottom: 11.2pt;
}

/* Page break */
.screenplay-doc-editor p.sp-page-break-line {
  text-align: center;
  color: #999;
  border-top: 1px dashed #ccc;
  padding-top: 4pt;
  padding-bottom: 11.2pt;
  font-size: 10pt;
  user-select: none;
}

/* Subtle focus highlight on current paragraph */
.screenplay-doc-editor p:focus {
  background: rgba(209, 139, 60, 0.04);
  border-radius: 2px;
}

/* =====================================================
   ELEMENT TYPE TOOLBAR
   ===================================================== */

.sp-element-toolbar {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 2px;
  background: var(--bg-elevated, rgba(0, 0, 0, 0.2));
  border-radius: 5px;
  border: 1px solid var(--border, #4b4b50);
}

.sp-element-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px 8px;
  color: var(--text-secondary, #b5b5b5);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.12s ease;
}

.sp-element-btn svg {
  flex-shrink: 0;
}

.sp-element-btn:hover {
  color: var(--text-primary, #e6e6e6);
  background: rgba(255, 255, 255, 0.06);
}

.sp-element-btn-active {
  color: #fff;
  background: var(--accent, #d18b3c);
  border-color: var(--accent, #d18b3c);
}

.sp-element-btn-active:hover {
  background: var(--accent, #d18b3c);
  filter: brightness(1.1);
}

/* Separator between structural and dialogue groups */
.sp-toolbar-sep {
  width: 1px;
  height: 16px;
  background: var(--border, #4b4b50);
  margin: 0 3px;
  flex-shrink: 0;
}

/* Disabled state for dialogue/parenthetical buttons when not in dialogue context */
.sp-element-btn-disabled {
  opacity: 0.3;
  cursor: default;
  pointer-events: none;
}

/* Header center layout */
.screenplay-header-center {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  flex-shrink: 0;
}

/* =====================================================
   SAVE STATUS INDICATOR
   ===================================================== */

.sp-save-status {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 4px;
}

.sp-save-dots {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex-shrink: 0;
}

.save-dot {
  display: block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #27ae60;
  flex-shrink: 0;
  transition: background 0.2s ease;
}

.save-dot.unsaved {
  background: var(--accent, #d18b3c);
}

.save-dot.error {
  background: #e74c3c;
}

.sp-save-labels {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.sp-save-label {
  font-size: 9px;
  font-weight: 600;
  color: var(--text-secondary, #b5b5b5);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  opacity: 0.7;
}

.sp-save-time {
  font-size: 10px;
  color: var(--text-secondary, #b5b5b5);
  opacity: 0.9;
  white-space: nowrap;
}

/* =====================================================
   RESPONSIVE
   ===================================================== */

@media (max-width: 900px) {
  .sp-element-btn {
    padding: 4px 6px;
  }
  .sp-element-btn svg {
    width: 12px;
    height: 12px;
  }
}
