/* CoAutor — Stylesheet v0.2 */
/* Clean, modern, reduced — inspired by Claude's UI */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg: #f5f5f0;
  --bg-chat: #fafaf7;
  --bg-input: #ffffff;
  --bg-hover: #eeeeea;
  --bg-active: #e8e8e3;
  --border: #e0ddd5;
  --border-light: #eae7e0;
  --text: #2c2c2c;
  --text-dim: #8a8680;
  --text-light: #b0aca5;
  --accent: #c96442;
  --accent-hover: #b55838;
  --accent-light: rgba(201, 100, 66, 0.08);
  --user-msg: #f0ede6;
  --ai-msg: #ffffff;
  --screenplay-bg: #ffffff;
  --screenplay-text: #1a1a1a;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --radius: 8px;
  --radius-lg: 12px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

html, body {
  height: 100%;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

/* ========================================
   Overlay & Modals
   ======================================== */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.overlay.hidden {
  display: none;
}

.onboarding-card {
  background: var(--bg-input);
  border-radius: 16px;
  padding: 48px;
  max-width: 580px;
  width: 90%;
  box-shadow: var(--shadow-md);
}

.onboarding-card h1 {
  font-size: 24px;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text);
}

.onboarding-sub {
  color: var(--text-dim);
  line-height: 1.5;
  margin-bottom: 32px;
}

.onboarding-steps {
  display: flex;
  flex-direction: column;
  gap: 20px;
  margin-bottom: 32px;
}

.onboarding-step {
  display: flex;
  gap: 16px;
  align-items: flex-start;
}

.step-number {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 13px;
  flex-shrink: 0;
}

.onboarding-step strong {
  display: block;
  margin-bottom: 2px;
  font-size: 14px;
}

.onboarding-step p {
  color: var(--text-dim);
  font-size: 13px;
  line-height: 1.5;
}

.onboarding-start-options {
  display: flex;
  gap: 12px;
}

#import-area {
  margin-top: 20px;
}

#import-text {
  width: 100%;
  height: 150px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  font-family: var(--font);
  font-size: 13px;
  color: var(--text);
  resize: none;
  outline: none;
  margin-bottom: 12px;
}

#import-text:focus {
  border-color: var(--accent);
}

/* Modal */
.modal-card {
  background: var(--bg-input);
  border-radius: 16px;
  padding: 32px;
  max-width: 480px;
  width: 90%;
  box-shadow: var(--shadow-md);
}

.modal-card h2 {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 20px;
}

.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 20px;
}

/* Title Form */
.title-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.title-form label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.title-form input,
.title-form textarea {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  font-family: var(--font);
  font-size: 14px;
  color: var(--text);
  outline: none;
}

.title-form input:focus,
.title-form textarea:focus {
  border-color: var(--accent);
}

/* Export Options */
.export-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.export-btn {
  display: grid;
  grid-template-columns: 32px 1fr;
  grid-template-rows: auto auto;
  gap: 0 12px;
  padding: 14px 16px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  text-align: left;
  font-family: var(--font);
  transition: border-color 0.15s, background 0.15s;
}

.export-btn:hover {
  border-color: var(--accent);
  background: var(--accent-light);
}

.export-icon {
  grid-row: 1 / 3;
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.export-btn span:nth-child(2) {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
}

.export-desc {
  font-size: 12px;
  color: var(--text-dim);
}

/* Buttons */
.btn-primary {
  background: var(--accent);
  color: white;
  border: none;
  border-radius: var(--radius);
  padding: 10px 20px;
  font-family: var(--font);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-secondary {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 20px;
  font-family: var(--font);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.15s;
}

.btn-secondary:hover {
  border-color: var(--text-dim);
}

/* ========================================
   Header / Schubladen-Tabs
   ======================================== */
#pots-bar {
  display: flex;
  align-items: center;
  padding: 0 16px;
  height: 44px;
  background: var(--bg-input);
  border-bottom: 1px solid var(--border);
  gap: 4px;
  overflow-x: auto;
  flex-shrink: 0;
}

#app-logo {
  font-weight: 700;
  font-size: 18px;
  color: var(--accent);
  margin-right: 24px;
  white-space: nowrap;
  letter-spacing: -0.5px;
  font-style: italic;
}

#pot-tabs {
  display: flex;
  gap: 2px;
}

.pot-tab {
  padding: 8px 14px;
  background: transparent;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  border-radius: 6px;
  white-space: nowrap;
  transition: background 0.12s, color 0.12s;
}

.pot-tab:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.pot-tab.active {
  background: var(--accent-light);
  color: var(--accent);
}

#add-pot-btn {
  background: none;
  border: 1px dashed var(--border);
  color: var(--text-light);
  width: 26px;
  height: 26px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-left: 4px;
  flex-shrink: 0;
  transition: border-color 0.15s, color 0.15s;
}

#add-pot-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

#header-actions {
  margin-left: auto;
  display: flex;
  gap: 6px;
}

#header-actions button {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 5px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-family: var(--font);
  font-size: 12px;
  font-weight: 500;
  transition: border-color 0.15s, color 0.15s;
}

#header-actions button:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* ========================================
   Schubladen-Panel
   ======================================== */
#pot-panel {
  background: var(--bg-input);
  border-bottom: 1px solid var(--border);
  overflow: hidden;
  transition: height 0.2s ease;
  height: 240px;
  flex-shrink: 0;
}

#pot-panel.collapsed {
  height: 0;
  border-bottom: none;
}

#pot-content {
  display: flex;
  height: calc(100% - 40px);
}

#pot-docs-list {
  width: 180px;
  border-right: 1px solid var(--border-light);
  overflow-y: auto;
  padding: 8px;
}

.doc-item {
  padding: 7px 10px;
  cursor: pointer;
  border-radius: 6px;
  font-size: 13px;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background 0.1s;
}

.doc-item:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.doc-item.active {
  background: var(--accent-light);
  color: var(--accent);
  font-weight: 500;
}

#pot-editor {
  flex: 1;
  padding: 8px;
}

#pot-editor-text {
  width: 100%;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border-light);
  border-radius: 6px;
  padding: 12px;
  font-family: var(--font);
  font-size: 13px;
  line-height: 1.6;
  resize: none;
  outline: none;
}

#pot-editor-text:focus {
  border-color: var(--accent);
}

#pot-actions {
  display: flex;
  gap: 8px;
  padding: 6px 12px;
  border-top: 1px solid var(--border-light);
  height: 40px;
  align-items: center;
}

#pot-actions button {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 4px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-family: var(--font);
  font-size: 12px;
  transition: border-color 0.15s, color 0.15s;
}

#pot-actions button:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* ========================================
   Workspace
   ======================================== */
#workspace {
  display: flex;
  flex: 1;
  overflow: hidden;
  min-height: 0;
}

/* ========================================
   Chat
   ======================================== */
#chat-pane {
  width: 42%;
  min-width: 300px;
  display: flex;
  flex-direction: column;
  background: var(--bg-chat);
}

#chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.chat-welcome {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-dim);
  line-height: 1.6;
}

.chat-welcome strong {
  color: var(--text);
  font-size: 15px;
}

.chat-msg {
  padding: 12px 16px;
  border-radius: var(--radius-lg);
  font-size: 14px;
  line-height: 1.6;
  max-width: 88%;
  white-space: pre-wrap;
  word-wrap: break-word;
}

.chat-msg.user {
  background: var(--user-msg);
  align-self: flex-end;
  border-bottom-right-radius: 4px;
  color: var(--text);
}

.chat-msg.assistant {
  background: var(--ai-msg);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
  border: 1px solid var(--border-light);
  color: var(--text);
}

.chat-msg .screenplay-inserted {
  color: var(--accent);
  font-size: 12px;
  margin-top: 8px;
  font-weight: 500;
}

.chat-msg .partial-edit-note {
  color: var(--accent);
  font-size: 12px;
  margin-top: 8px;
  font-weight: 500;
}

/* Streaming indicator */
.chat-msg.streaming::after {
  content: '▊';
  animation: blink 0.8s infinite;
  color: var(--accent);
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

/* Chat Form */
#chat-form {
  padding: 12px 16px 8px;
  background: var(--bg-chat);
}

#chat-input-wrap {
  display: flex;
  align-items: flex-end;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 4px 4px 4px 14px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

#chat-input-wrap:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}

#chat-input {
  flex: 1;
  background: none;
  border: none;
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  resize: none;
  outline: none;
  padding: 8px 0;
  max-height: 120px;
  overflow-y: auto;
}

#chat-send {
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 8px;
  width: 34px;
  height: 34px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s, opacity 0.15s;
}

#chat-send:hover {
  background: var(--accent-hover);
}

#chat-send:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

#chat-hint {
  text-align: center;
  font-size: 11px;
  color: var(--text-light);
  padding: 6px 0 2px;
}

/* ========================================
   Divider
   ======================================== */
#divider {
  width: 1px;
  background: var(--border);
  cursor: col-resize;
  flex-shrink: 0;
  position: relative;
  transition: background 0.15s;
}

#divider::after {
  content: '';
  position: absolute;
  inset: 0 -4px;
}

#divider:hover,
#divider.dragging {
  background: var(--accent);
}

/* ========================================
   Screenplay Editor
   ======================================== */
#editor-pane {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: #f8f8f5;
  min-width: 300px;
}

#screenplay-wrap {
  flex: 1;
  overflow-y: auto;
  display: flex;
  justify-content: center;
}

#screenplay {
  padding: 60px 0;
  width: 100%;
  max-width: 680px;
  padding-left: 60px;
  padding-right: 60px;
}

/* Fountain Editor — Single contentEditable with live CSS formatting */
#screenplay-editor {
  font-family: 'Courier New', Courier, monospace;
  font-size: 12pt;
  color: var(--screenplay-text);
  line-height: 1.1;
  outline: none;
  min-height: 100%;
  padding: 60px;
  max-width: 720px;
  margin: 0 auto;
  white-space: pre-wrap;
  word-wrap: break-word;
}

#screenplay-editor:empty::before {
  content: 'Beginne hier zu schreiben...\A\AINT. WOHNZIMMER - NACHT\A\AEine Kerze flackert auf dem Tisch.\A\AEVA\AHier fängt unsere Geschichte an.';
  color: #ccc;
  pointer-events: none;
  white-space: pre-wrap;
}

/* Fountain element formatting via CSS classes */
#screenplay-editor .fp-scene-heading {
  text-transform: uppercase;
  font-weight: bold;
  margin-top: 20px;
  margin-bottom: 12px;
}

#screenplay-editor .fp-action {
  margin-bottom: 12px;
}

#screenplay-editor .fp-character {
  text-transform: uppercase;
  margin-left: 37%;
  margin-bottom: 0;
  margin-top: 12px;
}

#screenplay-editor .fp-parenthetical {
  margin-left: 29%;
  max-width: 28%;
  margin-bottom: 0;
  font-style: italic;
}

#screenplay-editor .fp-dialogue {
  margin-left: 17%;
  max-width: 42%;
  margin-bottom: 0;
}

#screenplay-editor .fp-transition {
  text-align: right;
  text-transform: uppercase;
  margin: 12px 0;
}

#screenplay-editor .fp-empty {
  height: 12px;
}

#screenplay-editor div[data-placeholder]:empty::before {
  content: attr(data-placeholder);
  color: #ccc;
  pointer-events: none;
}

/* Format hint in toolbar */
#format-hint {
  font-size: 11px;
  color: var(--text-light);
}

/* Tool changes display */
.tool-changes {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.change-item {
  color: var(--accent);
  font-size: 12px;
  font-weight: 500;
}

/* Import drop zone */
.import-drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  padding: 40px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.import-drop-zone:hover,
.import-drop-zone.drag-over {
  border-color: var(--accent);
  background: var(--accent-light);
}

/* Editor Toolbar */
#editor-toolbar {
  display: flex;
  gap: 8px;
  padding: 8px 16px;
  background: var(--bg-input);
  border-top: 1px solid var(--border);
  align-items: center;
}

#paragraph-type {
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: var(--font);
  font-size: 12px;
  background: var(--bg);
  color: var(--text);
  outline: none;
}

#add-paragraph-btn {
  padding: 5px 14px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  cursor: pointer;
  font-family: var(--font);
  font-size: 12px;
  color: var(--text-dim);
  transition: border-color 0.15s, color 0.15s;
}

#add-paragraph-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

#toolbar-spacer {
  flex: 1;
}

#word-count {
  font-size: 11px;
  color: var(--text-light);
}

/* ========================================
   Footer
   ======================================== */
#status-bar {
  display: flex;
  justify-content: space-between;
  padding: 4px 16px;
  font-size: 11px;
  color: var(--text-light);
  background: var(--bg-input);
  border-top: 1px solid var(--border);
  height: 28px;
  align-items: center;
  flex-shrink: 0;
}

#project-name {
  cursor: pointer;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 4px;
  transition: background 0.15s;
}

#project-name:hover {
  color: var(--text);
  background: var(--bg-hover);
}

#save-status {
  color: var(--accent);
  transition: opacity 0.3s;
}

/* ========================================
   Scrollbars
   ======================================== */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-light);
}

/* ========================================
   Layout helpers
   ======================================== */
.hidden {
  display: none !important;
}

/* Full height layout */
body {
  display: flex;
  flex-direction: column;
}

/* ========================================
   Project Dropdown Menu
   ======================================== */
.dropdown-menu {
  position: fixed;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  min-width: 200px;
  z-index: 50;
  padding: 4px;
}

.dropdown-menu button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 12px;
  border: none;
  background: none;
  font-family: var(--font);
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  border-radius: 4px;
}

.dropdown-menu button:hover {
  background: var(--bg-hover);
}

.dropdown-menu button.active {
  color: var(--accent);
  font-weight: 500;
}

.dropdown-menu button.new-project {
  color: var(--accent);
}

.dropdown-menu hr {
  border: none;
  border-top: 1px solid var(--border-light);
  margin: 4px 0;
}
