/* Ductcare Chatbot - base styles. Button may be #ductcare-chatbot-button or .ductcare-chatbot-trigger (block wrapper). */

.ductcare-chatbot-window {
  position: fixed;
  bottom: 90px;
  left: -100%;
  height: 60vh;
  width: 85vw;
  max-width: 420px;
  background: #ffffff;
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.15);
  z-index: 9999;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: left 0.4s ease;
}

/* Window opens on the same side as the button (shared placement classes from config) */
.ductcare-chatbot-window.is-open.ductcare-chatbot-desktop-bottom_left {
  left: 20px;
  right: auto;
}

.ductcare-chatbot-window.is-open.ductcare-chatbot-desktop-bottom_right {
  right: 20px;
  left: auto;
}

.ductcare-chatbot-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  background: #023047; /* Deep blue like site header */
  color: #fff;
}

.ductcare-chatbot-header-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ductcare-chatbot-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ductcare-chatbot-debug-toggle {
  background: rgba(255, 255, 255, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.4);
  color: #fff;
  font-size: 11px;
  padding: 4px 8px;
  border-radius: 4px;
  cursor: pointer;
}
.ductcare-chatbot-debug-toggle:hover {
  background: rgba(255, 255, 255, 0.3);
}

.ductcare-chatbot-mascot {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background-color: #fff;
  background-image: url('/themes/ductcare/images/ductbot.png');
  background-size: cover;
  background-position: center;
  box-shadow: 0 0 0 2px #ff7f27; /* site orange accent */
}

.ductcare-chatbot-title {
  font-weight: 700;
  font-size: 12px;
}

.ductcare-chatbot-close {
  display: flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: none;
  color: #fff;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  padding: 4px 8px;
}
.ductcare-chatbot-close-icon {
  font-size: 1.2em;
}
.ductcare-chatbot-close-label {
  display: none;
}

.ductcare-chatbot-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  min-height: 120px;
  font-size: 12px;
}

.ductcare-chatbot-messages .message {
  margin-bottom: 8px;
  padding: 6px 10px;
  border-radius: 8px;
  max-width: 90%;
  font-size: 12px;
  font-weight: 700;
}

.ductcare-chatbot-messages .user-message {
  margin-left: auto;
  background: #0073aa;
  color: #fff;
}

.ductcare-chatbot-messages .bot-message {
  background: #f0f0f0;
  color: #333;
}

/* DuctBot (mascot) message: avatar + name + content */
.ductcare-chatbot-ductbot-message {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.ductcare-chatbot-message-sender {
  display: flex;
  align-items: center;
  gap: 6px;
}
.ductcare-chatbot-message-avatar.ductcare-chatbot-ductbot-avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background-image: url('/themes/ductcare/images/ductbot.png');
  background-size: cover;
  background-position: center;
  background-color: #fff;
  flex-shrink: 0;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.08);
}
.ductcare-chatbot-sender-name {
  font-weight: 600;
  font-size: 11px;
  color: #023047;
}
.ductcare-chatbot-message-content {
  padding-left: 30px;
  line-height: 1.4;
  font-weight: 700;
}

.ductcare-chatbot-booking-complete-text {
  font-weight: 700;
}

/* Choice buttons (e.g. Residential / Commercial, service types) */
.ductcare-chatbot-choice-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px 0 4px 30px;
}
.ductcare-chatbot-choice-btn {
  padding: 8px 14px;
  border-radius: 6px;
  border: 1px solid #023047;
  background: #fff;
  color: #023047;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.ductcare-chatbot-choice-btn:hover {
  background: #023047;
  color: #fff;
}

.ductcare-chatbot-input-wrapper {
  padding: 12px;
  border-top: 1px solid #ddd;
}

.ductcare-chatbot-input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #ccc;
  border-radius: 4px;
  resize: vertical;
  font-size: 12px;
  margin-bottom: 8px;
  box-sizing: border-box;
  min-height: auto !important;
}

.ductcare-chatbot-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  height: 50px;
}

.ductcare-chatbot-reset,
.ductcare-chatbot-send {
  padding: 6px 12px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 18px;
  border: none;
  width: 110px;
  
}

.ductcare-chatbot-reset {
  background: #f0f0f0;
  color: #333;
}

.ductcare-chatbot-send {
  background: #ff7f27; /* site orange */
  color: #fff;
}

/* Chat trigger: perfect circle; text and image overflow so the circle is not distorted */
#ductcare-chatbot-button,
.ductcare-chatbot-trigger {
  position: fixed;
  bottom: 20px;
  width: 100px;
  min-width: 64px;
  min-height: 64px;
  padding: 8px 0;
  border-radius: 50%;
  background: #ff7f27;
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font-size: 13px;
  font-weight: 600;
  z-index: 9998;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.3);
  overflow: visible;
  flex-shrink: 0;
}
.ductcare-chatbot-trigger-icon-wrap {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 52px;
  flex-shrink: 0;
}

#ductcare-chatbot-button:hover,
.ductcare-chatbot-trigger:hover {
  background: #f46b0e;
}

/* Inner circle clips the icon so the button stays a perfect circle; icon does not distort */
.ductcare-chatbot-trigger-icon {
  pointer-events: none;
  flex-shrink: 0;
}
#ductcare-chatbot-button .ductcare-chatbot-trigger-icon--image,
.ductcare-chatbot-trigger .ductcare-chatbot-trigger-icon--image {
  display: block;
  width: 90px;
  height: 90px;
  min-width: 52px;
  min-height: 52px;
  border-radius: 50%;
  background-image: url('/themes/ductcare/images/ductbot.png');
  background-size: cover;
  background-position: center;
  background-color: transparent;
  object-fit: cover;
}

/* Green online indicator on chat button */
.ductcare-chatbot-online-dot {
  position: absolute;
  
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: #22c55e;
  border: 2px solid #fff;
  flex-shrink: 0;
  pointer-events: none;
}
#ductcare-chatbot-button .ductcare-chatbot-online-dot,
.ductcare-chatbot-trigger .ductcare-chatbot-online-dot {
  position: absolute;
  top: -13px;
  right: -30px;
}

/* "Chat" label under the trigger icon */
.ductcare-chatbot-trigger-label {
  width: 100%;
  text-align: center;
  font-size: 15px;
  max-width: 60px;
  background: white;
  border-radius: 10px;
  margin: 0 auto;
  padding: 2px 4px;
  color: #f36f21;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
  line-height: 1.2;
  position: relative;
    top: 18px;
}

.ductcare-chatbot-error {
  color: #a00;
}

/* Debug popup: separate panel next to the chat */
.ductcare-chatbot-debug-popup {
  position: fixed;
  bottom: 90px;
  width: 320px;
  max-width: calc(100vw - 480px);
  max-height: 50vh;
  background: #1a1a1a;
  border-radius: 8px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.35);
  z-index: 10000;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}
.ductcare-chatbot-debug-popup.is-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}
.ductcare-chatbot-debug-popup--right {
  right: 440px;
  left: auto;
}
.ductcare-chatbot-debug-popup--left {
  left: 440px;
  right: auto;
}
.ductcare-chatbot-debug-popup-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 10px;
  background: #023047;
  color: #fff;
  font-size: 12px;
  font-weight: 600;
}
.ductcare-chatbot-debug-popup-close {
  background: transparent;
  border: none;
  color: #fff;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  padding: 0 4px;
}
.ductcare-chatbot-debug-popup-close:hover {
  opacity: 0.85;
}

.ductcare-chatbot-debug {
  font-family: monospace;
  font-size: 11px;
  background: #111;
  color: #8f8;
  padding: 6px 8px;
  max-height: 280px;
  overflow-y: auto;
  display: block;
  flex: 1;
  min-height: 80px;
}
.ductcare-chatbot-debug:empty {
  min-height: 60px;
}
.ductcare-chatbot-debug:empty::before {
  content: 'Request/response will appear here when you send a message';
  color: #666;
}

/* Desktop placement for button */
#ductcare-chatbot-button.ductcare-chatbot-desktop-bottom_right,
.ductcare-chatbot-trigger.ductcare-chatbot-desktop-bottom_right {
  right: 20px;
  left: auto;
}

#ductcare-chatbot-button.ductcare-chatbot-desktop-bottom_left,
.ductcare-chatbot-trigger.ductcare-chatbot-desktop-bottom_left {
  left: 20px;
  right: auto;
}

/* Desktop-only UI enhancement (do not affect mobile behavior) */
@media (min-width: 769px) {
  .ductcare-chatbot-window {
    bottom: 110px;
    max-width: 500px;
    height: 68vh;
    border-radius: 14px;
  }

  .ductcare-chatbot-window.is-open.ductcare-chatbot-desktop-bottom_right {
    right: 24px;
  }
  .ductcare-chatbot-window.is-open.ductcare-chatbot-desktop-bottom_left {
    left: 24px;
  }

  .ductcare-chatbot-header {
    padding: 14px 18px;
  }
  .ductcare-chatbot-mascot {
    width: 48px;
    height: 48px;
  }
  .ductcare-chatbot-title {
    font-size: 16px;
  }
  .ductcare-chatbot-close {
    font-size: 24px;
  }

  .ductcare-chatbot-messages {
    padding: 16px;
    font-size: 15px;
  }
  .ductcare-chatbot-messages .message {
    font-size: 15px;
    padding: 9px 12px;
    border-radius: 10px;
  }
  .ductcare-chatbot-message-avatar.ductcare-chatbot-ductbot-avatar {
    width: 30px;
    height: 30px;
  }
  .ductcare-chatbot-sender-name {
    font-size: 13px;
  }
  .ductcare-chatbot-message-content {
    padding-left: 36px;
    line-height: 1.5;
  }

  .ductcare-chatbot-choice-buttons {
    gap: 10px;
    padding-left: 36px;
  }
  .ductcare-chatbot-choice-btn {
    font-size: 14px;
    padding: 10px 16px;
    border-radius: 8px;
  }

  .ductcare-chatbot-input-wrapper {
    padding: 14px 16px;
  }
  .ductcare-chatbot-input {
    font-size: 15px;
    padding: 11px 12px;
    border-radius: 8px;
  }
  .ductcare-chatbot-reset,
  .ductcare-chatbot-send {
    font-size: 18px;
    width: 128px;
    border-radius: 8px;
    padding: 8px 14px;
  }

  #ductcare-chatbot-button,
  .ductcare-chatbot-trigger {
    width: 118px;
    min-width: 118px;
    min-height: 118px;
    bottom: 24px;
    gap: 6px;
  }
  .ductcare-chatbot-trigger-icon-wrap {
    width: 62px;
    height: 62px;
  }
  #ductcare-chatbot-button .ductcare-chatbot-trigger-icon--image,
  .ductcare-chatbot-trigger .ductcare-chatbot-trigger-icon--image {
    width: 104px;
    height: 104px;
  }
  .ductcare-chatbot-online-dot {
    width: 32px;
    height: 32px;
  }
  #ductcare-chatbot-button .ductcare-chatbot-online-dot,
  .ductcare-chatbot-trigger .ductcare-chatbot-online-dot {
    top: -12px;
    right: -34px;
  }
  .ductcare-chatbot-trigger-label {
    font-size: 17px;
    max-width: 72px;
    top: 19px;
  }
}

/* Mobile: fullscreen chat to avoid page zoom; top margin for fixed nav (~60px) */
@media (max-width: 768px) {
  #ductcare-chatbot-button, .ductcare-chatbot-trigger {
    position: fixed;
     z-index: 104 !important;
  }

  /* Lift the mobile chat trigger above the sticky booking total bar. */
  body.page-path-request #ductcare-chatbot-button,
  body.page-path-request .ductcare-chatbot-trigger,
  body.page-path-edit #ductcare-chatbot-button,
  body.page-path-edit .ductcare-chatbot-trigger {
    bottom: calc(env(safe-area-inset-bottom, 0px) + 104px);
  }

  /* Mobile: hide the trigger button while chat is open. */
  .ductcare-chatbot-window.is-open ~ #block-olivero-chatbotbutton,
  .ductcare-chatbot-window.is-open ~ .ductcare-chatbot-trigger,
  body:has(.ductcare-chatbot-window.is-open) #block-olivero-chatbotbutton {
    display: none !important;
  }
  
  .ductcare-chatbot-window{
    height: 65vh !important;
  }
  .ductcare-chatbot-window.is-open {
    top: 178px;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    max-width: none;
    height: calc(100vh - 60px);
    height: calc(100dvh - 60px);
    border-radius: 0;
    box-shadow: none;
    touch-action: manipulation;
  }
  .ductcare-chatbot-window.ductcare-chatbot-mobile-bottom_right.is-open,
  .ductcare-chatbot-window.ductcare-chatbot-mobile-bottom_left.is-open {
    left: 0;
    right: 0;
    bottom: 0;
  }

  /* At least 16px input font prevents iOS zoom on focus */
  .ductcare-chatbot-input {
    font-size: 16px;
  }

  /* Visible "Close" / exit option on fullscreen mobile */
  .ductcare-chatbot-close-label {
    display: inline;
    font-size: 16px;
    font-weight: 600;
  }
  .ductcare-chatbot-close {
    min-height: 44px;
    min-width: 44px;
    padding: 10px 14px;
    font-size: 16px;
  }
  .ductcare-chatbot-close-icon {
    font-size: 1.4em;
  }

  #ductcare-chatbot-button.ductcare-chatbot-mobile-bottom_right,
  .ductcare-chatbot-trigger.ductcare-chatbot-mobile-bottom_right {
    right: 20px;
    left: auto;
  }
  #ductcare-chatbot-button.ductcare-chatbot-mobile-bottom_left,
  .ductcare-chatbot-trigger.ductcare-chatbot-mobile-bottom_left {
    left: 20px;
    right: auto;
  }

  .ductcare-chatbot-debug-popup {
    bottom: 20px;
    width: 280px;
    max-height: 40vh;
  }
  .ductcare-chatbot-debug-popup--right {
    right: 20px;
  }
  .ductcare-chatbot-debug-popup--left {
    left: 20px;
  }
}

/* Desktop: hide trigger button while chat window is open */
@media (min-width: 769px) {
  #block-olivero-chatbotbutton,
  .ductcare-chatbot-trigger {
    transition: opacity 0.28s ease, transform 0.28s ease, visibility 0.28s ease;
  }

  .ductcare-chatbot-window.is-open ~ #block-olivero-chatbotbutton,
  .ductcare-chatbot-window.is-open ~ .ductcare-chatbot-trigger,
  body:has(.ductcare-chatbot-window.is-open) #block-olivero-chatbotbutton,
  body:has(.ductcare-chatbot-window.is-open) .ductcare-chatbot-trigger {
    opacity: 0 !important;
    transform: translateY(18px) !important;
    visibility: hidden !important;
    pointer-events: none !important;
  }
}
