* { box-sizing: border-box; }
html, body {
  height: 100vh;
  height: 100dvh; /* houdt rekening met de mobiele browserbalk, valt terug op 100vh als niet ondersteund */
}
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #0f1720;
  color: #e8edf2;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}
.hidden { display: none !important; }
.screen { width: 100%; height: 100%; }

/* LOGIN */
#login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, #0f1720, #1c2b3a);
}
.login-box {
  background: #16212c;
  padding: 32px 28px;
  border-radius: 16px;
  width: 90%;
  max-width: 380px;
  text-align: center;
  box-shadow: 0 10px 40px rgba(0,0,0,.4);
}
.login-box h1 { margin: 0 0 4px; font-size: 24px; }
.subtitle { color: #8a9bab; margin: 0 0 20px; font-size: 14px; }
#username-input, #password-input {
  width: 100%;
  padding: 14px;
  border-radius: 10px;
  border: 1px solid #2a3a4a;
  background: #0f1720;
  color: #fff;
  font-size: 16px;
  margin-bottom: 16px;
}
.lang-choice { display: flex; flex-direction: column; gap: 8px; margin-bottom: 20px; text-align: left; }
.lang-option {
  display: flex; align-items: center; gap: 8px;
  background: #0f1720; padding: 10px 14px; border-radius: 10px; cursor: pointer;
  border: 1px solid #2a3a4a;
}
#login-btn {
  background: #3b82f6; color: white; border: none;
  padding: 12px 20px; border-radius: 10px; font-size: 15px; cursor: pointer;
  width: 100%;
}
.pill-btn {
  background: #3b82f6; color: white; border: none;
  padding: 12px 18px; border-radius: 20px; font-size: 14px; cursor: pointer;
  white-space: nowrap;
}
.error-text { color: #f87171; font-size: 13px; min-height: 18px; margin-top: 10px; }

/* HOOFDSCHERM */
#app-screen { display: flex; flex-direction: column; }
.app-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 16px;
  padding-top: max(14px, env(safe-area-inset-top));
  background: #16212c; border-bottom: 1px solid #22303e;
  gap: 8px;
}
.status { display: flex; align-items: center; gap: 8px; font-size: 14px; min-width: 0; overflow: hidden; }
#peer-status-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.dot.online { background: #22c55e; }
.dot.offline { background: #6b7280; }
.header-actions { display: flex; flex-shrink: 0; }
.header-actions button {
  background: #22303e; border: none; color: white; font-size: 18px;
  padding: 8px 10px; border-radius: 10px; margin-left: 6px; cursor: pointer;
}

@media (max-width: 380px) {
  .app-header { padding-left: 12px; padding-right: 12px; }
  .header-actions button { padding: 7px 8px; font-size: 16px; margin-left: 4px; }
}

#chat-log {
  flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px;
}
.msg { max-width: 78%; padding: 10px 14px; border-radius: 14px; line-height: 1.4; font-size: 15px; }
.msg.me { align-self: flex-end; background: #3b82f6; color: white; border-bottom-right-radius: 4px; }
.msg.peer { align-self: flex-start; background: #22303e; border-bottom-left-radius: 4px; }
.msg .translated { display: block; opacity: 0.75; font-size: 13px; margin-top: 4px; font-style: italic; }
.msg img, .msg video { max-width: 100%; border-radius: 10px; margin-top: 4px; display: block; }
.msg .timestamp { display: block; font-size: 10px; opacity: 0.5; margin-top: 4px; }

.typing-indicator { padding: 0 16px 6px; font-size: 12px; color: #8a9bab; }

.composer {
  display: flex; align-items: center; gap: 6px; padding: 10px;
  padding-bottom: max(10px, env(safe-area-inset-bottom));
  background: #16212c; border-top: 1px solid #22303e;
}
.composer input[type=text] {
  flex: 1; min-width: 0; padding: 12px 14px; border-radius: 20px; border: none;
  background: #0f1720; color: white; font-size: 16px;
}
.composer button {
  background: #22303e; border: none; color: white; width: 42px; height: 42px;
  border-radius: 50%; font-size: 18px; cursor: pointer; flex-shrink: 0;
}
#send-btn { width: auto; border-radius: 20px; padding: 0 16px; flex-shrink: 0; }

/* Kleine schermen: iets compacter zodat alles op één rij blijft passen */
@media (max-width: 380px) {
  .composer { gap: 4px; padding: 8px; }
  .composer button { width: 38px; height: 38px; font-size: 16px; }
  #send-btn { padding: 0 12px; font-size: 14px; }
  .composer input[type=text] { padding: 10px 12px; }
}

/* BEL SCHERM */
.call-overlay {
  position: fixed; inset: 0; background: #000; z-index: 50;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.call-videos { position: relative; width: 100%; height: 100%; }
#remote-video { width: 100%; height: 100%; object-fit: cover; background: #111; }
#local-video {
  position: absolute; bottom: 100px; right: 16px; width: 110px; height: 150px;
  object-fit: cover; border-radius: 12px; border: 2px solid #333; background: #222;
}
.call-status { position: absolute; top: max(24px, env(safe-area-inset-top)); width: 100%; text-align: center; color: white; font-size: 15px; }
.call-controls {
  position: absolute; bottom: max(24px, env(safe-area-inset-bottom)); display: flex; gap: 20px; width: 100%; justify-content: center;
  flex-wrap: wrap; padding: 0 16px;
}
.call-controls button {
  width: 58px; height: 58px; border-radius: 50%; border: none; font-size: 22px; cursor: pointer;
  background: #22303e; color: white;
}
.call-controls button.hangup { background: #ef4444; }

.incoming-call-box {
  position: fixed; inset: 0; background: rgba(0,0,0,0.85); z-index: 60;
  display: flex; align-items: center; justify-content: center;
}
.incoming-box { text-align: center; color: white; }
.incoming-box div { display: flex; gap: 12px; margin-top: 20px; }
#accept-call-btn { background: #22c55e; }
#decline-call-btn { background: #ef4444; }

#record-screen video { width: 100%; height: 100%; object-fit: cover; }
#record-screen video.mirror { transform: scaleX(-1); }

/* FOTO LIGHTBOX */
.lightbox {
  position: fixed; inset: 0; z-index: 80;
  background: rgba(0,0,0,0.92);
  display: flex; align-items: center; justify-content: center;
  cursor: zoom-out;
  padding: 20px;
}
.lightbox img {
  max-width: 100%; max-height: 100%; border-radius: 8px;
  object-fit: contain;
}
.msg img { cursor: zoom-in; }

.msg { position: relative; }
.delete-btn {
  position: absolute; top: -10px; right: -8px;
  width: 26px; height: 26px; border-radius: 50%;
  background: #1c2b3a; border: 1px solid #3a4a5a; color: white;
  font-size: 12px; cursor: pointer; display: flex; align-items: center; justify-content: center;
  opacity: 0.85;
}
.delete-btn:hover { opacity: 1; background: #ef4444; }

/* CONNECTIE-BANNER */
.connection-banner {
  text-align: center; font-size: 13px; padding: 8px 12px;
  background: #7c2d12; color: #fed7aa;
  transition: background 0.3s;
}
.connection-banner.reconnected { background: #14532d; color: #bbf7d0; }

/* AFLEVER-STATUS (vinkjes) */
.status-tick { font-size: 11px; opacity: 0.75; margin-left: 4px; }
.status-tick.delivered { color: #93c5fd; }
.msg.pending { opacity: 0.6; }

/* BIJLAGE-MENU */
.attach-menu {
  position: absolute; bottom: 66px; left: 10px; right: 10px;
  background: #16212c; border: 1px solid #22303e; border-radius: 14px;
  padding: 8px; box-shadow: 0 -4px 20px rgba(0,0,0,.35); z-index: 40;
}
.menu-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  background: none; border: none; color: white; text-align: left;
  padding: 12px 10px; border-radius: 10px; font-size: 15px; cursor: pointer;
}
.menu-item:active { background: #22303e; }
.menu-divider { height: 1px; background: #22303e; margin: 6px 4px; }
.menu-label { padding: 4px 10px; font-size: 12px; color: #8a9bab; }
.self-destruct-chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 4px 10px 8px; }
.chip {
  background: #22303e; border: 1px solid #2a3a4a; color: #e8edf2;
  padding: 6px 12px; border-radius: 16px; font-size: 13px; cursor: pointer;
}
.chip.active { background: #3b82f6; border-color: #3b82f6; color: white; }

#attach-btn {
  position: relative;
  background: #22303e; border: none; color: white; width: 42px; height: 42px;
  border-radius: 50%; font-size: 20px; cursor: pointer; flex-shrink: 0;
}
#attach-btn.active-destruct::after {
  content: '🔥'; position: absolute; top: -4px; right: -4px; font-size: 12px;
}

.media-placeholder {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 6px; width: min(180px, 55vw); height: min(180px, 55vw); border-radius: 10px;
  background: #0f1720; border: 1px dashed #3a4a5a; cursor: pointer;
  font-size: 13px; text-align: center; padding: 12px;
}
.media-placeholder .icon { font-size: 32px; }

#logout-btn { font-size: 16px; }

/* SPRAAKBERICHT OPNEMEN */
.voice-overlay { background: linear-gradient(160deg, #0f1720, #1c2b3a); }
.voice-visual { display: flex; flex-direction: column; align-items: center; gap: 16px; }
.voice-icon { font-size: 72px; }
.voice-icon.recording { animation: voice-pulse 1.2s ease-in-out infinite; }
@keyframes voice-pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.15); opacity: 0.7; }
}
.voice-timer { font-size: 22px; color: #e8edf2; font-variant-numeric: tabular-nums; }
.msg audio { max-width: 220px; margin-top: 4px; display: block; }
