/* Live chat widget - see includes/chat_widget.php + js/chat-widget.js */

/* [hidden] and these classes' own `display` rules are equal specificity, and
   author CSS beats the UA stylesheet's [hidden]{display:none} either way -
   so without this, toggling the `hidden` attribute from JS would do nothing. */
.mm-chat-panel[hidden],
.mm-chat-gate[hidden],
.mm-chat-thread[hidden],
.mm-chat-form[hidden],
.mm-chat-badge[hidden] { display: none !important; }

.mm-chat-bubble {
  position: fixed; bottom: 92px; right: 24px; width: 56px; height: 56px; border-radius: 50%;
  background: var(--color-teal); color: #fff; display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow-md); z-index: 401; border: none; cursor: pointer; transition: transform .2s ease;
}
.mm-chat-bubble:hover { transform: scale(1.08); }
.mm-chat-bubble-icon-close { display: none; }
.mm-chat-bubble.is-open .mm-chat-bubble-icon-chat { display: none; }
.mm-chat-bubble.is-open .mm-chat-bubble-icon-close { display: block; }

.mm-chat-badge {
  position: absolute; top: -4px; right: -4px; min-width: 20px; height: 20px; padding: 0 5px;
  border-radius: 10px; background: var(--color-gold-deep); color: #fff; font-size: .72rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center; border: 2px solid var(--color-cream);
}

.mm-chat-panel {
  position: fixed; bottom: 158px; right: 24px; width: 360px; max-width: calc(100vw - 32px);
  height: 500px; max-height: calc(100vh - 190px); background: #fff; border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg); z-index: 401; display: flex; flex-direction: column; overflow: hidden;
  font-family: var(--font-body);
}

.mm-chat-header {
  display: flex; align-items: center; gap: 10px; padding: 14px 16px; background: var(--color-teal); color: #fff; flex: 0 0 auto;
}
.mm-chat-header img { border-radius: 6px; object-fit: cover; background: #fff; }
.mm-chat-header-text { display: flex; flex-direction: column; line-height: 1.3; flex: 1 1 auto; min-width: 0; }
.mm-chat-header-text strong { font-size: .95rem; }
.mm-chat-header-text span { font-size: .75rem; opacity: .8; }
.mm-chat-icon-btn { background: none; border: none; color: #fff; opacity: .85; cursor: pointer; padding: 4px; display: flex; }
.mm-chat-icon-btn:hover { opacity: 1; }

.mm-chat-gate { padding: 18px 16px; display: flex; flex-direction: column; gap: 10px; flex: 1 1 auto; overflow-y: auto; }
.mm-chat-gate p { font-size: .85rem; color: var(--color-ink-soft); margin: 0 0 4px; }
.mm-chat-gate input {
  padding: 10px 12px; border: 1px solid var(--color-border); border-radius: var(--radius-sm); font-family: inherit; font-size: .9rem;
}
.mm-chat-gate input:focus { outline: none; border-color: var(--color-teal); }

.mm-chat-thread { flex: 1 1 auto; overflow-y: auto; padding: 14px 12px; display: flex; flex-direction: column; gap: 10px; background: var(--color-cream); }
.mm-chat-msg { max-width: 82%; padding: 9px 12px; border-radius: 14px; font-size: .87rem; line-height: 1.45; white-space: pre-wrap; word-break: break-word; }
.mm-chat-msg-visitor { align-self: flex-end; background: var(--color-teal); color: #fff; border-bottom-right-radius: 4px; }
.mm-chat-msg-agent { align-self: flex-start; background: #fff; color: var(--color-ink); box-shadow: var(--shadow-sm); border-bottom-left-radius: 4px; }
.mm-chat-msg-system { align-self: center; background: transparent; color: var(--color-ink-soft); font-size: .78rem; font-style: italic; text-align: center; max-width: 100%; }
.mm-chat-msg-name { display: block; font-size: .7rem; font-weight: 600; margin-bottom: 3px; opacity: .75; }
.mm-chat-msg-time { display: block; font-size: .65rem; margin-top: 4px; opacity: .6; }

.mm-chat-form { display: flex; align-items: flex-end; gap: 8px; padding: 10px; border-top: 1px solid var(--color-border); flex: 0 0 auto; }
.mm-chat-form textarea {
  flex: 1 1 auto; resize: none; border: 1px solid var(--color-border); border-radius: var(--radius-sm);
  padding: 9px 12px; font-family: inherit; font-size: .87rem; max-height: 90px;
}
.mm-chat-form textarea:focus { outline: none; border-color: var(--color-teal); }
.mm-chat-send {
  flex: 0 0 auto; width: 38px; height: 38px; border-radius: 50%; border: none; background: var(--color-gold-deep);
  color: #fff; display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.mm-chat-send:hover { background: var(--color-gold); }
.mm-chat-send:disabled { opacity: .5; cursor: default; }

.mm-chat-ended { padding: 16px; text-align: center; }
.mm-chat-ended p { font-size: .85rem; color: var(--color-ink-soft); margin-bottom: 12px; }

@media (max-width: 480px) {
  .mm-chat-panel { right: 16px; left: 16px; width: auto; bottom: 148px; }
  .mm-chat-bubble { right: 16px; }
}
