/* =============================================
   SDI Transport AI Chatbot – UI Styles
   ============================================= */

:root {
  --sdi-primary:     #1a3a6b;
  --sdi-primary-dk:  #0f2548;
  --sdi-accent:      #e8a020;
  --sdi-accent-dk:   #c8880e;
  --sdi-white:       #ffffff;
  --sdi-bg:          #f4f6fa;
  --sdi-border:      #e0e6f0;
  --sdi-text:        #1c2840;
  --sdi-text-light:  #6b7a99;
  --sdi-bot-bubble:  #ffffff;
  --sdi-user-bubble: #1a3a6b;
  --sdi-shadow:      0 8px 40px rgba(26,58,107,0.18);
  --sdi-radius:      18px;
  --sdi-radius-sm:   10px;
  --sdi-transition:  0.25s cubic-bezier(0.4,0,0.2,1);
}

/* ── Widget Container ── */
#sdi-chat-widget {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 999999;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

/* ── Bubble Button ── */
#sdi-chat-bubble {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--sdi-primary) 0%, #2a5298 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(26,58,107,0.4);
  transition: transform var(--sdi-transition), box-shadow var(--sdi-transition);
  position: relative;
  margin-left: auto;
}

#sdi-chat-bubble:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 28px rgba(26,58,107,0.5);
}

#sdi-chat-bubble:active { transform: scale(0.96); }

#sdi-chat-bubble svg {
  width: 26px;
  height: 26px;
  color: var(--sdi-white);
  stroke: var(--sdi-white);
}

/* Pulse animation on bubble */
#sdi-chat-bubble::before {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  background: rgba(26,58,107,0.25);
  animation: sdi-pulse 2.5s ease-out infinite;
}

@keyframes sdi-pulse {
  0%   { transform: scale(1); opacity: 0.6; }
  70%  { transform: scale(1.35); opacity: 0; }
  100% { transform: scale(1.35); opacity: 0; }
}

#sdi-unread-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: #e53e3e;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #fff;
}

/* ── Chat Window ── */
#sdi-chat-window {
  width: 370px;
  max-width: calc(100vw - 48px);
  height: 560px;
  max-height: calc(100vh - 110px);
  background: var(--sdi-white);
  border-radius: var(--sdi-radius);
  box-shadow: var(--sdi-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  margin-bottom: 16px;
  animation: sdi-slide-up 0.3s cubic-bezier(0.4,0,0.2,1);
  border: 1px solid var(--sdi-border);
}

@keyframes sdi-slide-up {
  from { opacity: 0; transform: translateY(20px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ── Header ── */
#sdi-chat-header {
  background: linear-gradient(135deg, var(--sdi-primary) 0%, #2a5298 100%);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

#sdi-chat-header-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

#sdi-chat-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: rgba(255,255,255,0.18);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid rgba(255,255,255,0.35);
  flex-shrink: 0;
}

#sdi-chat-avatar svg {
  width: 22px;
  height: 22px;
  fill: var(--sdi-white);
}

#sdi-chat-name {
  color: var(--sdi-white);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.01em;
}

#sdi-chat-status {
  color: rgba(255,255,255,0.8);
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 1px;
}

.sdi-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #48bb78;
  display: inline-block;
  animation: sdi-blink 2s ease-in-out infinite;
}

@keyframes sdi-blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.4; }
}

#sdi-chat-minimize {
  background: rgba(255,255,255,0.15);
  border: none;
  border-radius: 8px;
  width: 32px;
  height: 32px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--sdi-transition);
  flex-shrink: 0;
}

#sdi-chat-minimize:hover { background: rgba(255,255,255,0.28); }
#sdi-chat-minimize svg {
  width: 16px;
  height: 16px;
  stroke: var(--sdi-white);
}

/* ── Mode Containers ── */
#sdi-chat-mode-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#sdi-prechat-form, #sdi-calc-container {
  flex: 1;
  overflow-y: auto;
}

/* ── Messages Area ── */
#sdi-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--sdi-bg);
  scroll-behavior: smooth;
}

#sdi-chat-messages::-webkit-scrollbar { width: 4px; }
#sdi-chat-messages::-webkit-scrollbar-track { background: transparent; }
#sdi-chat-messages::-webkit-scrollbar-thumb {
  background: var(--sdi-border);
  border-radius: 4px;
}

/* ── Message Bubbles ── */
.sdi-msg {
  display: flex;
  flex-direction: column;
  max-width: 82%;
  animation: sdi-msg-in 0.2s ease;
}

@keyframes sdi-msg-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.sdi-msg-bot  { align-self: flex-start; }
.sdi-msg-user { align-self: flex-end; }

.sdi-msg-bubble {
  padding: 11px 14px;
  border-radius: 16px;
  line-height: 1.55;
  word-break: break-word;
}

.sdi-msg-bot .sdi-msg-bubble {
  background: var(--sdi-bot-bubble);
  color: var(--sdi-text);
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
  border: 1px solid var(--sdi-border);
}

.sdi-msg-user .sdi-msg-bubble {
  background: var(--sdi-user-bubble);
  color: var(--sdi-white);
  border-bottom-right-radius: 4px;
}

.sdi-msg-time {
  font-size: 11px;
  color: var(--sdi-text-light);
  margin-top: 3px;
  padding: 0 4px;
}

.sdi-msg-bot .sdi-msg-time  { text-align: left; }
.sdi-msg-user .sdi-msg-time { text-align: right; }

/* Typing indicator */
.sdi-typing .sdi-msg-bubble {
  padding: 14px 18px;
}

.sdi-typing-dots {
  display: flex;
  gap: 5px;
  align-items: center;
}

.sdi-typing-dots span {
  width: 7px;
  height: 7px;
  background: var(--sdi-text-light);
  border-radius: 50%;
  animation: sdi-dot-bounce 1.2s infinite;
}

.sdi-typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.sdi-typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes sdi-dot-bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.5; }
  40%            { transform: translateY(-6px); opacity: 1; }
}

/* ── Quick Replies ── */
#sdi-quick-replies {
  display: flex;
  gap: 7px;
  padding: 10px 14px 6px;
  overflow-x: auto;
  flex-shrink: 0;
  background: var(--sdi-bg);
  border-top: 1px solid var(--sdi-border);
}

#sdi-quick-replies::-webkit-scrollbar { display: none; }

.sdi-quick-btn {
  white-space: nowrap;
  background: var(--sdi-white);
  color: var(--sdi-primary);
  border: 1.5px solid var(--sdi-primary);
  border-radius: 20px;
  padding: 6px 13px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--sdi-transition);
  flex-shrink: 0;
}

.sdi-quick-btn:hover {
  background: var(--sdi-primary);
  color: var(--sdi-white);
  transform: translateY(-1px);
}

/* ── Input Area ── */
#sdi-chat-input-area {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 12px 12px;
  background: var(--sdi-white);
  border-top: 1px solid var(--sdi-border);
  flex-shrink: 0;
}

#sdi-chat-input {
  flex: 1;
  border: 1.5px solid var(--sdi-border);
  border-radius: 22px;
  padding: 9px 14px;
  font-size: 14px;
  font-family: inherit;
  color: var(--sdi-text);
  resize: none;
  outline: none;
  max-height: 100px;
  overflow-y: auto;
  transition: border-color var(--sdi-transition);
  background: var(--sdi-bg);
  line-height: 1.4;
}

#sdi-chat-input:focus {
  border-color: var(--sdi-primary);
  background: var(--sdi-white);
}

#sdi-chat-input::placeholder { color: var(--sdi-text-light); }

#sdi-chat-send {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--sdi-primary);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--sdi-transition);
  flex-shrink: 0;
}

#sdi-chat-send:hover {
  background: var(--sdi-primary-dk);
  transform: scale(1.05);
}

#sdi-chat-send:disabled {
  background: var(--sdi-border);
  cursor: not-allowed;
  transform: none;
}

#sdi-chat-send svg {
  width: 18px;
  height: 18px;
  fill: var(--sdi-white);
}

/* ── Footer ── */
#sdi-chat-footer {
  background: var(--sdi-white);
  text-align: center;
  padding: 6px 12px 10px;
  font-size: 11px;
  color: var(--sdi-text-light);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  border-top: 1px solid var(--sdi-border);
  flex-shrink: 0;
}

.sdi-wa-link {
  display: flex;
  align-items: center;
  gap: 4px;
  color: #25D366;
  text-decoration: none;
  font-weight: 600;
  font-size: 12px;
  transition: opacity var(--sdi-transition);
}

.sdi-wa-link:hover { opacity: 0.75; }

/* ── Markdown-like formatting in bot messages ── */
.sdi-msg-bot .sdi-msg-bubble strong { font-weight: 700; }
.sdi-msg-bot .sdi-msg-bubble br { display: block; margin: 2px 0; }

/* ── Mobile responsive ── */
@media (max-width: 480px) {
  #sdi-chat-widget {
    bottom: 12px;
    right: 12px;
  }

  #sdi-chat-window {
    width: calc(100vw - 24px);
    height: calc(100vh - 90px);
    height: calc(100dvh - 90px);
    max-height: calc(100vh - 90px);
    max-height: calc(100dvh - 90px);
    border-radius: 16px;
    margin-bottom: 12px;
  }
}

/* ── Action Buttons (Booking / WhatsApp) ── */
.sdi-action-btn {
  display: inline-block;
  margin-top: 6px;
  padding: 9px 18px;
  background: var(--sdi-primary);
  color: var(--sdi-white);
  border-radius: 20px;
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  transition: background var(--sdi-transition);
}

.sdi-action-btn:hover {
  background: var(--sdi-primary-dk);
  color: var(--sdi-white);
}

.sdi-wa-action { background: #25D366; }
.sdi-wa-action:hover { background: #1da851; }

.sdi-bullet {
  display: block;
  padding-left: 4px;
  margin: 2px 0;
}

/* ── Feedback Buttons ── */
.sdi-msg-feedback { display: flex; gap: 8px; margin-top: 4px; margin-left: 10px; font-size: 11px; color: var(--sdi-text-light); }
.sdi-feedback-btn { background: none; border: none; padding: 2px; cursor: pointer; opacity: 0.6; font-size: 14px; transition: opacity 0.2s, transform 0.2s; }
.sdi-feedback-btn:hover { opacity: 1; transform: scale(1.1); }

/* ── Pre-Chat Form ── */
#sdi-prechat-form { padding: 20px; display: flex; flex-direction: column; gap: 12px; }
#sdi-prechat-form h4 { margin: 0 0 10px 0; color: var(--sdi-text); font-size: 16px; font-weight: 600; }
#sdi-prechat-form p { margin: 0; font-size: 13px; color: var(--sdi-text-light); line-height: 1.4; }
.sdi-form-group { display: flex; flex-direction: column; gap: 6px; }
.sdi-form-group label { font-size: 12px; font-weight: 500; color: var(--sdi-text); }
.sdi-form-input { padding: 10px 12px; border: 1px solid var(--sdi-border); border-radius: 8px; font-family: inherit; font-size: 13px; outline: none; transition: border-color 0.2s; }
.sdi-form-input:focus { border-color: var(--sdi-primary); }
#sdi-start-chat-btn { background: var(--sdi-primary); color: var(--sdi-white); border: none; border-radius: 8px; padding: 12px; font-weight: 600; font-size: 14px; cursor: pointer; margin-top: 8px; transition: background 0.2s; }
#sdi-start-chat-btn:hover { background: var(--sdi-primary-dk); }

/* ── Quick Calculator Mode ── */
#sdi-calc-container { display: none; background: var(--sdi-bg); }
#sdi-calculator-mode { padding: 20px; background: var(--sdi-white); border-radius: 12px; margin: 15px; box-shadow: 0 2px 10px rgba(0,0,0,0.05); }
.sdi-calc-group { margin-bottom: 15px; }
.sdi-calc-group label { display: block; font-size: 12px; font-weight: 600; margin-bottom: 6px; color: var(--sdi-text); }
#sdi-calculator-mode select,
#sdi-calculator-mode .sdi-calc-input { width: 100%; padding: 10px 32px 10px 10px; border: 1px solid var(--sdi-border); border-radius: 6px; background: var(--sdi-white); font-family: inherit; font-size: 13px; box-sizing: border-box; }
#sdi-calculator-mode .sdi-calc-input:focus { outline: none; border-color: var(--sdi-primary); }
.sdi-autocomplete-group { position: relative; }
.sdi-autocomplete-wrap { position: relative; }
.sdi-autocomplete-wrap::after {
  content: '';
  position: absolute;
  right: 12px;
  top: 50%;
  margin-top: -3px;
  border: 5px solid transparent;
  border-top-color: var(--sdi-text-light);
  pointer-events: none;
}
.sdi-autocomplete-list {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  z-index: 10;
  margin: 0;
  padding: 4px 0;
  list-style: none;
  max-height: 180px;
  overflow-y: auto;
  background: var(--sdi-white);
  border: 1px solid var(--sdi-border);
  border-radius: 6px;
  box-shadow: 0 4px 16px rgba(26, 58, 107, 0.15);
}
.sdi-autocomplete-list li {
  padding: 8px 12px;
  font-size: 13px;
  color: var(--sdi-text);
  cursor: pointer;
  line-height: 1.3;
}
.sdi-autocomplete-list li:hover,
.sdi-autocomplete-list li.sdi-ac-active {
  background: rgba(30, 64, 175, 0.08);
  color: var(--sdi-primary);
}
.sdi-autocomplete-list li.sdi-ac-empty {
  cursor: default;
  color: var(--sdi-text-light);
  font-style: italic;
}
.sdi-autocomplete-list li.sdi-ac-empty:hover { background: transparent; color: var(--sdi-text-light); }
#sdi-calc-result { margin-top: 20px; padding: 15px; background: rgba(37, 211, 102, 0.1); border-left: 4px solid #25D366; border-radius: 4px; font-weight: 600; font-size: 15px; text-align: center; display: none; }
.sdi-tab-bar { display: flex; border-bottom: 1px solid var(--sdi-border); background: var(--sdi-white); border-radius: 16px 16px 0 0; overflow: hidden; flex-shrink: 0; }
.sdi-tab { flex: 1; text-align: center; padding: 12px; font-size: 13px; font-weight: 600; color: var(--sdi-text-light); cursor: pointer; border-bottom: 2px solid transparent; transition: all 0.2s; }
.sdi-tab.active { color: var(--sdi-primary); border-bottom-color: var(--sdi-primary); background: rgba(30, 64, 175, 0.05); }
