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

:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --border: #d9dce1;
  --text: #1c1e21;
  --muted: #6b7280;
  --accent: #2563eb;
  --accent-text: #ffffff;
}

html, body {
  height: 100%;
}

body {
  display: flex;
  flex-direction: column;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}

/* ---------- Header ---------- */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex: 0 0 auto;
}

header h1 {
  font-size: 1.25rem;
}

/* ---------- Main / lijst ---------- */
main {
  flex: 1 1 auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

#chat-view {
  height: 100%;
}

.list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 16px;
}

/* ---------- Bericht ---------- */
.message {
  align-self: flex-start;
  max-width: min(680px, 90%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 8px 12px;
}

.message-text {
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.4;
}

.message-meta {
  margin-top: 4px;
  font-size: 0.72rem;
  color: var(--muted);
}

.edited-label {
  font-style: italic;
}

/* ---------- Item-acties (bewerk/verwijder) ---------- */
.item-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

.icon-btn {
  min-height: 44px;
  padding: 0 12px;
  font-size: 0.82rem;
  font-weight: 600;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--muted);
  cursor: pointer;
}

.icon-btn:active {
  transform: translateY(1px);
}

.edit-textarea {
  width: 100%;
  min-height: 64px;
  resize: vertical;
  padding: 8px 10px;
  font: inherit;
  border: 1px solid var(--accent);
  border-radius: 8px;
}

.message.editing {
  width: min(680px, 90%);
}

/* ---------- To-do view ---------- */
#todo-view {
  min-height: 100%;
}

.empty-hint {
  padding: 24px 16px;
  color: var(--muted);
  text-align: center;
}

.todo {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 6px 10px;
}

.todo-check-wrap {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.todo-check {
  width: 22px;
  height: 22px;
  cursor: pointer;
}

.todo-body {
  flex: 1 1 auto;
  min-width: 0;
  padding-top: 10px;
}

.todo-text {
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.4;
}

.todo.done .todo-text {
  text-decoration: line-through;
  color: var(--muted);
}

.todo-meta {
  margin-top: 2px;
  font-size: 0.72rem;
  color: var(--muted);
}

.todo .item-actions {
  margin-top: 0;
  padding-top: 6px;
}

.todo.editing {
  flex-direction: column;
}

.todo.editing .edit-textarea {
  margin-top: 4px;
}

/* ---------- Composer ---------- */
#composer {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;   /* textarea boven, knoppen-rij eronder */
  align-items: stretch;
  gap: 8px;
  padding: 10px 16px;
  background: var(--surface);
  border-top: 1px solid var(--border);
}

#input {
  width: 100%;
  resize: none;
  max-height: 160px;
  /* Hoog genoeg voor ~3 leesbare regels. */
  min-height: 88px;
  padding: 10px 12px;
  font: inherit;
  line-height: 1.4;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
}

.composer-buttons {
  display: flex;
  flex-wrap: nowrap;        /* alles op één rij */
  gap: 8px;
}

/* Send is de primaire actie en de breedste knop: vult de resterende ruimte. */
#send-btn {
  flex: 1 1 auto;
  min-width: 120px;
}

button {
  min-height: 44px;
  padding: 0 16px;
  font: inherit;
  font-weight: 600;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}

button:active {
  transform: translateY(1px);
}

#send-btn {
  background: var(--accent);
  color: var(--accent-text);
  border-color: var(--accent);
}

/* Kleinere, secundaire knoppen naast Send (hoogte blijft 44px tap-target). */
#addtodo-btn,
#upload-btn {
  padding: 0 10px;
  font-size: 0.82rem;
  color: var(--muted);
}

/* ---------- Afbeeldingsbericht ---------- */
.message-image {
  display: block;
  max-width: 100%;
  max-height: 260px;
  border-radius: 8px;
  cursor: pointer;
}

.message.image-message {
  padding: 6px;
}

/* ---------- Lightbox ---------- */
.lightbox {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(0, 0, 0, 0.85);
  align-items: center;
  justify-content: center;
  padding: 16px;
  cursor: zoom-out;
}

.lightbox:not([hidden]) {
  display: flex;
}

.lightbox img {
  max-width: 95vw;
  max-height: 95vh;
  object-fit: contain;
  border-radius: 4px;
}
