/* Bord AI - side panel, chat bubbles and launcher */

/* ---------- Launcher button (sits above the status bar) ---------- */
.ai-launcher {
  position: fixed;
  right: 22px;
  bottom: 52px;
  z-index: 45;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: 999px;
  border: none;
  color: #ffffff;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.2px;
  background: linear-gradient(135deg, #2563eb 0%, #7c3aed 100%);
  box-shadow: 0 10px 24px -6px rgba(37, 99, 235, 0.55), 0 0 0 1px rgba(255, 255, 255, 0.12) inset;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
}

.ai-launcher:hover {
  transform: translateY(-2px);
  box-shadow: 0 16px 30px -8px rgba(37, 99, 235, 0.65);
}

.ai-launcher .ai-spark {
  width: 18px;
  height: 18px;
}

/* ---------- Panel ---------- */
.ai-panel {
  width: 400px;
  max-width: 92vw;
  background: #ffffff;
  border-left: 1px solid #e2e8f0;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  box-shadow: -12px 0 30px -18px rgba(15, 23, 42, 0.35);
  overflow: hidden;
}

.ai-panel-head {
  padding: 12px 14px;
  border-bottom: 1px solid #e2e8f0;
  background: linear-gradient(135deg, #1e3a8a 0%, #4c1d95 100%);
  color: #ffffff;
  flex-shrink: 0;
}

.ai-badge {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.22);
}

/* ---------- Quick action chips ---------- */
.ai-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px 12px;
  border-bottom: 1px solid #f1f5f9;
  background: #f8fafc;
  flex-shrink: 0;
}

.ai-chip {
  font-size: 11px;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid #e2e8f0;
  background: #ffffff;
  color: #475569;
  cursor: pointer;
  transition: all 0.12s ease;
  white-space: nowrap;
}

.ai-chip:hover {
  border-color: #93c5fd;
  color: #1d4ed8;
  background: #eff6ff;
}

.ai-chip:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.ai-chip .ai-chip-hint {
  font-family: 'Kurdish', 'Cairo', sans-serif;
  color: #94a3b8;
  margin-inline-start: 5px;
  font-weight: 500;
}

/* ---------- Message log ---------- */
.ai-log {
  flex: 1;
  overflow-y: auto;
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: #ffffff;
}

.ai-msg-user {
  align-self: flex-end;
  max-width: 88%;
  background: #2563eb;
  color: #ffffff;
  padding: 8px 12px;
  border-radius: 14px 14px 4px 14px;
  font-size: 12.5px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
  unicode-bidi: plaintext;
}

.ai-msg-ai {
  align-self: flex-start;
  max-width: 96%;
  width: 100%;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 14px 14px 14px 4px;
  overflow: hidden;
}

.ai-msg-error {
  align-self: flex-start;
  max-width: 96%;
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #b91c1c;
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 12px;
  line-height: 1.55;
  white-space: pre-wrap;
}

/* Banner: the site is open on an address that cannot run PHP */
.ai-env-warning {
  margin: 10px 12px 0;
  padding: 9px 11px;
  border-radius: 9px;
  background: #fffbeb;
  border: 1px solid #fde68a;
  color: #92400e;
  font-size: 11px;
  line-height: 1.55;
}

.ai-env-warning code {
  background: #fef3c7;
  padding: 1px 4px;
  border-radius: 4px;
  font-size: 10.5px;
}

/* Rendered document preview inside a bubble */
.ai-preview {
  max-height: 240px;
  overflow: hidden;
  position: relative;
  padding: 12px 14px;
  background: #ffffff;
  font-size: 11px;
  line-height: 1.6;
  color: #1e293b;
  border-bottom: 1px solid #f1f5f9;
}

.ai-preview::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 46px;
  background: linear-gradient(to bottom, rgba(255, 255, 255, 0), #ffffff);
  pointer-events: none;
}

.ai-preview table { width: 100%; border-collapse: collapse; }
.ai-preview td, .ai-preview th { border: 1px solid #cbd5e1; padding: 3px 5px; }
.ai-preview img { max-width: 100%; }

.ai-msg-foot {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  padding: 8px 10px;
  background: #f8fafc;
}

.ai-act {
  font-size: 11px;
  font-weight: 600;
  padding: 4px 9px;
  border-radius: 7px;
  border: 1px solid #e2e8f0;
  background: #ffffff;
  color: #475569;
  cursor: pointer;
  transition: all 0.12s ease;
}

.ai-act:hover { border-color: #93c5fd; color: #1d4ed8; background: #eff6ff; }
.ai-act-primary { background: #2563eb; border-color: #2563eb; color: #ffffff; }
.ai-act-primary:hover { background: #1d4ed8; border-color: #1d4ed8; color: #ffffff; }

.ai-meta {
  font-size: 10px;
  color: #94a3b8;
  margin-inline-start: auto;
  font-weight: 500;
}

/* ---------- Composer ---------- */
.ai-composer {
  border-top: 1px solid #e2e8f0;
  padding: 10px 12px 12px;
  background: #ffffff;
  flex-shrink: 0;
}

.ai-textarea {
  width: 100%;
  min-height: 74px;
  max-height: 180px;
  resize: vertical;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  padding: 9px 11px;
  font-size: 12.5px;
  line-height: 1.6;
  color: #0f172a;
  outline: none;
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
  unicode-bidi: plaintext;
  font-family: 'Inter', 'Kurdish', 'Cairo', sans-serif;
}

.ai-textarea:focus {
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.14);
}

.ai-send {
  background: linear-gradient(135deg, #2563eb 0%, #7c3aed 100%);
  color: #ffffff;
  border: none;
  border-radius: 9px;
  padding: 8px 16px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: opacity 0.12s ease, transform 0.12s ease;
}

.ai-send:hover:not(:disabled) { transform: translateY(-1px); }
.ai-send:disabled { opacity: 0.55; cursor: not-allowed; }

/* Auto-insert switch */
.ai-switch {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  color: #475569;
  cursor: pointer;
  user-select: none;
}

.ai-switch-track {
  width: 30px;
  height: 17px;
  border-radius: 999px;
  background: #cbd5e1;
  position: relative;
  transition: background 0.15s ease;
  flex-shrink: 0;
}

.ai-switch-track.on { background: #2563eb; }

.ai-switch-knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: #ffffff;
  transition: transform 0.15s ease;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.25);
}

.ai-switch-track.on .ai-switch-knob { transform: translateX(13px); }

/* ---------- Thinking indicator ---------- */
.ai-thinking {
  display: flex;
  align-items: center;
  gap: 8px;
  align-self: flex-start;
  font-size: 12px;
  color: #64748b;
  padding: 8px 12px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 14px 14px 14px 4px;
}

.ai-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #7c3aed;
  animation: aiPulse 1.05s infinite ease-in-out;
}

.ai-dot:nth-child(2) { animation-delay: 0.16s; }
.ai-dot:nth-child(3) { animation-delay: 0.32s; }

@keyframes aiPulse {
  0%, 80%, 100% { opacity: 0.25; transform: scale(0.8); }
  40%           { opacity: 1;    transform: scale(1); }
}

/* ---------- Key health rows ---------- */
.ai-key-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border: 1px solid #e2e8f0;
  border-radius: 9px;
  font-size: 11.5px;
  background: #ffffff;
}

.ai-key-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.ai-key-dot.ok   { background: #10b981; box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.16); }
.ai-key-dot.busy { background: #f59e0b; box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.16); }
.ai-key-dot.dead { background: #ef4444; box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.16); }

@media print {
  .ai-panel, .ai-launcher { display: none !important; }
}
