/* F-137: chat-functie shared components. Gebruikt door operatie-app
   (werk-chat in melding-detail + project-chat in klantproject-detail)
   en monteur-app (chat-views in detail + werklijst). Klant-app NIET. */

body.v2 .chat-panel {
  background: var(--c-surface-2);
  border: 1px solid var(--c-border);
  border-radius: 12px;
  padding: 0;
  margin-bottom: 14px;
  overflow: hidden;
  display: flex; flex-direction: column;
}

body.v2 .chat-panel-head {
  padding: 14px 18px;
  border-bottom: 1px solid var(--c-border);
  display: flex; align-items: center; gap: 10px;
  background: #fff;
}
body.v2 .chat-panel-icon {
  width: 28px; height: 28px;
  background: var(--brand-black); color: #fff;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
body.v2 .chat-panel-icon svg { width: 14px; height: 14px; }
body.v2 .chat-panel-meta { flex: 1; min-width: 0; }
body.v2 .chat-panel-title {
  font-size: 10px; font-weight: 700; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--c-text-3);
}
body.v2 .chat-panel-sub {
  font-size: 13px; font-weight: 600; color: var(--c-text);
  margin-top: 2px;
}
body.v2 .chat-panel-badge {
  background: var(--brand-taupe); color: var(--brand-black);
  padding: 2px 8px; border-radius: 99px;
  font-size: 10px; font-weight: 700;
  flex-shrink: 0;
}

body.v2 .chat-body {
  padding: 16px 18px;
  background: var(--c-bg);
  max-height: 360px; overflow-y: auto;
  display: flex; flex-direction: column; gap: 10px;
}
body.v2 .chat-body.mobile { max-height: 320px; padding: 14px; }
body.v2 .chat-body.tall { max-height: 500px; }

body.v2 .chat-day-divider {
  text-align: center; font-size: 10.5px; color: var(--c-text-3);
  margin: 6px 0; text-transform: uppercase; letter-spacing: 0.08em;
  font-weight: 600;
}

body.v2 .msg-empty {
  text-align: center; color: var(--c-text-2);
  font-size: 13px; padding: 32px 16px;
  line-height: 1.5;
}

body.v2 .msg-row { display: flex; gap: 8px; max-width: 86%; }
body.v2 .msg-row.mine { align-self: flex-end; flex-direction: row-reverse; }

body.v2 .msg-avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--brand-taupe); color: var(--brand-black);
  display: flex; align-items: center; justify-content: center;
  font-size: 10.5px; font-weight: 700; flex-shrink: 0;
  letter-spacing: -0.01em;
}
body.v2 .msg-row.mine .msg-avatar { background: var(--brand-black); color: #fff; }
body.v2 .msg-avatar.op { background: var(--brand-graphite); color: #fff; }

body.v2 .msg-content { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
body.v2 .msg-row.mine .msg-content { align-items: flex-end; }

body.v2 .msg-meta {
  font-size: 10.5px; color: var(--c-text-3);
  padding: 0 4px;
}
body.v2 .msg-meta strong { color: var(--c-text-2); font-weight: 600; }
body.v2 .msg-meta .role-chip {
  background: var(--c-border); color: var(--c-text-2);
  font-size: 9.5px; padding: 1px 6px; border-radius: 99px;
  margin-left: 4px; font-weight: 600;
}

body.v2 .msg-bubble {
  background: #fff;
  border: 1px solid var(--c-border);
  border-radius: var(--r-sm) var(--r-sm) var(--r-sm) 4px;
  padding: 8px 12px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--c-text);
  white-space: pre-wrap;
  word-wrap: break-word;
  box-shadow: var(--sh-xs);
}
body.v2 .msg-row.mine .msg-bubble {
  background: var(--brand-black);
  color: #fff;
  border-color: var(--brand-black);
  border-radius: var(--r-sm) var(--r-sm) 4px var(--r-sm);
}
body.v2 .msg-row.op .msg-bubble {
  background: rgba(179, 155, 136, 0.10);
  border-color: var(--brand-taupe);
}

/* Bijlagen */
body.v2 .msg-attach-photo {
  margin-top: 6px;
  border-radius: var(--r-xs);
  overflow: hidden;
  border: 1px solid var(--c-border);
  max-width: 240px;
  display: block;
}
body.v2 .msg-attach-photo img {
  width: 100%; height: auto; display: block; cursor: pointer;
}
body.v2 .msg-row.mine .msg-attach-photo { border-color: rgba(255,255,255,0.2); }

body.v2 .msg-attach-file {
  margin-top: 6px;
  display: flex; align-items: center; gap: 10px;
  background: rgba(26, 25, 25, 0.04);
  border: 1px solid var(--c-border);
  border-radius: var(--r-xs);
  padding: 8px 10px;
  max-width: 260px;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s;
}
body.v2 .msg-attach-file:hover { background: rgba(26, 25, 25, 0.07); }
body.v2 .msg-row.mine .msg-attach-file {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.18);
}
body.v2 .msg-attach-file-icon {
  width: 32px; height: 32px; flex-shrink: 0;
  background: var(--st-critical-bg); color: var(--st-critical);
  border-radius: var(--r-xs);
  display: flex; align-items: center; justify-content: center;
  font-size: 9px; font-weight: 700; letter-spacing: 0.05em;
}
body.v2 .msg-row.mine .msg-attach-file-icon {
  background: rgba(255,255,255,0.15); color: #fff;
}
body.v2 .msg-attach-file-meta { flex: 1; min-width: 0; }
body.v2 .msg-attach-file-name {
  font-size: 12px; font-weight: 600; color: var(--c-text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
body.v2 .msg-row.mine .msg-attach-file-name { color: #fff; }
body.v2 .msg-attach-file-size {
  font-size: 10.5px; color: var(--c-text-3); margin-top: 1px;
}
body.v2 .msg-row.mine .msg-attach-file-size { color: rgba(255,255,255,0.6); }
body.v2 .msg-attach-file-dl { color: var(--c-text-3); flex-shrink: 0; }
body.v2 .msg-row.mine .msg-attach-file-dl { color: rgba(255,255,255,0.6); }

/* Input + disclaimer */
body.v2 .chat-input-row {
  padding: 12px 14px;
  background: #fff;
  border-top: 1px solid var(--c-border);
  display: flex; gap: 8px; align-items: flex-end;
}
body.v2 .chat-input-row textarea {
  flex: 1;
  border: 1px solid var(--c-border-strong);
  border-radius: 18px;
  padding: 8px 14px;
  font-size: 13px;
  font-family: inherit;
  background: #fff;
  color: var(--c-text);
  resize: none;
  min-height: 36px; max-height: 90px;
  outline: none;
  transition: border-color 0.15s;
}
body.v2 .chat-input-row textarea:focus { border-color: var(--brand-black); }
body.v2 .chat-input-row button {
  width: 36px; height: 36px; border-radius: 50%;
  border: none; cursor: pointer; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  transition: opacity 0.15s, background 0.15s;
}
body.v2 .chat-input-row button:hover { opacity: 0.85; }
body.v2 .chat-input-row button:disabled { opacity: 0.4; cursor: not-allowed; }
body.v2 .chat-input-row button svg { width: 16px; height: 16px; }
body.v2 .chat-input-row .btn-attach {
  background: var(--c-surface-2);
  color: var(--c-text-2);
  border: 1px solid var(--c-border);
}
body.v2 .chat-input-row .btn-attach:hover { background: #fff; color: var(--brand-black); }
body.v2 .chat-input-row .btn-send {
  background: var(--brand-black);
  color: #fff;
}

body.v2 .chat-disclaimer {
  padding: 6px 14px 8px;
  background: #fff;
  font-size: 10.5px;
  line-height: 1.4;
  color: var(--c-text-3);
  font-style: italic;
  text-align: center;
  border-top: 0;
}

/* Pending-attachments-preview boven input-row */
body.v2 .chat-pending {
  padding: 8px 14px;
  background: var(--c-surface-2);
  border-top: 1px solid var(--c-border);
  display: flex; gap: 8px; flex-wrap: wrap;
}
body.v2 .chat-pending-item {
  background: #fff;
  border: 1px solid var(--c-border);
  border-radius: var(--r-xs);
  padding: 4px 8px 4px 4px;
  display: flex; align-items: center; gap: 6px;
  font-size: 11.5px;
  max-width: 200px;
}
body.v2 .chat-pending-item img {
  width: 28px; height: 28px;
  object-fit: cover; border-radius: 4px;
}
body.v2 .chat-pending-item .name {
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  color: var(--c-text);
}
body.v2 .chat-pending-item .remove {
  background: none; border: none; color: var(--c-text-3);
  cursor: pointer; padding: 0 2px;
  width: auto; height: auto; border-radius: 0;
  flex-shrink: 0;
}
body.v2 .chat-pending-item .remove:hover { color: var(--st-critical); opacity: 1; }

/* Monteur chat-card variant - inline in melding-detail */
body.v2 #view-monteur .chat-panel {
  background: var(--c-surface);
  box-shadow: var(--sh-sm);
}
body.v2 #view-monteur .chat-panel-head { background: var(--c-surface); }
body.v2 #view-monteur .chat-body { background: var(--c-bg); }
