/* ============================================================
   LIVECHAT WIDGET - Floating Chat untuk Pengunjung Website
   ============================================================ */

.lc-widget { 
  position: fixed; 
  bottom: 68px; 
  right: 24px; 
  z-index: 99999; 
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1), transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), visibility 0.3s;
}

/* Kunci dan sembunyikan livechat saat popup welcome/banner aktif */
.lc-widget.lc-widget-locked,
body.modal-open .lc-widget {
  opacity: 0 !important;
  visibility: hidden !important;
  pointer-events: none !important;
  transform: scale(0.6) translateY(20px) !important;
}

.lc-toggle {
  width: 60px; height: 60px; border-radius: 50%;
  background: linear-gradient(135deg, #0EA5E9, #8B5CF6);
  color: #fff; border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 20px rgba(14, 165, 233, 0.4);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative; font-size: 24px;
}
.lc-toggle:hover { transform: scale(1.08); box-shadow: 0 6px 28px rgba(14, 165, 233, 0.5); }
.lc-toggle:active { transform: scale(0.95); }
.lc-toggle-icon, .lc-toggle-close { transition: all 0.3s ease; }
.lc-toggle-close { font-size: 22px; }

.lc-toggle-badge {
  position: absolute; top: -4px; right: -4px;
  background: #EF4444; color: #fff; border-radius: 50%;
  width: 22px; height: 22px; font-size: 11px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid #fff;
  animation: badgePulse 2s infinite;
}
@keyframes badgePulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.15); } }

/* Chat Window */
.lc-window {
  position: absolute; bottom: 72px; right: 0;
  width: 390px; height: 560px; max-height: calc(100vh - 90px); max-height: calc(100dvh - 90px);
  background: #1a1a2e; color: #e8e8e8;
  border-radius: 16px; overflow: hidden;
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.45);
  display: flex; flex-direction: column;
  transform: translateY(20px) scale(0.95);
  opacity: 0; pointer-events: none;
  visibility: hidden;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 100000;
}
.lc-window.open {
  transform: translateY(0) scale(1);
  opacity: 1; pointer-events: auto;
  visibility: visible;
}
.lc-window.fullscreen {
  position: fixed !important; top: 0 !important; left: 0 !important; right: 0 !important; bottom: 0 !important;
  width: 100vw !important; width: 100% !important; height: 100vh !important; height: 100dvh !important; max-height: 100dvh !important;
  border-radius: 0 !important; margin: 0 !important; z-index: 999999 !important;
  box-shadow: none !important; transform: none !important;
}

/* Header */
.lc-header {
  padding: 12px 16px;
  background: linear-gradient(135deg, #0f0f2e 0%, #1a1a3e 100%);
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  flex-shrink: 0;
}
.lc-header-info { display: flex; align-items: center; gap: 10px; min-width: 0; }
.lc-header-back-btn {
  background: transparent; border: none;
  color: rgba(255,255,255,0.85); width: 34px; height: 34px; border-radius: 50%;
  display: none; align-items: center; justify-content: center;
  font-size: 16px; cursor: pointer; margin-right: 2px;
  transition: all 0.2s; flex-shrink: 0;
}
.lc-header-back-btn:hover { background: rgba(255,255,255,0.12); color: #fff; }
.lc-header-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.lc-header-expand-btn {
  background: rgba(255,255,255,0.08); border: none;
  width: 32px; height: 32px; border-radius: 50%;
  color: rgba(255,255,255,0.7); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.2s; font-size: 13px;
}
.lc-header-expand-btn:hover { background: rgba(255,255,255,0.15); color: #fff; }
.lc-header-avatar {
  width: 40px; height: 40px; border-radius: 50%;
  background: linear-gradient(135deg, #0EA5E9, #8B5CF6);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; color: #fff; flex-shrink: 0;
}
.lc-header-title { font-weight: 700; font-size: 14px; color: #fff; }
.lc-header-subtitle { font-size: 12px; color: rgba(255,255,255,0.6); display: flex; align-items: center; gap: 5px; }
.lc-online-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: #22C55E; display: inline-block;
  animation: onlinePulse 2s infinite;
}
@keyframes onlinePulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }
.lc-header-close {
  background: rgba(255,255,255,0.08); border: none;
  width: 32px; height: 32px; border-radius: 50%;
  color: rgba(255,255,255,0.7); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.2s; font-size: 14px;
}
.lc-header-close:hover { background: rgba(255,255,255,0.15); color: #fff; }

/* Messages Body */
.lc-body {
  flex: 1; overflow-y: auto; padding: 16px;
  display: flex; flex-direction: column; gap: 10px;
  background: #13132b;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.1) transparent;
}
.lc-body::-webkit-scrollbar { width: 5px; }
.lc-body::-webkit-scrollbar-track { background: transparent; }
.lc-body::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 10px; }

/* Welcome Message */
.lc-welcome {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  height: 100%; color: rgba(255,255,255,0.4); text-align: center; gap: 12px;
}
.lc-welcome-icon { font-size: 48px; opacity: 0.3; }
.lc-welcome p { font-size: 14px; margin: 0; }

/* Chat Bubbles */
.lc-msg { max-width: 82%; animation: msgSlideIn 0.25s ease; display: flex; flex-direction: column; }
@keyframes msgSlideIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

.lc-msg.visitor { align-self: flex-end; align-items: flex-end; }
.lc-msg.bot, .lc-msg.admin { align-self: flex-start; align-items: flex-start; }

.lc-bubble {
  padding: 8px 12px 6px 12px; border-radius: 16px;
  font-size: 13.5px; line-height: 1.5; word-wrap: break-word; word-break: break-word;
  position: relative; min-width: 70px;
}
.lc-msg.visitor .lc-bubble {
  background: linear-gradient(135deg, #0EA5E9, #0284C7);
  color: #fff; border-bottom-right-radius: 4px;
}
.lc-msg.bot .lc-bubble,
.lc-msg.admin .lc-bubble {
  background: rgba(139, 92, 246, 0.16);
  color: #e0d4f7; border-bottom-left-radius: 4px;
  border: 1px solid rgba(139, 92, 246, 0.2);
}

.lc-msg-sender {
  font-size: 11px; font-weight: 600; margin-bottom: 3px;
  color: rgba(255,255,255,0.5);
}
.lc-msg.visitor .lc-msg-sender { text-align: right; }

/* WhatsApp Style Meta & Status Checkmarks */
.lc-msg-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  font-size: 10.5px;
  line-height: 1;
  margin-top: 4px;
  margin-left: 8px;
  float: right;
  user-select: none;
}
.lc-msg-time {
  font-size: 10px;
  opacity: 0.8;
  white-space: nowrap;
}
.lc-msg.visitor .lc-msg-meta { color: rgba(255,255,255,0.85); }
.lc-msg.bot .lc-msg-meta,
.lc-msg.admin .lc-msg-meta { color: rgba(255,255,255,0.5); }

.lc-tick {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  line-height: 1;
}
.lc-tick-pending {
  color: rgba(255,255,255,0.45);
}
.lc-tick-sent {
  color: rgba(255,255,255,0.65);
}
.lc-tick-delivered {
  color: rgba(255,255,255,0.7);
}
.lc-tick-read {
  color: #38bdf8 !important; /* WhatsApp Bright Cyan */
  text-shadow: 0 0 6px rgba(56, 189, 248, 0.45);
}

.lc-msg img.lc-chat-img {
  max-width: 220px; max-height: 200px;
  border-radius: 10px; cursor: pointer;
  object-fit: cover; display: block;
  transition: transform 0.2s;
}
.lc-msg img.lc-chat-img:hover { transform: scale(1.03); }

/* Footer / Input */
.lc-footer {
  padding: 12px; border-top: 1px solid rgba(255,255,255,0.06);
  background: #1a1a2e;
  pointer-events: auto;
  position: relative;
  z-index: 10;
}
.lc-input-wrapper {
  display: flex; align-items: center; gap: 6px;
  background: rgba(255,255,255,0.05);
  border-radius: 24px; padding: 4px 6px;
  border: 1px solid rgba(255,255,255,0.08);
  transition: border-color 0.2s;
  pointer-events: auto;
  cursor: text;
}
.lc-input-wrapper:focus-within { border-color: rgba(14, 165, 233, 0.4); }

.lc-input {
  flex: 1; background: transparent; border: none;
  color: #e8e8e8; font-size: 13px; padding: 8px 6px;
  outline: none; min-width: 0;
  pointer-events: auto;
  cursor: text;
}
.lc-input::placeholder { color: rgba(255,255,255,0.3); }

.lc-input-btn {
  width: 34px; height: 34px; border-radius: 50%;
  border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.2s; font-size: 14px; flex-shrink: 0;
}
.lc-btn-attach {
  background: transparent; color: rgba(255,255,255,0.4);
}
.lc-btn-attach:hover { color: #0EA5E9; background: rgba(14, 165, 233, 0.1); }
.lc-btn-send {
  background: linear-gradient(135deg, #0EA5E9, #0284C7);
  color: #fff;
}
.lc-btn-send:hover { background: linear-gradient(135deg, #38BDF8, #0EA5E9); transform: scale(1.05); }

/* Upload Preview */
.lc-upload-preview {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px; margin-top: 8px;
  background: rgba(255,255,255,0.05);
  border-radius: 10px; border: 1px solid rgba(255,255,255,0.08);
}
.lc-upload-preview img {
  width: 40px; height: 40px; border-radius: 6px; object-fit: cover;
}
.lc-upload-preview span { flex: 1; font-size: 12px; color: rgba(255,255,255,0.6); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lc-upload-remove {
  background: rgba(239, 68, 68, 0.15); border: none;
  width: 28px; height: 28px; border-radius: 50%;
  color: #EF4444; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; transition: all 0.2s;
}
.lc-upload-remove:hover { background: rgba(239, 68, 68, 0.3); }

/* Session Closed Banner */
.lc-closed-banner {
  padding: 10px 14px; text-align: center;
  background: rgba(239, 68, 68, 0.1);
  color: rgba(255,255,255,0.5); font-size: 12px;
  border-top: 1px solid rgba(239, 68, 68, 0.1);
}

/* Typing Indicator */
.lc-typing { display: flex; gap: 4px; padding: 10px 14px; align-self: flex-start; }
.lc-typing-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: rgba(255,255,255,0.3);
  animation: typingBounce 1.4s infinite both;
}
.lc-typing-dot:nth-child(2) { animation-delay: 0.2s; }
.lc-typing-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes typingBounce { 0%, 80%, 100% { transform: translateY(0); } 40% { transform: translateY(-6px); } }

/* Image Modal Overlay */
.lc-img-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.85); z-index: 999999;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; animation: fadeIn 0.2s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.lc-img-overlay img { max-width: 90%; max-height: 90%; border-radius: 8px; }

/* Responsive & Full Page on Mobile (Android & iPhone) */
@media (max-width: 768px) {
  .lc-widget {
    bottom: 64px;
    right: 16px;
  }
  .lc-toggle {
    width: 54px;
    height: 54px;
    font-size: 22px;
  }
  /* Sembunyikan toggle button saat popup livechat terbuka penuh */
  .lc-widget.lc-chat-open .lc-toggle {
    display: none !important;
  }
  /* POPUP FULL PAGE SAAT DIKLIK DI HP (TIDAK TERPOTONG) */
  .lc-window.open {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100vw !important;
    width: 100% !important;
    height: 100vh !important;
    height: 100dvh !important;
    max-height: 100dvh !important;
    border-radius: 0 !important;
    margin: 0 !important;
    z-index: 999999 !important;
    box-shadow: none !important;
    transform: none !important;
  }
  .lc-header {
    padding-top: max(12px, env(safe-area-inset-top));
    padding-left: max(14px, env(safe-area-inset-left));
    padding-right: max(14px, env(safe-area-inset-right));
  }
  .lc-header-back-btn {
    display: flex !important;
  }
  .lc-body {
    padding: 14px;
    -webkit-overflow-scrolling: touch;
  }
  .lc-footer {
    padding-bottom: max(12px, env(safe-area-inset-bottom));
    padding-left: max(12px, env(safe-area-inset-left));
    padding-right: max(12px, env(safe-area-inset-right));
  }
  .lc-input {
    font-size: 16px !important; /* Mencegah auto-zoom Safari di iPhone */
  }
  .lc-prechat {
    padding: 16px max(16px, env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  }
}

/* Kunci scroll halaman latar belakang saat livechat full page dibuka */
body.lc-modal-open {
  overflow: hidden !important;
}

/* Penyesuaian tombol Scroll-to-Top agar berada di atas livechat dan tidak menutupi navbar bottom */
.scroll-to-top {
  bottom: 140px !important;
}
@media (max-width: 480px) {
  .scroll-to-top {
    bottom: 126px !important;
  }
}

/* Avatar CS di Header */
.lc-header-avatar {
  position: relative;
  overflow: hidden;
}
.lc-header-avatar .lc-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

/* Pre-Chat Form Container */
.lc-prechat {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: #13132b;
  overflow-y: auto;
  padding: 16px;
  scrollbar-width: thin;
}
.lc-prechat-body {
  margin: auto 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.lc-prechat-cs-box {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.09);
  padding: 12px 14px;
  border-radius: 14px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
}
.lc-prechat-cs-avatar {
  position: relative;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, #0EA5E9 0%, #2563EB 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  font-size: 19px;
  flex-shrink: 0;
  box-shadow: 0 3px 10px rgba(14, 165, 233, 0.35);
  border: 2px solid rgba(255, 255, 255, 0.12);
}
.lc-prechat-cs-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}
.lc-prechat-cs-avatar .lc-prechat-status-badge {
  position: absolute;
  bottom: 0px;
  right: 0px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #22C55E;
  border: 2px solid #13132b;
  box-shadow: 0 0 6px rgba(34, 197, 94, 0.8);
}
.lc-prechat-cs-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.lc-prechat-cs-name {
  font-weight: 700;
  font-size: 14px;
  color: #fff;
  line-height: 1.3;
}
.lc-prechat-cs-desc {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.65);
  line-height: 1.3;
  display: flex;
  align-items: center;
  gap: 6px;
}
.lc-prechat-greeting {
  text-align: center;
  padding: 4px 6px;
}
.lc-prechat-title {
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  margin-bottom: 6px;
  line-height: 1.3;
}
.lc-prechat-desc {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.7);
  line-height: 1.5;
  margin: 0;
}
.lc-form-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 8px;
}
.lc-form-label {
  font-size: 12px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.85);
  display: flex;
  align-items: center;
}
.lc-form-input {
  width: 100%;
  padding: 9px 12px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  color: #fff;
  font-size: 13px;
  outline: none;
  transition: all 0.2s ease;
  box-sizing: border-box;
  pointer-events: auto !important;
  touch-action: manipulation !important;
  user-select: text !important;
  -webkit-user-select: text !important;
}
.lc-form-input:focus {
  border-color: #0EA5E9;
  background: rgba(255, 255, 255, 0.1);
  box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.25);
}
.lc-form-hint {
  font-size: 10.5px;
  color: rgba(255, 255, 255, 0.45);
}
.lc-alert-error {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.4);
  color: #FCA5A5;
  padding: 7px 10px;
  border-radius: 6px;
  font-size: 11.5px;
  margin-bottom: 10px;
}
.lc-btn-start {
  width: 100%;
  padding: 10px;
  border-radius: 8px;
  border: none;
  background: linear-gradient(135deg, #0EA5E9, #8B5CF6);
  color: #fff;
  font-size: 13.5px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 4px 14px rgba(14, 165, 233, 0.35);
  margin-top: 4px;
}
.lc-btn-start:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(14, 165, 233, 0.45);
  filter: brightness(1.08);
}
.lc-btn-start:active {
  transform: translateY(0);
}

