/**
 * Surface Kit — AI Chatbot Widget Styles
 */

/* ── Toggle button (floating) ───────────────────────────────────────────── */
#drstk-ai-chat {
  position: fixed;
  z-index: 99990;
  --chat-color: #005a5b;
}

#drstk-ai-chat.drstk-pos-bottom-right {
  bottom: 24px;
  right: 24px;
}

#drstk-ai-chat.drstk-pos-bottom-left {
  bottom: 24px;
  left: 24px;
}

#drstk-ai-chat-toggle {
  width: 58px !important;
  height: 58px !important;
  min-width: 58px !important;
  min-height: 58px !important;
  max-width: 58px !important;
  max-height: 58px !important;
  border-radius: 50%;
  background: var(--chat-color, #005a5b);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 !important;
  margin: 0 !important;
  line-height: 1 !important;
  font-size: 0;
  box-sizing: border-box;
  flex: 0 0 58px;
  flex-shrink: 0;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.22);
  transition:
    transform 0.2s,
    box-shadow 0.2s;
  position: relative;
  z-index: 2;
}

#drstk-ai-chat-toggle:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.28);
}

#drstk-ai-chat-toggle svg {
  width: 26px !important;
  height: 26px !important;
  min-width: 26px !important;
  min-height: 26px !important;
  max-width: 26px !important;
  max-height: 26px !important;
  color: #fff;
  fill: none;
  stroke: currentColor;
  display: block;
  flex: 0 0 26px;
  pointer-events: none;
}

/* ── Chat panel ─────────────────────────────────────────────────────────── */
#drstk-ai-chat-panel {
  display: none; /* JS sets display:flex then adds .drstk-ai-open */
  flex-direction: column;
  position: absolute;
  bottom: 70px;
  width: 356px;
  max-width: calc(100vw - 32px);
  min-height: 400px;
  max-height: 520px;
  background: #fff;
  border-radius: 18px;
  border: 1px solid #e2e8f0;
  box-shadow: 0 16px 40px -22px rgba(15, 23, 42, 0.5);
  overflow: hidden;
  opacity: 0;
  transform: translateY(12px) scale(0.97);
  transition:
    opacity 0.25s ease,
    transform 0.25s ease;
  z-index: 1;
}

/* Position panel relative to button side */
#drstk-ai-chat.drstk-pos-bottom-right #drstk-ai-chat-panel {
  right: 0;
}

#drstk-ai-chat.drstk-pos-bottom-left #drstk-ai-chat-panel {
  left: 0;
}

#drstk-ai-chat-panel.drstk-ai-open {
  opacity: 1;
  transform: translateY(0) scale(1);
}

/* ── Panel header ───────────────────────────────────────────────────────── */
#drstk-ai-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  background: var(--chat-color, #005a5b);
  color: #fff;
  flex-shrink: 0;
}

#drstk-ai-chat-title {
  font-weight: 600;
  font-size: 15px;
  letter-spacing: 0.01em;
}

#drstk-ai-chat-header > #drstk-ai-chat-advanced-toggle {
  margin-left: auto;
  margin-right: 8px;
}

#drstk-ai-chat-close {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
  color: rgba(255, 255, 255, 0.8);
}

#drstk-ai-chat-close:hover {
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
}

#drstk-ai-chat-close svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
  pointer-events: none;
}

#drstk-ai-chat-advanced-toggle {
  width: 30px;
  height: 30px;
  min-width: 30px;
  border-radius: 8px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.28);
  color: #fff;
  cursor: pointer;
  transition: background 0.16s ease;
}

#drstk-ai-chat-advanced-toggle:hover {
  background: rgba(255, 255, 255, 0.3);
}

#drstk-ai-chat-advanced-toggle svg {
  width: 14px;
  height: 14px;
  display: block;
  pointer-events: none;
}

#drstk-ai-chat-advanced {
  display: none;
  padding: 9px 12px;
  border-bottom: 1px solid #e2e8f0;
  background: #f8fafc;
}

#drstk-ai-chat-advanced.is-open {
  display: flex;
  align-items: center;
  justify-content: flex-end;
}

#drstk-ai-chat-clear-history {
  border: 1px solid #cbd5e1;
  background: #fff;
  color: #334155;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  padding: 6px 11px;
  cursor: pointer;
}

#drstk-ai-chat-clear-history:hover {
  border-color: #ef4444;
  color: #b91c1c;
}

/* ── Messages area ──────────────────────────────────────────────────────── */
#drstk-ai-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px 14px 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
  background: #fbfdff;
}

.drstk-ai-msg {
  max-width: 84%;
  padding: 9px 13px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.5;
  word-break: break-word;
  white-space: pre-wrap;
}

.drstk-ai-msg--user {
  background: var(--chat-color, #005a5b);
  color: #fff;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}

.drstk-ai-msg--assistant {
  background: #eef3f8;
  color: #1e293b;
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}

/* ── Typing indicator ───────────────────────────────────────────────────── */
.drstk-ai-typing {
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 5px;
}

.drstk-ai-typing span {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #94a3b8;
  animation: drstk-bounce 1.2s infinite;
}

.drstk-ai-typing span:nth-child(2) {
  animation-delay: 0.2s;
}
.drstk-ai-typing span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes drstk-bounce {
  0%,
  80%,
  100% {
    transform: translateY(0);
  }
  40% {
    transform: translateY(-5px);
  }
}

/* ── Input bar ──────────────────────────────────────────────────────────── */
#drstk-ai-chat-footer {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 12px 12px;
  border-top: 1px solid #e2e8f0;
  background: #ffffff;
  flex-shrink: 0;
}

#drstk-ai-chat-powered {
  padding: 0 12px 10px;
  font-size: 11px;
  line-height: 1.2;
  color: #64748b;
  text-align: left;
  flex-shrink: 0;
}

#drstk-ai-chat-input {
  flex: 1;
  resize: none;
  border: 1px solid #cbd5e1;
  border-radius: 12px;
  padding: 9px 12px;
  font-size: 14px;
  line-height: 1.4;
  outline: none;
  font-family: inherit;
  max-height: 110px;
  transition: border-color 0.15s;
  color: #1e293b;
  background: #f8fafc;
}

#drstk-ai-chat-input:focus {
  border-color: var(--chat-color, #005a5b);
  background: #fff;
}

#drstk-ai-chat-input:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

#drstk-ai-chat-send {
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: var(--chat-color, #005a5b);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition:
    opacity 0.15s,
    transform 0.15s;
}

#drstk-ai-chat-send:hover:not(:disabled) {
  opacity: 0.88;
  transform: scale(1.06);
}

#drstk-ai-chat-send:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

#drstk-ai-chat-send svg {
  width: 17px;
  height: 17px;
  fill: #fff;
  pointer-events: none;
}

/* ── Mobile ─────────────────────────────────────────────────────────────── */
@media (max-width: 480px) {
  #drstk-ai-chat-panel {
    width: calc(100vw - 48px);
    max-height: 70vh;
  }
}
