/* Chat Box Container */
#aisys-chat-box {
  font-family: 'Questrial', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 360px;
  max-height: 550px;
  background: #ffffff;
  border-radius: 14px;
  display: none;
  flex-direction: column;
  box-shadow: 0 10px 28px rgba(0,0,0,0.15);
  overflow: hidden;
  animation: aisysSlideUp 0.25s ease-out;
  z-index: 99998;
}

@keyframes aisysSlideUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Header */
.aisys-header {
  background: #721530;
  color: #fff;
  padding: 14px 16px;
  font-size: 15px;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: space-between;   /* ⭐ keep left and right groups separate */
  gap: 10px;
}

.aisys-header svg { width: 22px; height: 22px; }

/* ⭐ Right-side icon group */
.aisys-header-right {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}

/* ⭐ Sound toggle button — fixed vertical centering + square hitbox */
.aisys-sound-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;              /* perfect square */
  height: 24px;
  padding: 0;               /* remove excess padding */
  border-radius: 4px;
  cursor: pointer;
}

.aisys-sound-btn svg {
  width: 20px;
  height: 20px;
}

.aisys-sound-btn:hover {
  background: rgba(255,255,255,0.2);
}

/* ⭐ Minimise button — fixed vertical alignment */
.aisys-min-btn {
  display: flex;
  align-items: center;     /* vertical centering */
  justify-content: center; /* horizontal centering */
  width: 26px;             /* visually matched to sound button */
  height: 26px;
  padding: 0;              /* remove old uneven padding */
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  color: #fff;
  border-radius: 4px;
  line-height: 1;
  cursor: pointer;
  user-select: none;
}

.aisys-min-btn:hover {
  background: rgba(255,255,255,0.2);
}

/* Messages */
#aisys-chat-messages {
  padding: 12px;
  height: 380px;
  overflow-y: auto;
  font-size: 14px;
  line-height: 1.45;
}

/* Input */
.aisys-input-wrap { border-top: 1px solid #ddd; }

#aisys-chat-input {
  width: 100%;
  padding: 12px;
  border: none;
  font-size: 14px;
}
#aisys-chat-input:focus { outline: none; }

/* Typing dots */
.aisys-typing-dot {
  width: 6px;
  height: 6px;
  margin: 0 2px;
  background: #444;
  border-radius: 50%;
  display: inline-block;
  animation: aisysDotBounce 1.2s infinite;
}
.aisys-typing-dot:nth-child(2) { animation-delay: .15s }
.aisys-typing-dot:nth-child(3) { animation-delay: .3s }

@keyframes aisysDotBounce {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-5px); }
}

#aisys-msg { min-height: 100px; }

/* --- Chat Launcher (bubble + label) --- */
#aisys-chat-launch {
  position: fixed;
  bottom: 20px;
  right: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  z-index: 99999;
  cursor: pointer;
}

/* Bubble button */
#aisys-chat-btn {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: #721530;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  color: white;
  box-shadow: 0 6px 18px rgba(0,0,0,0.25);
  transition: 0.2s ease;
}

#aisys-chat-btn:hover { transform: scale(1.07); }

/* Label */
#aisys-chat-label {
  background: #fff;
  color: #721530;
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  font-family: 'Questrial', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  box-shadow: 0 4px 12px rgba(0,0,0,.15);
  white-space: nowrap;
  animation: aisysFadeIn .3s ease;
}

@media(max-width:500px) {
  #aisys-chat-label { display:none; }
}

@keyframes aisysFadeIn {
  from { opacity:0; transform:translateY(4px); }
  to   { opacity:1; transform:translateY(0); }
}

/* Chat message bubbles */
.aisys-msg {
  margin: 6px 0;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 14px;
  line-height: 1.45;
}

.aisys-ai {
  background: #f7f2f2;
  color: #3b1c1c;
}

.aisys-user {
  background: #eef1f5;
  color: #2a2f36;
  text-align: right;
}

.aisys-msg b {
  color: #721530;
  font-weight: 600;
}

/* Contact Form styles */
#aisys-contact-form {
  display:none;
  padding: 14px;
  background: #fafafa;
  border-top: 1px solid #ddd;
  font-family: 'Questrial', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

#aisys-contact-form input,
#aisys-contact-form textarea {
  width: 100%;
  padding: 10px;
  margin-bottom: 8px;
  font-size: 14px;
  border: 1px solid #ccc;
  border-radius: 6px;
  outline: none;
  box-sizing: border-box;
}

#aisys-contact-form input:focus,
#aisys-contact-form textarea:focus {
  border-color: #721530;
}

#aisys-contact-form button {
  width: 100%;
  padding: 10px;
  background: #721530;
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: 0.2s;
}

#aisys-contact-form button:hover {
  background: #962047;
}

/* Avatar inside header */
.aisys-header .aisys-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  object-fit: cover;
}

/* Hide chat label on small screens */
@media (max-width: 580px) {
  #aisys-chat-label {
    display: none !important;
  }
}

/* --- Send Button --- */
.aisys-send-btn {
  background: #721530;
  border: none;
  color: #fff;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  cursor: pointer;
  margin-right: 10px;
}

.aisys-send-btn:hover {
  background: #962047;
}

.aisys-input-container {
  display: flex;
  align-items: center;
  border-top: 1px solid #ddd;
}

.aisys-msg.aisys-ai {
    white-space: pre-wrap;
}

.aisys-msg ul + br {
  display: none; /* hides an immediate trailing <br> if present */
}

.aisys-send-btn,
#aisys-send-btn {
  background: #721530;
  border: none;
  color: #fff;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  cursor: pointer;
  margin-right: 10px;
}

.aisys-send-btn:hover,
#aisys-send-btn:hover {
  background: #962047;
}

.aisys-send-btn svg,
#aisys-send-btn svg {
  width: 20px;
  height: 20px;
  display: block !important;
}

@media (max-width: 420px) {

  #aisys-chat-box {
    right: 8px;
    left: 8px;               /* allow it to shrink instead of overflow */
    width: auto;             /* override fixed 360px */
    max-width: none;

    bottom: calc(8px + env(safe-area-inset-bottom));
    max-height: calc(100vh - 16px);
    box-sizing: border-box;
  }

  #aisys-chat-messages {
    height: auto;
    max-height: calc(100vh - 220px); /* header + input + safe breathing room */
  }

}