#livechat-bubble {
  position: fixed;
  bottom: 18px;
  right: 18px;
  background: var(--livechat-accent, #00d000);
  color: var(--livechat-header-text, #0a0a0a);
  padding: 10px 14px;
  border-radius: 9999px;
  cursor: pointer;
  z-index: 99999;
  font-size: 15px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  box-shadow: 0 2px 8px rgba(0,0,0,.15);
}
#livechat-bubble .bubble-status{ width:10px; height:10px; background:#fff; border-radius:50%; }
#livechat-bubble .bubble-icon{ font-size:18px; }

#livechat-widget {
  position: fixed;
  bottom: 18px; right: 18px;
  width: 340px;
  height: min(560px, calc(100vh - 36px));
  max-height: calc(100vh - 36px);
  background: #fff; border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0,0,0,.2);
  display: none; flex-direction: column; overflow: hidden;
  z-index: 99998;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
}
#livechat-widget.chat-maximized {
  width: min(720px, calc(100vw - 36px));
  height: calc(100vh - 36px);
  max-height: calc(100vh - 36px);
}

#chat-header {
  background: var(--livechat-accent, #00d000); color: var(--livechat-header-text, #0a0a0a);
  flex:0 0 auto;
  align-self:stretch;
  width:100%;
  max-width:none;
  min-width:0;
  margin:0;
  box-sizing:border-box;
  padding: 10px; display:flex; justify-content:space-between; align-items:center;
}
#livechat-widget.chat-maximized > #chat-header {
  width:100%;
  max-width:none;
}
#livechat-widget .agent-info{ display:flex; align-items:center; gap:10px; min-width:0; }
#livechat-widget .agent-avatar{ width:32px; height:32px; border-radius:50%; }
#livechat-widget .agent-name{ font-weight:700; color: var(--livechat-header-text, #0a0a0a); }
#livechat-widget .agent-status{ font-size:12px; color: var(--livechat-header-text, #0a0a0a); opacity:.85; }
#livechat-widget .phcenter-bot-status-badge{
  display:inline-flex;
  align-items:center;
  gap:6px;
  max-width:170px;
  margin-left:2px;
  padding:2px 8px;
  border-radius:999px;
  background:#f1f5f9;
  color:#475569;
  font:600 12px/1.4 system-ui,-apple-system,Segoe UI,Roboto,Arial,sans-serif;
  white-space:nowrap;
  vertical-align:middle;
}
#livechat-widget .phcenter-bot-status-badge[data-status="online"]{
  background:#dcfce7;
  color:#166534;
}
#livechat-widget .phcenter-bot-status-badge[data-status="offline"]{
  background:#f1f5f9;
  color:#475569;
}
#livechat-widget .phcenter-bot-status-dot{
  display:inline-block;
  width:8px;
  height:8px;
  border-radius:50%;
  background:#94a3b8;
  flex:0 0 auto;
}
#livechat-widget .phcenter-bot-status-text{
  min-width:0;
  overflow:hidden;
  text-overflow:ellipsis;
}
#livechat-widget .chat-actions button{ background:transparent; border:0; color: var(--livechat-header-text, #0a0a0a); font-size:18px; margin-left:8px; cursor:pointer; }

#livechat-widget .livechat-customer-name {
  padding: .55rem .8rem;
  border-bottom: 1px solid #a7f3d0;
  background: #d1fae5;
  color: #065f46;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.35;
  overflow-wrap: anywhere;
  word-break: break-word;
  flex: 0 0 auto;
}
#livechat-widget .livechat-customer-name[hidden] {
  display: none !important;
}
#livechat-widget .livechat-contact-email {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding: 7px 10px;
  border-bottom: 1px solid #e5e7eb;
  background: #fff;
  color: #111827;
  font-size: 13px;
  line-height: 1.3;
}
#livechat-widget .livechat-contact-email-label {
  flex: 0 0 auto;
  font-weight: 700;
}
#livechat-widget .livechat-contact-email a {
  flex: 1 1 auto;
  min-width: 0;
  color: var(--livechat-link, #1d4ed8);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-decoration: underline;
}
#livechat-widget .livechat-contact-email button {
  flex: 0 0 auto;
  border: 1px solid #d1d5db;
  border-radius: 9999px;
  padding: 4px 10px;
  background: #f8fafc;
  color: #111827;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}
#livechat-widget .livechat-contact-email button:hover,
#livechat-widget .livechat-contact-email button:focus {
  background: #e5e7eb;
  outline: none;
}

#chat-body {
  flex:1 1 auto;
  min-height:0;
  width:100%;
  box-sizing:border-box;
  padding:10px;
  overflow-y:auto;
  display:flex;
  flex-direction:column;
  gap:8px;
  background:#f6f6f6;
}

/* Bubbles: higher contrast */
#livechat-widget .message{ display:flex; flex-direction:column; min-width:0; }
#livechat-widget .message .bubble{
  box-sizing:border-box;
  min-width:0;
  max-width:80%;
  overflow-wrap:anywhere;
  word-break:break-word;
  white-space:normal;
}
#livechat-widget .message.agent .bubble{
  background: var(--livechat-agent-bg, #0f172a);
  color: var(--livechat-agent-text, #f8fafc);
  border-radius:16px; padding:10px;
  box-shadow: 0 1px 3px rgba(0,0,0,.18);
}
#livechat-widget .message.user .bubble{
  background: var(--livechat-user-bg, #e5e7eb); color: var(--livechat-user-text, #111827);
  align-self:flex-end; border-radius:16px; padding:10px;
}

/* Links */
#chat-body .bubble a { color: var(--livechat-link, #1d4ed8); text-decoration:underline; overflow-wrap:anywhere; word-break:break-word; }
#chat-body .bubble a:hover { text-decoration:none; }
#livechat-widget .message.agent .bubble a { color: var(--livechat-link-agent, #93c5fd); } /* light blue on dark bubble */
#chat-body .bubble .livechat-attachment-image {
  max-width: 220px;
  max-height: 220px;
  border-radius: 8px;
  display: block;
  margin-top: 8px;
}

#livechat-guest-email-panel {
  padding: .6rem .7rem;
  border-top: 1px solid #e5e7eb;
  background: #fff;
}
#livechat-widget .livechat-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;
}
#livechat-guest-email-panel label {
  display: block;
  margin: 0 0 .35rem;
  color: #111827;
  font-size: 13px;
  font-weight: 700;
}
#livechat-widget .livechat-guest-email-row {
  display: flex;
  gap: .5rem;
}
#livechat-guest-email {
  flex: 1;
  min-width: 0;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  padding: .55rem .65rem;
}
#livechat-guest-email-save {
  border: 0;
  border-radius: 8px;
  padding: .55rem .75rem;
  background: var(--livechat-send-bg, #3b82f6);
  color: #fff;
  cursor: pointer;
}
#livechat-guest-email-error {
  min-height: 18px;
  margin-top: .25rem;
  color: #b91c1c;
  font-size: 12px;
}

/* Input row */
#chat-input{
  position:relative;
  flex:0 0 auto;
  display:flex;
  gap:.5rem;
  padding:.5rem;
  border-top:1px solid #e5e7eb;
  background:#fff;
  box-sizing:border-box;
  width:100%;
}
#chat-input input{
  flex:1; border:1px solid #e5e7eb; border-radius:9999px; padding:.6rem .9rem; background:#fff; outline:none;
  min-width:0;
}
#chat-input button{
  width:42px; height:42px; border-radius:9999px; border:none;
  background: var(--livechat-send-bg, #3b82f6); color:#fff; font-size:18px; line-height:1;
  flex:0 0 42px;
  display:flex; align-items:center; justify-content:center; cursor:pointer;
}
#chat-input button:hover{ background: var(--livechat-send-hover, #2563eb); }
#chat-input #chat-upload{
  background:#f3f4f6;
  color:#64727d;
  border:1px solid #d1d5db;
}
#chat-input #chat-upload:hover{
  background:#e5e7eb;
}
#chat-input #chat-upload .chat-upload-icon,
#chat-input #chat-emoji .chat-emoji-icon{
  width:24px;
  height:24px;
  display:block;
  fill:none;
  stroke:currentColor;
  stroke-width:2.2;
  stroke-linecap:round;
  stroke-linejoin:round;
}
#chat-input #chat-emoji{
  background:#f3f4f6;
  color:#64727d;
  border:1px solid #d1d5db;
}
#chat-input #chat-emoji:hover,
#chat-input #chat-emoji[aria-expanded="true"]{
  background:#e5e7eb;
}
#chat-input #chat-emoji .chat-emoji-icon circle:not([r="1"]){
  fill:none;
}
#chat-input #chat-emoji .chat-emoji-icon circle[r="1"]{
  fill:currentColor;
  stroke:none;
}
#chat-emoji-picker{
  position:absolute;
  left:.5rem;
  bottom:calc(100% + 8px);
  z-index:2;
  width:244px;
  max-width:calc(100% - 1rem);
  padding:8px;
  display:grid;
  grid-template-columns:repeat(6, 34px);
  gap:6px;
  justify-content:start;
  background:#fff;
  border:1px solid #d1d5db;
  border-radius:10px;
  box-shadow:0 8px 24px rgba(15,23,42,.18);
}
#chat-emoji-picker[hidden]{
  display:none !important;
}
#chat-emoji-picker button{
  width:34px;
  height:34px;
  flex:0 0 34px;
  border:0;
  border-radius:8px;
  background:#f8fafc;
  color:#111827;
  font-size:20px;
  line-height:1;
}
#chat-emoji-picker button:hover,
#chat-emoji-picker button:focus{
  background:#e5e7eb;
  outline:none;
}
#chat-input #chat-upload[disabled],
#chat-input button[disabled]{
  cursor:wait;
  opacity:.7;
}

@media (max-width: 520px) {
  #livechat-widget,
  #livechat-widget.chat-maximized {
    right: 8px;
    bottom: 8px;
    width: calc(100vw - 16px);
    height: calc(100vh - 16px);
    max-height: calc(100vh - 16px);
  }
}
