/* ═══════════════════════════════════════════════════════════
   PACABOT — Public sales-agent chat widget
   Arabic-first · RTL · Dark brand palette matches style.css
   ═══════════════════════════════════════════════════════════ */

/* Bottom-LEFT because the site is RTL; the trailing edge for a
   right-to-left reader is the left side of the viewport. */
.sw-fab {
  position: fixed;
  bottom: 24px;
  left: 24px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, #F5A623 0%, #E48F0D 100%);
  color: #070B24;
  cursor: pointer;
  box-shadow: 0 12px 32px rgba(245, 166, 35, 0.45),
              0 4px 12px rgba(0, 0, 0, 0.30);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9998;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  padding: 0;
}
.sw-fab:hover {
  transform: translateY(-2px);
  box-shadow: 0 16px 40px rgba(245, 166, 35, 0.55),
              0 6px 16px rgba(0, 0, 0, 0.35);
}
.sw-fab svg { width: 26px; height: 26px; }
.sw-fab[aria-expanded="true"] { display: none; }

.sw-fab-pulse {
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid rgba(245, 166, 35, 0.6);
  animation: sw-pulse 2.2s infinite;
  pointer-events: none;
}
@keyframes sw-pulse {
  0%   { transform: scale(1);   opacity: 0.7; }
  100% { transform: scale(1.6); opacity: 0;   }
}

/* Panel */
.sw-panel {
  position: fixed;
  bottom: 24px;
  left: 24px;
  width: 380px;
  height: 560px;
  max-height: calc(100vh - 48px);
  background: #0D1435;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.55);
  display: none;
  flex-direction: column;
  overflow: hidden;
  z-index: 9999;
  font-family: 'Alexandria', system-ui, sans-serif;
  color: #F4F7FF;
  direction: rtl;
  text-align: right;
}
.sw-panel.sw-open { display: flex; }

.sw-header {
  padding: 14px 16px;
  background: linear-gradient(90deg, #121A47 0%, #18225A 100%);
  border-bottom: 1px solid rgba(255, 255, 255, 0.10);
  display: flex;
  align-items: center;
  gap: 10px;
}
.sw-header-title {
  flex: 1;
  font-size: 0.95rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}
.sw-live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #22C55E;
  box-shadow: 0 0 8px rgba(34, 197, 94, 0.6);
  display: inline-block;
  animation: sw-live 1.6s infinite;
}
@keyframes sw-live {
  0%, 100% { opacity: 1;   }
  50%      { opacity: 0.4; }
}
.sw-close {
  background: transparent;
  border: none;
  color: #8A90B8;
  cursor: pointer;
  padding: 6px;
  border-radius: 8px;
  line-height: 0;
}
.sw-close:hover { background: rgba(255,255,255,0.08); color: #F4F7FF; }

.sw-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.2) transparent;
}
.sw-messages::-webkit-scrollbar { width: 6px; }
.sw-messages::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.2);
  border-radius: 3px;
}

.sw-msg {
  max-width: 82%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 0.9rem;
  line-height: 1.55;
  word-wrap: break-word;
  white-space: pre-wrap;
}
.sw-msg-assistant {
  background: #18225A;
  border: 1px solid rgba(255,255,255,0.08);
  color: #F4F7FF;
  align-self: flex-start;
  border-bottom-right-radius: 4px;
}
.sw-msg-user {
  background: linear-gradient(135deg, #F5A623 0%, #E48F0D 100%);
  color: #070B24;
  align-self: flex-end;
  border-bottom-left-radius: 4px;
  font-weight: 500;
}
.sw-msg-error {
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.35);
  color: #FCA5A5;
  align-self: flex-start;
  font-size: 0.85rem;
}

.sw-typing {
  align-self: flex-start;
  display: flex;
  gap: 4px;
  padding: 10px 14px;
  background: #18225A;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 14px;
  border-bottom-right-radius: 4px;
}
.sw-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #8A90B8;
  animation: sw-typing 1.2s infinite;
}
.sw-typing span:nth-child(2) { animation-delay: 0.2s; }
.sw-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes sw-typing {
  0%, 60%, 100% { transform: translateY(0);   opacity: 0.4; }
  30%           { transform: translateY(-4px); opacity: 1;   }
}

.sw-input-row {
  border-top: 1px solid rgba(255,255,255,0.08);
  padding: 12px;
  display: flex;
  gap: 8px;
  align-items: flex-end;
  background: #0A1030;
}
.sw-input {
  flex: 1;
  background: #121A47;
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 12px;
  padding: 10px 12px;
  color: #F4F7FF;
  font-family: inherit;
  font-size: 0.9rem;
  resize: none;
  max-height: 96px;
  min-height: 40px;
  outline: none;
  direction: rtl;
  text-align: right;
}
.sw-input:focus { border-color: #F5A623; }
.sw-send {
  background: #F5A623;
  color: #070B24;
  border: none;
  border-radius: 12px;
  width: 40px;
  height: 40px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease;
  padding: 0;
  flex-shrink: 0;
}
.sw-send:hover:not(:disabled) { background: #E48F0D; }
.sw-send:disabled {
  background: rgba(245, 166, 35, 0.35);
  cursor: not-allowed;
}
.sw-send svg { width: 18px; height: 18px; transform: scaleX(-1); /* arrow points right in RTL context */ }

.sw-hint {
  text-align: center;
  font-size: 0.72rem;
  color: #525780;
  padding: 6px 12px 10px;
  background: #0A1030;
}

/* Mobile — full-screen panel below 640px */
@media (max-width: 640px) {
  .sw-panel {
    bottom: 0;
    left: 0;
    right: 0;
    top: 0;
    width: 100%;
    height: 100%;
    max-height: 100%;
    border-radius: 0;
    border: none;
  }
  .sw-fab {
    bottom: 16px;
    left: 16px;
    width: 56px;
    height: 56px;
  }
}
