/* APICanvas — modern API doc builder */

:root {
  --bg: #0f1116;
  --surface: #161a22;
  --surface-hover: #1c2129;
  --border: #2a3142;
  --text: #e6edf5;
  --text-muted: #8b9cb8;
  --accent: #3fb950;
  --accent-dim: #238636;
  --accent-glow: rgba(63, 185, 80, 0.15);
  --danger: #f85149;
  --warning: #d29922;
  --radius: 10px;
  --radius-sm: 6px;
  --font: "Outfit", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", monospace;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.app-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.header-row .btn {
  flex-shrink: 0;
}

.logo {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, var(--accent) 0%, #56d364 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.tagline {
  margin: 0.25rem 0 0;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.main {
  flex: 1;
  display: grid;
  grid-template-columns: 380px 1fr;
  min-height: 0;
}

@media (max-width: 900px) {
  .main {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }
}

.editor-panel {
  overflow-y: auto;
  padding: 1.25rem 1.25rem 2rem;
  border-right: 1px solid var(--border);
  background: var(--surface);
}

.form-section {
  margin-bottom: 1.75rem;
}

.form-section h2 {
  margin: 0 0 0.75rem;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.section-head h2 {
  margin: 0;
}

label {
  display: block;
  margin-bottom: 0.35rem;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
}

input[type="text"],
textarea,
select {
  width: 100%;
  padding: 0.6rem 0.75rem;
  margin-bottom: 0.85rem;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: border-color 0.15s, box-shadow 0.15s;
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

input::placeholder,
textarea::placeholder {
  color: var(--text-muted);
  opacity: 0.7;
}

textarea {
  min-height: 100px;
  resize: vertical;
}

select {
  cursor: pointer;
  width: auto;
  min-width: 100px;
  margin-right: 0.5rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 0.9rem;
  font-family: var(--font);
  font-size: 0.85rem;
  font-weight: 500;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, transform 0.1s;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: var(--accent);
  color: #0d1117;
}

.btn-primary:hover {
  background: #56d364;
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
}

.btn-ghost:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.btn-danger {
  background: transparent;
  color: var(--danger);
}

.btn-danger:hover {
  background: rgba(248, 81, 73, 0.12);
}

.endpoint-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1rem 1.25rem;
  margin-bottom: 1rem;
}

.endpoint-card-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
}

.endpoint-card-header select {
  margin-bottom: 0;
}

.endpoint-card-header input {
  flex: 1;
  min-width: 120px;
  margin-bottom: 0;
}

.endpoint-card-remove {
  margin-left: auto;
  padding: 0.35rem 0.5rem;
  font-size: 0.8rem;
}

.preview-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--bg);
}

.preview-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
}

.preview-toolbar-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.preview-label {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.doc-id-badge {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  padding: 0.25rem 0.5rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-muted);
}

.preview-toolbar a.btn {
  text-decoration: none;
  color: inherit;
}

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

.doc-preview {
  flex: 1;
  overflow-y: auto;
  padding: 2rem 2.5rem 3rem;
}

.doc {
  max-width: 720px;
  margin: 0 auto;
}

.doc-title {
  margin: 0 0 0.25rem;
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
}

.doc-base-url {
  font-family: var(--font-mono);
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 2rem;
  word-break: break-all;
}

.doc-endpoint {
  margin-bottom: 2.5rem;
  padding-bottom: 2rem;
  border-bottom: 1px solid var(--border);
}

.doc-endpoint:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

.doc-endpoint-method {
  display: inline-block;
  padding: 0.2rem 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 4px;
  margin-right: 0.5rem;
}

.doc-endpoint-method.get { background: rgba(63, 185, 80, 0.2); color: var(--accent); }
.doc-endpoint-method.post { background: rgba(210, 153, 34, 0.2); color: var(--warning); }
.doc-endpoint-method.put { background: rgba(56, 139, 253, 0.2); color: #389bfd; }
.doc-endpoint-method.patch { background: rgba(56, 139, 253, 0.2); color: #389bfd; }
.doc-endpoint-method.delete { background: rgba(248, 81, 73, 0.2); color: var(--danger); }

.doc-endpoint-path {
  font-family: var(--font-mono);
  font-size: 1.05rem;
  font-weight: 500;
  color: var(--text);
}

.doc-endpoint-heading {
  margin: 1rem 0 0.5rem;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.doc-code-block {
  margin: 0;
  padding: 1rem 1.25rem;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  line-height: 1.6;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text);
}

.doc-code-block.empty {
  color: var(--text-muted);
  font-style: italic;
}

.toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  padding: 0.65rem 1.25rem;
  font-size: 0.9rem;
  font-weight: 500;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  opacity: 0;
  transition: transform 0.25s, opacity 0.25s;
  pointer-events: none;
  z-index: 100;
}

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

/* Share / view mode: hide editor when URL has hash data */
body.view-mode .editor-panel {
  display: none;
}

body.view-mode .main {
  grid-template-columns: 1fr;
}

body.view-mode .preview-toolbar .export-actions {
  display: flex;
}

body.view-mode .doc-preview {
  max-width: 800px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}
