#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: 2147483000;
  font-size: 15px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  box-shadow: 0 2px 8px rgba(0,0,0,.15);
  pointer-events: auto !important;
  text-decoration: none;
}
#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: 2147482999;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  pointer-events: auto !important;
}
#livechat-widget:target {
  display: flex;
}
#livechat-bubble:focus + #livechat-widget,
#livechat-bubble:active + #livechat-widget {
  display: flex;
}
body:has(#livechat-widget:target) #livechat-bubble {
  display: none;
}
#livechat-widget.chat-maximized {
  width: min(720px, calc(100vw - 36px));
  height: calc(100vh - 36px);
  max-height: calc(100vh - 36px);
}

#livechat-widget #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:flex-start;
}
#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; flex:1 1 auto; }
#livechat-widget .agent-info > div{ min-width:0; flex:1 1 auto; }
#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 .agent-status-row{
  display:flex;
  align-items:flex-start;
  gap:4px;
  min-width:0;
  width:100%;
  flex-direction:column;
}
#livechat-widget .phcenter-bot-status-badge{
  display:flex !important;
  align-items:flex-start;
  gap:6px;
  width:100%;
  max-width:100% !important;
  box-sizing:border-box;
  margin:0;
  padding:2px 8px;
  border-radius:12px;
  background:#f1f5f9;
  color:#475569;
  font:600 12px/1.4 system-ui,-apple-system,Segoe UI,Roboto,Arial,sans-serif;
  white-space:normal !important;
  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{
  display:block;
  flex:1 1 auto;
  min-width:0;
  white-space:normal !important;
  overflow:visible !important;
  text-overflow:clip !important;
  overflow-wrap:anywhere;
  word-break:break-word;
}
#livechat-widget .chat-actions{
  display:flex;
  align-items:center;
  gap:4px;
  flex:0 0 auto;
  position:relative;
  z-index:3;
}
#livechat-widget .chat-actions button{
  background:transparent;
  border:0;
  color: var(--livechat-header-text, #0a0a0a);
  font-size:18px;
  margin-left:4px;
  cursor:pointer;
  min-width:36px;
  min-height:36px;
  padding:6px;
  line-height:1;
  touch-action:manipulation;
  -webkit-tap-highlight-color:rgba(0,0,0,0);
  pointer-events:auto;
}

#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;
}

#livechat-widget #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 */
#livechat-widget #chat-body .bubble a { color: var(--livechat-link, #1d4ed8); text-decoration:underline; overflow-wrap:anywhere; word-break:break-word; }
#livechat-widget #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 */
#livechat-widget #chat-body .bubble .livechat-attachment-image {
  max-width: 220px;
  max-height: 220px;
  border-radius: 8px;
  display: block;
  margin-top: 8px;
}

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

/* Input row */
#livechat-widget #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%;
}
#livechat-widget #chat-input input{
  flex:1; border:1px solid #e5e7eb; border-radius:9999px; padding:.6rem .9rem; background:#fff; outline:none;
  min-width:0;
}
#livechat-widget #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;
}
#livechat-widget #chat-input > button:not(#chat-upload):not(#chat-emoji):not(#chat-send){
  display:none !important;
}
#livechat-widget #chat-input button:hover{ background: var(--livechat-send-hover, #2563eb); }
#livechat-widget #chat-input #chat-upload{
  background:#f3f4f6;
  color:#64727d;
  border:1px solid #d1d5db;
}
#livechat-widget #chat-input #chat-upload:hover{
  background:#e5e7eb;
}
#livechat-widget #chat-input #chat-upload .chat-upload-icon,
#livechat-widget #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;
}
#livechat-widget #chat-input #chat-emoji{
  background:#f3f4f6;
  color:#64727d;
  border:1px solid #d1d5db;
}
#livechat-widget #chat-input #chat-emoji:hover,
#livechat-widget #chat-input #chat-emoji[aria-expanded="true"]{
  background:#e5e7eb;
}
#livechat-widget #chat-input #chat-emoji .chat-emoji-icon circle:not([r="1"]){
  fill:none;
}
#livechat-widget #chat-input #chat-emoji .chat-emoji-icon circle[r="1"]{
  fill:currentColor;
  stroke:none;
}
#livechat-widget #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);
}
#livechat-widget #chat-emoji-picker[hidden]{
  display:none !important;
}
#livechat-widget #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;
}
#livechat-widget #chat-emoji-picker button:hover,
#livechat-widget #chat-emoji-picker button:focus{
  background:#e5e7eb;
  outline:none;
}
#livechat-widget #chat-input #chat-upload[disabled],
#livechat-widget #chat-input button[disabled]{
  cursor:wait;
  opacity:.7;
}

@media (max-width: 520px) {
  #livechat-widget,
  #livechat-widget.chat-maximized {
    top: 8px !important;
    left: 8px !important;
    right: 8px !important;
    bottom: 8px !important;
    width: auto !important;
    max-width: calc(100vw - 16px) !important;
    height: auto !important;
    max-height: none !important;
    border-radius: 12px 12px 10px 10px;
  }
  #livechat-widget #chat-header {
    position:relative;
    display:flex !important;
    align-items:flex-start;
    gap:6px;
    min-height:84px;
    padding:10px 98px 10px 10px;
    overflow:visible;
    z-index:15;
  }
  #livechat-widget .agent-info{
    width:100%;
    max-width:100%;
  }
  #livechat-widget .agent-avatar{
    flex:0 0 32px;
  }
  #livechat-widget .chat-actions {
    position:fixed !important;
    top:calc(env(safe-area-inset-top, 0px) + 10px);
    right:12px;
    z-index:2147483001;
    background:var(--livechat-accent, #00d000);
    border-radius:10px;
    padding:2px;
    box-shadow:0 2px 10px rgba(0,0,0,.18);
  }
  #livechat-widget .chat-actions button {
    min-width:44px;
    min-height:44px;
    font-size:22px;
    margin-left:0;
  }
  #livechat-widget #chat-close {
    font-size:24px;
    font-weight:700;
  }
}

@supports not (height: 100dvh) {
  @media (max-width: 520px) {
    #livechat-widget,
    #livechat-widget.chat-maximized {
      top: 8px !important;
      bottom: 8px !important;
      height: auto !important;
      max-height: none !important;
    }
  }
}
