/* chatbot-widget.css - Star Engineering Works: matches site theme (white / logo red / star blue) */
:root {
  --bot-red: #e31820;
  --bot-red-dark: #b8121a;
  --bot-blue: #2b3088;
  --bot-blue-dark: #191c52;
  --bot-bg: #f8fafc;
  --bot-card: #ffffff;
  --bot-line: #e2e8f0;
  --bot-text: #1e293b;
  --bot-muted: #64748b;
  --bot-shadow: 0 10px 30px rgba(25, 28, 82, 0.22);
}

/* ---------- Floating toggle button (right side, above the back-to-top button) ---------- */
.ai-bot-toggle {
  position: fixed;
  right: 12px;
  bottom: 90px;              /* back-to-top is 55px high at bottom:20px, so this sits right above it */
  z-index: 99990;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--bot-blue), var(--bot-blue-dark));
  border: 3px solid #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(25, 28, 82, 0.4);
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}
.ai-bot-toggle:hover { transform: scale(1.08); box-shadow: 0 8px 22px rgba(227, 24, 32, 0.35); }
.ai-bot-toggle svg { width: 38px; height: 38px; }
.ai-bot-toggle::after {
  content: "";
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 2px solid var(--bot-red);
  opacity: 0;
  animation: botPing 2.6s ease-out infinite;
}
@keyframes botPing { 0% { transform: scale(0.85); opacity: 0.6; } 100% { transform: scale(1.3); opacity: 0; } }

/* ---------- Chat window (smaller, right side) ---------- */
.ai-chat-window {
  position: fixed;
  right: 12px;
  bottom: 160px;             /* opens above the bot icon */
  width: 300px;
  max-width: calc(100vw - 24px);
  height: 400px;
  max-height: calc(100vh - 180px);
  background: rgba(255, 255, 255, 0.72);
  -webkit-backdrop-filter: blur(14px) saturate(160%);
  backdrop-filter: blur(14px) saturate(160%);
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.65);
  box-shadow: var(--bot-shadow);
  display: none;
  flex-direction: column;
  overflow: hidden;
  z-index: 99999;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}
.ai-chat-window.open { display: flex !important; animation: botRise 0.25s ease-out; }
@keyframes botRise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

/* ---------- Greeting bubble (shows next to the icon on page load) ---------- */
.ai-greet-bubble {
  position: fixed;
  right: 80px;
  bottom: 100px;
  z-index: 99989;
  display: none;
  align-items: center;
  gap: 8px;
  padding: 9px 10px 9px 14px;
  background: rgba(255, 255, 255, 0.85);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(25, 28, 82, 0.15);
  border-left: 3px solid var(--bot-red);
  border-radius: 12px 12px 4px 12px;
  box-shadow: 0 6px 18px rgba(25, 28, 82, 0.2);
  color: var(--bot-blue-dark);
  font: 600 13px/1.2 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  cursor: pointer;
  white-space: nowrap;
}
.ai-greet-bubble.show { display: flex; animation: botPop 0.35s ease-out; }
.ai-greet-close { background: transparent; border: 0; color: var(--bot-muted); font-size: 16px; line-height: 1; cursor: pointer; padding: 0 2px; }
.ai-greet-close:hover { color: var(--bot-red); }
@keyframes botPop { from { opacity: 0; transform: translateX(10px) scale(0.95); } to { opacity: 1; transform: none; } }

/* ---------- Header ---------- */
.ai-chat-header {
  background: linear-gradient(90deg, rgba(25, 28, 82, 0.92), rgba(43, 48, 136, 0.88));
  color: #fff;
  padding: 8px 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  border-bottom: 3px solid var(--bot-red);
}
.ai-chat-header .head-avatar {
  width: 34px; height: 34px; flex-shrink: 0; border-radius: 50%;
  background: rgba(255, 255, 255, 0.12); border: 1px solid rgba(255, 255, 255, 0.35);
  display: flex; align-items: center; justify-content: center;
}
.ai-chat-header .head-avatar svg { width: 26px; height: 26px; }
.ai-chat-header .title-box { flex: 1; min-width: 0; }
.ai-chat-header .title-box strong {
  display: block; font-size: 13px; font-weight: 700; letter-spacing: 0.4px;
  text-transform: uppercase; color: #fff;
}
.bot-status {
  display: flex; align-items: center; gap: 6px; margin-top: 1px;
  font-size: 10px; letter-spacing: 1px; color: #bbf7d0;
}
.bot-status i {
  width: 7px; height: 7px; border-radius: 50%; background: #4ade80;
  box-shadow: 0 0 6px #4ade80; animation: botBlink 1.8s ease-in-out infinite;
}
@keyframes botBlink { 50% { opacity: 0.35; } }
.ai-chat-close {
  background: transparent; border: 0; border-radius: 6px;
  color: #fff; font-size: 22px; line-height: 1; cursor: pointer; padding: 2px 8px; opacity: 0.85;
}
.ai-chat-close:hover { opacity: 1; background: rgba(255, 255, 255, 0.15); }

/* ---------- Messages area ---------- */
.ai-chat-messages {
  flex: 1;
  padding: 12px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 9px;
  background: transparent;
  scrollbar-width: thin;
  scrollbar-color: #cbd5e1 transparent;
}

/* ---------- Hero ---------- */
.robo-hero-box {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: linear-gradient(135deg, var(--bot-blue), var(--bot-blue-dark));
  border-radius: 10px;
  border-left: 4px solid var(--bot-red);
  padding: 11px 12px;
  box-shadow: 0 4px 12px rgba(25, 28, 82, 0.2);
}
.robo-hero-text { flex: 1; }
.robo-hero-title {
  margin: 0; font-size: 14px; font-weight: 800; line-height: 1.3;
  color: #fff; letter-spacing: 0.5px; text-transform: uppercase;
}
.robo-hero-sub { margin: 4px 0 0; font-size: 11px; color: #cbd5f5; line-height: 1.4; }
.robo-bot-badge {
  width: 52px; height: 52px; flex-shrink: 0; border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  border: 2px solid rgba(255, 255, 255, 0.5);
  display: flex; align-items: center; justify-content: center;
  animation: botFloat 3.2s ease-in-out infinite;
}
.robo-bot-badge svg { width: 38px; height: 38px; }
@keyframes botFloat { 50% { transform: translateY(-3px); } }

/* Robot SVG parts */
.bot-eye { transform-box: fill-box; transform-origin: center; animation: botEyes 4.5s infinite; }
@keyframes botEyes { 0%, 92%, 100% { transform: scaleY(1); } 95% { transform: scaleY(0.1); } }
.bot-ant { animation: botBlink 1.4s ease-in-out infinite; }

/* ---------- Option buttons & chips ---------- */
.robo-options-list, .robo-chips { display: flex; flex-direction: column; gap: 7px; }
.robo-chips { flex-direction: row; flex-wrap: wrap; gap: 6px; align-self: flex-start; max-width: 100%; }

.robo-option-btn, .robo-chip {
  position: relative;
  background: rgba(255, 255, 255, 0.8);
  border: 1px solid rgba(25, 28, 82, 0.15);
  color: var(--bot-blue-dark);
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.18s ease;
  border-radius: 8px;
}
.robo-option-btn { width: 100%; padding: 9px 12px 9px 28px; font-size: 12.5px; text-align: left; }
.robo-option-btn::before {
  content: "\203A"; position: absolute; left: 12px; top: 50%; transform: translateY(-52%);
  color: var(--bot-red); font-size: 17px; font-weight: 800;
}
.robo-chip { padding: 6px 12px; font-size: 12px; border-radius: 16px; }
.robo-option-btn:hover, .robo-chip:hover {
  background: var(--bot-blue); border-color: var(--bot-blue); color: #fff;
  box-shadow: 0 3px 10px rgba(43, 48, 136, 0.25);
}
.robo-chip.primary { background: var(--bot-red); border-color: var(--bot-red); color: #fff; }
.robo-chip.primary:hover { background: var(--bot-red-dark); border-color: var(--bot-red-dark); box-shadow: 0 3px 10px rgba(227, 24, 32, 0.35); }

/* ---------- Bubbles ---------- */
.ai-msg {
  max-width: 88%; padding: 9px 12px; border-radius: 12px;
  font-size: 12.8px; line-height: 1.5; word-break: break-word;
}
.ai-msg.bot {
  background: rgba(255, 255, 255, 0.85); color: var(--bot-text); align-self: flex-start;
  border: 1px solid rgba(25, 28, 82, 0.12); border-left: 3px solid var(--bot-blue);
  border-bottom-left-radius: 4px; box-shadow: 0 1px 4px rgba(15, 23, 42, 0.06);
}
.ai-msg.user {
  background: var(--bot-red); color: #fff; align-self: flex-end;
  border-bottom-right-radius: 4px; box-shadow: 0 2px 8px rgba(227, 24, 32, 0.25);
}
.ai-msg.bot a { color: var(--bot-red); font-weight: 700; text-decoration: underline; white-space: nowrap; }
.ai-msg.bot a:hover { color: var(--bot-blue); }
.ai-msg.bot strong { color: var(--bot-blue-dark); }

/* Typing dots */
.ai-msg.typing { display: flex; gap: 5px; align-items: center; padding: 11px 13px; }
.ai-msg.typing span {
  width: 7px; height: 7px; border-radius: 50%; background: var(--bot-blue);
  animation: botDots 1.1s infinite ease-in-out;
}
.ai-msg.typing span:nth-child(2) { animation-delay: 0.15s; }
.ai-msg.typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes botDots { 0%, 80%, 100% { opacity: 0.25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-4px); } }

/* ---------- Input bar ---------- */
.ai-chat-input-area {
  display: flex; align-items: center; gap: 8px; padding: 9px 10px;
  background: rgba(255, 255, 255, 0.6); border-top: 1px solid rgba(25, 28, 82, 0.12);
}
.ai-chat-input-area input {
  flex: 1; height: 36px; border: 1px solid var(--bot-line); border-radius: 18px;
  padding: 0 14px; font-size: 13px; color: var(--bot-text); background: rgba(255, 255, 255, 0.85); outline: none;
}
.ai-chat-input-area input::placeholder { color: #94a3b8; }
.ai-chat-input-area input:focus { border-color: var(--bot-blue); box-shadow: 0 0 0 3px rgba(43, 48, 136, 0.12); background: #fff; }
.ai-chat-input-area button {
  background: var(--bot-red); color: #fff; border: none; border-radius: 50%;
  width: 36px; height: 36px; display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: background 0.2s ease;
}
.ai-chat-input-area button:hover { background: var(--bot-red-dark); }
.ai-chat-input-area button:disabled, .ai-chat-input-area input:disabled { opacity: 0.55; cursor: not-allowed; }

@media (max-width: 480px) {
  .ai-chat-window { right: 10px; bottom: 150px; width: min(300px, calc(100vw - 20px)); max-width: none; height: 380px; max-height: calc(100vh - 170px); }
  .ai-greet-bubble { right: 72px; bottom: 92px; }
  .ai-bot-toggle { right: 10px; bottom: 84px; width: 54px; height: 54px; }
  .ai-bot-toggle svg { width: 34px; height: 34px; }
}
@media (prefers-reduced-motion: reduce) {
  .ai-bot-toggle::after, .robo-bot-badge, .bot-eye, .bot-ant, .bot-status i, .ai-msg.typing span { animation: none !important; }
}
