.store-chat-root {
  position: fixed;
  z-index: 1050;
  right: 16px;
  bottom: 72px;
  font-family: inherit;
  color: #0f172a;
}

/* Storefront templates often set light text on body; keep chat panel readable */
.store-chat-root .store-chat-panel,
.store-chat-root .store-chat-messages,
.store-chat-root .store-chat-panel-foot {
  color: #0f172a;
}

.store-chat-fab {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 0;
  background: linear-gradient(145deg, #1a6b9a, #0b3d5c);
  color: #fff;
  font-size: 22px;
  box-shadow: 0 8px 24px rgba(11, 61, 92, 0.35);
  cursor: pointer;
}

.store-chat-panel {
  position: absolute;
  right: 0;
  bottom: 64px;
  width: min(380px, calc(100vw - 24px));
  height: min(520px, calc(100vh - 140px));
  max-height: min(520px, 72vh);
  display: flex;
  flex-direction: column;
  background: #fff;
  border-radius: 18px;
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.22);
  overflow: hidden;
  border: 1px solid rgba(15, 23, 42, 0.06);
}

.store-chat-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 12px 12px 14px;
  background: linear-gradient(135deg, #0f4a6e 0%, #0b3d5c 100%);
  color: #fff;
  flex-shrink: 0;
}

.store-chat-head-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.store-chat-head-icon {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.14);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.store-chat-head-titles strong {
  display: block;
  font-size: 15px;
  line-height: 1.2;
}

.store-chat-head-titles small {
  display: block;
  font-size: 11px;
  opacity: 0.82;
  line-height: 1.2;
}

.store-chat-head-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.store-chat-head-btn {
  border: 1px solid rgba(255, 255, 255, 0.35);
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  cursor: pointer;
  line-height: 1.3;
}

.store-chat-head-btn:hover {
  background: rgba(255, 255, 255, 0.18);
}

.store-chat-head-btn--icon {
  width: 32px;
  height: 32px;
  padding: 0;
  font-size: 20px;
  line-height: 1;
  border-radius: 10px;
}

.store-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px 12px;
  background: #f4f7fa;
  min-height: 0;
  -webkit-overflow-scrolling: touch;
}

.store-chat-empty {
  margin: 0;
  padding: 1.25rem 0.75rem;
  text-align: center;
  font-size: 13px;
  line-height: 1.5;
  color: #64748b;
}

.store-chat-empty em {
  font-style: normal;
  font-weight: 700;
  color: #0b3d5c;
}

.store-chat-empty.is-hidden {
  display: none;
}

.store-chat-msg {
  margin-bottom: 12px;
  max-width: 88%;
  clear: both;
}

.store-chat-msg--customer {
  margin-left: auto;
  text-align: right;
}

.store-chat-msg--customer .store-chat-msg-who {
  text-align: right;
}

.store-chat-msg-body {
  font-size: 13px;
  line-height: 1.45;
  word-break: break-word;
}

.store-chat-msg--customer .store-chat-msg-body {
  background: #0b3d5c;
  color: #fff;
  display: inline-block;
  padding: 9px 12px;
  border-radius: 14px 14px 4px 14px;
  text-align: left;
}

.store-chat-msg--staff .store-chat-msg-body,
.store-chat-msg--bot .store-chat-msg-body {
  background: #fff;
  color: #0f172a;
  border: 1px solid #e2e8f0;
  display: inline-block;
  padding: 9px 12px;
  border-radius: 14px 14px 14px 4px;
  text-align: left;
}

.store-chat-msg--bot .store-chat-msg-body {
  background: #eef6fc;
  border-color: #c5d9e8;
}

.store-chat-msg--staff .store-chat-msg-body {
  background: #f0fdf4;
  border-color: #bbf7d0;
  color: #14532d;
}

.store-chat-msg-who {
  display: block;
  font-size: 10px;
  color: #64748b;
  margin-bottom: 4px;
  letter-spacing: 0.02em;
}

.store-chat-panel-foot {
  padding: 10px 12px 12px;
  border-top: 1px solid #e2e8f0;
  background: #fff;
  flex-shrink: 0;
}

.store-chat-guest-fields {
  padding: 10px 10px 8px;
  margin-bottom: 8px;
  border-radius: 12px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
}

.store-chat-guest-label {
  margin: 0;
  font-weight: 600;
}

.store-chat-panel-foot .form-control {
  color: #0f172a;
  background-color: #fff;
  border-color: #e2e8f0;
}

.store-chat-panel-foot .form-control::placeholder {
  color: #64748b;
  opacity: 1;
}

.store-chat-compose {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.store-chat-compose .store-chat-image-btn {
  flex-shrink: 0;
  border: 0;
  background: #eef2f7;
  color: #0b3d5c;
  border-radius: 10px;
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  margin: 0;
}

.store-chat-compose .store-chat-image-btn input {
  display: none;
}

.store-chat-input {
  flex: 1;
  min-width: 0;
  resize: none;
  min-height: 38px;
  max-height: 100px;
  border-radius: 12px;
  padding: 8px 12px;
  line-height: 1.35;
}

.store-chat-send-btn {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 12px;
  background: linear-gradient(145deg, #1a6b9a, #0b3d5c);
  color: #fff;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 14px rgba(11, 61, 92, 0.35);
}

.store-chat-send-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.store-chat-img-thumb {
  max-width: 200px;
  max-height: 160px;
  border-radius: 8px;
  display: block;
}

.store-chat-foot-row {
  display: flex;
  gap: 6px;
  align-items: flex-end;
}

.store-chat-foot-row .store-chat-image-btn {
  flex-shrink: 0;
  border: 0;
  background: #eef2f7;
  color: #0b3d5c;
  border-radius: 8px;
  width: 36px;
  height: 36px;
  cursor: pointer;
}

.store-chat-foot-row .store-chat-image-btn input {
  display: none;
}

/* POS drawer */
.pos-chat-drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: min(400px, 100vw);
  height: 100%;
  z-index: 1300;
  background: #fff;
  box-shadow: -8px 0 32px rgba(0, 0, 0, 0.15);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.25s ease;
}

.pos-chat-drawer.is-open {
  transform: translateX(0);
}

.pos-chat-drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1295;
  background: rgba(0, 0, 0, 0.35);
  display: none;
}

.pos-chat-drawer-backdrop.is-open {
  display: block;
}

.pos-chat-drawer-head {
  padding: 12px 14px;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.pos-chat-drawer-body {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.pos-chat-drawer-body.is-conversation .pos-chat-thread-list {
  display: none;
}

.pos-chat-thread-list {
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}

.pos-chat-list-hint {
  border-bottom: 1px solid #f1f5f9;
}

.pos-chat-thread-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  padding: 12px 14px;
  border: 0;
  border-bottom: 1px solid #f1f5f9;
  background: #fff;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s ease;
}

.pos-chat-thread-item:hover,
.pos-chat-thread-item:focus {
  background: #f8fafc;
  outline: none;
}

.pos-chat-thread-item-main {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  flex: 1;
  min-width: 0;
}

.pos-chat-thread-item-time {
  font-size: 11px;
  flex-shrink: 0;
}

.pos-chat-conversation {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.pos-chat-thread-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid #e2e8f0;
  background: #fff;
  flex-shrink: 0;
}

.pos-chat-back-btn {
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 10px;
  background: #f1f5f9;
  color: #0f172a;
  cursor: pointer;
  flex-shrink: 0;
}

.pos-chat-thread-bar-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.25;
}

.pos-chat-thread-bar-text strong {
  font-size: 15px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pos-chat-messages-pane {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  background: #f4f7fa;
  min-height: 0;
}

.pos-chat-msg {
  margin-bottom: 12px;
  max-width: 88%;
  clear: both;
}

.pos-chat-msg--in {
  margin-right: auto;
}

.pos-chat-msg--out {
  margin-left: auto;
  text-align: right;
}

.pos-chat-msg-meta {
  font-size: 10px;
  color: #64748b;
  margin-bottom: 4px;
  letter-spacing: 0.02em;
}

.pos-chat-msg--out .pos-chat-msg-meta {
  text-align: right;
}

.pos-chat-msg-body {
  display: inline-block;
  padding: 9px 12px;
  border-radius: 14px;
  font-size: 13px;
  line-height: 1.45;
  text-align: left;
  word-break: break-word;
}

.pos-chat-msg--in .pos-chat-msg-body {
  background: #fff;
  color: #0f172a;
  border: 1px solid #e2e8f0;
  border-bottom-left-radius: 4px;
}

.pos-chat-msg--out .pos-chat-msg-body {
  background: #0b3d5c;
  color: #fff;
  border-bottom-right-radius: 4px;
}

.pos-chat-msg--bot .pos-chat-msg-body {
  background: #eef6fc;
  border: 1px solid #c5d9e8;
  color: #0f172a;
}

.pos-chat-reply {
  padding: 10px 12px 12px;
  border-top: 1px solid #e2e8f0;
  background: #fff;
  flex-shrink: 0;
}

.pos-chat-reply .form-control {
  resize: vertical;
  min-height: 2.5rem;
  max-height: 120px;
  margin-bottom: 8px;
}

.pos-chat-reply-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.pos-chat-file-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 767px) {
  .store-chat-root {
    right: 12px;
    bottom: calc(68px + env(safe-area-inset-bottom, 0px));
  }
  .store-chat-panel {
    width: calc(100vw - 24px);
    height: min(480px, calc(100vh - 120px));
    bottom: 60px;
    border-radius: 16px;
  }
}

.staff-chat-thread {
  max-height: 420px;
  overflow-y: auto;
  padding: 14px 12px;
  background: #f4f7fa;
}

@media (min-width: 768px) {
  .store-chat-root {
    bottom: 24px;
  }
}
