:root {
  --bg: #0f0f12;
  --surface: #18181c;
  --border: #2a2a30;
  --text: #e4e4e7;
  --text-muted: #a1a1aa;
  --primary: #7c3aed;
  --primary-hover: #8b5cf6;
  --error: #f87171;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

.app {
  display: flex;
  height: 100vh;
  min-height: 100vh;
  overflow: hidden;
}

.sidebar {
  width: 280px;
  min-width: 280px;
  height: 100vh;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  overflow-y: auto;
  flex-shrink: 0;
}

.sidebar-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}
.sidebar-title {
  font-size: 1rem;
  font-weight: 600;
  margin: 0;
}
.btn-text {
  font-size: 0.8rem;
  padding: 0.25rem 0.5rem;
  background: transparent;
  color: var(--text-muted);
  border: none;
  cursor: pointer;
}
.btn-text:hover { color: var(--primary); }
.sidebar-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin: 0;
}

.conversation-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.conversation-list-placeholder {
  font-size: 0.85rem;
  color: var(--text-muted);
  padding: 0.75rem;
  margin: 0;
}

.conversation-item {
  padding: 0.5rem 0.6rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9rem;
  border: none;
  background: transparent;
  color: var(--text);
  text-align: left;
}

.conversation-item:hover {
  background: var(--border);
}

.conversation-item.active {
  background: var(--primary);
  color: white;
}

.conversation-item .item-title {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
}
.conversation-item .item-title-text {
  flex: 1;
  min-width: 0;
  display: block;
}
.conversation-item .direction-icon {
  flex-shrink: 0;
  font-size: 1rem;
  line-height: 1;
  opacity: 0.9;
}
.conversation-item .direction-icon[title="Uitgaand"] {
  color: var(--primary);
}
.conversation-item .direction-icon[title="Inkomend"] {
  color: #22c55e;
}
.conversation-item.active .direction-icon[title="Uitgaand"] {
  color: rgba(255,255,255,0.95);
}
.conversation-item.active .direction-icon[title="Inkomend"] {
  color: #86efac;
}
.conversation-item .item-badge {
  font-weight: 400;
  font-size: 0.8em;
  opacity: 0.9;
}
.conversation-item .meta {
  display: block;
  font-size: 0.8rem;
  margin-top: 0.35rem;
  line-height: 1.45;
  color: var(--text-muted);
  min-height: 1.2em;
}
.conversation-item.active .meta {
  color: rgba(255,255,255,0.9);
}
.conversation-item.active .item-badge {
  opacity: 0.8;
}

.load-actions-sidebar .btn-block { width: 100%; margin-top: 4px; }

.fetch-by-id-row {
  display: flex;
  gap: 6px;
  margin-top: 6px;
  align-items: center;
}
.fetch-by-id-row .input-conversation-id {
  flex: 1;
  min-width: 0;
  padding: 6px 8px;
  font-size: 0.875rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg);
  color: var(--text);
}
.fetch-by-id-row .input-conversation-id::placeholder { color: var(--text-muted); }

.upload-paste-collapse {
  font-size: 0.85rem;
  margin-top: 0.5rem;
}

.upload-paste-collapse summary { cursor: pointer; color: var(--text-muted); }
.upload-paste-collapse textarea, .upload-paste-collapse .input-file {
  margin-top: 0.5rem;
  width: 100%;
  padding: 0.4rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font: inherit;
}

.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 100vh;
  overflow: hidden;
  padding: 1rem 1.5rem;
  max-width: 900px;
}

.call-meta-section {
  margin-bottom: 1rem;
  flex-shrink: 0;
}
.call-meta-section h2 {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-muted);
  margin: 0;
}
.btn-sm {
  font-size: 0.8rem;
  padding: 0.35rem 0.6rem;
}
.call-meta-section .btn-sm {
  flex-shrink: 0;
}
.call-meta-content {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  font-size: 0.9rem;
}
.call-meta-dl {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.25rem 1.5rem;
  margin: 0;
}
.call-meta-dl dt { color: var(--text-muted); font-weight: 500; }
.call-meta-dl dd { margin: 0; }
.call-meta-empty { margin: 0; color: var(--text-muted); font-size: 0.9rem; }
.call-meta-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.5rem;
}
.call-meta-actions .btn-sm { flex-shrink: 0; }
.no-recording-msg { margin: 0; color: var(--text-muted); font-style: italic; }

.summary-section {
  margin-bottom: 1rem;
  flex-shrink: 0;
}

.summary-section h2, .output-section h2 {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-muted);
  margin: 0 0 0.5rem 0;
}

.summary-content {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  font-size: 0.95rem;
  color: var(--text-muted);
}

.output-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.output-section .output-header {
  margin-bottom: 0.5rem;
  flex-shrink: 0;
}

.btn-icon {
  padding: 0.35rem 0.6rem;
  font-size: 0.8rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  cursor: pointer;
}

.btn-icon:hover {
  background: var(--border);
}

.transcript-output {
  flex: 1;
  min-height: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem 1.25rem;
  overflow-y: auto;
  word-break: break-word;
}

.transcript-output.formatted p { margin: 0 0 0.75em 0; line-height: 1.6; }
.transcript-output.formatted p.para-break { margin-bottom: 0.5em; height: 0; }
.transcript-output.formatted ul,
.transcript-output.formatted ol { margin: 0.5em 0 1em; padding-left: 1.5em; }
.transcript-output.formatted ul { list-style-type: disc; }
.transcript-output.formatted ol { list-style-type: decimal; }
.transcript-output.formatted li { margin: 0.35em 0; line-height: 1.5; }
.transcript-output.formatted strong { font-weight: 700; color: var(--text); }
.transcript-output.formatted em { font-style: italic; color: var(--text-muted); }
.transcript-output.formatted .content-heading { font-size: 1rem; font-weight: 700; margin: 1em 0 0.5em; color: var(--text); }
.transcript-output.formatted .content-subheading { font-size: 0.95rem; font-weight: 600; margin: 0.75em 0 0.35em; color: var(--text-muted); }
.transcript-output.formatted .speaker-block { margin: 1.25em 0; padding: 0.75rem 1rem; background: rgba(124, 58, 237, 0.06); border-left: 4px solid var(--primary); border-radius: 0 6px 6px 0; }
.transcript-output.formatted .speaker-label { display: block; font-weight: 700; font-size: 0.95rem; color: var(--primary); margin-bottom: 0.5em; }
.transcript-output.formatted .speaker-content { margin: 0; }
.transcript-output.formatted .speaker-content p { margin: 0 0 0.5em 0; }
.transcript-output.formatted .speaker-content ul.transcript-list { margin: 0.4em 0 0.6em 1.25em; }
.transcript-output.formatted .speaker-content ul.transcript-list li { margin: 0.4em 0; line-height: 1.55; }
.summary-content.formatted .speaker-block { margin: 0.75em 0; border-left: 3px solid var(--primary); padding-left: 0.6rem; }
.summary-content.formatted .speaker-label { font-weight: 700; font-size: 0.85rem; color: var(--primary); margin-bottom: 0.25em; }
.summary-content.formatted p { margin: 0 0 0.6em 0; line-height: 1.5; }
.summary-content.formatted ul,
.summary-content.formatted ol { margin: 0.4em 0 0.75em; padding-left: 1.35em; }
.summary-content.formatted li { margin: 0.25em 0; }
.summary-content.formatted strong { font-weight: 700; }
.summary-content.formatted em { font-style: italic; }
.summary-content.formatted .content-heading { font-size: 0.95rem; font-weight: 700; margin: 0.75em 0 0.4em; }
.summary-content.formatted .content-subheading { font-size: 0.9rem; font-weight: 600; margin: 0.5em 0 0.25em; }

.chat-section {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
  max-height: 50vh;
}

.chat-messages {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

.chat-msg {
  max-width: 85%;
  padding: 0.6rem 0.9rem;
  border-radius: 10px;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.95rem;
}

.chat-msg.user {
  align-self: flex-end;
  background: var(--primary);
  color: white;
}

.chat-msg.assistant {
  align-self: flex-start;
  background: var(--surface);
  border: 1px solid var(--border);
}

.chat-form {
  display: flex;
  gap: 0.5rem;
  align-items: flex-end;
}

.chat-form textarea {
  flex: 1;
  min-height: 44px;
  padding: 0.6rem 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font: inherit;
  resize: none;
}

.chat-form .btn { flex-shrink: 0; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 1rem;
  border: none;
  border-radius: 8px;
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
}

.btn:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn-secondary { background: var(--surface); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover:not(:disabled) { background: var(--border); }

.error { color: var(--error); font-size: 0.85rem; margin: 0.25rem 0 0 0; }
.status { color: var(--text-muted); font-size: 0.85rem; margin: 0.25rem 0 0 0; }

@media (max-width: 640px) {
  .app { flex-direction: column; height: 100vh; }
  .sidebar { width: 100%; min-width: 0; max-height: 40vh; height: auto; }
  .main { height: auto; flex: 1; min-height: 0; }
}
