/* ===== Design Tokens (Light, Gov-Style) ===== */
:root {
  --bg: #f7f9fc;
  --panel: #ffffff;
  --panel-elev: #ffffffcc;
  --text: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --primary: #1242a7;
  --primary-600: #0f3890;
  --accent: #16a34a;
  --accent-600: #12813d;
  --warn: #ef4444;
  --focus: #93c5fd;
  --shadow: 0 10px 30px rgba(2, 8, 23, 0.08);
  --radius: 14px;

  /* chat bubble colors */
  --visitor-bg: #eaf2ff;
  --visitor-border: #cfe0ff;
  --visitor-text: #0f2b6d;
  --admin-bg: #f7fafc;
  --admin-border: #e5e7eb;
  --admin-text: #0f172a;
}

* {
  box-sizing: border-box;
}
html,
body {
  height: 100%;
  font-family: "Montserrat", sans-serif;
}

body {
  margin: 0;
  font-family: "Montserrat", sans-serif;
  background: radial-gradient(1200px 600px at 50% -10%, rgba(18, 66, 167, 0.08), transparent 55%),
    linear-gradient(180deg, #f9fbff, #f7f9fc 30%, #f6f8fb 100%);
  color: var(--text);
}

/* font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue",
    Arial, "Noto Sans", "Montserrat", sans-serif; */

/* Setting the "Guest text" */
#list .item .row strong {
  font-size: 14px;
  font-weight: 600;
}

#list .item .row .offline {
  font-size: 14px;
  font-weight: 500;
}

.list card p {
  font-weight: 900;
}

/* ===== App Shell ===== */
.app {
  max-width: 1100px;
  margin: 28px auto;
  padding: 0 18px;
}
header {
  background: linear-gradient(180deg, #ffffff, #f7f9fc);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  border-radius: 20px;
  padding: 18px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 700;
}
.brand .crest {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: conic-gradient(from 210deg, #1242a7, #1b5bd1, #1242a7);
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 900;
  box-shadow: 0 6px 16px rgba(18, 66, 167, 0.22);
}

.crest {
  width: 32px; /* atur di sini kalau mau 24px, 40px, dll */
  height: 32px;
  flex: 0 0 32px; /* jangan ikut melar */
}

.crest img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.login-header .logo-icon {
  width: 40px; /* ubah sesuai kebutuhan, ex: 32px */
  height: 40px;
  flex: 0 0 40px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-header .logo-icon img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.login-sub {
  font-size: 14px;
  font-weight: lighter;
}

.brand .logo-icon {
  width: 40px; /* ubah sesuai kebutuhan, ex: 32px */
  height: 40px;
  flex: 0 0 40px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.brand .logo-icon img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.brand small {
  display: block;
  color: var(--muted);
  font-weight: 600;
  font-size: 12px;
  letter-spacing: 0.3px;
}
h1 {
  margin: 0;
  font-size: 18px;
}
#status {
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  background: #eaf2ff;
  color: #0f3890;
  border: 1px solid #cfe0ff;
}

/* Buttons / Inputs */
a {
  color: var(--primary);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}
button {
  padding: 10px 14px;
  border: none;
  border-radius: 12px;
  font-weight: 700;
  cursor: pointer;
  background: var(--primary);
  color: #fff;
  box-shadow: 0 6px 14px rgba(18, 66, 167, 0.18);
}
button.secondary {
  background: #0b122003;
  color: var(--primary);
  border: 1px solid var(--line);
  box-shadow: none;
}
button.danger {
  background: var(--warn);
}
button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}
input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #fff;
  color: #0f172a;
  outline: none;
  transition: border 0.15s, box-shadow 0.15s;
}
input:focus {
  border-color: #bcd3ff;
  box-shadow: 0 0 0 4px rgba(147, 197, 253, 0.35);
}
label.switch {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Cards */
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

/* ===== Visitor Chat ===== */
.join {
  margin-top: 14px;
}
.join .card {
  padding: 16px;
}
.join form {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.join form button {
  min-width: 120px;
}

.chat {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  margin-top: 14px;
}
.messages {
  display: flex;
  flex-direction: column;
}
.messages .card {
  min-height: 460px;
  display: flex;
  flex-direction: column;
}
#messages {
  list-style: none;
  margin: 0;
  padding: 16px;
  flex: 1;
  overflow: auto;
}

/* message container */
.message {
  margin-bottom: 12px;
  display: flex;
  flex-direction: column;
  max-width: 85%;
}
.meta {
  display: flex;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  margin: 2px 4px 6px;
}

/* modern chat bubble */
.bubble {
  display: inline-block;
  padding: 12px 14px;
  border-radius: 16px;
  border: 1px solid var(--line);
  box-shadow: 0 1px 4px rgba(2, 8, 23, 0.06);
  word-wrap: break-word;
  line-height: 1.5;
  font-size: 15px;
  max-width: min(85%, 680px);
}

/* visitor (right) */
.message.visitor {
  align-self: flex-end;
  text-align: right;
}
.message.visitor .bubble {
  background: var(--visitor-bg);
  border-color: var(--visitor-border);
  color: var(--visitor-text);
  border-bottom-right-radius: 6px;
}
.message.visitor .meta {
  justify-content: flex-end;
  text-align: right;
}

/* admin (left) */
.message.admin {
  align-self: flex-start;
  text-align: left;
}
.message.admin .bubble {
  background: var(--admin-bg);
  border-color: var(--admin-border);
  color: var(--admin-text);
  border-bottom-left-radius: 6px;
}
.message.admin .meta {
  justify-content: flex-start;
}

/* system message */
/* .system {
  color: #6b7280;
  font-style: italic;
  text-align: center;
  margin: 8px 0;
} */

/* .system {
  text-align: center;
  font-style: italic;
  background: #f7f8fa;
  color: #555;
  border-radius: 8px;
  padding: 6px 12px;
  display: inline-block;
  margin: 8px auto;
  border: 1px dashed #ddd;
} */

/* message form */
#message-form {
  display: flex;
  gap: 10px;
  padding: 12px;
  border-top: 1px solid var(--line);
  background: #fbfdff;
  border-radius: 0 0 var(--radius) var(--radius);
}

/* offline banner */
/* #offline-banner {
  margin: 12px 0;
  padding: 12px;
  border: 1px dashed #cbd5e1;
  border-radius: 12px;
  background: #fafafa;
  color: #334155;
} */

#offline-banner {
  color: #b91c1c; /* calm red text */
  font-style: italic;
  text-align: center;
  margin: 12px auto;
  background: #fef2f2; /* pale red background */
  padding: 8px 14px;
  border: 1px solid #fecaca; /* soft red border */
  border-radius: 12px;
  display: inline-block;
  max-width: 100%;
}

#offline-banner:hover {
  background: #fee2e2;
  border-color: #fca5a5;
}

/* image inside message */
.bubble img {
  max-width: 300px;
  height: auto;
  display: block;
  border-radius: 12px;
  border: 1px solid var(--admin-border);
  box-shadow: 0 6px 18px rgba(2, 8, 23, 0.08);
}

/* typing */
.typing-indicator {
  display: inline-block;
  background: #eef3ff;
  color: #3b4cca;
  padding: 6px 12px;
  border-radius: 14px;
  margin: 8px 12px;
  font-size: 13px;
  font-style: italic;
}

/* Message Notification */
#toast-container {
  position: fixed;
  right: 16px;
  bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 9999;
}

.toast {
  background: #0f172a;
  color: #f9fafb;
  min-width: 420px;
  max-width: 520px;
  padding: 12px 10px;
  border-radius: 14px;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.45);
  font-size: 13px;
  cursor: pointer;
  opacity: 0;
  transform: translateX(20px);
  transition: opacity 0.18s ease-out, transform 0.18s ease-out;
}

.toast--show {
  opacity: 1;
  transform: translateX(0);
}

.toast__title {
  height: 120px;
  width: 120px;
}

.toast__body {
  color: #e5e7eb;
}
.toast__meta {
  font-size: 11px;
  color: #9ca3af;
}

/* ===== Admin Layout ===== */
.admin-layout {
  display: grid;
  grid-template-columns: 310px 1fr;
  gap: 14px;
  margin-top: 14px;
}
.list.card {
  padding: 14px;
}
.list h3 {
  margin: 6px 2px 12px;
}
.item {
  padding-top: 30px;
  padding: 10px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #fff;
  cursor: pointer;
  margin-bottom: 10px;
  transition: transform 0.06s;
}

.item .row:first-child span.online,
.item .row:first-child span.offline {
  display: inline-block;
  margin-top: 4px; /* ubah sesuai kebutuhan */
}

.item:hover {
  transform: translateY(-1px);
}
.item.active {
  outline: 2px solid #bcd3ff;
}

/* Css new style for audio */
/* NEW: Orange “new visitor” dot on a conversation list item */
.item.has-new {
  position: relative;
}
.item.has-new::after {
  content: "";
  position: absolute;
  top: 10px;
  right: 10px;
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: #f59e0b; /* amber-500 */
  box-shadow: 0 0 0 4px rgba(245, 158, 11, 0.18);
}

.row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}
.badge {
  background: #eef2ff;
  border: 1px solid #dbe5ff;
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 12px;
  font-weight: 700;
  color: #0f3890;
}
.online {
  color: #16a34a;
  font-weight: 700;
}
.offline {
  color: #ef4444;
  font-weight: 700;
}
.right.card {
  display: flex;
  flex-direction: column;
}
.toolbar {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #fff, #fafcff);
}
.msgs {
  flex: 1;
  overflow: auto;
  padding: 14px;
}
.inputbar {
  display: flex;
  gap: 10px;
  padding: 12px;
  border-top: 1px solid var(--line);
  background: #fbfdff;
}

/* Admin transcript alignment */
.msgs .message {
  margin-bottom: 12px;
  display: flex;
  flex-direction: column;
  max-width: 85%;
}
.msgs .meta {
  display: flex;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  margin: 2px 4px 6px;
}
.msgs .bubble {
  display: inline-block;
  padding: 12px 14px;
  border-radius: 16px;
  border: 1px solid var(--line);
  box-shadow: 0 1px 4px rgba(2, 8, 23, 0.06);
  word-wrap: break-word;
  line-height: 1.5;
  font-size: 15px;
  max-width: min(85%, 680px);
}

/* right side visitor (admin view) */
.msgs .message.visitor {
  align-self: flex-end;
  text-align: right;
}
.msgs .message.visitor .bubble {
  background: var(--visitor-bg);
  border-color: var(--visitor-border);
  color: var(--visitor-text);
  border-bottom-right-radius: 6px;
}
.msgs .message.visitor .meta {
  justify-content: flex-end;
  text-align: right;
}

/* left side admin */
.msgs .message.admin {
  align-self: flex-start;
  text-align: left;
}
.msgs .message.admin .bubble {
  background: var(--admin-bg);
  border-color: var(--admin-border);
  color: var(--admin-text);
  border-bottom-left-radius: 6px;
}
.msgs .message.admin .meta {
  justify-content: flex-start;
}

/* images in admin transcript */
.msgs .bubble img {
  max-width: 320px;
  height: auto;
  border-radius: 12px;
  border: 1px solid var(--admin-border);
  box-shadow: 0 6px 20px rgba(2, 8, 23, 0.08);
  display: block;
}

/* ===== Loading Overlay ===== */
.loading-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #eef4ff, #f7fafc);
  color: #0f172a;
  z-index: 9999;
  transition: opacity 0.4s ease;
  border-top: 6px solid var(--primary);
}
.spinner {
  width: 66px;
  height: 66px;
  border: 6px solid rgba(2, 8, 23, 0.08);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 16px;
  box-shadow: 0 0 22px rgba(22, 163, 74, 0.25);
}
.loading-overlay p {
  margin: 0;
  font-weight: 700;
  letter-spacing: 0.3px;
  color: #1f2937;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
.loading-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

/* Utilities */
.muted {
  color: var(--muted);
  font-size: 80%;
}
.hidden {
  display: none;
}

/* Responsive bubble width */
@media (max-width: 480px) {
  .bubble {
    max-width: 92vw;
  }
}
/* === Lightbox (image viewer) === */
.viewer {
  position: fixed;
  inset: 0;
  background: rgba(2, 8, 23, 0.66);
  backdrop-filter: blur(3px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 10000;
}
.viewer.open {
  display: flex;
}

.viewer__inner {
  position: relative;
  max-width: 92vw;
  max-height: 90vh;
  display: grid;
  grid-template-rows: 1fr auto;
  gap: 10px;
}

.viewer__img-wrap {
  position: relative;
  display: grid;
  place-items: center;
  max-height: 80vh;
}
.viewer__img {
  max-width: 92vw;
  max-height: 80vh;
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
  background: #fff;
}

.viewer__caption {
  color: #e5e7eb;
  font-size: 13px;
  text-align: center;
}

.viewer__close,
.viewer__prev,
.viewer__next {
  position: absolute;
  top: 14px;
  width: 36px;
  height: 36px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.9);
  color: #0f172a;
  border: 1px solid #e5e7eb;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
  display: grid;
  place-items: center;
  font-weight: 900;
  cursor: pointer;
  user-select: none;
}
.viewer__close {
  right: 14px;
}
.viewer__prev {
  left: 14px;
}
.viewer__next {
  right: 60px;
}

.viewer__close:focus,
.viewer__prev:focus,
.viewer__next:focus {
  outline: 3px solid rgba(147, 197, 253, 0.6);
}
/* === Read receipt status text under bubbles === */
.status {
  margin-top: 6px;
  font-size: 12px;
  color: #94a3b8; /* slate-400 */
}
.message.visitor .status {
  text-align: right;
}
.message.admin .status {
  text-align: left;
}

/* === Inside-scroll overrides (add at the very end of your CSS) === */

/* Visitor chat card becomes a fixed-height flex column */
.messages {
  min-height: 0;
} /* lets child flexbox shrink properly */
.messages .card {
  height: 70vh; /* the chat box height */
  min-height: 420px; /* keep reasonable height on small screens */
  display: flex;
  flex-direction: column;
}

/* The transcript list is the scrollable area inside the card */
#messages {
  flex: 1 1 auto;
  min-height: 0; /* critical for correct inner scroll */
  overflow: auto; /* inner scrolling happens here */
  padding: 16px; /* keep your original padding */
}

/* Make sure the outer grid doesn’t force page scroll */
.chat {
  min-height: 0;
}

/* Admin: right panel becomes a fixed-height flex column */
.right.card {
  display: flex;
  flex-direction: column;
  height: 70vh;
  min-height: 420px;
}

/* Admin transcript area scrolls inside the panel */
.msgs {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding: 14px; /* keep your original padding */
}

/* === Chat bubble polish (drop-in overrides) ========================= */

/* Give each message a bit more room and nicer spacing */
.message {
  max-width: 80%;
  margin-bottom: 14px;
  display: flex;
  flex-direction: column;
  gap: 4px; /* puts a tiny gap between .meta and .bubble */
}

/* Meta (name • time) sits above the bubble and aligns with it */
.meta {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
  margin: 0; /* reset older margins */
  opacity: 0.9;
}

/* Align meta text with its side, same as bubble alignment */
.message.admin .meta {
  text-align: left;
  padding-left: 8px; /* visually hugs the bubble edge */
}
.message.visitor .meta {
  text-align: right;
  padding-right: 8px;
}

/* Make bubbles wider, rounder, and a touch softer */
.bubble {
  display: inline-block;
  padding: 12px 18px;
  border-radius: 18px;
  border: 1px solid var(--line);
  box-shadow: 0 1px 4px rgba(2, 8, 23, 0.06);
  line-height: 1.5;
  font-size: 15px;
  width: auto;
  max-width: 90%; /* wider than before */
  background: #f8faff;
  transition: box-shadow 0.15s ease;
}

/* Visitor (right) — soft blue gradient, right tail softened */
.message.visitor {
  align-self: flex-end;
  align-items: flex-end;
  text-align: right;
}
.message.visitor .bubble {
  background: linear-gradient(135deg, #eaf2ff, #dbe7ff);
  border-color: #c0d5ff;
  color: var(--visitor-text);
  border-bottom-right-radius: 8px;
}

/* Admin (left) — light neutral bubble */
.message.admin {
  align-self: flex-start;
  align-items: flex-start;
  text-align: left;
}
.message.admin .bubble {
  background: #f9fafc;
  border-color: #e3e8ef;
  color: var(--admin-text);
  border-bottom-left-radius: 8px;
}

/* Hover lift (nice on admin transcript review) */
.bubble:hover {
  box-shadow: 0 2px 8px rgba(2, 8, 23, 0.08);
}

/* System messages look tidy and centered but not cramped */
.system {
  color: #6b7280;
  font-style: italic;
  text-align: center;
  margin: 12px auto;
  background: #f3f4f6;
  padding: 8px 14px;
  border-radius: 12px;
  display: inline-block;
  max-width: 92%;
}

/* Slightly larger image previews look better with wider bubbles */
.bubble img {
  max-width: 340px; /* was 300px */
  height: auto;
  display: block;
  border-radius: 12px;
  border: 1px solid var(--admin-border);
  box-shadow: 0 6px 18px rgba(2, 8, 23, 0.08);
}

/* Mobile: keep bubbles comfortable on small screens */
@media (max-width: 480px) {
  .message {
    max-width: 92%;
  }
  .bubble {
    max-width: 92vw;
  }
}

/* Optional: if you have any sticky toolbars/headers in the panels, they’ll stay visible
   while the transcript (#messages / .msgs) scrolls underneath. */

/* Small screens: make the panels use more vertical space */
@media (max-height: 740px) {
  .messages .card,
  .right.card {
    height: calc(100vh - 260px); /* adjust if your header/join/toolbars differ */
  }
}

/* === Admin: make the conversations list scroll inside the left card === */

/* Make the left card a fixed-height flex column */
.admin-layout .list.card {
  display: flex;
  flex-direction: column;
  height: 70vh; /* adjust to taste (or use calc(100vh - Xpx)) */
  min-height: 420px; /* keeps a reasonable size on small screens */
  overflow: hidden; /* hide outer scrollbars; inner #list will scroll */
}

/* Keep the "Conversations" header visible while the list scrolls */
.admin-layout .list.card h3 {
  position: sticky;
  top: 0;
  margin: 0 2px 10px;
  padding: 8px 4px 10px;
  background: #fff; /* match your panel color */
  z-index: 1;
  border-bottom: 1px solid var(--line);
}

/* The scrollable area */
#list {
  flex: 1 1 auto;
  min-height: 0; /* IMPORTANT so the child can actually shrink */
  overflow-y: auto; /* <-- inner scrolling happens here */
  padding-right: 6px; /* avoid content touching the scrollbar */
  scroll-behavior: smooth;
}

/* Tidy, thin scrollbar (optional) */
#list::-webkit-scrollbar {
  width: 6px;
}
#list::-webkit-scrollbar-thumb {
  background: rgba(2, 8, 23, 0.18);
  border-radius: 4px;
}
#list::-webkit-scrollbar-thumb:hover {
  background: rgba(2, 8, 23, 0.3);
}
#list {
  scrollbar-width: thin;
} /* Firefox */

/* Quick response */

.quick-reply-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}

.quick-reply-btn {
  border: none;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 13px;
  cursor: pointer;
  background: #e5edff;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.1);
  white-space: nowrap;
}

.quick-reply-btn:hover {
  opacity: 0.9;
}

.quick-reply-btn {
  pointer-events: auto;
  cursor: pointer;
  opacity: 1;
}

/* Quick reply chips aktif */
.quick-reply-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px 12px;
  background: #f9fbff;
}

.quick-reply-btn {
  border: none;
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  background: #e5edff; /* biru muda */
  color: #1242a7; /* biru utama */
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.12);
  cursor: pointer;
  opacity: 1; /* penting: jangan dipucatkan */
  pointer-events: auto; /* pastikan bisa diklik */
}

.quick-reply-btn:hover {
  background: #d3e3ff;
  transform: translateY(-1px);
}
