/* Delta Chatbot — ويدجت محادثة منبثقة */

.delta-chat {
  position: fixed;
  right: max(16px, env(safe-area-inset-right, 16px));
  bottom: max(16px, env(safe-area-inset-bottom, 16px));
  z-index: 120;
  font-family: inherit;
}

.delta-chat-fab {
  position: relative;
  width: 60px;
  height: 60px;
  border: 0;
  border-radius: 50%;
  padding: 0;
  cursor: pointer;
  background: linear-gradient(135deg, #00425a 0%, #1a96b8 100%);
  box-shadow: 0 8px 28px rgba(26, 150, 184, .4), 0 2px 8px rgba(0, 66, 90, .2);
  transition: transform .25s cubic-bezier(.22, 1, .36, 1), box-shadow .25s ease;
  touch-action: manipulation;
}

.delta-chat-fab:hover {
  transform: scale(1.06);
  box-shadow: 0 12px 32px rgba(26, 150, 184, .5), 0 4px 12px rgba(14, 26, 52, .2);
}

.delta-chat-fab:active { transform: scale(.96); }

.delta-chat-fab__icon {
  display: block;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  overflow: hidden;
}

.delta-chat-fab__icon svg { width: 100%; height: 100%; display: block; }

.delta-chat-fab__pulse {
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid rgba(26, 150, 184, .35);
  animation: deltaChatPulse 2.4s ease-out infinite;
  pointer-events: none;
}

.delta-chat.is-open .delta-chat-fab__pulse { animation: none; opacity: 0; }

@keyframes deltaChatPulse {
  0%   { transform: scale(1); opacity: .7; }
  70%  { transform: scale(1.18); opacity: 0; }
  100% { transform: scale(1.18); opacity: 0; }
}

/* لوحة المحادثة — شكل هاتف صغير */
.delta-chat-panel {
  position: absolute;
  right: 0;
  bottom: calc(68px + 12px);
  width: min(380px, calc(100vw - 32px));
  max-height: min(560px, calc(100vh - 120px));
  opacity: 0;
  visibility: hidden;
  transform: translateY(16px) scale(.96);
  transform-origin: bottom right;
  transition: opacity .28s ease, transform .32s cubic-bezier(.22, 1, .36, 1), visibility .28s;
  pointer-events: none;
}

.delta-chat.is-open .delta-chat-panel {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.delta-chat-phone {
  display: flex;
  flex-direction: column;
  height: min(520px, calc(100vh - 140px));
  background: linear-gradient(180deg, #f8fafc 0%, #fff 12%);
  border-radius: 28px;
  border: 1px solid rgba(23, 40, 73, .1);
  box-shadow: 0 24px 64px rgba(14, 26, 52, .22), 0 0 0 1px rgba(255, 255, 255, .6) inset;
  overflow: hidden;
}

.delta-chat-notch {
  width: 72px;
  height: 5px;
  margin: 10px auto 4px;
  border-radius: 999px;
  background: rgba(23, 40, 73, .12);
  flex-shrink: 0;
}

.delta-chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 16px 14px;
  background: linear-gradient(135deg, #00425a 0%, #1a96b8 100%);
  color: #fff;
  flex-shrink: 0;
}

.delta-chat-header__avatar {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: rgba(255, 255, 255, .12);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #12afc4;
  flex-shrink: 0;
}

.delta-chat-header__avatar svg { width: 36px; height: 36px; }

.delta-chat-header__meta {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.delta-chat-header__meta strong {
  font-size: .95rem;
  font-weight: 700;
  line-height: 1.2;
}

.delta-chat-header__meta span {
  font-size: .75rem;
  opacity: .78;
  line-height: 1.3;
}

.delta-chat-close {
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 10px;
  background: rgba(255, 255, 255, .1);
  color: #fff;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background .15s ease;
}

.delta-chat-close:hover { background: rgba(255, 255, 255, .2); }

.delta-chat-messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
}

.delta-chat-msg {
  max-width: 88%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: .9rem;
  line-height: 1.55;
  word-break: break-word;
}

.delta-chat-msg--bot {
  align-self: flex-start;
  background: #fff;
  color: var(--ink-800, #1a2744);
  border: 1px solid rgba(23, 40, 73, .08);
  border-end-start-radius: 4px;
  box-shadow: 0 1px 3px rgba(23, 40, 73, .06);
}

.delta-chat-msg--user {
  align-self: flex-end;
  background: linear-gradient(135deg, #00425a, #1a96b8);
  color: #fff;
  border-end-end-radius: 4px;
}

.delta-chat-msg a {
  color: inherit;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.delta-chat-msg--bot a { color: #1a96b8; }

.delta-chat-msg--typing {
  display: inline-flex;
  gap: 4px;
  padding: 14px 18px;
}

.delta-chat-msg--typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #8d9498;
  animation: deltaChatDot 1.2s ease-in-out infinite;
}

.delta-chat-msg--typing span:nth-child(2) { animation-delay: .15s; }
.delta-chat-msg--typing span:nth-child(3) { animation-delay: .3s; }

@keyframes deltaChatDot {
  0%, 80%, 100% { transform: translateY(0); opacity: .4; }
  40% { transform: translateY(-5px); opacity: 1; }
}

.delta-chat-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 14px 10px;
  flex-shrink: 0;
}

.delta-chat-chip {
  border: 1px solid rgba(26, 150, 184, .25);
  background: rgba(26, 150, 184, .06);
  color: #1a96b8;
  font-size: .78rem;
  font-weight: 600;
  padding: 7px 12px;
  border-radius: 999px;
  cursor: pointer;
  font-family: inherit;
  transition: background .15s ease, border-color .15s ease;
  touch-action: manipulation;
}

.delta-chat-chip:hover {
  background: rgba(26, 150, 184, .12);
  border-color: rgba(26, 150, 184, .4);
}

.delta-chat-form {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px calc(14px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid rgba(23, 40, 73, .08);
  background: #fff;
  flex-shrink: 0;
}

.delta-chat-input {
  flex: 1;
  min-width: 0;
  border: 1px solid rgba(23, 40, 73, .12);
  border-radius: 14px;
  padding: 11px 14px;
  font-size: 16px;
  font-family: inherit;
  background: #f4f6fa;
  color: var(--ink-900, #142c4b);
  transition: border-color .2s ease, box-shadow .2s ease;
}

.delta-chat-input:focus {
  outline: 0;
  border-color: #1a96b8;
  box-shadow: 0 0 0 3px rgba(26, 150, 184, .15);
  background: #fff;
}

.delta-chat-send {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  border: 0;
  border-radius: 14px;
  background: linear-gradient(135deg, #00425a, #1a96b8);
  color: #fff;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform .15s ease, opacity .15s ease;
  touch-action: manipulation;
}

html[dir="rtl"] .delta-chat-send svg { transform: scaleX(-1); }

.delta-chat-send:hover { transform: scale(1.04); }
.delta-chat-send:disabled { opacity: .5; cursor: not-allowed; transform: none; }

@media (max-width: 480px) {
  .delta-chat {
    right: max(12px, env(safe-area-inset-right, 12px));
    bottom: max(12px, env(safe-area-inset-bottom, 12px));
  }

  .delta-chat-panel {
    width: calc(100vw - 24px);
    right: -4px;
    bottom: calc(64px + 8px);
    max-height: calc(100vh - 100px);
  }

  .delta-chat-phone { height: min(480px, calc(100vh - 120px)); }
}

@media (prefers-reduced-motion: reduce) {
  .delta-chat-fab__pulse { animation: none; }
  .delta-chat-panel { transition: none; }
}
