/* MesueTech AI Chat — ChatGPT-style */
:root {
  --ai-accent: #7c3aed;
  --ai-accent-deep: #5b21b6;
  --ai-surface: #fff;
  --ai-border: rgba(12, 40, 30, .1);
  --ai-bg: #f4f6f8;
}

#mesue-ai-root {
  position: fixed;
  inset-inline-end: 1.25rem;
  bottom: 1.25rem;
  z-index: 9999;
  font-family: Cairo, IBM Plex Sans Arabic, sans-serif;
}

.mesue-ai-fab {
  width: 58px; height: 58px; border-radius: 50%; border: none; cursor: pointer;
  background: linear-gradient(135deg, var(--ai-accent-deep), var(--ai-accent));
  color: #fff; box-shadow: 0 10px 28px rgba(91, 33, 182, .35);
  display: grid; place-items: center; transition: transform .2s;
}
.mesue-ai-fab:hover { transform: scale(1.06); }
.mesue-ai-fab svg { width: 26px; height: 26px; }

#mesue-ai-root .mesue-ai-panel {
  position: absolute; inset-inline-end: 0; bottom: 72px;
  width: min(400px, calc(100vw - 2rem)); height: min(580px, calc(100vh - 6rem));
  opacity: 0; visibility: hidden; transform: translateY(10px);
}
#mesue-ai-root .mesue-ai-panel.open { opacity: 1; visibility: visible; transform: none; }

.mesue-ai-panel {
  background: var(--ai-surface); border: 1px solid var(--ai-border);
  border-radius: 20px; box-shadow: 0 24px 60px rgba(12, 40, 30, .2);
  display: flex; flex-direction: column; overflow: hidden;
  transition: opacity .2s, transform .2s, visibility .2s;
}

.mesue-ai-head {
  padding: .85rem 1rem; background: linear-gradient(135deg, var(--ai-accent-deep), var(--ai-accent));
  color: #fff; display: flex; align-items: center; justify-content: space-between; flex-shrink: 0;
}
.mesue-ai-head strong { font-size: .95rem; display: block; }
.mesue-ai-head small { font-size: .72rem; opacity: .88; }
.mesue-ai-close {
  background: rgba(255,255,255,.15); border: none; color: #fff; width: 32px; height: 32px;
  border-radius: 8px; cursor: pointer; font-size: 1.1rem; text-decoration: none;
  display: grid; place-items: center;
}

.mesue-ai-models, .mesue-ai-model-bar-host .mesue-ai-models {
  display: flex; flex-wrap: wrap; gap: .4rem; padding: .65rem .75rem;
  background: #fafafa; border-bottom: 1px solid var(--ai-border); flex-shrink: 0;
}
.mesue-ai-model-btn {
  border: 1px solid var(--ai-border); background: #fff; border-radius: 999px;
  padding: .35rem .7rem; font-size: .75rem; font-weight: 600; cursor: pointer;
  font-family: inherit; transition: all .15s; white-space: nowrap;
}
.mesue-ai-model-btn:hover { border-color: var(--ai-accent); color: var(--ai-accent-deep); }
.mesue-ai-model-btn.active {
  background: rgba(124, 58, 237, .12); border-color: var(--ai-accent); color: var(--ai-accent-deep);
}

.mesue-ai-msgs {
  flex: 1; min-height: 180px; overflow-y: auto; padding: 1rem .85rem;
  display: flex; flex-direction: column; gap: .85rem; background: var(--ai-bg);
}
.mesue-ai-msg-row { display: flex; align-items: flex-end; gap: .5rem; max-width: 100%; }
.mesue-ai-msg-row.user { flex-direction: row-reverse; align-self: flex-end; }
.mesue-ai-msg-row.bot { align-self: flex-start; }
.mesue-ai-avatar {
  width: 30px; height: 30px; border-radius: 50%; background: #fff; border: 1px solid var(--ai-border);
  display: grid; place-items: center; font-size: .9rem; flex-shrink: 0;
}
.mesue-ai-msg {
  max-width: calc(100% - 40px); padding: .7rem .9rem; border-radius: 16px;
  font-size: .88rem; line-height: 1.6; word-break: break-word;
}
.mesue-ai-msg.user {
  background: linear-gradient(135deg, var(--ai-accent-deep), var(--ai-accent)); color: #fff;
  border-bottom-left-radius: 4px;
}
.mesue-ai-msg.bot {
  background: #fff; border: 1px solid var(--ai-border); border-bottom-right-radius: 4px;
}
.mesue-ai-msg a { color: var(--ai-accent-deep); font-weight: 600; }
.mesue-ai-msg.user a { color: #fff; text-decoration: underline; }

.mesue-ai-typing-dots { display: inline-flex; gap: 4px; padding: .25rem 0; }
.mesue-ai-typing-dots span {
  width: 7px; height: 7px; border-radius: 50%; background: #999;
  animation: mesue-ai-bounce 1.2s ease-in-out infinite;
}
.mesue-ai-typing-dots span:nth-child(2) { animation-delay: .15s; }
.mesue-ai-typing-dots span:nth-child(3) { animation-delay: .3s; }
@keyframes mesue-ai-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: .4; }
  30% { transform: translateY(-5px); opacity: 1; }
}

.mesue-ai-foot {
  padding: .65rem .75rem; border-top: 1px solid var(--ai-border); background: #fff; flex-shrink: 0;
}
.mesue-ai-form {
  display: flex; gap: .5rem; align-items: flex-end;
  background: var(--ai-bg); border: 1px solid var(--ai-border); border-radius: 14px; padding: .4rem .5rem;
}
.mesue-ai-input {
  flex: 1; border: none; background: transparent; padding: .5rem .4rem;
  font-family: inherit; font-size: .9rem; resize: none; min-height: 38px; max-height: 120px; outline: none;
}
.mesue-ai-send {
  width: 38px; height: 38px; border: none; border-radius: 10px; flex-shrink: 0;
  background: var(--ai-accent); color: #fff; font-weight: 800; cursor: pointer; font-size: 1.1rem;
}
.mesue-ai-send:disabled { opacity: .45; cursor: not-allowed; }
.mesue-ai-meta { font-size: .68rem; color: #888; margin-top: .4rem; text-align: center; }
.mesue-ai-meta a { color: var(--ai-accent-deep); }

/* Full page embedded */
.mesue-ai-mount { width: 100%; }
.mesue-ai-panel-embedded {
  width: 100%; height: min(680px, calc(100vh - 260px)); min-height: 480px;
  opacity: 1 !important; visibility: visible !important; transform: none !important;
}
.mesue-ai-page-section .container { max-width: 920px !important; }

@media (max-width: 600px) {
  #mesue-ai-root { inset-inline-end: .75rem; bottom: .75rem; }
  #mesue-ai-root .mesue-ai-panel { width: calc(100vw - 1.5rem); }
  .mesue-ai-model-btn { font-size: .7rem; padding: .3rem .55rem; }
}
