/* Tahour AI Chat Widget – RTL, bottom-right floating */

/* Orange accent: #e45a2a (Orange on White) */
#tahour-chat-root {
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  z-index: 9999;
  font-family: 'Tajawal', sans-serif;
  direction: rtl;
  --tahour-orange: #e45a2a;
  --tahour-orange-dark: #c94d22;
}

/* Floating button – fades out when panel is open */
#tahour-chat-btn {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, #e45a2a 0%, #c94d22 100%);
  color: #fff;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(228, 90, 42, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.25s ease, box-shadow 0.25s ease, opacity 0.5s ease, visibility 0.5s ease;
}

#tahour-chat-root.is-open #tahour-chat-btn {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

#tahour-chat-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 20px rgba(228, 90, 42, 0.5);
}

#tahour-chat-btn svg {
  width: 28px;
  height: 28px;
}

/* Panel – fades in/out only (no slide) */
#tahour-chat-panel {
  position: absolute;
  bottom: calc(56px + 12px);
  right: 0;
  width: 360px;
  max-width: calc(100vw - 2rem);
  height: 480px;
  max-height: calc(100vh - 8rem);
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.5s ease, visibility 0.5s ease, bottom 0.4s ease;
}

#tahour-chat-root.is-open #tahour-chat-panel {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  bottom: 0;
}

/* Header */
#tahour-chat-header {
  padding: 14px 16px;
  background: linear-gradient(135deg, #e45a2a 0%, #c94d22 100%);
  color: #fff;
  display: flex;
  align-items: center;
  gap: 10px;
}

#tahour-chat-header h2 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 700;
  color: #fff;
}

#tahour-chat-close {
  margin-right: auto;
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: #fff;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  line-height: 1;
}

#tahour-chat-close:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* Messages area */
#tahour-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #f8fafc;
}

#tahour-chat-messages .msg {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 0.95rem;
  line-height: 1.5;
  white-space: pre-wrap;
  word-wrap: break-word;
}

/* RTL: user on the right (flex-start), agent on the left (flex-end) */
#tahour-chat-messages .msg.user {
  align-self: flex-start;
  background: #e45a2a;
  color: #fff;
  border-bottom-right-radius: 4px;
}

#tahour-chat-messages .msg.agent {
  align-self: flex-end;
  background: #fff;
  color: #1e293b;
  border: 1px solid #e2e8f0;
  border-bottom-left-radius: 4px;
}

/* Typing indicator (agent side = left in RTL) */
#tahour-chat-messages .msg.typing {
  align-self: flex-end;
  background: #fff;
  border: 1px solid #e2e8f0;
  padding: 12px 16px;
}

.tahour-typing-dots {
  display: flex;
  gap: 4px;
  align-items: center;
}

.tahour-typing-dots span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #94a3b8;
  animation: tahour-bounce 0.6s ease-in-out infinite;
}

.tahour-typing-dots span:nth-child(2) { animation-delay: 0.1s; }
.tahour-typing-dots span:nth-child(3) { animation-delay: 0.2s; }

@keyframes tahour-bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}

/* Input area */
#tahour-chat-form {
  padding: 12px;
  background: #fff;
  border-top: 1px solid #e2e8f0;
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

#tahour-chat-input {
  flex: 1;
  min-height: 44px;
  max-height: 120px;
  padding: 10px 14px;
  border: 1px solid #e2e8f0;
  border-radius: 22px;
  font-family: inherit;
  font-size: 0.95rem;
  direction: rtl;
  resize: none;
}

#tahour-chat-input:focus {
  outline: none;
  border-color: #e45a2a;
  box-shadow: 0 0 0 2px rgba(228, 90, 42, 0.2);
}

#tahour-chat-send {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: #e45a2a;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

#tahour-chat-send:hover:not(:disabled) {
  background: #c94d22;
}

/* Send icon reversed for RTL (paper plane points left) */
#tahour-chat-send svg.tahour-send-icon {
  transform: scaleX(-1);
}

#tahour-chat-send:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

#tahour-chat-send svg {
  width: 20px;
  height: 20px;
}

@media (max-width: 480px) {
  #tahour-chat-panel {
    width: calc(100vw - 1rem);
    right: 0.5rem;
    bottom: calc(56px + 8px);
    height: 70vh;
  }
}
