/* ==========================================================================
   Customer Service & Booking Representative Widget (فهد — خدمة العملاء والحجوزات)
   Compact Floating Widget Stylesheet
   ========================================================================== */

:root {
  --ai-primary: #059669;
  --ai-primary-dark: #047857;
  --ai-accent: #d97706;
  --ai-bg-bubble: #ffffff;
  --ai-bg-user: #ecfdf5;
  --ai-bg-bot: #f8fafc;
  --ai-border: #e2e8f0;
  --ai-text-main: #0f172a;
  --ai-text-muted: #64748b;
}

/* Floating Trigger Button (Positioned above fixed bottom bar) */
.ai-bot-trigger {
  position: fixed;
  bottom: calc(68px + env(safe-area-inset-bottom, 0px));
  right: 14px;
  z-index: 9998;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: linear-gradient(135deg, #059669 0%, #047857 100%) !important;
  color: #ffffff !important;
  padding: 6px 12px;
  border-radius: 9999px;
  border: 1.5px solid #a7f3d0;
  box-shadow: 0 4px 14px rgba(5, 150, 105, 0.35);
  cursor: pointer;
  font-family: 'Cairo', system-ui, -apple-system, sans-serif;
  font-size: 11.5px;
  font-weight: 700;
  direction: rtl;
  transition: all 0.2s ease;
  text-decoration: none;
}

.ai-bot-trigger:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 18px rgba(5, 150, 105, 0.45);
}

.ai-bot-trigger .ai-pulse-dot {
  position: relative;
  display: flex;
  width: 7px;
  height: 7px;
}

.ai-bot-trigger .ai-pulse-dot span:first-child {
  position: absolute;
  display: inline-flex;
  height: 100%;
  width: 100%;
  border-radius: 9999px;
  background-color: #34d399;
  opacity: 0.75;
  animation: ai-ping 1.5s cubic-bezier(0, 0, 0.2, 1) infinite;
}

.ai-bot-trigger .ai-pulse-dot span:last-child {
  position: relative;
  display: inline-flex;
  border-radius: 9999px;
  height: 7px;
  width: 7px;
  background-color: #10b981;
}

@keyframes ai-ping {
  75%, 100% {
    transform: scale(2);
    opacity: 0;
  }
}

/* Compact Chat Window (Positioned above fixed bottom bar) */
.ai-bot-window {
  position: fixed;
  bottom: calc(68px + env(safe-area-inset-bottom, 0px));
  right: 14px;
  width: 320px;
  max-width: calc(100vw - 28px);
  height: 420px;
  max-height: calc(100vh - 120px);
  background: #ffffff;
  border-radius: 16px;
  box-shadow: 0 16px 36px -8px rgba(0, 0, 0, 0.28);
  border: 1px solid #cbd5e1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 9999;
  direction: rtl;
  font-family: 'Cairo', system-ui, -apple-system, sans-serif;
  opacity: 0;
  transform: scale(0.95) translateY(12px);
  pointer-events: none;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.ai-bot-window.ai-open {
  opacity: 1;
  transform: scale(1) translateY(0);
  pointer-events: auto;
}

/* Compact Window Header */
.ai-bot-header {
  background: linear-gradient(135deg, #065f46 0%, #047857 100%);
  color: #ffffff;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #059669;
}

.ai-bot-header-info {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ai-bot-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #ffffff;
  color: #065f46;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  border: 1.5px solid #a7f3d0;
  flex-shrink: 0;
}

.ai-bot-title {
  font-size: 12.5px;
  font-weight: 800;
  line-height: 1.2;
}

.ai-bot-status {
  font-size: 10px;
  color: #a7f3d0;
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 1px;
}

.ai-bot-status::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #34d399;
}

.ai-bot-close-btn {
  background: rgba(255, 255, 255, 0.15);
  border: none;
  color: #ffffff;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 13px;
  transition: all 0.2s;
}

.ai-bot-close-btn:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* Chat Messages Stream */
.ai-bot-messages {
  flex: 1;
  padding: 10px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: #f8fafc;
  scroll-behavior: smooth;
}

/* Message Bubbles */
.ai-msg {
  display: flex;
  flex-direction: column;
  max-width: 88%;
  animation: ai-slide-in 0.2s ease-out;
}

@keyframes ai-slide-in {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: translateY(0); }
}

.ai-msg-bot {
  align-self: flex-start;
}

.ai-msg-user {
  align-self: flex-end;
}

.ai-msg-bubble {
  padding: 8px 11px;
  border-radius: 13px;
  font-size: 12px;
  line-height: 1.55;
  word-break: break-word;
  white-space: pre-line;
}

.ai-msg-bot .ai-msg-bubble {
  background: #ffffff;
  color: #1e293b;
  border-bottom-right-radius: 4px;
  border: 1px solid #e2e8f0;
  box-shadow: 0 1px 2px rgba(0,0,0,0.03);
}

.ai-msg-user .ai-msg-bubble {
  background: linear-gradient(135deg, #059669 0%, #047857 100%);
  color: #ffffff;
  border-bottom-left-radius: 4px;
}

.ai-msg-time {
  font-size: 9px;
  color: #94a3b8;
  margin-top: 2px;
  padding: 0 4px;
}

.ai-msg-user .ai-msg-time {
  text-align: left;
}

/* In-Chat Confirm Box */
.ai-confirm-box {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.ai-confirm-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 12px;
  background: linear-gradient(135deg, #059669 0%, #047857 100%);
  color: #ffffff !important;
  border: 1.5px solid #a7f3d0;
  border-radius: 9px;
  font-size: 11.5px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(5, 150, 105, 0.3);
  transition: all 0.2s ease;
  font-family: inherit;
  width: 100%;
}

.ai-confirm-btn:hover {
  background: #065f46;
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(5, 150, 105, 0.45);
}

.ai-confirm-hint {
  font-size: 9.5px;
  color: #64748b;
  text-align: center;
}

/* In-Chat Electronic Ticket Card */
.ai-ticket-card {
  margin-top: 8px;
  background: #ffffff;
  border: 1.5px solid #10b981;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 4px 16px rgba(16, 185, 129, 0.15);
  font-family: inherit;
  direction: rtl;
}

.ai-ticket-header {
  background: linear-gradient(135deg, #065f46 0%, #047857 100%);
  color: #ffffff;
  padding: 8px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.ai-ticket-badge {
  font-size: 11px;
  font-weight: 800;
  color: #d1fae5;
}

.ai-ticket-number {
  font-size: 10px;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.2);
  padding: 2px 6px;
  border-radius: 5px;
  letter-spacing: 0.5px;
}

.ai-ticket-body {
  padding: 9px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 11px;
  color: #1e293b;
  background: #f8fafc;
}

.ai-ticket-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px dashed #e2e8f0;
  padding-bottom: 3px;
}

.ai-ticket-row span {
  color: #64748b;
  font-size: 10.5px;
}

.ai-ticket-row strong {
  color: #0f172a;
  font-weight: 700;
}

.ai-ticket-total {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 4px;
  padding-top: 5px;
  border-top: 1.5px solid #cbd5e1;
  font-size: 11.5px;
  font-weight: 800;
  color: #065f46;
}

.ai-ticket-total strong {
  font-size: 13px;
  color: #047857;
}

.ai-ticket-status {
  font-size: 9.5px;
  color: #059669;
  font-weight: 700;
  text-align: center;
  background: #ecfdf5;
  padding: 4px;
  border-radius: 5px;
  margin-top: 2px;
}

.ai-ticket-actions {
  padding: 7px 10px;
  background: #ffffff;
  border-top: 1px solid #e2e8f0;
  text-align: center;
}

.ai-ticket-btn-primary {
  display: block;
  width: 100%;
  padding: 7px 10px;
  background: linear-gradient(135deg, #059669 0%, #047857 100%);
  color: #ffffff !important;
  border-radius: 7px;
  font-size: 11px;
  font-weight: 800;
  text-decoration: none !important;
  text-align: center;
  transition: transform 0.15s;
}

.ai-ticket-btn-primary:hover {
  transform: translateY(-1px);
  filter: brightness(1.05);
}

/* Typing Indicator */
.ai-typing {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 7px 11px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  width: fit-content;
}

.ai-typing-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #059669;
  opacity: 0.4;
  animation: ai-blink 1.4s infinite both;
}

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

@keyframes ai-blink {
  0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); }
  40% { opacity: 1; transform: scale(1.1); }
}

/* Compact Chat Input Bar */
.ai-bot-footer {
  padding: 7px 9px;
  background: #ffffff;
  border-top: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  gap: 5px;
}

.ai-bot-input {
  flex: 1;
  height: 33px;
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  border-radius: 9999px;
  padding: 0 11px;
  font-size: 12px;
  font-family: inherit;
  color: #0f172a;
  outline: none;
  direction: rtl;
}

.ai-bot-input:focus {
  background: #ffffff;
  border-color: #059669;
}

.ai-bot-send-btn {
  width: 33px;
  height: 33px;
  border-radius: 50%;
  background: linear-gradient(135deg, #059669 0%, #047857 100%);
  color: #ffffff;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 13px;
  flex-shrink: 0;
  transition: transform 0.15s;
}

.ai-bot-send-btn:hover {
  transform: scale(1.05);
}

/* Mobile Responsiveness */
@media (max-width: 640px) {
  .ai-bot-window {
    bottom: calc(64px + env(safe-area-inset-bottom, 0px));
    right: 8px;
    left: 8px;
    width: auto;
    max-width: none;
    height: 390px;
    max-height: 60vh;
    border-radius: 14px;
  }

  .ai-bot-trigger {
    bottom: calc(64px + env(safe-area-inset-bottom, 0px));
    right: 8px;
    padding: 5px 10px;
    font-size: 11px;
  }
}
