/* Foundry Honey live chat: customer AI help + admin monitoring */
.live-chat-widget {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 240;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 12px;
}

body.modal-open .live-chat-widget {
  display: none;
}

.live-chat-toggle {
  position: relative;
  width: 62px;
  height: 62px;
  border: 0;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--primary-deep));
  color: #fff;
  font-size: 1.45rem;
  cursor: pointer;
  box-shadow: 0 16px 34px rgba(244, 180, 0, 0.36);
  display: grid;
  place-items: center;
}

.live-chat-badge {
  position: absolute;
  top: -5px;
  right: -5px;
  min-width: 23px;
  height: 23px;
  padding: 0 7px;
  border-radius: 999px;
  background: #7c1c1c;
  color: white;
  border: 2px solid #fffdf7;
  font-size: 0.72rem;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.live-chat-panel {
  width: min(390px, calc(100vw - 24px));
  max-height: min(680px, calc(100vh - 96px));
  overflow: hidden;
  border: 1px solid rgba(237, 218, 182, 0.95);
  border-radius: 24px;
  background: #fffdfa;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.18);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
}

.live-chat-admin-panel {
  width: min(900px, calc(100vw - 24px));
  height: min(680px, calc(100vh - 96px));
  grid-template-rows: auto minmax(0, 1fr);
}

.live-chat-head {
  padding: 16px 18px;
  background: linear-gradient(135deg, #ffcf57, #f1a800);
  color: #fff;
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: flex-start;
}

.live-chat-head strong {
  display: block;
}

.live-chat-head p {
  margin: 5px 0 0;
  color: rgba(255, 255, 255, 0.92);
  line-height: 1.35;
  font-size: 0.9rem;
}

.live-chat-head-actions,
.live-chat-thread-list-head {
  display: flex;
  gap: 8px;
  align-items: center;
}

.live-chat-mini-btn {
  min-height: 34px;
  border: 0;
  border-radius: 10px;
  padding: 0 10px;
  background: rgba(255, 255, 255, 0.24);
  color: #fff;
  cursor: pointer;
  font-weight: 800;
}

.live-chat-thread-list-head .live-chat-mini-btn {
  color: #7d5810;
  background: #fff3cf;
  border: 1px solid #f0dfbc;
}

.live-chat-messages {
  min-height: 300px;
  overflow: auto;
  padding: 16px;
  display: grid;
  gap: 10px;
  align-content: start;
  background: #fffdf7;
}

.live-chat-bubble-wrap {
  display: grid;
  gap: 4px;
}

.live-chat-bubble-wrap.is-own {
  justify-items: end;
}

.live-chat-bubble {
  max-width: 86%;
  padding: 11px 13px;
  border-radius: 16px;
  line-height: 1.45;
  white-space: normal;
  overflow-wrap: anywhere;
}

.live-chat-bubble-customer {
  margin-left: auto;
  background: linear-gradient(135deg, var(--primary), var(--primary-deep));
  color: #fff;
}

.live-chat-bubble-admin {
  background: #eef5ff;
  color: #24406f;
  border: 1px solid #ccddff;
}

.live-chat-bubble-ai {
  background: #fff2cc;
  color: #6d5848;
}

.live-chat-bubble-system {
  background: #f3ead3;
  color: var(--text-soft);
  border: 1px dashed #d9c299;
}

.live-chat-meta-line {
  color: var(--text-soft);
  font-size: 0.75rem;
}

.live-chat-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  padding: 14px;
  border-top: 1px solid rgba(237, 218, 182, 0.95);
  background: #fffdf7;
}

.live-chat-form input {
  min-height: 46px;
  border: 1px solid #ecd8b4;
  border-radius: 14px;
  padding: 0 14px;
  outline: none;
  background: #fff;
  font: inherit;
}

.live-chat-form input:disabled,
.live-chat-send:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.live-chat-send {
  min-height: 46px;
  border: 0;
  border-radius: 14px;
  padding: 0 17px;
  background: linear-gradient(135deg, var(--primary), var(--primary-deep));
  color: white;
  font-weight: 800;
  cursor: pointer;
}

.live-chat-empty {
  margin: 0;
  padding: 16px;
  border-radius: 16px;
  border: 1px dashed #e2c98e;
  background: #fff8ea;
  color: var(--text-soft);
}

.live-chat-admin-shell {
  min-height: 0;
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
}

.live-chat-thread-list-wrap {
  min-height: 0;
  border-right: 1px solid rgba(237, 218, 182, 0.95);
  background: #fff8ea;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

.live-chat-thread-list-head {
  justify-content: space-between;
  padding: 14px;
  border-bottom: 1px solid rgba(237, 218, 182, 0.95);
}

.live-chat-thread-list {
  min-height: 0;
  overflow: auto;
  padding: 10px;
  display: grid;
  gap: 10px;
  align-content: start;
}

.live-chat-thread-btn {
  width: 100%;
  text-align: left;
  border: 1px solid #f0dfbc;
  border-radius: 18px;
  padding: 13px;
  background: #fffdf7;
  cursor: pointer;
  display: grid;
  gap: 6px;
}

.live-chat-thread-btn.active {
  border-color: #e3b54a;
  background: #fff4d8;
  box-shadow: 0 10px 22px rgba(244, 180, 0, 0.14);
}

.live-chat-thread-top,
.live-chat-thread-bottom {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}

.live-chat-thread-top strong {
  font-size: 0.95rem;
}

.live-chat-thread-preview,
.live-chat-thread-bottom {
  color: var(--text-soft);
  font-size: 0.82rem;
}

.live-chat-thread-unread {
  min-width: 22px;
  height: 22px;
  border-radius: 999px;
  background: #7c1c1c;
  color: white;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.74rem;
  font-weight: 800;
}

.live-chat-conversation-wrap {
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
}

.live-chat-conversation-meta {
  padding: 14px 16px;
  border-bottom: 1px solid rgba(237, 218, 182, 0.95);
  background: #fffdf7;
  display: grid;
  gap: 3px;
}

.live-chat-conversation-meta span {
  color: var(--text-soft);
  font-size: 0.88rem;
}

.live-chat-admin-panel .live-chat-messages {
  min-height: 0;
}

.live-chat-messages::-webkit-scrollbar,
.live-chat-thread-list::-webkit-scrollbar {
  width: 10px;
}

.live-chat-messages::-webkit-scrollbar-thumb,
.live-chat-thread-list::-webkit-scrollbar-thumb {
  background: #e6c66b;
  border-radius: 999px;
}

.live-chat-messages::-webkit-scrollbar-track,
.live-chat-thread-list::-webkit-scrollbar-track {
  background: #fff7df;
}

@media (max-width: 900px) {
  .live-chat-admin-panel {
    width: min(96vw, 720px);
  }

  .live-chat-admin-shell {
    grid-template-columns: 1fr;
    grid-template-rows: 210px minmax(0, 1fr);
  }

  .live-chat-thread-list-wrap {
    border-right: 0;
    border-bottom: 1px solid rgba(237, 218, 182, 0.95);
  }
}

@media (max-width: 640px) {
  .live-chat-widget {
    right: 12px;
    bottom: 12px;
  }

  .live-chat-panel,
  .live-chat-admin-panel {
    width: calc(100vw - 16px);
    max-height: calc(100vh - 86px);
  }

  .live-chat-form {
    grid-template-columns: 1fr;
  }
}


/* Chatbot monitor controls */
.live-chat-admin-panel .live-chat-form {
  grid-template-columns: minmax(0, 1fr) auto auto;
}

.live-chat-ai-btn {
  min-height: 46px;
  border: 1px solid #f0dfbc;
  border-radius: 14px;
  padding: 0 15px;
  background: #fff4d8;
  color: #7d5810;
  font-weight: 800;
  cursor: pointer;
}

.live-chat-ai-btn:disabled,
.live-chat-send:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

@media (max-width: 640px) {
  .live-chat-admin-panel .live-chat-form {
    grid-template-columns: 1fr;
  }
}


/* Phone/mobile chatbot patch */
@media (max-width: 640px) {
  .live-chat-widget {
    right: 10px;
    bottom: 10px;
    max-width: calc(100vw - 20px);
    z-index: 260;
  }

  .live-chat-toggle {
    width: 56px;
    height: 56px;
  }

  .live-chat-panel,
  .live-chat-admin-panel {
    width: calc(100vw - 20px);
    max-height: calc(100vh - 84px);
    max-height: calc(100dvh - 84px);
    border-radius: 20px;
  }

  .live-chat-head {
    padding: 13px 14px;
    gap: 10px;
  }

  .live-chat-head p {
    font-size: 0.84rem;
  }

  .live-chat-mini-btn {
    min-height: 32px;
    padding: 0 9px;
  }

  .live-chat-messages {
    min-height: 250px;
    padding: 12px;
  }

  .live-chat-bubble {
    max-width: 92%;
    padding: 10px 12px;
    font-size: 0.93rem;
  }

  .live-chat-form {
    grid-template-columns: 1fr auto;
    padding: 10px;
    gap: 8px;
  }

  .live-chat-form input,
  .live-chat-send {
    min-height: 44px;
  }

  .live-chat-send {
    padding: 0 14px;
  }

  .live-chat-admin-shell {
    grid-template-columns: 1fr;
    grid-template-rows: 190px minmax(0, 1fr);
  }

  .live-chat-thread-list-head,
  .live-chat-conversation-meta {
    padding: 12px;
  }

  .live-chat-thread-list {
    padding: 8px;
  }

  .live-chat-thread-btn {
    border-radius: 15px;
    padding: 11px;
  }
}

@media (max-width: 390px) {
  .live-chat-panel,
  .live-chat-admin-panel {
    width: calc(100vw - 12px);
    max-height: calc(100vh - 72px);
    max-height: calc(100dvh - 72px);
  }

  .live-chat-widget {
    right: 6px;
    bottom: 6px;
  }

  .live-chat-form {
    grid-template-columns: 1fr;
  }
}



/* Admin chatbot monitor alignment fix
   Customer messages stay on the LEFT.
   Admin and chatbot replies stay on the RIGHT for easier monitoring. */
.live-chat-admin-panel .live-chat-bubble-wrap {
  justify-items: start;
}

.live-chat-admin-panel .live-chat-bubble-wrap.is-sender-customer {
  justify-items: start;
}

.live-chat-admin-panel .live-chat-bubble-wrap.is-sender-admin,
.live-chat-admin-panel .live-chat-bubble-wrap.is-sender-ai {
  justify-items: end;
}

.live-chat-admin-panel .live-chat-bubble-customer {
  margin-left: 0;
  margin-right: auto;
  background: #fff2cc;
  color: #5f421b;
  border: 1px solid #efd89a;
}

.live-chat-admin-panel .live-chat-bubble-admin {
  margin-left: auto;
  background: linear-gradient(135deg, var(--primary), var(--primary-deep));
  color: #fff;
  border: 0;
}

.live-chat-admin-panel .live-chat-bubble-ai {
  margin-left: auto;
  background: #eef5ff;
  color: #24406f;
  border: 1px solid #ccddff;
}

.live-chat-admin-panel .live-chat-bubble-system {
  margin-left: auto;
  margin-right: auto;
}

.live-chat-admin-panel .live-chat-bubble-wrap.is-sender-admin .live-chat-meta-line,
.live-chat-admin-panel .live-chat-bubble-wrap.is-sender-ai .live-chat-meta-line {
  text-align: right;
}

.live-chat-admin-panel .live-chat-bubble-wrap.is-sender-customer .live-chat-meta-line {
  text-align: left;
}

/* Smaller floating chat button on phone so it does not cover content */
@media (max-width: 640px) {
  .live-chat-toggle {
    width: 50px !important;
    height: 50px !important;
    box-shadow: 0 14px 24px rgba(217, 150, 0, 0.28) !important;
  }

  .live-chat-widget {
    right: 12px !important;
    bottom: 12px !important;
  }
}


/* Chatbot quick shortcuts: suggested next actions after useful chatbot answers. */
.live-chat-shortcuts {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin: 8px 0 0;
  max-width: 100%;
}

.live-chat-shortcut {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  border-radius: 999px;
  border: 1px solid rgba(227, 170, 0, 0.38);
  background: #fff8e6;
  color: #5a341c;
  font-size: 0.82rem;
  font-weight: 800;
  text-decoration: none;
  box-shadow: 0 8px 18px rgba(226, 161, 0, 0.12);
  transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.live-chat-shortcut:hover,
.live-chat-shortcut:focus-visible {
  background: #ffc428;
  color: #3d2316;
  transform: translateY(-1px);
  box-shadow: 0 12px 24px rgba(226, 161, 0, 0.22);
}

.live-chat-shortcut span:last-child {
  white-space: nowrap;
}

@media (max-width: 480px) {
  .live-chat-shortcuts {
    gap: 6px;
  }

  .live-chat-shortcut {
    flex: 1 1 auto;
    justify-content: center;
    padding: 8px 9px;
    font-size: 0.78rem;
  }
}
