/* ── Kemenag Live Chat Widget ──────────────────────────── */

/* Floating button */
#kmlc-bubble {
  position: fixed; bottom: 24px; right: 24px; z-index: 99990;
  width: 56px; height: 56px; border-radius: 50%;
  background: linear-gradient(135deg, #158684, #0d5c5a);
  box-shadow: 0 4px 18px rgba(21,134,132,.45);
  border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: transform .2s, box-shadow .2s;
}
#kmlc-bubble:hover { transform: scale(1.1); box-shadow: 0 6px 24px rgba(21,134,132,.55); }
#kmlc-bubble svg   { width: 26px; height: 26px; fill: #fff; pointer-events: none; }

#kmlc-badge {
  position: absolute; top: -3px; right: -3px;
  background: #ef4444; color: #fff;
  font-size: 10px; font-weight: 700; line-height: 1;
  min-width: 18px; height: 18px; border-radius: 9999px;
  display: none; align-items: center; justify-content: center;
  padding: 0 4px; border: 2px solid #fff;
  font-family: 'Poppins', sans-serif;
}

/* Chat box */
#kmlc-box {
  position: fixed; bottom: 92px; right: 24px; z-index: 99989;
  width: 340px; height: 500px;
  background: #fff; border-radius: 16px;
  box-shadow: 0 8px 40px rgba(0,0,0,.18);
  display: flex; flex-direction: column; overflow: hidden;
  transform: scale(.85) translateY(30px); opacity: 0; pointer-events: none;
  transition: transform .25s cubic-bezier(.34,1.56,.64,1), opacity .2s;
}
#kmlc-box.open { transform: scale(1) translateY(0); opacity: 1; pointer-events: all; }

/* Header */
#kmlc-head {
  background: linear-gradient(135deg, #158684, #0d5c5a);
  padding: 14px 14px 12px; color: #fff; flex-shrink: 0;
  display: flex; align-items: center; gap: 10px;
}
#kmlc-head-avatar {
  width: 38px; height: 38px; border-radius: 50%;
  background: rgba(255,255,255,.2);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
#kmlc-head-avatar svg { width: 20px; height: 20px; fill: #fff; }
#kmlc-head-info        { flex: 1; min-width: 0; }
#kmlc-head-info strong { display: block; font-size: .86rem; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#kmlc-head-info span   { font-size: .7rem; opacity: .8; }
#kmlc-close {
  background: none; border: none; color: #fff; cursor: pointer;
  opacity: .75; font-size: 22px; line-height: 1; padding: 0 2px;
  transition: opacity .15s; flex-shrink: 0;
}
#kmlc-close:hover { opacity: 1; }

/* Screen: greeting */
#kmlc-screen-greet {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 24px 22px; gap: 10px;
}
#kmlc-greet-icon {
  width: 62px; height: 62px; border-radius: 50%;
  background: linear-gradient(135deg,#e6f4f4,#b6e2e1);
  display: flex; align-items: center; justify-content: center; margin-bottom: 4px;
}
#kmlc-greet-icon svg    { width: 30px; height: 30px; fill: #158684; }
#kmlc-greet-title       { font-size: 1rem; font-weight: 700; color: #111827; text-align: center; }
#kmlc-greet-sub         { font-size: .76rem; color: #6b7280; text-align: center; line-height: 1.5; margin-top: -4px; }
#kmlc-form-name,
#kmlc-form-email {
  width: 100%; padding: 9px 12px;
  border: 1.5px solid #e5e7eb; border-radius: 8px;
  font-size: .82rem; outline: none; font-family: 'Poppins', sans-serif;
  transition: border-color .15s; color: #111827;
}
#kmlc-form-name:focus,
#kmlc-form-email:focus { border-color: #158684; }
#kmlc-btn-start {
  width: 100%; padding: 10px; border: none;
  background: linear-gradient(135deg, #158684, #0f6e6c);
  color: #fff; border-radius: 8px; font-size: .85rem; font-weight: 700;
  cursor: pointer; transition: opacity .15s; margin-top: 2px;
  font-family: 'Poppins', sans-serif;
}
#kmlc-btn-start:hover   { opacity: .88; }
#kmlc-btn-start:disabled{ opacity: .6; cursor: wait; }
#kmlc-skip-link {
  font-size: .72rem; color: #9ca3af; cursor: pointer;
  text-decoration: underline; margin-top: 0;
}
#kmlc-skip-link:hover   { color: #158684; }

/* Screen: chat */
#kmlc-screen-chat { display: none; flex: 1; flex-direction: column; overflow: hidden; }

/* Messages */
#kmlc-messages {
  flex: 1; overflow-y: auto; padding: 14px 12px;
  display: flex; flex-direction: column; gap: 10px;
}
#kmlc-messages::-webkit-scrollbar       { width: 4px; }
#kmlc-messages::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 2px; }

.kmlc-msg               { display: flex; flex-direction: column; max-width: 82%; }
.kmlc-msg.visitor       { align-self: flex-end;   align-items: flex-end; }
.kmlc-msg.operator      { align-self: flex-start; align-items: flex-start; }
.kmlc-msg-bubble {
  padding: 8px 12px; border-radius: 12px;
  font-size: .8rem; line-height: 1.5; word-break: break-word;
}
.kmlc-msg.visitor  .kmlc-msg-bubble {
  background: linear-gradient(135deg,#158684,#0f6e6c); color: #fff;
  border-bottom-right-radius: 3px;
}
.kmlc-msg.operator .kmlc-msg-bubble {
  background: #f3f4f6; color: #111827;
  border-bottom-left-radius: 3px;
}
.kmlc-msg-time { font-size: .63rem; color: #9ca3af; margin-top: 2px; padding: 0 4px; }
.kmlc-msg-name { font-size: .63rem; color: #9ca3af; margin-bottom: 2px; padding: 0 4px; font-weight: 600; }
.kmlc-msg-system {
  align-self: center; font-size: .7rem; color: #9ca3af;
  background: #f9fafb; border: 1px solid #e5e7eb;
  border-radius: 9999px; padding: 4px 12px; text-align: center;
}

/* Closed banner */
#kmlc-closed-banner {
  display: none; padding: 8px 14px;
  background: #fef3c7; border-top: 1px solid #fde68a;
  font-size: .73rem; color: #92400e; text-align: center; flex-shrink: 0;
}

/* Input area */
#kmlc-input-wrap {
  border-top: 1px solid #f0f0f0; padding: 8px 10px;
  display: flex; align-items: flex-end; gap: 8px; flex-shrink: 0; background: #fff;
}
#kmlc-input {
  flex: 1; border: 1.5px solid #e5e7eb; border-radius: 10px;
  padding: 8px 11px; font-size: .82rem; resize: none; outline: none;
  font-family: 'Poppins', sans-serif; min-height: 38px; max-height: 90px;
  transition: border-color .15s; line-height: 1.4; color: #111827;
}
#kmlc-input:focus      { border-color: #158684; }
#kmlc-input:disabled   { background: #f9fafb; color: #9ca3af; }
#kmlc-send {
  width: 36px; height: 36px; border-radius: 50%; border: none;
  background: #158684; color: #fff; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s; flex-shrink: 0;
}
#kmlc-send:hover   { background: #0f6e6c; }
#kmlc-send:disabled{ background: #9ca3af; cursor: not-allowed; }
#kmlc-send svg     { width: 16px; height: 16px; fill: #fff; }

/* Mobile */
@media (max-width: 420px) {
  #kmlc-box    { width: calc(100vw - 16px); right: 8px; bottom: 84px; height: calc(100svh - 110px); border-radius: 12px; }
  #kmlc-bubble { right: 14px; bottom: 18px; }
}
