/* ChatGPT Floating Widget Styles */
.chatbot-container {
  position: fixed;
  bottom: 180px;
  right: 20px;
  width: 380px;
  max-width: calc(100vw - 40px);
  height: 600px;
  max-height: calc(100vh - 200px);
  background: #ffffff;
  border-radius: 20px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
  display: none;
  flex-direction: column;
  z-index: 9999;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

.chatbot-container.active {
  display: flex;
}

.chatbot-header {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-radius: 20px 20px 0 0;
}

.chatbot-header h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
}

.chatbot-close {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: white;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  transition: background 0.3s;
}

.chatbot-close:hover {
  background: rgba(255, 255, 255, 0.3);
}

.chatbot-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  background: #f8f9fa;
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.chatbot-message {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.chatbot-message.user {
  flex-direction: row-reverse;
}

.chatbot-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.chatbot-message.bot .chatbot-avatar {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
}

.chatbot-message.user .chatbot-avatar {
  background: #e9ecef;
  color: #495057;
}

.chatbot-text {
  max-width: 75%;
  padding: 12px 16px;
  border-radius: 18px;
  line-height: 1.5;
  font-size: 14px;
  word-wrap: break-word;
}

.chatbot-text a {
  color: #667eea;
  text-decoration: underline;
  word-break: break-all;
  transition: color 0.2s ease;
  cursor: pointer;
}

.chatbot-text a:hover {
  color: #764ba2;
  text-decoration: underline;
}

.chatbot-text a:visited {
  color: #764ba2;
}

.chatbot-message.bot .chatbot-text {
  background: white;
  color: #333;
  border-bottom-left-radius: 4px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.chatbot-message.user .chatbot-text {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border-bottom-right-radius: 4px;
}

.chatbot-typing {
  display: flex;
  gap: 5px;
  padding: 12px 16px;
  background: white;
  border-radius: 18px;
  border-bottom-left-radius: 4px;
  width: fit-content;
}

.chatbot-typing span {
  width: 8px;
  height: 8px;
  background: #999;
  border-radius: 50%;
  animation: typing 1.4s infinite;
}

.chatbot-typing span:nth-child(2) {
  animation-delay: 0.2s;
}

.chatbot-typing span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes typing {
  0%, 60%, 100% {
    transform: translateY(0);
    opacity: 0.7;
  }
  30% {
    transform: translateY(-10px);
    opacity: 1;
  }
}

.chatbot-input-area {
  padding: 15px;
  background: white;
  border-top: 1px solid #e9ecef;
  display: flex;
  gap: 10px;
  align-items: flex-end;
}

.chatbot-input {
  flex: 1;
  border: 1px solid #e9ecef;
  border-radius: 20px;
  padding: 12px 18px;
  font-size: 14px;
  resize: none;
  max-height: 100px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.3s;
}

.chatbot-input:focus {
  border-color: #667eea;
}

.chatbot-send {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border: none;
  color: white;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  transition: transform 0.2s, box-shadow 0.2s;
  flex-shrink: 0;
}

.chatbot-send:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.chatbot-send:active {
  transform: scale(0.95);
}

.chatbot-send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.chatbot-toggle {
  position: fixed;
  bottom: 110px;
  right: 40px;
  width: 60px;
  height: 60px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border: none;
  border-radius: 50%;
  color: white;
  font-size: 28px;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(102, 126, 234, 0.4);
  z-index: 9998;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.3s, box-shadow 0.3s;
  animation: pulse 2s ease-in-out infinite;
}

.chatbot-toggle:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 25px rgba(102, 126, 234, 0.5);
  animation-play-state: paused;
}

.chatbot-toggle.active {
  background: #dc3545;
  box-shadow: 0 4px 20px rgba(220, 53, 69, 0.4);
  animation: none;
}

/* Pulse animation for chat icon */
@keyframes pulse {
  0%, 100% {
    transform: scale(1);
    box-shadow: 0 4px 20px rgba(102, 126, 234, 0.4);
  }
  50% {
    transform: scale(1.05);
    box-shadow: 0 6px 30px rgba(102, 126, 234, 0.6);
  }
}

/* Bounce animation alternative */
@keyframes bounce {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-5px);
  }
}

.chatbot-toggle:not(.active) {
  animation: pulse 2s ease-in-out infinite, bounce 3s ease-in-out infinite;
}

.chatbot-badge {
  position: absolute;
  top: -5px;
  right: -5px;
  width: 20px;
  height: 20px;
  background: #dc3545;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: bold;
  border: 2px solid white;
}

.chatbot-badge.hidden {
  display: none;
}

/* Tooltip Styles */
.chatbot-tooltip {
  position: fixed;
  bottom: 185px;
  right: 40px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 12px 18px;
  border-radius: 25px;
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
  opacity: 0;
  transform: translateY(10px) scale(0.9);
  pointer-events: none;
  z-index: 10000;
  transition: opacity 0.4s ease, transform 0.4s ease;
  animation: tooltipShow 4s ease-in-out infinite;
}

.chatbot-tooltip::after {
  content: '';
  position: absolute;
  bottom: -8px;
  right: 20px;
  width: 0;
  height: 0;
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-top: 8px solid #667eea;
}

.chatbot-toggle.active ~ .chatbot-tooltip,
.chatbot-toggle:hover ~ .chatbot-tooltip {
  animation: none;
  opacity: 0 !important;
  display: none !important;
}

@keyframes tooltipShow {
  0%, 100% {
    opacity: 0;
    transform: translateY(10px) scale(0.9);
  }
  10%, 90% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* RTL Support for tooltip */
[dir="rtl"] .chatbot-tooltip {
  right: auto;
  left: 0;
}

[dir="rtl"] .chatbot-tooltip::after {
  right: auto;
  left: 20px;
}

/* RTL Support */
[dir="rtl"] .chatbot-container {
  right: auto;
  left: 20px;
}

[dir="rtl"] .chatbot-toggle {
  right: auto;
  left: 40px;
}

[dir="rtl"] #chatbot-tooltip {
  right: auto;
  left: 40px;
}

[dir="rtl"] .chatbot-message.user {
  flex-direction: row;
}

[dir="rtl"] .chatbot-text {
  direction: rtl;
  text-align: right;
}

/* Mobile Responsive */
@media (max-width: 480px) {
  .chatbot-container {
    width: 100%;
    height: 100%;
    max-width: 100vw;
    max-height: 100vh;
    bottom: 0;
    right: 0;
    border-radius: 0;
  }

  .chatbot-header {
    border-radius: 0;
  }

  .chatbot-toggle {
    bottom: 20px;
    right: 20px;
  }

  #chatbot-tooltip {
    bottom: 95px;
    right: 20px;
    font-size: 12px;
    padding: 10px 15px;
    white-space: normal;
    max-width: 200px;
  }

  [dir="rtl"] .chatbot-toggle {
    right: auto;
    left: 20px;
  }

  [dir="rtl"] #chatbot-tooltip {
    right: auto;
    left: 20px;
  }
}

/* Scrollbar Styling */
.chatbot-messages::-webkit-scrollbar {
  width: 6px;
}

.chatbot-messages::-webkit-scrollbar-track {
  background: #f1f1f1;
}

.chatbot-messages::-webkit-scrollbar-thumb {
  background: #888;
  border-radius: 3px;
}

.chatbot-messages::-webkit-scrollbar-thumb:hover {
  background: #555;
}

.chatbot-order-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(6px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 10001;
  opacity: 0;
  transition: opacity 0.35s ease;
  --chatbot-order-primary: #667eea;
  --chatbot-order-accent: #764ba2;
}

.chatbot-order-overlay.active {
  display: flex;
}

.chatbot-order-overlay.show {
  opacity: 1;
}

.chatbot-order-modal {
  width: min(90vw, 480px);
  background: radial-gradient(circle at top, rgba(255, 255, 255, 0.98), #ffffff);
  border-radius: 24px;
  box-shadow: 0 30px 80px rgba(15, 23, 42, 0.25);
  transform: translateY(40px) scale(0.95);
  opacity: 0;
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.4s ease;
  border: 1px solid rgba(102, 126, 234, 0.15);
  color: #0f172a;
  overflow: hidden;
  position: relative;
  direction: rtl;
}

.chatbot-order-overlay.show .chatbot-order-modal {
  transform: translateY(0) scale(1);
  opacity: 1;
}

.chatbot-order-header {
  background: linear-gradient(135deg, var(--chatbot-order-primary), var(--chatbot-order-accent));
  color: #fff;
  padding: 24px 28px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.chatbot-order-title-group h4 {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.chatbot-order-title-group p {
  margin: 6px 0 0;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.85);
  line-height: 1.6;
}

.chatbot-order-close {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: #fff;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: 22px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.3s ease, background 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chatbot-order-close:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: scale(1.05);
}

.chatbot-order-form {
  padding: 24px 28px 32px;
  max-height: 70vh;
  overflow-y: auto;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.95) 0%, #f8f9ff 100%);
}

.chatbot-order-fields {
  display: grid;
  gap: 18px;
}

.chatbot-order-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.chatbot-order-label {
  font-size: 14px;
  font-weight: 600;
  color: #1e293b;
  display: flex;
  align-items: center;
  gap: 4px;
}

.chatbot-order-required {
  color: var(--chatbot-order-primary);
}

.chatbot-order-input {
  width: 100%;
  border-radius: 14px;
  border: 1px solid rgba(102, 126, 234, 0.25);
  padding: 12px 16px;
  font-size: 14px;
  background: rgba(255, 255, 255, 0.9);
  color: #0f172a;
  transition: border 0.3s ease, box-shadow 0.3s ease, background 0.3s ease;
  outline: none;
}

.chatbot-order-select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, rgba(102, 126, 234, 0.6) 50%), linear-gradient(135deg, rgba(102, 126, 234, 0.6) 50%, transparent 50%);
  background-position: calc(100% - 18px) calc(50% - 5px), calc(100% - 12px) calc(50% - 5px);
  background-size: 7px 7px, 7px 7px;
  background-repeat: no-repeat;
}

.chatbot-order-input:focus {
  border-color: var(--chatbot-order-primary);
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.15);
  background: #fff;
}

.chatbot-order-field.has-error .chatbot-order-input {
  border-color: #ef4444;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

.chatbot-order-field-error {
  font-size: 12px;
  color: #ef4444;
  min-height: 16px;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.chatbot-order-field.has-error .chatbot-order-field-error {
  opacity: 1;
}

.chatbot-order-error {
  margin-top: 20px;
  padding: 12px 16px;
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: 12px;
  color: #b91c1c;
  font-size: 13px;
  line-height: 1.6;
  display: none;
}

.chatbot-order-error.is-visible {
  display: block;
}

.chatbot-order-actions {
  margin-top: 28px;
  display: flex;
  justify-content: flex-start;
}

.chatbot-order-submit {
  border: none;
  border-radius: 999px;
  padding: 12px 26px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  background: linear-gradient(135deg, var(--chatbot-order-primary), var(--chatbot-order-accent));
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  box-shadow: 0 15px 35px rgba(102, 126, 234, 0.35);
  transition: transform 0.3s ease, box-shadow 0.3s ease, filter 0.3s ease;
}

.chatbot-order-submit:hover {
  transform: translateY(-2px) scale(1.01);
  box-shadow: 0 18px 40px rgba(118, 75, 162, 0.35);
  filter: brightness(1.02);
}

.chatbot-order-submit:active {
  transform: scale(0.97);
}

.chatbot-order-submit.is-loading {
  cursor: wait;
  opacity: 0.85;
}

.chatbot-order-submit.is-loading .chatbot-order-submit-text {
  opacity: 0.7;
}

.chatbot-order-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: chatbot-spin 0.75s linear infinite;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.chatbot-order-submit.is-loading .chatbot-order-spinner {
  opacity: 1;
}

@keyframes chatbot-spin {
  to {
    transform: rotate(360deg);
  }
}

body.chatbot-order-open {
  overflow: hidden;
}

@media (max-width: 600px) {
  .chatbot-order-modal {
    width: min(96vw, 420px);
    border-radius: 20px;
  }

  .chatbot-order-header {
    padding: 22px 20px 14px;
  }

  .chatbot-order-form {
    padding: 22px 20px 28px;
  }
}
