/* SMUL chat widget. Scoped with #smul-chat- prefix to avoid clashes with site styles. */

#smul-chat-root,
#smul-chat-root * {
  box-sizing: border-box;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

#smul-chat-root {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 2147483000;
}

#smul-chat-button {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: #2351db;
  color: #fff;
  border: none;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(35, 81, 219, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: transform 0.15s ease;
}
#smul-chat-button:hover { transform: scale(1.05); }
#smul-chat-button svg { width: 28px; height: 28px; }

#smul-chat-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  background: #e64545;
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  display: none;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
#smul-chat-badge.visible { display: inline-flex; }

#smul-chat-panel {
  position: absolute;
  right: 0;
  bottom: 76px;
  width: 340px;
  height: 480px;
  max-height: calc(100vh - 100px);
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.18);
  display: none;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid #e6e8ef;
}
#smul-chat-panel.open { display: flex; }

#smul-chat-header {
  background: #2351db;
  color: #fff;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
#smul-chat-header .smul-chat-title { font-weight: 600; font-size: 15px; }
#smul-chat-header .smul-chat-sub { font-size: 11px; opacity: 0.85; display: flex; align-items: center; gap: 6px; margin-top: 2px; }
#smul-chat-header .smul-chat-dot {
  width: 8px; height: 8px; border-radius: 50%; background: #6b7280;
}
#smul-chat-header .smul-chat-dot.connected { background: #34d399; }
#smul-chat-close {
  background: transparent;
  border: none;
  color: #fff;
  cursor: pointer;
  font-size: 22px;
  line-height: 1;
  padding: 0 4px;
}

#smul-chat-body {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 14px;
  background: #f6f8fc;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.smul-chat-msg {
  max-width: 80%;
  padding: 8px 12px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.4;
  word-wrap: break-word;
  white-space: pre-wrap;
}
.smul-chat-msg.visitor {
  align-self: flex-end;
  background: #2351db;
  color: #fff;
  border-bottom-right-radius: 4px;
}
.smul-chat-msg.operator {
  align-self: flex-start;
  background: #fff;
  color: #1f2937;
  border: 1px solid #e6e8ef;
  border-bottom-left-radius: 4px;
}
.smul-chat-msg.system {
  align-self: center;
  background: transparent;
  color: #6b7280;
  font-size: 12px;
  text-align: center;
}
.smul-chat-time { display: block; font-size: 10px; opacity: 0.7; margin-top: 4px; }

#smul-chat-form-pre {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 18px 16px;
  background: #fff;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
#smul-chat-form-pre h4 { margin: 0; font-size: 15px; color: #1f2937; }
#smul-chat-form-pre p { margin: 0; color: #6b7280; font-size: 13px; }
#smul-chat-form-pre label { font-size: 12px; color: #374151; font-weight: 600; }
#smul-chat-form-pre input {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 14px;
}
#smul-chat-form-pre input:focus { outline: 2px solid #2351db; outline-offset: -1px; }
#smul-chat-form-pre button {
  margin-top: 4px;
  padding: 10px;
  background: #2351db;
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
#smul-chat-form-pre button:disabled { opacity: 0.6; cursor: progress; }
.smul-chat-error { color: #c0392b; font-size: 12px; }

#smul-chat-input-row {
  flex-shrink: 0;
  padding: 10px;
  border-top: 1px solid #e6e8ef;
  background: #fff;
  display: flex;
  gap: 8px;
}
#smul-chat-input {
  flex: 1;
  resize: none;
  height: 38px;
  max-height: 100px;
  padding: 9px 11px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
}
#smul-chat-input:focus { outline: 2px solid #2351db; outline-offset: -1px; }
#smul-chat-send {
  padding: 0 14px;
  background: #2351db;
  color: #fff;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
}
#smul-chat-send:disabled { opacity: 0.5; cursor: not-allowed; }

@media (max-width: 480px) {
  #smul-chat-panel {
    width: calc(100vw - 24px);
    height: calc(100vh - 100px);
  }
}
