/* SIGNS Bot — chat.signs.nl. Licht, modern, mobiel-first. Geen frameworks. */
@import url('https://fonts.googleapis.com/css2?family=DM+Sans:opsz,wght@9..40,400;9..40,500;9..40,600;9..40,700&display=swap');

* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-soft: #eff4ff;
  --on-primary: #ffffff;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --success: #16a34a;
  --success-soft: #f0fdf4;
  --warn: #d97706;
  --warn-soft: #fffbeb;
  --bg: #f6f8fc;
  --surface: #ffffff;
  --fg: #0f172a;
  --muted: #64748b;
  --muted-2: #94a3b8;
  --border: #e6ecf5;
  --border-strong: #d6deea;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow-sm: 0 1px 2px rgba(15,23,42,.06), 0 1px 3px rgba(15,23,42,.04);
  --shadow-md: 0 4px 16px rgba(15,23,42,.08);
  --shadow-lg: 0 12px 32px rgba(15,23,42,.12);
}
html, body { height: 100%; }
body {
  font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--fg);
  -webkit-font-smoothing: antialiased;
  display: flex; flex-direction: column;
  height: 100dvh;
  font-size: 16px;
  line-height: 1.5;
}
button { font-family: inherit; cursor: pointer; }

/* ---------- Login ---------- */
.login-wrap {
  min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 24px;
  background:
    radial-gradient(900px 500px at 50% -10%, rgba(37,99,235,.10), transparent 60%),
    var(--bg);
}
.login-card {
  width: 100%; max-width: 400px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 22px; padding: 36px 30px;
  box-shadow: var(--shadow-lg);
}
.brand { display: flex; align-items: center; gap: 11px; margin-bottom: 6px; }
.brand .logo {
  width: 38px; height: 38px; border-radius: 11px;
  background: linear-gradient(135deg, var(--primary), #5b8bff);
  display: grid; place-items: center; color: #fff; box-shadow: var(--shadow-sm);
}
.brand h1 { font-size: 20px; font-weight: 700; letter-spacing: -.01em; }
.login-card .sub { color: var(--muted); font-size: 14px; margin: 8px 0 26px; }
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; font-weight: 500; color: var(--fg); margin-bottom: 7px; }
.field input {
  width: 100%; background: var(--surface); border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-sm); padding: 13px 15px; color: var(--fg); font-size: 16px;
  outline: none; transition: border-color .15s, box-shadow .15s;
}
.field input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.btn {
  width: 100%; background: var(--primary); color: var(--on-primary); border: none;
  border-radius: var(--radius-sm); padding: 14px; font-size: 16px; font-weight: 600; margin-top: 8px;
  transition: background .15s, transform .05s;
}
.btn:hover { background: var(--primary-hover); }
.btn:active { transform: translateY(1px); }
.btn:disabled { background: #c7d2e6; cursor: not-allowed; }
.error { color: var(--danger); font-size: 13px; margin-top: 14px; min-height: 18px; text-align: center; }

/* ---------- App shell ---------- */
header {
  background: var(--surface); border-bottom: 1px solid var(--border);
  padding: 12px 18px; display: flex; align-items: center; gap: 11px; flex-shrink: 0;
  box-shadow: var(--shadow-sm); z-index: 10;
}
header .logo {
  width: 32px; height: 32px; border-radius: 9px;
  background: linear-gradient(135deg, var(--primary), #5b8bff);
  display: grid; place-items: center; color: #fff; flex-shrink: 0;
}
header .titles h1 { font-size: 16px; font-weight: 700; letter-spacing: -.01em; line-height: 1.2; }
header .titles .tenant { font-size: 12.5px; color: var(--muted); }
header .right { margin-left: auto; display: flex; align-items: center; gap: 14px; }
.conn { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.conn .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted-2); transition: background .2s; }
.conn .dot.ok { background: var(--success); } .conn .dot.warn { background: var(--warn); } .conn .dot.err { background: var(--danger); }
.iconbtn {
  background: transparent; border: none; color: var(--muted); padding: 8px; border-radius: 9px;
  display: grid; place-items: center; transition: background .15s, color .15s;
}
.iconbtn:hover { background: var(--muted); background: var(--primary-soft); color: var(--primary); }

#messages { flex: 1; overflow-y: auto; padding: 20px 16px; display: flex; flex-direction: column; gap: 14px; }
.row { display: flex; }
.row.user { justify-content: flex-end; }

.msg { max-width: 80%; padding: 11px 15px; border-radius: var(--radius); font-size: 15px; line-height: 1.55; white-space: pre-wrap; word-break: break-word; box-shadow: var(--shadow-sm); }
.msg.user { background: var(--primary); color: #fff; border-bottom-right-radius: 5px; }
.msg.bot { background: var(--surface); border: 1px solid var(--border); border-bottom-left-radius: 5px; }
.msg.bot .label { font-size: 11px; font-weight: 600; color: var(--primary); margin-bottom: 4px; letter-spacing: .02em; }
.msg .time { font-size: 10.5px; color: rgba(255,255,255,.7); margin-top: 5px; text-align: right; }
.msg.bot .time { color: var(--muted-2); }
.msg.system { align-self: center; background: transparent; box-shadow: none; color: var(--muted); font-size: 12.5px; text-align: center; max-width: 92%; }
.loading::after { content: ''; animation: dots 1.4s steps(4) infinite; }
@keyframes dots { 0%{content:''} 25%{content:'.'} 50%{content:'..'} 75%{content:'...'} }

/* ---------- Action card ---------- */
.card {
  align-self: stretch; max-width: 540px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-md); overflow: hidden;
  animation: cardin .28s cubic-bezier(.2,.7,.3,1);
}
@keyframes cardin { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.card .top { display: flex; align-items: center; gap: 9px; padding: 13px 16px 10px; }
.card .src {
  display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 600;
  color: var(--primary); background: var(--primary-soft); padding: 3px 9px; border-radius: 999px;
}
.card .from { font-weight: 600; font-size: 14.5px; color: var(--fg); }
.badge {
  margin-left: auto; font-size: 11px; font-weight: 600; padding: 3px 9px; border-radius: 999px;
  display: inline-flex; align-items: center; gap: 5px;
}
.badge.high { color: var(--success); background: var(--success-soft); }
.badge.medium { color: var(--warn); background: var(--warn-soft); }
.badge.low { color: var(--danger); background: var(--danger-soft); }
.badge .bdot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.card .subject { padding: 0 16px 4px; font-size: 13px; color: var(--muted); }
.card .quote {
  margin: 4px 16px 12px; padding: 10px 13px; background: var(--bg); border-left: 3px solid var(--border-strong);
  border-radius: 0 10px 10px 0; font-size: 13.5px; color: #334155; white-space: pre-wrap; word-break: break-word;
  max-height: 120px; overflow-y: auto;
}
.card .draft-label { padding: 0 16px; font-size: 11px; font-weight: 600; color: var(--muted-2); letter-spacing: .03em; text-transform: uppercase; }
.card .draft {
  margin: 6px 16px 0; font-size: 15px; line-height: 1.55; color: var(--fg);
  white-space: pre-wrap; word-break: break-word;
}
.card .edit {
  width: calc(100% - 32px); margin: 6px 16px 0; border: 1.5px solid var(--primary); border-radius: 10px;
  padding: 11px 13px; font-size: 15px; font-family: inherit; color: var(--fg); resize: vertical; min-height: 90px;
  outline: none;
}
.card .edit:focus { box-shadow: 0 0 0 3px var(--primary-soft); }
.card .why { padding: 8px 16px 0; font-size: 12px; color: var(--muted-2); display: flex; align-items: center; gap: 5px; }
.card .actions { display: flex; gap: 8px; padding: 12px 16px 14px; justify-content: flex-end; flex-wrap: wrap; }
.act {
  min-height: 38px; padding: 0 16px; border: none; border-radius: 9px; font-size: 13.5px; font-weight: 600;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; transition: background .15s, transform .05s, box-shadow .15s;
}
.act.send { padding: 0 18px; }
.act:active { transform: translateY(1px); }
.act.send { background: var(--primary); color: #fff; }
.act.send:hover { background: var(--primary-hover); }
.act.edit { background: var(--surface); color: var(--fg); border: 1.5px solid var(--border-strong); }
.act.edit:hover { border-color: var(--primary); color: var(--primary); }
.act.reject { background: var(--surface); color: var(--danger); border: 1.5px solid var(--border-strong); }
.act.reject:hover { border-color: var(--danger); background: var(--danger-soft); }
.act:disabled { opacity: .5; cursor: not-allowed; }
.card.resolved { opacity: .65; }
.card .resolved-bar {
  padding: 12px 16px; font-size: 13.5px; font-weight: 600; display: flex; align-items: center; gap: 8px;
}
.card .resolved-bar.sent { color: var(--success); background: var(--success-soft); }
.card .resolved-bar.rejected { color: var(--danger); background: var(--danger-soft); }
.card .resolved-bar.failed { color: var(--warn); background: var(--warn-soft); }

/* ---------- Composer ---------- */
#input-area { background: var(--surface); border-top: 1px solid var(--border); padding: 12px 16px; display: flex; gap: 10px; flex-shrink: 0; align-items: flex-end; }
#input {
  flex: 1; background: var(--bg); border: 1.5px solid var(--border-strong); border-radius: 13px;
  padding: 12px 15px; color: var(--fg); font-size: 16px; outline: none; resize: none; font-family: inherit;
  max-height: 120px; transition: border-color .15s, box-shadow .15s;
}
#input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
#send {
  background: var(--primary); color: #fff; border: none; border-radius: 13px; width: 48px; height: 48px;
  display: grid; place-items: center; flex-shrink: 0; transition: background .15s, transform .05s;
}
#send:hover { background: var(--primary-hover); }
#send:active { transform: translateY(1px); }
#send:disabled { background: #c7d2e6; cursor: not-allowed; }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(15,23,42,.45); display: grid; place-items: center;
  padding: 20px; z-index: 100; animation: fadein .15s ease-out;
}
.modal-backdrop[hidden] { display: none; }
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }
.modal {
  width: 100%; max-width: 380px; background: var(--surface); border-radius: 18px;
  padding: 24px; box-shadow: var(--shadow-lg); animation: cardin .2s cubic-bezier(.2,.7,.3,1);
}
.modal h2 { font-size: 17px; font-weight: 700; margin-bottom: 16px; }
.modal-actions { display: flex; gap: 8px; margin-top: 18px; }
.modal-actions .act { flex: 1; }

/* ---------- Empty state ---------- */
.empty {
  align-self: center; text-align: center; color: var(--muted); margin: auto; padding: 24px; max-width: 320px;
}
.empty svg { color: var(--border-strong); margin-bottom: 10px; }
.empty .t { font-weight: 600; color: var(--fg); font-size: 15px; margin-bottom: 4px; }
.empty .s { font-size: 13.5px; }

@media (max-width: 600px) {
  .msg { max-width: 88%; }
  #messages { padding: 14px 12px; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
