/* wp-content/plugins/ucc-ai-chat-widget/assets/ucc-ai-chat-widget.css */

/* =========================
   Global safety: box sizing
   ========================= */
.ucc-chat-wrap,
.ucc-chat-wrap * {
  box-sizing: border-box;
}

/* =========================
   Container positioning
   ========================= */
.ucc-chat-wrap {
  position: fixed;
  bottom: 18px;
  z-index: 2147483000;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Arial;
}

/* Default desktop offsets */
.ucc-chat-wrap.right { right: 18px; }
.ucc-chat-wrap.left  { left: 18px; }

/* =========================
   Floating bubble
   ========================= */
.ucc-chat-bubble {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  cursor: pointer;
  background: #111827;
  color: #fff;
  font-weight: 600;
  user-select: none;
  box-shadow: 0 6px 18px rgba(0,0,0,.15);
}

/* =========================
   Chat panel
   ========================= */
.ucc-chat-panel {
  position: absolute;
  bottom: 70px;

  /* Critical: never exceed viewport width */
  width: min(360px, calc(100vw - 24px));

  max-height: 520px;
  display: none;
  flex-direction: column;

  background: #fff;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0,0,0,.2);
}

/* Anchor panel to the chosen side */
.ucc-chat-wrap.right .ucc-chat-panel { right: 0; left: auto; }
.ucc-chat-wrap.left  .ucc-chat-panel { left: 0;  right: auto; }

/* =========================
   Header
   ========================= */
.ucc-chat-header {
  padding: 12px 14px;
  background: #111827;
  color: #fff;
  font-size: 14px;
  font-weight: 700;
}

.ucc-chat-close {
  float: right;
  cursor: pointer;
  opacity: .85;
}

/* =========================
   Messages area
   ========================= */
.ucc-chat-body {
  padding: 12px;
  overflow: auto;
  gap: 10px;
  display: flex;
  flex-direction: column;
  height: 340px;
  background: #fafafa;
}

.ucc-chat-row { display: flex; gap: 8px; }
.ucc-chat-row.user { justify-content: flex-end; }

.ucc-chat-msg {
  max-width: 80%;
  padding: 10px 12px;
  border-radius: 12px;
  line-height: 1.3;
  font-size: 14px;
  word-wrap: break-word;
  white-space: pre-wrap;
}

.ucc-chat-msg.user {
  background: #111827;
  color: #fff;
  border-bottom-right-radius: 4px;
}

.ucc-chat-msg.bot {
  background: #e5e7eb;
  color: #111827;
  border-bottom-left-radius: 4px;
}

.ucc-chat-time {
  font-size: 11px;
  color: #9ca3af;
  align-self: flex-end;
  margin-top: 2px;
}

.ucc-chat-typing {
  font-size: 12px;
  color: #6b7280;
  padding: 6px 12px;
}

/* =========================
   Footer (input + send)
   ========================= */
.ucc-chat-footer {
  padding: 10px;
  border-top: 1px solid #eee;
  background: #fff;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.ucc-chat-input {
  font-size: 14px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid #ddd;
  outline: none;
  min-width: 0; /* prevents grid overflow on narrow screens */
}

.ucc-chat-send {
  padding: 10px 14px;
  border-radius: 10px;
  border: none;
  cursor: pointer;
  background: #111827;
  color: #fff;
  font-weight: 600;
}

.ucc-chat-send[disabled] {
  opacity: .6;
  cursor: not-allowed;
}

/* =========================
   Responsive safeguards
   ========================= */

/* Covers common “mobile mode” widths in responsive testers */
@media (max-width: 768px) {
  .ucc-chat-wrap.right { right: 12px; }
  .ucc-chat-wrap.left  { left: 12px; }

  /* Keep panel within viewport */
  .ucc-chat-panel {
    width: calc(100vw - 24px);
  }

  /* Slightly reduce chat height on smaller screens */
  .ucc-chat-body {
    height: 300px;
  }
}

/* Very small phones */
@media (max-width: 380px) {
  .ucc-chat-body {
    height: 260px;
  }
  .ucc-chat-send {
    padding: 10px 12px;
  }
}
