﻿:root {
  --bg-1: #f4f6f8;
  --bg-2: #d7e7df;
  --surface: rgba(255, 255, 255, 0.88);
  --surface-strong: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --brand: #0f766e;
  --brand-2: #115e59;
  --danger: #b91c1c;
  --shadow: 0 20px 40px rgba(15, 118, 110, 0.16);
  --radius: 18px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Plus Jakarta Sans", "Segoe UI", sans-serif;
  color: var(--text);
  min-height: 100vh;
  background:
    radial-gradient(circle at 10% 10%, #fef3c7 0%, transparent 35%),
    radial-gradient(circle at 85% 20%, #bae6fd 0%, transparent 32%),
    linear-gradient(145deg, var(--bg-1), var(--bg-2));
}

.container {
  width: min(980px, 92vw);
  margin: 28px auto;
}

.card {
  background: var(--surface);
  border: 1px solid rgba(255, 255, 255, 0.7);
  box-shadow: var(--shadow);
  border-radius: var(--radius);
  backdrop-filter: blur(8px);
  padding: 24px;
}

h1, h2, h3 {
  margin-top: 0;
  line-height: 1.2;
}

h1 {
  font-size: clamp(1.6rem, 1.2rem + 1.5vw, 2.3rem);
}

p { color: var(--muted); }

label {
  font-size: 0.92rem;
  font-weight: 600;
  display: block;
  margin-bottom: 6px;
}

input, textarea, button, select {
  width: 100%;
  border-radius: 12px;
  border: 1px solid #d1d5db;
  padding: 12px 14px;
  font: inherit;
}

input:focus, textarea:focus, select:focus {
  outline: 2px solid rgba(15, 118, 110, 0.3);
  border-color: var(--brand);
}

button {
  border: none;
  cursor: pointer;
  transition: transform .15s ease, background-color .15s ease;
}

button:hover { transform: translateY(-1px); }

.btn-primary {
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff;
  font-weight: 700;
}

.btn-secondary {
  background: #e5e7eb;
  color: #1f2937;
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.grid {
  display: grid;
  gap: 16px;
}

.grid-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.flash {
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 14px;
}

.flash-error {
  background: #fef2f2;
  color: #7f1d1d;
  border: 1px solid #fecaca;
}

.flash-success {
  background: #ecfdf5;
  color: #065f46;
  border: 1px solid #a7f3d0;
}

.chat-shell {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

#chatMessages {
  background: linear-gradient(180deg, #fdfefe, #f7fbf9);
  border: 1px solid #e5e7eb;
  border-radius: 14px;
  height: 58vh;
  overflow-y: auto;
  padding: 16px;
}

.message-row {
  display: flex;
  flex-direction: column;
  margin-bottom: 14px;
}

.message-row.own {
  align-items: flex-end;
}

.message-row.other {
  align-items: flex-start;
}

.message-line {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.message-line.own {
  flex-direction: row-reverse;
}

.message-line.other {
  flex-direction: row;
}

.message-bubble {
  width: fit-content;
  max-width: min(78%, 700px);
  border-radius: 16px;
  padding: 10px 12px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.05);
}

.message-bubble.own {
  background: linear-gradient(135deg, #d1fae5, #a7f3d0);
  border-bottom-right-radius: 6px;
}

.message-bubble.other {
  background: #eef2f7;
  border-bottom-left-radius: 6px;
}

.message-bubble .meta {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 0.76rem;
  color: var(--muted);
  margin-bottom: 4px;
}

.message-bubble .text {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.reaction-summary {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 6px;
}

.message-row.own .reaction-summary {
  justify-content: flex-end;
}

.message-row.other .reaction-summary {
  justify-content: flex-start;
}

.reaction-chip {
  width: auto;
  border: 1px solid #d1d5db;
  background: #ffffff;
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 0.82rem;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.reaction-chip.active {
  border-color: #22c55e;
  background: #ecfdf5;
}

.reaction-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  position: relative;
}

.reaction-toggle {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  border: 1px solid #cbd5e1;
  background: #ffffff;
  color: #334155;
  font-size: 15px;
  padding: 0;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.reaction-picker {
  display: none;
  gap: 6px;
  flex-wrap: nowrap;
  white-space: nowrap;
  overflow-x: auto;
  overflow-y: hidden;
  max-width: min(70vw, 320px);
  padding: 6px;
  border: 1px solid #d1d5db;
  border-radius: 999px;
  background: #ffffff;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.09);
}

.message-line.own .reaction-picker {
  position: absolute;
  right: 36px;
  bottom: -2px;
}

.message-line.other .reaction-picker {
  position: absolute;
  left: 36px;
  bottom: -2px;
}

.reaction-picker.open {
  display: flex;
}

.reaction-pick {
  width: auto;
  padding: 3px 7px;
  border-radius: 999px;
  border: 1px solid #d1d5db;
  background: #ffffff;
  font-size: 0.82rem;
}

.reaction-pick:hover,
.reaction-chip:hover,
.reaction-toggle:hover {
  opacity: 1;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  margin-bottom: 6px;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 580px;
}

th, td {
  border-bottom: 1px solid #e5e7eb;
  padding: 10px 8px;
  text-align: left;
  font-size: 0.95rem;
}

.actions {
  display: flex;
  gap: 8px;
}

.mini {
  font-size: 0.82rem;
  color: var(--muted);
}

a {
  color: var(--brand-2);
  text-decoration: none;
}

@media (max-width: 760px) {
  .grid-2 {
    grid-template-columns: 1fr;
  }

  #chatMessages {
    height: 52vh;
  }

  .message-bubble {
    max-width: 88%;
  }

  .message-line.own .reaction-picker,
  .message-line.other .reaction-picker {
    position: absolute;
    left: auto;
    right: 0;
    bottom: 34px;
  }
}



/* Composer emoji picker */
.composer-tools {
  display: flex;
  align-items: center;
  gap: 8px;
  position: relative;
}

.composer-emoji-toggle {
  width: 34px;
  height: 34px;
  border-radius: 999px;
  border: 1px solid #cbd5e1;
  background: #ffffff;
  color: #334155;
  padding: 0;
  font-size: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.composer-emoji-picker {
  display: none;
  position: absolute;
  top: 40px;
  left: 0;
  z-index: 30;
  gap: 6px;
  flex-wrap: wrap;
  width: min(92vw, 360px);
  padding: 8px;
  border: 1px solid #d1d5db;
  border-radius: 12px;
  background: #ffffff;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.09);
}

.composer-emoji-picker.open {
  display: flex;
}

.compose-emoji-item {
  width: 34px;
  height: 34px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #ffffff;
  padding: 0;
  font-size: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Composer layout */
#sendForm {
  gap: 10px;
}

#sendForm #message {
  min-height: 82px;
  resize: vertical;
  background: #ffffff;
}

.composer-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.composer-row .composer-tools {
  flex: 1;
}

.composer-send {
  width: auto;
  min-width: 116px;
  padding: 10px 16px;
  border-radius: 12px;
  box-shadow: 0 6px 16px rgba(15, 118, 110, 0.22);
}

@media (max-width: 640px) {
  .composer-row {
    flex-direction: column;
    align-items: stretch;
  }

  .composer-send {
    width: 100%;
    min-width: 0;
  }

  .composer-emoji-picker {
    width: min(92vw, 320px);
  }
}

/* WhatsApp-like composer */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.whatsapp-composer {
  display: flex;
  align-items: center;
  gap: 8px;
}

.composer-shell {
  position: relative;
  flex: 1;
  display: flex;
  align-items: center;
  gap: 6px;
  background: #f1f1f1;
  border: 1px solid #e5e7eb;
  border-radius: 999px;
  padding: 6px 10px;
}

.composer-icon-btn {
  width: 30px;
  height: 30px;
  min-width: 30px;
  border-radius: 999px;
  border: none;
  background: transparent;
  color: #111827;
  font-size: 21px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.composer-plus {
  font-size: 28px;
  font-weight: 400;
  transform: translateY(-1px);
}

.composer-attach-menu {
  display: none;
  position: absolute;
  left: 8px;
  bottom: 52px;
  z-index: 35;
  min-width: 180px;
  padding: 6px;
  border: 1px solid #d1d5db;
  border-radius: 12px;
  background: #ffffff;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.16);
  gap: 6px;
}

.composer-attach-menu.open {
  display: grid;
}

.attach-item {
  width: 100%;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  background: #ffffff;
  color: #111827;
  font-size: 0.9rem;
  text-align: left;
  padding: 8px 10px;
}

.attach-item[disabled] {
  color: #9ca3af;
  background: #f9fafb;
}

.composer-emoji-toggle {
  font-size: 20px;
}

#sendForm #message {
  flex: 1;
  margin: 0;
  border: none;
  background: transparent;
  box-shadow: none;
  outline: none;
  min-height: 30px;
  max-height: 120px;
  padding: 6px 2px;
  resize: none;
  line-height: 1.35;
}

#sendForm #message:focus {
  outline: none;
  border: none;
}

.composer-send {
  width: 46px;
  height: 46px;
  min-width: 46px;
  border-radius: 999px;
  border: none;
  background: #21c063;
  color: #ffffff;
  font-size: 22px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 16px rgba(33, 192, 99, 0.35);
}

.composer-send:hover {
  background: #1dad58;
}

.composer-send.recording-stop {
  background: #ef4444;
  box-shadow: 0 6px 16px rgba(239, 68, 68, 0.35);
}

.composer-emoji-picker {
  display: none;
  position: absolute;
  bottom: 52px;
  left: 10px;
  z-index: 30;
  gap: 6px;
  flex-wrap: wrap;
  width: min(92vw, 340px);
  padding: 8px;
  border: 1px solid #d1d5db;
  border-radius: 12px;
  background: #ffffff;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.16);
}

.composer-emoji-picker.open {
  display: flex;
}

.compose-emoji-item {
  width: 34px;
  height: 34px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #ffffff;
  padding: 0;
  font-size: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

@media (max-width: 640px) {
  .composer-row.whatsapp-composer {
    flex-direction: row;
    align-items: center;
  }

  .composer-shell {
    padding: 5px 8px;
  }

  .composer-send {
    width: 42px;
    height: 42px;
    min-width: 42px;
  }

  .composer-emoji-picker {
    width: min(92vw, 300px);
  }

  .composer-attach-menu {
    min-width: 170px;
    left: 4px;
  }
}

/* Message moderation + activity */
.message-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.message-delete {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  border: 1px solid #d1d5db;
  background: #ffffff;
  font-size: 14px;
  line-height: 1;
  padding: 0;
}

.message-row.deleted .text {
  color: #6b7280;
  font-style: italic;
}

.message-bubble.deleted {
  background: #f3f4f6;
}

.typing-indicator {
  margin-top: 2px;
  font-size: 0.85rem;
  color: #4b5563;
}

.unread-divider {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #0f766e;
  font-size: 0.8rem;
  margin: 8px 0;
}

.unread-divider::before,
.unread-divider::after {
  content: '';
  height: 1px;
  background: #99f6e4;
  flex: 1;
}

.jump-latest {
  width: auto;
  justify-self: center;
  border-radius: 999px;
  border: 1px solid #99f6e4;
  background: #ecfeff;
  color: #115e59;
  padding: 6px 12px;
  font-size: 0.85rem;
}

.online-indicator {
  margin: 0;
  font-size: 0.85rem;
  color: #0f766e;
  background: #ecfeff;
  border: 1px solid #99f6e4;
  border-radius: 10px;
  padding: 8px 10px;
}


.composer-voice {
  width: 46px;
  height: 46px;
  min-width: 46px;
  border-radius: 999px;
  border: 1px solid #d1d5db;
  background: #ffffff;
  font-size: 20px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.composer-voice.recording {
  background: #fee2e2;
  border-color: #ef4444;
  color: #b91c1c;
}

.voice-audio {
  display: block;
  width: min(260px, 68vw);
  margin-top: 4px;
}

.chat-image {
  display: block;
  max-width: min(300px, 72vw);
  max-height: 320px;
  border-radius: 12px;
  border: 1px solid #e5e7eb;
  margin-top: 4px;
  object-fit: cover;
}

.voice-meta {
  font-size: 0.75rem;
  color: #6b7280;
  margin-top: 4px;
}
