/* Chat Support Widget Styles */

.chat-support-widget {
  position: fixed;
  z-index: 1200;
  bottom: 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  pointer-events: none;
}

.chat-support-widget.chat-support-widget--left {
  left: 24px;
  align-items: flex-start;
}

.chat-support-widget.chat-support-widget--left .chat-window {
  left: 0;
  transform-origin: bottom left;
}

.chat-support-widget.chat-support-widget--left .chat-bubble__close {
  right: auto;
  left: -8px;
}

.chat-support-widget.chat-support-widget--right {
  right: 24px;
  align-items: flex-end;
}

.chat-support-widget.chat-support-widget--right .chat-window {
  right: 0;
  transform-origin: bottom right;
}

@media (max-width: 600px) {
  .chat-support-widget {
    bottom: 16px;
  }

  .chat-support-widget.chat-support-widget--left {
    left: 16px;
  }

  .chat-support-widget.chat-support-widget--right {
    right: 16px;
  }
}

.chat-bubble-wrapper {
  position: relative;
  display: inline-flex;
  pointer-events: auto;
}

.chat-bubble {
  position: relative;
  width: 64px;
  height: 64px;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  background: linear-gradient(135deg, #3f51b5, #5c6bc0);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 12px 24px rgba(63, 81, 181, 0.32);
  transition: transform 0.25s ease, box-shadow 0.25s ease;
  padding: 0;
}

.chat-bubble:hover {
  transform: scale(1.05);
  box-shadow: 0 16px 32px rgba(63, 81, 181, 0.38);
}

.chat-bubble:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(63, 81, 181, 0.35), 0 12px 24px rgba(63, 81, 181, 0.32);
}

.chat-bubble__icon {
  font-size: 28px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chat-bubble__icon i {
  font-size: 28px;
}

.chat-bubble__close {
  position: absolute;
  top: -8px;
  right: -8px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, #43a047, #66bb6a);
  color: #ffffff;
  border: 2px solid #ffffff;
  box-shadow: 0 6px 12px rgba(67, 160, 71, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  cursor: pointer;
  padding: 0;
}

.chat-bubble__close:hover {
  transform: scale(1.05);
  box-shadow: 0 8px 16px rgba(67, 160, 71, 0.4);
}

.chat-bubble__close-icon {
  position: relative;
  display: block;
  width: 14px;
  height: 14px;
}

.chat-bubble__close-icon::before,
.chat-bubble__close-icon::after {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  width: 2px;
  height: 100%;
  background: #ffffff;
  border-radius: 1px;
  transform-origin: center;
}

.chat-bubble__close-icon::before {
  transform: translateX(-50%) rotate(45deg);
}

.chat-bubble__close-icon::after {
  transform: translateX(-50%) rotate(-45deg);
}

.chat-bubble__pulse {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.4);
  animation: chatBubblePulse 2.4s ease-in-out infinite;
}

@keyframes chatBubblePulse {
  0% {
    transform: scale(1);
    opacity: 0.8;
  }
  70% {
    transform: scale(1.5);
    opacity: 0;
  }
  100% {
    transform: scale(1.5);
    opacity: 0;
  }
}

.chat-window {
  position: absolute;
  bottom: 80px;
  width: clamp(280px, 28vw, 420px);
  max-width: calc(100vw - 48px);
  height: clamp(380px, 60vh, 600px);
  max-height: min(70vh, 640px);
  background-color: #ffffff;
  border-radius: 18px;
  box-shadow: 0 24px 48px rgba(15, 23, 42, 0.18);
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  transform: translate3d(0,24px,0) scale(0.96);
  transition: opacity 0.25s ease, transform 0.25s ease;
  will-change: transform, opacity;
  contain: layout paint;
  display: flex;
  flex-direction: column;
}

.chat-window.chat-window--open {
  opacity: 1;
  pointer-events: auto;
  transform: translate3d(0,0,0) scale(1);
}

.chat-window.chat-window--rtl {
  direction: rtl;
}

.chat-window.chat-window--rtl .chat-window__title {
  flex-direction: row-reverse;
  text-align: right;
}

.chat-window.chat-window--rtl .chat-window__actions {
  flex-direction: row-reverse;
}

@media (max-width: 600px) {
  .chat-window {
    width: min(94vw, 360px);
    height: min(80vh, 520px);
    max-height: min(80vh, 560px);
  }
}

.chat-window__header {
  background: linear-gradient(135deg, #3f51b5, #5c6bc0);
  color: #ffffff;
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.chat-window__title {
  display: flex;
  align-items: center;
  gap: 12px;
}

.chat-window__title-icon {
  font-size: 28px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chat-window__title-icon i {
  font-size: 24px;
}

.chat-window__title-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.chat-window__title-primary {
  font-family: "elmessiri-font", Arial, Helvetica, sans-serif;
  font-size: 16px;
  font-weight: 600;
}

.chat-window__title-secondary {
  font-family: "cairo-font", Arial, Helvetica, sans-serif;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.85);
}

.chat-window__actions {
  display: flex;
  gap: 4px;
}

.chat-window__actions button {
  color: #ffffff;
  background: transparent;
  border: none;
  cursor: pointer;
  width: 36px;
  height: 36px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.2s ease;
}

.chat-window__actions button:hover {
  background-color: rgba(255, 255, 255, 0.1);
}

.chat-window__actions button:focus {
  outline: 2px solid rgba(255, 255, 255, 0.5);
  outline-offset: 2px;
}

.chat-window__actions-icon {
  font-size: 20px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chat-window__actions-icon i {
  font-size: 18px;
}

.chat-window__body {
  background-color: #f5f7fb;
  flex: 1;
  min-height: 280px;
  overflow: auto;
  display: flex;
  touch-action: manipulation;
}

.chat-window__body--inactive {
  visibility: hidden;
  pointer-events: none;
  opacity: 0;
}

.chat-ai-container {
  display: block;
  height: 100%;
  width: 100%;
  position: relative;
}

.chat-ai-container iframe {
  width: 100%;
  height: 100%;
  border: 0;
  background-color: transparent;
}

.chat-ai-container__loader {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 2;
}

.chat-ai-container__spinner {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 4px solid rgba(63, 81, 181, 0.25);
  border-top-color: #3f51b5;
  animation: spin 0.9s linear infinite;
}

@keyframes spin {
  to { 
    transform: rotate(360deg); 
  }
}

/* Hide widget when not visible */
.chat-support-widget.hidden {
  display: none;
}
