/* ═══════════════════════════════════════════════
   SAMI27 IA CHAT STYLES (MOBILE FRIENDLY)
═══════════════════════════════════════════════ */

.sami-chat-wrapper {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  font-family: var(--font-body, 'Inter', sans-serif);
}

.sami-chat-bubble {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--gradient-primary, linear-gradient(135deg, #3b82f6 0%, #06b6d4 100%));
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(59, 130, 246, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  position: relative;
}

.sami-chat-bubble:hover {
  transform: translateY(-4px) scale(1.05);
  box-shadow: 0 8px 30px rgba(59, 130, 246, 0.6);
}

.bubble-avatar {
  font-family: var(--font-display, 'Cinzel', serif);
  font-size: 24px;
  font-weight: 700;
  color: #fff;
  position: relative;
  line-height: 1;
}

.bubble-online {
  position: absolute;
  bottom: 0px;
  right: -4px;
  width: 14px;
  height: 14px;
  background: #10b981;
  border: 2px solid var(--clr-bg, #050811);
  border-radius: 50%;
  animation: pulse-online 2s infinite ease-in-out;
}

@keyframes pulse-online {
  0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.4); }
  70% { box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
  100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.sami-chat-window {
  position: absolute;
  bottom: 80px;
  right: 0;
  width: 350px;
  height: 500px;
  max-width: calc(100vw - 48px);
  max-height: calc(100vh - 120px);
  background: var(--clr-surface, #0b1120);
  border: 1px solid var(--clr-border, rgba(99, 179, 237, 0.12));
  border-radius: 20px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  transform: translateY(20px) scale(0.95);
  transform-origin: bottom right;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.sami-chat-window.open {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

.sami-chat-header {
  padding: 16px 20px;
  background: rgba(17, 24, 39, 0.9);
  border-bottom: 1px solid var(--clr-border, rgba(99, 179, 237, 0.12));
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.header-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--gradient-primary, linear-gradient(135deg, #3b82f6 0%, #06b6d4 100%));
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display, 'Cinzel', serif);
  font-weight: 700;
  color: #fff;
  font-size: 16px;
}

.header-info div {
  display: flex;
  flex-direction: column;
  line-height: 1.3;
}

.header-info strong {
  color: var(--clr-text, #f1f5f9);
  font-size: 15px;
  font-weight: 600;
}

.header-info span {
  color: #10b981;
  font-size: 12px;
}

.sami-chat-close {
  background: none;
  border: none;
  color: var(--clr-text-muted, #94a3b8);
  cursor: pointer;
  padding: 4px;
  transition: color 0.2s;
}

.sami-chat-close:hover {
  color: var(--clr-text, #f1f5f9);
}

.sami-chat-close svg {
  width: 20px;
  height: 20px;
}

.sami-chat-body {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
  background: var(--clr-bg, #050811);
  scroll-behavior: smooth;
}

.chat-msg {
  display: flex;
  flex-direction: column;
  max-width: 85%;
}

.chat-msg.ai-msg {
  align-self: flex-start;
}

.chat-msg.user-msg {
  align-self: flex-end;
}

.msg-content {
  padding: 12px 16px;
  line-height: 1.5;
  font-size: 14px;
}

.ai-msg .msg-content {
  background: var(--clr-surface-2, #111827);
  color: var(--clr-text, #f1f5f9);
  border-radius: 16px 16px 16px 4px;
  border: 1px solid var(--clr-border, rgba(99, 179, 237, 0.12));
}

.user-msg .msg-content {
  background: var(--gradient-primary, linear-gradient(135deg, #3b82f6 0%, #06b6d4 100%));
  color: #fff;
  border-radius: 16px 16px 4px 16px;
}

.chat-typing {
  align-self: flex-start;
  background: var(--clr-surface-2, #111827);
  padding: 12px 16px;
  border-radius: 16px 16px 16px 4px;
  border: 1px solid var(--clr-border, rgba(99, 179, 237, 0.12));
  display: flex;
  gap: 4px;
}

.chat-typing span {
  width: 6px;
  height: 6px;
  background: var(--clr-text-muted, #94a3b8);
  border-radius: 50%;
  animation: typing 1.4s infinite ease-in-out both;
}

.chat-typing span:nth-child(1) { animation-delay: -0.32s; }
.chat-typing span:nth-child(2) { animation-delay: -0.16s; }

@keyframes typing {
  0%, 80%, 100% { transform: scale(0); }
  40% { transform: scale(1); }
}

.sami-chat-footer {
  padding: 16px;
  background: var(--clr-surface, #0b1120);
  border-top: 1px solid var(--clr-border, rgba(99, 179, 237, 0.12));
}

.sami-chat-form {
  display: flex;
  gap: 12px;
  background: var(--clr-bg, #050811);
  padding: 6px 6px 6px 16px;
  border-radius: 100px;
  border: 1px solid var(--clr-border, rgba(99, 179, 237, 0.12));
}

.sami-chat-form input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--clr-text, #f1f5f9);
  font-size: 14px;
  font-family: inherit;
}

.sami-chat-form button {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--gradient-primary, linear-gradient(135deg, #3b82f6 0%, #06b6d4 100%));
  border: none;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s;
}

.sami-chat-form button:hover {
  transform: scale(1.1);
}

.sami-chat-form button svg {
  width: 16px;
  height: 16px;
}

/* ── 100% MOBILE FRIENDLY ── */
@media (max-width: 480px) {
  .sami-chat-wrapper {
    bottom: 20px;
    right: 20px;
  }
  
  .sami-chat-bubble {
    width: 54px;
    height: 54px;
  }

  .bubble-avatar {
    font-size: 20px;
  }

  /* Full screen chat window on mobile */
  .sami-chat-window {
    position: fixed;
    bottom: 0px;
    right: 0px;
    width: 100vw;
    height: 100dvh;
    max-width: 100vw;
    max-height: 100dvh;
    border-radius: 0;
    z-index: 10000;
  }

  /* Make header look like a real app navigation on mobile */
  .sami-chat-header {
    padding: 20px 16px 16px; /* A bit more top padding for safety */
    border-radius: 0;
  }
}

/* -----------------------------------------------
   RTL SUPPORT (ARABIC)
----------------------------------------------- */
[dir="rtl"] .sami-chat-form {
  padding: 6px 16px 6px 6px;
}

