#blc-bubble {
  position: fixed;
  bottom: 24px;
  right: 24px; /* default — overridden by JS */
  width: 56px;
  height: 56px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(0,0,0,0.2);
  z-index: 9999;
  transition: transform 0.2s;
}
#blc-bubble:hover { transform: scale(1.08); }
#blc-bubble svg { width: 50%; height: 50%; color: #fff; }

#blc-window {
  position: fixed;
  bottom: 90px;
  right: 24px; /* default — overridden by JS */
  width: 360px;
  max-width: calc(100vw - 48px);
  height: 520px;
  max-height: calc(100vh - 120px);
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.18);
  display: flex;
  flex-direction: column;
  z-index: 9998;
  overflow: hidden;
  transition: opacity 0.2s, transform 0.2s;
}
#blc-window.blc-closed {
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px);
}

#blc-header {
  padding: 14px 16px;
  color: #fff;
  font-weight: 600;
  font-size: 15px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}
#blc-close {
  background: none;
  border: none;
  color: #fff;
  cursor: pointer;
  font-size: 16px;
  padding: 0;
  line-height: 1;
  opacity: 0.85;
}
#blc-close:hover { opacity: 1; }

#blc-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.blc-msg { display: flex; }
.blc-msg-customer { justify-content: flex-end; }
.blc-msg-agent, .blc-msg-system { justify-content: flex-start; }

.blc-bubble-text {
  max-width: 78%;
  padding: 9px 13px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.45;
  word-break: break-word;
}
.blc-msg-customer .blc-bubble-text {
  background: #0073aa;
  color: #fff;
  border-bottom-right-radius: 4px;
}
.blc-msg-agent .blc-bubble-text {
  background: #f0f0f1;
  color: #1d2327;
  border-bottom-left-radius: 4px;
}
.blc-msg-system .blc-bubble-text {
  background: #e8f4fd;
  color: #0073aa;
  font-style: italic;
  border-radius: 8px;
}

#blc-quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 12px 10px;
}

.blc-qa-btn {
  border: 1px solid #c9d1d9;
  background: #ffffff;
  color: #1d2327;
  border-radius: 16px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
}

.blc-qa-btn:hover {
  background: #f1f5f9;
}

#blc-typing {
  padding: 6px 16px;
  font-size: 12px;
  color: #888;
  font-style: italic;
  flex-shrink: 0;
}

#blc-form-area {
  border-top: 1px solid #e0e0e0;
  padding: 12px;
  flex-shrink: 0;
}

#blc-send-btn {
  padding: 9px 16px;
  border: none;
  border-radius: 6px;
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
  flex-shrink: 0;
}
#blc-send-btn:hover { opacity: 0.88; }

#blc-chat-form {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

#blc-input {
  flex: 1;
  resize: none;
  padding: 8px 10px;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 14px;
  line-height: 1.4;
  font-family: inherit;
}
#blc-input:focus { outline: none; border-color: #0073aa; }

#blc-chat-form #blc-send-btn {
  width: auto;
  padding: 9px 16px;
  flex-shrink: 0;
}

.blc-hidden { display: none !important; }

@media (max-width: 600px) {
  #blc-window {
    /* Mobile layout: keep top gap, but avoid a huge empty middle area */
    left: 12px !important;
    right: 12px !important;
    width: auto !important;
    top: calc(env(safe-area-inset-top, 0px) + 12px) !important;
    bottom: auto !important;
    height: min(62vh, 520px) !important;
    max-height: calc(100vh - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px) - 88px) !important;
    border-radius: 12px;
  }

  #blc-messages {
    min-height: 0;
  }

  #blc-bubble { bottom: 16px; }
}

/* ── Order Lookup Form ───────────────────────────────────────────────────── */
#blc-order-form,
#blc-checkout-form {
  background: #f8f9fa;
  border: 1px solid #ddd;
  border-radius: 10px;
  padding: 14px 14px 12px;
  margin-bottom: 10px;
  position: relative;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}
.blc-order-form-close {
  position: absolute;
  top: 8px;
  right: 10px;
  background: none;
  border: none;
  font-size: 16px;
  color: #888;
  cursor: pointer;
  padding: 0;
  line-height: 1;
}
.blc-order-form-close:hover { color: #333; }
.blc-order-form-title {
  font-size: 13px;
  font-weight: 600;
  margin: 0 0 10px;
  color: #333;
}
#blc-order-form input,
#blc-checkout-form input,
#blc-checkout-form select,
#blc-checkout-form textarea {
  display: block;
  width: 100%;
  padding: 7px 10px;
  margin-bottom: 8px;
  border: 1px solid #ccc;
  border-radius: 6px;
  font-size: 13px;
  box-sizing: border-box;
}
#blc-order-form input:focus,
#blc-checkout-form input:focus,
#blc-checkout-form select:focus,
#blc-checkout-form textarea:focus { outline: none; border-color: #0073aa; }
#blc-order-submit,
#blc-checkout-submit {
  width: 100%;
  padding: 8px;
  background: #0073aa;
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
#blc-order-submit:hover,
#blc-checkout-submit:hover { opacity: 0.88; }
