/* =========================================================
   AIT Chatbot Widget  — Responsive + Top-Left Resize
   ========================================================= */

/* --- Toggle Button --- */
.ait-chat-toggle {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 9998;
  border: 0;
  border-radius: 999px;
  padding: 11px 18px;
  background: #0a3a77;
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(0,0,0,0.25);
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.ait-chat-toggle:disabled {
  background: #6b7280;
  cursor: not-allowed;
}

/* --- Panel --- */
.ait-chat-panel {
  position: fixed;
  right: 16px;
  bottom: 64px;
  /* default size — JS will override via inline style */
  width: min(380px, calc(100vw - 32px));
  height: min(520px, calc(100vh - 120px));
  min-width: 280px;
  min-height: 300px;
  max-width: 80vw;
  max-height: 80vh;
  background: #fff;
  border: 1px solid #cfd8e3;
  border-radius: 12px;
  box-shadow: 0 12px 28px rgba(0,0,0,0.22);
  z-index: 9999;
  display: none;           /* hidden until .open */
  flex-direction: column;
  overflow: hidden;
  resize: none;            /* disable browser native resize */
  box-sizing: border-box;
}
.ait-chat-panel.open {
  display: flex;
}

/* --- Top-left resize handle --- */
.ait-chat-resize-handle {
  position: absolute;
  top: 0;
  left: 0;
  width: 22px;
  height: 22px;
  cursor: nw-resize;
  z-index: 10;
  /* visual cue: two diagonal lines */
  background:
    linear-gradient(135deg,
      transparent 30%,
      rgba(255,255,255,0.55) 30%, rgba(255,255,255,0.55) 45%,
      transparent 45% 55%,
      rgba(255,255,255,0.55) 55%, rgba(255,255,255,0.55) 70%,
      transparent 70%);
  border-radius: 12px 0 0 0;
}

/* --- Header --- */
.ait-chat-header {
  background: #0a3a77;
  color: #fff;
  padding: 10px 12px 10px 26px; /* left padding leaves room for resize handle */
  font-size: 14px;
  font-weight: 600;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
  user-select: none;
}
.ait-chat-close {
  border: 0;
  background: transparent;
  color: #fff;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  padding: 0 4px;
  -webkit-tap-highlight-color: transparent;
}

/* --- Messages area --- */
.ait-chat-messages {
  flex: 1 1 auto;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 10px 12px;
  background: #f6f8fb;
  -webkit-overflow-scrolling: touch;
}
.ait-chat-msg {
  margin-bottom: 10px;
  padding: 8px 11px;
  border-radius: 10px;
  font-size: 14px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  max-width: 90%;
}
.ait-chat-msg.user {
  background: #dbeafe;
  margin-left: auto;
}
.ait-chat-msg.bot {
  background: #fff;
  border: 1px solid #d4dbe6;
  margin-right: auto;
}

/* --- Footer / Input --- */
.ait-chat-footer {
  border-top: 1px solid #e3e8ef;
  padding: 8px;
  display: flex;
  gap: 6px;
  align-items: flex-end;
  flex-shrink: 0;
  background: #fff;
}
.ait-chat-input {
  flex: 1 1 auto;
  min-height: 40px;
  max-height: 120px;
  resize: vertical;
  border: 1px solid #cfd8e3;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 14px;
  font-family: inherit;
  box-sizing: border-box;
  outline: none;
}
.ait-chat-input:focus {
  border-color: #0a3a77;
}
.ait-chat-send {
  flex-shrink: 0;
  border: 0;
  border-radius: 8px;
  padding: 9px 14px;
  background: #0a7a53;
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.ait-chat-send:disabled {
  background: #8aa99d;
  cursor: not-allowed;
}

/* =========================================================
   Mobile — full-width panel pinned to bottom
   ========================================================= */
@media (max-width: 520px) {
  .ait-chat-toggle {
    right: 12px;
    bottom: 12px;
    padding: 10px 14px;
    font-size: 13px;
  }
  .ait-chat-panel {
    right: 0 !important;
    left: 0 !important;
    bottom: 58px !important;
    width: 100% !important;
    max-width: 100vw !important;
    border-radius: 14px 14px 0 0;
    /* allow taller panel on mobile, user scrolls messages */
    height: 65vh !important;
    max-height: 80vh !important;
  }
  .ait-chat-resize-handle {
    display: none;  /* no resize on mobile */
  }
}
