/* ============================================================
   Octa Food — مساعد الذكاء الاصطناعي (حاسبة المعادلات وتكلفة الأوردرات)
   ثابت في يمين الشاشة، على الصفحة الرئيسية فقط.
   ============================================================ */

:root {
  --oai-navy: #101820;
  --oai-red: #d71920;
  --oai-red-dark: #9f1117;
  --oai-line: #dfe4e8;
  --oai-ink: #17212b;
  --oai-muted: #69747e;
  --oai-bg: #f6f4ef;
}

.oai-launcher {
  position: fixed;
  z-index: 9998;
  bottom: 26px;
  right: 22px;
  width: 60px;
  height: 60px;
  border: none;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(145deg, var(--oai-red), var(--oai-red-dark));
  color: #fff;
  cursor: pointer;
  box-shadow: 0 10px 26px rgba(159, 17, 23, .38), 0 2px 6px rgba(0, 0, 0, .2);
  transition: transform .18s ease, box-shadow .18s ease;
}

.oai-launcher:hover {
  transform: translateY(-3px) scale(1.04);
  box-shadow: 0 14px 30px rgba(159, 17, 23, .45), 0 3px 8px rgba(0, 0, 0, .22);
}

.oai-launcher svg {
  width: 26px;
  height: 26px;
}

.oai-launcher .oai-ping {
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid rgba(215, 25, 32, .55);
  animation: oaiPing 2.4s ease-out infinite;
  pointer-events: none;
}

@keyframes oaiPing {
  0%   { transform: scale(.85); opacity: .9; }
  75%  { transform: scale(1.35); opacity: 0; }
  100% { transform: scale(1.35); opacity: 0; }
}

.oai-launcher .oai-dot {
  position: absolute;
  top: -2px;
  left: -2px;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: #ffb020;
  border: 2px solid #fff;
}

@media (prefers-reduced-motion: reduce) {
  .oai-launcher .oai-ping { animation: none; }
}

/* ===== Panel ===== */
.oai-panel {
  position: fixed;
  z-index: 9999;
  bottom: 100px;
  right: 22px;
  width: 372px;
  max-width: calc(100vw - 32px);
  height: 560px;
  max-height: calc(100vh - 140px);
  display: flex;
  flex-direction: column;
  background: #fff;
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 24px 60px rgba(16, 24, 32, .28), 0 4px 16px rgba(16, 24, 32, .12);
  opacity: 0;
  transform: translateY(16px) scale(.98);
  pointer-events: none;
  transition: opacity .18s ease, transform .18s ease;
}

.oai-panel.open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.oai-head {
  flex-shrink: 0;
  padding: 16px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  background: linear-gradient(135deg, var(--oai-navy), #1c2733);
  color: #fff;
}

.oai-head .oai-avatar {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(215, 25, 32, .22);
  border: 1px solid rgba(215, 25, 32, .5);
  color: #ff8a8a;
}

.oai-head .oai-avatar svg { width: 20px; height: 20px; }

.oai-head .oai-title-wrap { flex: 1; min-width: 0; }
.oai-head strong { display: block; font-size: 14px; }
.oai-head small {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 2px;
  color: #b9c2ca;
  font-size: 11px;
}
.oai-head small .oai-live {
  width: 6px; height: 6px; border-radius: 50%; background: #3cc07a;
  box-shadow: 0 0 0 0 rgba(60, 192, 122, .6);
  animation: oaiLive 1.8s ease-out infinite;
}
@keyframes oaiLive {
  0% { box-shadow: 0 0 0 0 rgba(60,192,122,.55); }
  70% { box-shadow: 0 0 0 6px rgba(60,192,122,0); }
  100% { box-shadow: 0 0 0 0 rgba(60,192,122,0); }
}

.oai-close {
  width: 30px; height: 30px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  border: none; border-radius: 8px;
  background: rgba(255, 255, 255, .08);
  color: #fff; cursor: pointer;
}
.oai-close:hover { background: rgba(255, 255, 255, .18); }
.oai-close svg { width: 16px; height: 16px; }

.oai-chips {
  flex-shrink: 0;
  display: flex;
  gap: 7px;
  padding: 10px 14px;
  overflow-x: auto;
  background: var(--oai-bg);
  border-bottom: 1px solid var(--oai-line);
}
.oai-chip {
  flex-shrink: 0;
  padding: 7px 12px;
  border: 1px solid var(--oai-line);
  border-radius: 20px;
  background: #fff;
  color: var(--oai-ink);
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.oai-chip:hover { border-color: var(--oai-red); color: var(--oai-red); }

.oai-chip-train {
  margin-inline-start: auto;
  text-decoration: none;
  background: var(--oai-bg);
  color: var(--oai-muted);
}

.oai-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--oai-bg);
}

.oai-msg {
  max-width: 86%;
  padding: 10px 13px;
  border-radius: 13px;
  font-size: 13px;
  line-height: 1.7;
  white-space: pre-wrap;
}
.oai-msg.bot {
  align-self: flex-start;
  background: #fff;
  border: 1px solid var(--oai-line);
  color: var(--oai-ink);
  border-start-start-radius: 4px;
}
.oai-msg.user {
  align-self: flex-end;
  background: var(--oai-red);
  color: #fff;
  border-start-end-radius: 4px;
}
.oai-msg.bot b { color: var(--oai-red-dark); }

.oai-msg.bot small {
  display: block;
  margin-top: 7px;
  color: var(--oai-muted);
  font-size: 11px;
  line-height: 1.6;
}

.oai-action-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: 10px;
  padding: 8px 13px;
  border-radius: 8px;
  background: var(--oai-red);
  color: #fff !important;
  text-decoration: none;
  font-weight: 800;
  line-height: 1.4;
}

.oai-action-link:hover {
  background: var(--oai-red-dark);
}

.oai-typing {
  align-self: flex-start;
  display: flex;
  gap: 4px;
  padding: 12px 14px;
  background: #fff;
  border: 1px solid var(--oai-line);
  border-radius: 13px;
  border-start-start-radius: 4px;
}
.oai-typing span {
  width: 6px; height: 6px; border-radius: 50%; background: var(--oai-muted);
  animation: oaiTyping 1s ease-in-out infinite;
}
.oai-typing span:nth-child(2) { animation-delay: .15s; }
.oai-typing span:nth-child(3) { animation-delay: .3s; }
@keyframes oaiTyping {
  0%, 60%, 100% { transform: translateY(0); opacity: .5; }
  30% { transform: translateY(-3px); opacity: 1; }
}

.oai-input-row {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px;
  background: #fff;
  border-top: 1px solid var(--oai-line);
}
.oai-input-row input {
  flex: 1;
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid var(--oai-line);
  border-radius: 20px;
  font: inherit;
  font-size: 13px;
  color: var(--oai-ink);
  background: var(--oai-bg);
}
.oai-input-row input:focus { outline: 2px solid rgba(215, 25, 32, .18); border-color: var(--oai-red); }
.oai-send {
  width: 40px; height: 40px; flex-shrink: 0;
  border: none; border-radius: 50%;
  background: var(--oai-red);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
}
.oai-send:hover { background: var(--oai-red-dark); }
.oai-send:disabled { opacity: .45; cursor: not-allowed; }
.oai-send svg { width: 17px; height: 17px; }

/* RTL mirrors the send icon */
[dir="rtl"] .oai-send svg { transform: scaleX(-1); }

@media (max-width: 460px) {
  .oai-panel {
    right: 12px;
    left: 12px;
    width: auto;
    bottom: 92px;
  }
  .oai-launcher { right: 16px; bottom: 18px; }
}
