/* ===== AI Sidebar Directive ===== */

/* Wrapper carries no layout — each child positions itself independently.
   No pointer-events:none here (was blocking clicks on overlapping page elements). */
.aisb { display: contents; }

/* Floating toggle button (collapsed state) — green pill, navy iconography
   (matches the topbar "Ask Clinera AI" button for brand consistency) */
.aisb-fab {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 9990;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 18px;
  background: linear-gradient(135deg, #5cdb94 0%, #3fc97a 100%);
  color: #05396b;
  border: none;
  border-radius: 999px;
  box-shadow: 0 6px 20px rgba(92, 219, 148, 0.45);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s, filter 0.15s;
}
.aisb-fab:hover {
  filter: brightness(1.05);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(92, 219, 148, 0.6);
}
.aisb-fab i.fa {
  color: #05396b;
  font-size: 16px;
}

/* Open panel */
.aisb-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: 420px;
  max-width: 100vw;
  height: 100vh;
  background: #fff;
  border-left: 1px solid #e5e7eb;
  box-shadow: -8px 0 32px rgba(0, 0, 0, 0.08);
  display: flex;
  flex-direction: column;
  z-index: 9991;
  animation: aisbSlideIn 0.2s ease-out;
}
@keyframes aisbSlideIn {
  from { transform: translateX(100%); }
  to   { transform: translateX(0); }
}

/* Header — navy with green accent logo */
.aisb-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: #05396b;
  color: #fff;
}
.aisb-head-left { display: flex; align-items: center; gap: 10px; }
.aisb-logo {
  width: 30px;
  height: 30px;
  border-radius: 7px;
  background: #5cdb94;
  color: #05396b;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
}
.aisb-title strong { display: block; font-size: 14px; color: #fff; line-height: 1.2; }
.aisb-title small  { display: block; font-size: 11px; color: rgba(255,255,255,0.7); margin-top: 2px; }

.aisb-head-right { display: flex; gap: 4px; }
.aisb-icon-btn {
  width: 30px;
  height: 30px;
  border: none;
  background: transparent;
  border-radius: 6px;
  color: rgba(255,255,255,0.75);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.aisb-icon-btn:hover { background: rgba(255,255,255,0.12); color: #fff; }

/* Body */
.aisb-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  background: #fafafa;
}

.aisb-welcome { padding: 16px 0; }
.aisb-welcome-text { font-size: 14px; color: #4b5563; margin-bottom: 12px; }

.aisb-pills {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.aisb-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  text-align: left;
  font-size: 13px;
  color: #374151;
  cursor: pointer;
  transition: all 0.15s;
}
.aisb-pill:hover {
  border-color: #5cdb94;
  background: #ebfbf2;
  color: #05396b;
}
.aisb-pill .fa { color: #05396b; width: 16px; }

/* Messages */
.aisb-msg { margin-bottom: 12px; }
.aisb-msg--user { display: flex; justify-content: flex-end; }
.aisb-bubble {
  max-width: 85%;
  padding: 8px 12px;
  background: #05396b;
  color: #fff;
  border-radius: 16px 16px 4px 16px;
  font-size: 13px;
  line-height: 1.5;
  word-wrap: break-word;
}

.aisb-card {
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 12px;
  font-size: 13px;
  line-height: 1.5;
}
.aisb-card-body p { margin: 0 0 8px; color: #1f2937; }
.aisb-card-body p:last-child { margin: 0; }
.aisb-card-body h4 { font-size: 14px; margin: 8px 0 4px; color: #111827; }
.aisb-card-body h5 { font-size: 13px; margin: 6px 0 4px; color: #374151; }
.aisb-card-body code {
  background: #f3f4f6;
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 12px;
  font-family: monospace;
}
.aisb-card-body li {
  list-style: disc;
  margin-left: 18px;
  color: #1f2937;
}

.aisb-stage {
  font-size: 11px;
  color: #6b7280;
  margin-bottom: 8px;
  font-style: italic;
}

.aisb-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid #f3f4f6;
}
.aisb-act {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  font-size: 11px;
  color: #4b5563;
  cursor: pointer;
}
.aisb-act:hover { background: #ebfbf2; border-color: #5cdb94; color: #05396b; }
.aisb-act:disabled { opacity: 0.5; cursor: not-allowed; }
.aisb-act .fa { color: #05396b; }

/* Loading dots */
.aisb-dots { display: inline-flex; gap: 4px; padding: 4px 0; }
.aisb-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #9ca3af;
  animation: aisbBlink 1.2s infinite ease-in-out;
}
.aisb-dots span:nth-child(2) { animation-delay: 0.2s; }
.aisb-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes aisbBlink {
  0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); }
  40% { opacity: 1; transform: scale(1); }
}

/* Input */
.aisb-input {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid #e5e7eb;
  background: white;
}
.aisb-input textarea {
  flex: 1;
  resize: none;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 13px;
  font-family: inherit;
  outline: none;
  min-height: 40px;
  max-height: 120px;
}
.aisb-input textarea:focus { border-color: #05396b; }

.aisb-send {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: none;
  background: #05396b;
  color: #fff;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.aisb-send:disabled {
  background: #d1d5db;
  cursor: not-allowed;
}
.aisb-send:hover:not(:disabled) {
  background: #0a4a8a;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(5, 57, 107, 0.4);
}

.aisb-stop {
  background: #ef4444 !important;
}
.aisb-stop:hover {
  background: #dc2626 !important;
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.4) !important;
}

/* Inline links inside AI responses (sidebar) */
.aisb-link {
  color: #05396b;
  text-decoration: none;
  border-bottom: 1px dashed #5cdb94;
  font-weight: 500;
}
.aisb-link:hover {
  color: #042a52;
  border-bottom-style: solid;
  background: #ebfbf2;
}
.aisb-link::after {
  content: ' \f08e';
  font-family: FontAwesome;
  font-size: 9px;
  vertical-align: super;
  opacity: 0.6;
  margin-left: 2px;
}

/* ===== Mobile / Tablet ===== */
@media (max-width: 767px) {
  /* Smaller, icon-only circular FAB to save space — keeps green pill identity */
  .aisb-fab {
    right: 14px;
    bottom: 14px;
    padding: 0;
    border-radius: 50%;
    width: 52px;
    height: 52px;
    justify-content: center;
    gap: 0;
  }
  .aisb-fab .fa { font-size: 20px; color: #05396b; }
  /* Hide any text label inside the FAB on mobile */
  .aisb-fab > span:not(.fa),
  .aisb-fab .aisb-fab-label { display: none; }

  /* Full-screen panel on mobile */
  .aisb-panel {
    width: 100vw;
    max-width: 100vw;
    border-left: none;
  }
  .aisb-head { padding: 10px 12px; }
  .aisb-title { font-size: 13px; }
  .aisb-input { padding: 10px; }
  .aisb-input textarea { font-size: 14px; }
  .aisb-pill { font-size: 12px; padding: 6px 10px; }
}
