/* ═══════════════════════════════════════════════════════════
   KLINIK NOVI — WhatsApp Web Replica CSS
   ═══════════════════════════════════════════════════════════ */
:root {
  --wa-bg-darker:   #111b21;
  --wa-bg-dark:     #202c33;
  --wa-bg-mid:      #2a3942;
  --wa-bg-hover:    #2a3942;
  --wa-bg-active:   #2d4a54;
  --wa-border:      #3b4a54;
  --wa-teal:        #00a884;
  --wa-teal-dark:   #008c6e;
  --wa-teal-bubble: #005c4b;
  --wa-teal-glow:   rgba(0,168,132,.3);
  --wa-text-1:      #e9edef;
  --wa-text-2:      #aebac1;
  --wa-text-3:      #667781;
  --icon-color:     #aebac1;
  --bubble-in:      #202c33;
  --bubble-out:     #005c4b;
  --wa-input-bg:    #2a3942;
  --wa-search-bg:   #202c33;
  --wa-tick:        #53bdeb;

  --font: 'Inter','Segoe UI',system-ui,sans-serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body, html { height: 100%; overflow: hidden; font-family: var(--font); background: var(--wa-bg-darker); }

/* ─── SHELL ────────────────────────────────────────────────── */
#app {
  display: flex;
  height: 100vh;
  max-width: 100vw;
  overflow: hidden;
  background: var(--wa-bg-darker);
}

/* ════════════════════════════════════════════════════════════
   SIDEBAR
   ════════════════════════════════════════════════════════════ */
#sidebar {
  width: 420px;
  min-width: 300px;
  max-width: 460px;
  background: var(--wa-bg-dark);
  border-right: 1px solid var(--wa-border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex-shrink: 0;
}

/* Header */
#sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: var(--wa-bg-mid);
  min-height: 59px;
}

#sidebar-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--wa-text-1);
}

/* Live badge */
#live-badge {
  font-size: 10px;
  font-weight: 700;
  color: var(--wa-teal);
  background: rgba(0,168,132,.12);
  border: 1px solid rgba(0,168,132,.35);
  border-radius: 99px;
  padding: 3px 9px;
  letter-spacing: .4px;
  animation: pulse-badge 2.5s infinite;
}
#live-badge.offline {
  color: #ef4444;
  background: rgba(239,68,68,.1);
  border-color: rgba(239,68,68,.3);
  animation: none;
}
@keyframes pulse-badge {
  0%,100% { box-shadow: 0 0 0 0 var(--wa-teal-glow); }
  50%     { box-shadow: 0 0 0 5px transparent; }
}

/* Status strip */
#status-bar {
  display: flex;
  align-items: center;
  gap: 0;
  background: var(--wa-bg-dark);
  border-bottom: 1px solid var(--wa-border);
  padding: 6px 0;
}
.status-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 4px 8px;
}
.status-num {
  font-size: 20px;
  font-weight: 700;
  color: var(--wa-teal);
  line-height: 1;
}
.status-lbl {
  font-size: 9px;
  color: var(--wa-text-3);
  text-transform: uppercase;
  letter-spacing: .5px;
  margin-top: 2px;
}
.status-sep { width: 1px; background: var(--wa-border); height: 32px; }

/* Search */
#search-wrap {
  padding: 8px 12px;
  background: var(--wa-bg-dark);
  border-bottom: 1px solid var(--wa-border);
}
.wa-search-box {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--wa-search-bg);
  border-radius: 8px;
  padding: 8px 14px;
}
.wa-search-box i { color: var(--wa-text-3); font-size: 15px; flex-shrink: 0; }
.wa-search-box input {
  background: none;
  border: none;
  outline: none;
  width: 100%;
  font: 14px var(--font);
  color: var(--wa-text-1);
}
.wa-search-box input::placeholder { color: var(--wa-text-3); }

/* Contact list */
#contact-list {
  flex: 1;
  overflow-y: auto;
}
.list-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 200px;
  color: var(--wa-text-3);
  font-size: 13px;
  text-align: center;
}

/* Contact item */
.contact-row {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 12px 16px;
  cursor: pointer;
  border-bottom: 1px solid rgba(59,74,84,.45);
  transition: background .12s;
  position: relative;
}
.contact-row:hover  { background: var(--wa-bg-hover); }
.contact-row.active { background: var(--wa-bg-active); }

.wa-avatar {
  width: 49px; height: 49px;
  border-radius: 50%;
  background: linear-gradient(135deg,#1b6c6c,#00a884);
  display: flex; align-items: center; justify-content: center;
  font-size: 19px; font-weight: 700;
  color: #fff;
  flex-shrink: 0;
  text-transform: uppercase;
  user-select: none;
}
.wa-avatar.purple { background: linear-gradient(135deg,#7c3aed,#a78bfa); }
.wa-avatar.blue   { background: linear-gradient(135deg,#1d4ed8,#60a5fa); }
.wa-avatar.rose   { background: linear-gradient(135deg,#be185d,#f472b6); }

.contact-info { flex: 1; min-width: 0; }
.contact-top  { display: flex; justify-content: space-between; align-items: baseline; }
.contact-name { font-size: 15px; font-weight: 500; color: var(--wa-text-1); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 200px; }
.contact-time { font-size: 11px; color: var(--wa-text-3); flex-shrink: 0; margin-left: 8px; }
.contact-bot  { display: flex; justify-content: space-between; align-items: center; margin-top: 3px; }
.contact-preview { font-size: 13px; color: var(--wa-text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 210px; }
.contact-unread {
  min-width: 20px; height: 20px;
  border-radius: 99px;
  background: var(--wa-teal);
  color: #111;
  font-size: 11px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0 5px;
  flex-shrink: 0;
}
.agent-tag {
  font-size: 9px;
  font-weight: 600;
  color: #a78bfa;
  background: rgba(124,58,237,.18);
  border: 1px solid rgba(167,139,250,.3);
  border-radius: 4px;
  padding: 1px 6px;
  margin-left: 6px;
}

/* ── My avatar small ── */
#my-avatar {
  width: 40px; height: 40px;
  font-size: 14px;
}

/* ════════════════════════════════════════════════════════════
   CHAT PANEL
   ════════════════════════════════════════════════════════════ */
#chat-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--wa-bg-darker);
  overflow: hidden;
  position: relative;
}

/* WA web dot-pattern background */
#chat-panel::before {
  content: '';
  position: absolute; inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23182229' fill-opacity='0.9'%3E%3Ccircle cx='7' cy='7' r='1.5'/%3E%3Ccircle cx='27' cy='7' r='1.5'/%3E%3Ccircle cx='47' cy='7' r='1.5'/%3E%3Ccircle cx='17' cy='17' r='1.5'/%3E%3Ccircle cx='37' cy='17' r='1.5'/%3E%3Ccircle cx='57' cy='17' r='1.5'/%3E%3Ccircle cx='7' cy='27' r='1.5'/%3E%3Ccircle cx='27' cy='27' r='1.5'/%3E%3Ccircle cx='47' cy='27' r='1.5'/%3E%3Ccircle cx='17' cy='37' r='1.5'/%3E%3Ccircle cx='37' cy='37' r='1.5'/%3E%3Ccircle cx='57' cy='37' r='1.5'/%3E%3Ccircle cx='7' cy='47' r='1.5'/%3E%3Ccircle cx='27' cy='47' r='1.5'/%3E%3Ccircle cx='47' cy='47' r='1.5'/%3E%3Ccircle cx='17' cy='57' r='1.5'/%3E%3Ccircle cx='37' cy='57' r='1.5'/%3E%3Ccircle cx='57' cy='57' r='1.5'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 0;
}

/* Splash */
#chat-splash {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  z-index: 1;
}
.splash-inner {
  text-align: center;
  padding: 40px;
  border-top: 6px solid var(--wa-teal);
}
.splash-inner h4 { font-size: 32px; font-weight: 300; color: var(--wa-text-1); margin-bottom: 10px; }
.splash-inner p  { font-size: 14px; color: var(--wa-text-2); }
.splash-inner small { font-size: 12px; color: var(--wa-text-3); }
#splash-info { color: var(--wa-teal); font-size: 13px; font-weight: 500; }

/* Topbar */
#chat-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
  background: var(--wa-bg-mid);
  min-height: 59px;
  border-bottom: 1px solid var(--wa-border);
  position: relative; z-index: 2;
  flex-shrink: 0;
  gap: 12px;
}
.flex-1 { flex: 1; }
.min-w-0 { min-width: 0; }
.chat-name-txt    { font-size: 16px; font-weight: 600; color: var(--wa-text-1); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-status-txt  { font-size: 12px; color: var(--wa-text-3); }

.node-pill {
  font-size: 10px; font-weight: 600;
  border-radius: 99px;
  padding: 3px 10px;
  background: rgba(0,168,132,.15);
  border: 1px solid rgba(0,168,132,.4);
  color: var(--wa-teal);
  white-space: nowrap;
}
.node-pill.agent-pill { background: rgba(124,58,237,.18); border-color: rgba(167,139,250,.4); color: #a78bfa; }

/* ── In-chat search ─────────────────────────────────────────── */
.chat-search-box {
  display: flex;
  align-items: center;
  border-radius: 20px;
  border: 1px solid var(--wa-border);
  background: var(--wa-bg-darker);
  overflow: hidden;
  transition: width .25s ease;
  width: 34px;
  height: 34px;
}
.chat-search-box.open {
  width: 230px;
}

/* The search icon button — perfectly centered circle */
.chat-search-btn,
.chat-search-close {
  width: 34px;
  height: 34px;
  min-width: 34px;
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  cursor: pointer;
  display: grid;
  place-items: center;
  color: var(--icon-color);
  font-size: 15px;
  flex-shrink: 0;
}
.chat-search-btn:focus,
.chat-search-close:focus { outline: none; }
.chat-search-btn:hover,
.chat-search-close:hover { color: var(--wa-text-1); }

/* Expandable input */
.chat-search-input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  font: 13px var(--font);
  color: var(--wa-text-1);
  padding: 0 4px;
  min-width: 0;
  width: 0;
}
.chat-search-input::placeholder { color: var(--wa-text-3); }

/* Search highlight */
.search-highlight {
  background: rgba(255,210,0,.4);
  border-radius: 2px;
  padding: 0 1px;
}

/* Body */
#chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 8px 5% 8px;
  position: relative; z-index: 1;
  display: flex; flex-direction: column;
}
#messages { display: flex; flex-direction: column; padding-bottom: 4px; }

/* Date separator */
.date-sep {
  align-self: center;
  background: var(--wa-bg-mid);
  border: 1px solid var(--wa-border);
  border-radius: 8px;
  padding: 4px 12px;
  font-size: 12px;
  color: var(--wa-text-2);
  margin: 10px 0;
}

/* Bubble */
.wa-bubble-wrap {
  display: flex;
  flex-direction: column;
  max-width: 72%;
  margin: 0 0 10px;
  gap: 4px;
}
.wa-bubble-wrap:last-child { margin-bottom: 0; }
.wa-bubble-wrap.out { align-self: flex-end; align-items: flex-end; }
.wa-bubble-wrap.in  { align-self: flex-start; align-items: flex-start; }

@keyframes fadeUp { from { opacity:0; transform:translateY(4px); } to { opacity:1; transform:none; } }

/* Sender label — only show above INCOMING messages */
.bubble-label {
  font-size: 11px;
  color: var(--wa-text-3);
  margin: 0;
  padding: 0 3px;
}
.wa-bubble-wrap.out .bubble-label { display: none; }

.wa-bubble {
  margin: 0;
  padding: 6px 10px 6px;
  border-radius: 7.5px;
  font-size: 14.2px;
  line-height: 1.5;
  word-break: break-word;
  word-wrap: break-word;
  position: relative;
  box-shadow: 0 1px 0.5px rgba(0,0,0,.3);
  min-width: 50px;
}
.wa-bubble-wrap.in .wa-bubble {
  background: var(--bubble-in);
  color: var(--wa-text-1);
  border-top-left-radius: 0;
}
.wa-bubble-wrap.out .wa-bubble {
  background: var(--bubble-out);
  color: #e9edef;
  border-top-right-radius: 0;
}
/* Bubble tail */
.wa-bubble-wrap.in .wa-bubble::before {
  content: '';
  position: absolute; top: 0; left: -8px;
  border-top: 8px solid var(--bubble-in);
  border-left: 8px solid transparent;
}
.wa-bubble-wrap.out .wa-bubble::before {
  content: '';
  position: absolute; top: 0; right: -8px;
  border-top: 8px solid var(--bubble-out);
  border-right: 8px solid transparent;
}

.bubble-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 3px;
  margin-top: 2px;
}
.bubble-time { font-size: 11px; color: var(--wa-text-3); }
.wa-bubble-wrap.out .bubble-time { color: rgba(233,237,239,.55); }
.tick-icon { color: var(--wa-tick); font-size: 13px; }

/* Footer */
#chat-footer {
  background: var(--wa-bg-mid);
  border-top: 1px solid var(--wa-border);
  padding: 14px 24px;
  text-align: center;
  font-size: 12px;
  color: var(--wa-text-3);
  position: relative; z-index: 2;
  flex-shrink: 0;
}

/* ── Scrollbar ─────────────────────────────────────────────── */
::-webkit-scrollbar           { width: 6px; }
::-webkit-scrollbar-track     { background: transparent; }
::-webkit-scrollbar-thumb     { background: #2d3f4a; border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: #3d5060; }

/* ── Responsive ────────────────────────────────────────────── */
@media (max-width: 768px) {
  #sidebar { width: 100%; max-width: 100%; }
  #chat-panel { display: none; }
}

/* ── Login Screen ──────────────────────────────────────────── */
.login-screen {
  position: absolute;
  inset: 0;
  background: var(--wa-bg-darker);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity .3s ease, visibility .3s ease;
}
.login-screen.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}
.login-box {
  background: var(--wa-bg-dark);
  border: 1px solid var(--wa-border);
  padding: 40px;
  border-radius: 12px;
  width: 400px;
  max-width: 90%;
  text-align: center;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
  animation: fadeUp .3s ease;
}
.login-header h3 {
  color: var(--wa-text-1);
  font-size: 22px;
  margin-bottom: 6px;
  font-weight: 400;
}
.login-header p {
  color: var(--wa-text-3);
  font-size: 13.5px;
  margin-bottom: 30px;
}
#login-password {
  width: 100%;
  background: var(--wa-search-bg);
  border: 1px solid var(--wa-border);
  color: var(--wa-text-1);
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 15px;
  outline: none;
  margin-bottom: 12px;
  text-align: center;
  transition: border-color .2s;
}
#login-password:focus {
  border-color: var(--wa-teal);
}
.login-error {
  color: #ef4444;
  font-size: 13px;
  margin-bottom: 12px;
}
.login-btn {
  width: 100%;
  background: var(--wa-teal);
  color: #111;
  border: none;
  padding: 12px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 15px;
  cursor: pointer;
  transition: background .2s;
}
.login-btn:hover { background: var(--wa-teal-dark); color: #fff; }
.login-btn:active { transform: translateY(1px); }

/* Mirror WA: reaksi pada pesan & pesan dicabut */
.reaction-line { font-size: 12px; color: var(--wa-text-3); margin-top: 6px; line-height: 1.3; }
.wa-bubble-wrap.revoked .wa-bubble { opacity: 0.72; }
