/* =============================================================================
   BISDEL AI CHAT SUPPORT WIDGET STYLESHEET
   Responsive, Floating, Multi-Tenant Aware, Mobile-Optimized
   ============================================================================= */

:root {
  --bai-primary: #2563eb;
  --bai-primary-hover: #1d4ed8;
  --bai-secondary: #0f172a;
  --bai-accent: #f59e0b;
  --bai-success: #10b981;
  --bai-danger: #ef4444;
  --bai-bg-card: #1e293b;
  --bai-text: #f8fafc;
  --bai-text-muted: #94a3b8;
  --bai-border: rgba(255, 255, 255, 0.1);
  --bai-shadow: 0 20px 40px -15px rgba(0, 0, 0, 0.5);
}

/* Floating Launcher Button */
.bai-launcher {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  box-shadow: 0 8px 25px rgba(37, 99, 235, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 99998;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  border: 2px solid rgba(255, 255, 255, 0.2);
}

.bai-launcher:hover {
  transform: scale(1.08) translateY(-2px);
  box-shadow: 0 12px 30px rgba(37, 99, 235, 0.6);
}

.bai-launcher .bai-launcher-icon {
  font-size: 28px;
  line-height: 1;
  transition: transform 0.3s ease;
}

.bai-launcher .bai-unread-dot {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 14px;
  height: 14px;
  background: #10b981;
  border: 2px solid #0f172a;
  border-radius: 50%;
  animation: baiPulse 2s infinite;
}

@keyframes baiPulse {
  0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
  70% { box-shadow: 0 0 0 8px rgba(16, 185, 129, 0); }
  100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

/* Toast Notification Popup on Screen / Phone */
.bai-toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 999999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 380px;
  width: calc(100% - 40px);
  pointer-events: none;
}

.bai-toast {
  background: #0f172a;
  color: #fff;
  padding: 14px 18px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: flex-start;
  gap: 12px;
  animation: baiSlideIn 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  pointer-events: auto;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.bai-toast.success { border-left: 4px solid #10b981; }
.bai-toast.danger { border-left: 4px solid #ef4444; }
.bai-toast.info { border-left: 4px solid #2563eb; }

@keyframes baiSlideIn {
  from { transform: translateX(100%) scale(0.9); opacity: 0; }
  to { transform: translateX(0) scale(1); opacity: 1; }
}

/* Chat Main Window */
.bai-window {
  position: fixed;
  bottom: 96px;
  right: 24px;
  width: 400px;
  max-width: calc(100vw - 32px);
  height: 600px;
  max-height: calc(100vh - 120px);
  background: #0b1120;
  border: 1px solid var(--bai-border);
  border-radius: 20px;
  box-shadow: var(--bai-shadow);
  display: none;
  flex-direction: column;
  z-index: 99999;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  animation: baiWindowOpen 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.bai-window.active {
  display: flex;
}

@keyframes baiWindowOpen {
  from { transform: scale(0.92) translateY(20px); opacity: 0; }
  to { transform: scale(1) translateY(0); opacity: 1; }
}

/* Header */
.bai-header {
  background: linear-gradient(135deg, #1e293b, #0f172a);
  padding: 16px 18px;
  border-bottom: 1px solid var(--bai-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.bai-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.bai-avatar {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: linear-gradient(135deg, #2563eb, #3b82f6);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.bai-title-area {
  display: flex;
  flex-direction: column;
}

.bai-title-name {
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.2px;
}

.bai-subtitle {
  color: #10b981;
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 5px;
  font-weight: 500;
}

.bai-subtitle .bai-online-pip {
  width: 7px;
  height: 7px;
  background: #10b981;
  border-radius: 50%;
  display: inline-block;
}

.bai-header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.bai-btn-icon {
  background: rgba(255, 255, 255, 0.08);
  border: none;
  color: #cbd5e1;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  transition: all 0.2s ease;
}

.bai-btn-icon:hover {
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
}

/* User & Child Panel Context Ribbon */
.bai-context-ribbon {
  background: rgba(37, 99, 235, 0.15);
  border-bottom: 1px solid rgba(37, 99, 235, 0.25);
  padding: 8px 16px;
  font-size: 12px;
  color: #93c5fd;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Messages Area */
.bai-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  scroll-behavior: smooth;
}

.bai-messages::-webkit-scrollbar {
  width: 5px;
}
.bai-messages::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 10px;
}

.bai-msg-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.bai-msg-row.ai {
  justify-content: flex-start;
}

.bai-msg-row.user {
  justify-content: flex-end;
}

.bai-bubble {
  max-width: 85%;
  padding: 12px 15px;
  border-radius: 16px;
  font-size: 13.5px;
  line-height: 1.5;
  word-break: break-word;
}

.bai-msg-row.ai .bai-bubble {
  background: #1e293b;
  color: #f1f5f9;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-bottom-left-radius: 4px;
}

.bai-msg-row.user .bai-bubble {
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: #ffffff;
  border-bottom-right-radius: 4px;
}

.bai-bubble p {
  margin: 0 0 8px 0;
}
.bai-bubble p:last-child {
  margin-bottom: 0;
}
.bai-bubble code {
  background: rgba(0, 0, 0, 0.3);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: monospace;
  font-size: 12px;
  color: #facc15;
}

/* Quick Action Chips */
.bai-quick-actions {
  padding: 8px 16px 12px;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
}
.bai-quick-actions::-webkit-scrollbar {
  display: none;
}

.bai-chip {
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #e2e8f0;
  padding: 7px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.2s ease;
}

.bai-chip:hover {
  background: var(--bai-primary);
  border-color: var(--bai-primary);
  color: #fff;
  transform: translateY(-1px);
}

/* Typing Indicator */
.bai-typing-dots {
  display: inline-flex;
  gap: 4px;
  align-items: center;
  padding: 6px 10px;
}

.bai-dot {
  width: 6px;
  height: 6px;
  background: #94a3b8;
  border-radius: 50%;
  animation: baiDotBlink 1.4s infinite both;
}

.bai-dot:nth-child(2) { animation-delay: 0.2s; }
.bai-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes baiDotBlink {
  0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); }
  40% { opacity: 1; transform: scale(1.2); }
}

/* Input Area */
.bai-input-area {
  padding: 12px 16px;
  background: #0f172a;
  border-top: 1px solid var(--bai-border);
  display: flex;
  align-items: center;
  gap: 8px;
}

.bai-input {
  flex: 1;
  background: #1e293b;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 25px;
  padding: 10px 16px;
  color: #fff;
  font-size: 13.5px;
  outline: none;
  transition: border-color 0.2s;
}

.bai-input:focus {
  border-color: var(--bai-primary);
}

.bai-btn-send {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--bai-primary);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  transition: all 0.2s;
}

.bai-btn-send:hover {
  background: var(--bai-primary-hover);
  transform: scale(1.05);
}

/* Embedded Action Modals (Inside Chat) */
.bai-action-panel {
  background: #1e293b;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 14px;
  padding: 14px;
  margin-top: 10px;
}

.bai-form-group {
  margin-bottom: 10px;
}

.bai-form-label {
  display: block;
  font-size: 11.5px;
  color: #94a3b8;
  margin-bottom: 4px;
  font-weight: 600;
  text-transform: uppercase;
}

.bai-select, .bai-input-field, .bai-textarea {
  width: 100%;
  background: #0f172a;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  padding: 8px 10px;
  color: #fff;
  font-size: 13px;
  outline: none;
  box-sizing: border-box;
}

.bai-textarea {
  font-family: monospace;
  resize: vertical;
  min-height: 70px;
}

.bai-btn-submit {
  width: 100%;
  background: #10b981;
  color: #fff;
  border: none;
  padding: 9px 12px;
  border-radius: 8px;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.2s;
}

.bai-btn-submit:hover {
  background: #059669;
}

/* Mobile Responsiveness */
@media (max-width: 600px) {
  .bai-window {
    right: 0;
    bottom: 0;
    width: 100vw;
    height: 85vh;
    max-height: 85vh;
    border-radius: 24px 24px 0 0;
  }
  .bai-launcher {
    bottom: 80px; /* Don't cover mobile bottom nav bar */
    right: 18px;
    width: 54px;
    height: 54px;
  }
}

/* Receipt Card & MoMo Checkout Enhancements */
.bai-receipt-card {
  background: #0b1120;
  border: 2px solid #10b981;
  border-radius: 14px;
  padding: 16px;
  margin-top: 10px;
  color: #fff;
}
.bai-receipt-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px dashed rgba(255, 255, 255, 0.2);
  padding-bottom: 10px;
  margin-bottom: 12px;
}
.bai-receipt-row {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
  font-size: 12.5px;
  color: #cbd5e1;
}
.bai-receipt-row strong {
  color: #fff;
}
.bai-radio-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.06);
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
  border: 1px solid rgba(255, 255, 255, 0.12);
  font-size: 12.5px;
  color: #e2e8f0;
}
.bai-radio-pill input[type="radio"] {
  accent-color: #2563eb;
}
.bai-checkbox-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  color: #93c5fd;
  margin-top: 4px;
  cursor: pointer;
}
.bai-checkbox-row input {
  accent-color: #2563eb;
}

/* Rating Card Styles */
.bai-rating-card {
  background: #0f172a;
  border: 1px solid rgba(250, 204, 21, 0.3);
  border-radius: 12px;
  padding: 14px;
  margin-top: 10px;
  text-align: center;
  color: #fff;
}
.bai-rating-title {
  font-size: 13.5px;
  font-weight: 700;
  color: #facc15;
  margin-bottom: 4px;
}
.bai-rating-subtitle {
  font-size: 12px;
  color: #94a3b8;
  margin-bottom: 10px;
}
.bai-stars {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-bottom: 10px;
}
.bai-star-btn {
  background: none;
  border: none;
  font-size: 26px;
  cursor: pointer;
  color: #475569;
  transition: transform 0.15s, color 0.15s;
  padding: 0 4px;
}
.bai-star-btn:hover,
.bai-star-btn.active {
  color: #facc15;
  transform: scale(1.2);
}
.bai-rating-feedback {
  width: 100%;
  box-sizing: border-box;
  background: #1e293b;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  color: #fff;
  padding: 8px 10px;
  font-size: 12px;
  resize: none;
  height: 50px;
  margin-bottom: 8px;
  display: none;
}
.bai-btn-rating-submit {
  width: 100%;
  background: #f59e0b;
  color: #000;
  font-weight: 700;
  border: none;
  border-radius: 6px;
  padding: 7px 12px;
  cursor: pointer;
  font-size: 12.5px;
  display: none;
  transition: background 0.2s;
}
.bai-btn-rating-submit:hover {
  background: #d97706;
}

/* Bulk Data Order System Styles */
.bai-net-selector {
  display: flex;
  gap: 6px;
  margin-bottom: 10px;
}
.bai-net-btn {
  flex: 1;
  padding: 8px 4px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: #0f172a;
  color: #94a3b8;
  font-size: 11.5px;
  font-weight: 700;
  cursor: pointer;
  text-align: center;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}
.bai-net-btn:hover {
  background: #1e293b;
  border-color: #3b82f6;
  color: #fff;
}
.bai-net-btn.active {
  background: #1e40af;
  border-color: #60a5fa;
  color: #fff;
  box-shadow: 0 0 12px rgba(59, 130, 246, 0.35);
}
.bai-bulk-stats-card {
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  padding: 8px 12px;
  margin-top: 6px;
  margin-bottom: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
}
.bai-stat-pill {
  font-weight: 800;
  color: #60a5fa;
}
.bai-stat-cost {
  font-weight: 800;
  color: #34d399;
  font-size: 13.5px;
}
.bai-invalid-notice {
  font-size: 11.5px;
  color: #f87171;
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.2);
  border-radius: 6px;
  padding: 5px 8px;
  margin-top: 6px;
  display: none;
}
