/* ============================================================
   المساعد الذكي — in-app Arabic smart assistant (additive)
   Midnight Emerald styling. Loaded after styles.css.
   ============================================================ */

#sa-fab {
  position: fixed;
  bottom: calc(var(--navh, 104px) + 14px + env(safe-area-inset-bottom));
  right: 16px;
  z-index: 60;
  display: none;
  align-items: center;
  gap: 8px;
  border: none;
  border-radius: 999px;
  padding: 13px 18px;
  font-family: inherit;
  font-size: 1.02rem;
  font-weight: 800;
  color: #241a03;
  background: linear-gradient(135deg, var(--gold-light), var(--gold-deep));
  box-shadow: 0 10px 26px rgba(212, 175, 55, 0.45);
  cursor: pointer;
}
#sa-fab.show { display: inline-flex; }
#sa-fab .sa-robot { font-size: 1.35rem; }
#sa-fab.attn { animation: sa-pulse 2.2s infinite; }
@keyframes sa-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.07); }
}

#sa-sheet {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  pointer-events: none;
}
#sa-sheet.open { pointer-events: auto; }
#sa-sheet .sa-scrim {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  opacity: 0;
  transition: opacity 0.3s;
}
#sa-sheet.open .sa-scrim { opacity: 1; }

#sa-box {
  position: relative;
  height: 86%;
  max-height: 720px;
  background: var(--bg1);
  border: 1px solid var(--card-border);
  border-bottom: none;
  border-radius: 24px 24px 0 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateY(103%);
  transition: transform 0.34s cubic-bezier(0.2, 0.9, 0.25, 1);
  box-shadow: 0 -18px 60px rgba(0, 0, 0, 0.55);
}
#sa-sheet.open #sa-box { transform: translateY(0); }

.sa-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 14px;
  background: rgba(255, 255, 255, 0.045);
  border-bottom: 1px solid var(--card-border);
  flex-shrink: 0;
}
.sa-ava {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--teal-deep), var(--teal));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.35rem;
  box-shadow: 0 4px 14px var(--teal-glow);
}
.sa-head .sa-t { flex: 1; min-width: 0; }
.sa-head .sa-t b { font-size: 1.02rem; }
.sa-head .sa-t span { display: block; font-size: 0.78rem; color: var(--muted); }
.sa-hbtn {
  border: 1px solid var(--card-border);
  background: var(--card);
  color: var(--ink);
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 0.85rem;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
}

#sa-msgs {
  flex: 1;
  overflow-y: auto;
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 9px;
}
.sa-msg {
  max-width: 86%;
  padding: 11px 14px;
  border-radius: 18px;
  font-size: 1rem;
  line-height: 1.7;
  word-wrap: break-word;
  animation: sa-pop 0.22s ease;
}
@keyframes sa-pop {
  from { opacity: 0; transform: translateY(7px); }
}
.sa-bot {
  align-self: flex-start;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-bottom-right-radius: 6px;
}
.sa-user {
  align-self: flex-end;
  background: linear-gradient(135deg, var(--teal-deep), var(--teal));
  color: #fff;
  font-weight: 600;
  border-bottom-left-radius: 6px;
}
.sa-typing {
  align-self: flex-start;
  background: var(--card);
  border: 1px solid var(--card-border);
  padding: 13px 16px;
  border-radius: 18px;
}
.sa-typing i {
  display: inline-block;
  width: 7px;
  height: 7px;
  margin: 0 2px;
  border-radius: 50%;
  background: var(--muted);
  animation: sa-blink 1s infinite;
}
.sa-typing i:nth-child(2) { animation-delay: 0.2s; }
.sa-typing i:nth-child(3) { animation-delay: 0.4s; }
@keyframes sa-blink {
  0%, 100% { opacity: 0.25; }
  50% { opacity: 1; }
}
.sa-card {
  background: var(--ok-bg);
  border: 1.5px solid var(--teal);
  border-radius: 14px;
  padding: 10px 12px;
  margin-top: 8px;
  line-height: 2;
}
.sa-card b { color: var(--gold-light); }

#sa-quick {
  padding: 4px 12px 2px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  flex-shrink: 0;
  max-height: 38%;
  overflow-y: auto;
}
.sa-q {
  border: 1.5px solid var(--teal);
  background: rgba(18, 163, 127, 0.13);
  color: #d9fff4;
  border-radius: 999px;
  padding: 11px 16px;
  font-size: 0.95rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
}
.sa-q:active { background: rgba(18, 163, 127, 0.32); }
.sa-q.big {
  width: 100%;
  padding: 14px 16px;
  font-size: 1.02rem;
  border-radius: 15px;
  text-align: right;
}
.sa-q.gold {
  border-color: var(--gold);
  background: var(--warn-bg);
  color: var(--warn);
}
.sa-q.plain {
  border-color: var(--card-border);
  background: var(--card);
  color: var(--ink);
}

.sa-bar {
  display: flex;
  gap: 8px;
  padding: 10px 12px calc(14px + env(safe-area-inset-bottom));
  flex-shrink: 0;
}
#sa-tin {
  flex: 1;
  border: 1px solid var(--card-border);
  background: var(--card);
  border-radius: 999px;
  padding: 12px 16px;
  color: var(--ink);
  font-size: 0.98rem;
  font-family: inherit;
  outline: none;
  min-width: 0;
}
#sa-tin:focus { border-color: var(--teal); }
#sa-send {
  width: 50px;
  height: 50px;
  flex-shrink: 0;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  font-size: 1.25rem;
  color: #241a03;
  background: linear-gradient(135deg, var(--gold-light), var(--gold-deep));
  box-shadow: 0 6px 18px rgba(212, 175, 55, 0.4);
}
