/* Clinera AI Chat */

.aic {
  display: flex;
  height: calc(100vh - 50px);
  margin: -15px;
  background: #f4f5f7;
  font-family: inherit;
}

/* ── Sidebar ────────────────────────────── */
.aic-side {
  width: 260px;
  min-width: 260px;
  background: #f9fafc;
  border-right: 1px solid #d2d6de;
  display: flex;
  flex-direction: column;
  transition: margin-left 0.2s ease;
}
.aic-side:not(.aic-side--open) {
  margin-left: -260px;
}

.aic-side-top { padding: 14px; }
.aic-new-btn {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 10px 14px; background: #fff;
  border: 1px solid #d2d6de; border-radius: 8px;
  color: #333; font-size: 13px; font-weight: 600; cursor: pointer;
  transition: all 0.15s;
}
.aic-new-btn:hover { background: #f0f2f5; border-color: #bbb; }
.aic-new-btn i { color: #5cdb94; }

.aic-sessions { flex: 1; overflow-y: auto; padding: 4px 8px; }
.aic-sessions-label {
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px;
  color: #999; padding: 8px 8px 6px;
}
.aic-session {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 10px; border-radius: 6px; color: #555;
  font-size: 13px; cursor: pointer; transition: all 0.12s;
}
.aic-session:hover { background: #eef0f3; color: #333; }
.aic-session--active { background: rgba(92,219,148,0.1); color: #05396b; }
.aic-session--active i { color: #5cdb94 !important; }
.aic-session i { font-size: 12px; color: #aaa; flex-shrink: 0; }
.aic-session span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.aic-session-x {
  opacity: 0; background: none; border: none; color: #bbb;
  font-size: 11px; cursor: pointer; padding: 2px 4px;
}
.aic-session:hover .aic-session-x { opacity: 1; }
.aic-session-x:hover { color: #ef4444; }

.aic-sessions-empty { text-align: center; padding: 24px 8px; color: #bbb; font-size: 12px; }

.aic-side-bottom {
  padding: 12px 16px; border-top: 1px solid #e5e7eb;
}
.aic-side-brand strong { display: block; color: #05396b; font-size: 13px; }
.aic-side-brand span { color: #999; font-size: 11px; }

/* ── Main ────────────────────────────────── */
.aic-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.aic-head {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 18px; background: #fff; border-bottom: 1px solid #e5e7eb;
}
.aic-toggle {
  background: none; border: 1px solid #e2e4e8; border-radius: 6px;
  width: 32px; height: 32px; display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: #64748b; font-size: 14px;
}
.aic-toggle:hover { background: #f1f5f9; }
.aic-head-title { font-size: 15px; font-weight: 700; color: #05396b; }
.aic-head-tag {
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px;
  background: #5cdb94; color: #fff; padding: 2px 8px; border-radius: 4px;
}

/* ── Messages ────────────────────────────── */
.aic-body { flex: 1; overflow-y: auto; padding: 20px 0; scroll-behavior: smooth; }

.aic-welcome {
  display: flex; flex-direction: column; align-items: center;
  padding: 60px 20px 30px; text-align: center;
}
.aic-welcome-logo {
  width: 56px; height: 56px; border-radius: 14px;
  background: #05396b; color: #5cdb94;
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; font-weight: 800; margin-bottom: 18px;
}
.aic-welcome h2 { font-size: 22px; font-weight: 700; color: #05396b; margin: 0 0 6px; }
.aic-welcome p { font-size: 14px; color: #8a95a3; margin: 0 0 28px; }

.aic-suggestions {
  display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px;
  max-width: 600px; width: 100%;
}
.aic-sug {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px; background: #fff; border: 1px solid #e5e7eb; border-radius: 10px;
  font-size: 13px; font-weight: 500; color: #374151; cursor: pointer;
  text-align: left; transition: all 0.15s;
}
.aic-sug:hover { border-color: #5cdb94; background: #f0fdf4; }
.aic-sug i { color: #5cdb94; font-size: 14px; width: 18px; text-align: center; }

/* ── AI Response Card ─────────────────────── */
.aic-msg {
  padding: 4px 20px;
  max-width: 780px; margin: 0 auto; width: 100%;
}
.aic-msg--user { display: flex; justify-content: flex-end; }
.aic-msg--ai { display: flex; justify-content: flex-start; }

.aic-card {
  background: #fff;
  border: 1px solid #e2e5ea;
  border-radius: 12px;
  overflow: hidden;
  max-width: 92%;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.aic-card-head {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 16px;
  background: #f8faf9;
  border-bottom: 1px solid #eef0f3;
}
.aic-card-logo {
  width: 24px; height: 24px; border-radius: 6px;
  background: #05396b; color: #5cdb94;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 800; flex-shrink: 0;
}
.aic-card-name {
  font-size: 12px; font-weight: 700; color: #05396b;
  letter-spacing: 0.2px;
}
.aic-card-body {
  padding: 14px 16px; font-size: 14px; line-height: 1.65; color: #1f2937;
}

/* ── Follow-up action buttons ──────────── */
.aic-card-actions {
  padding: 8px 16px 12px;
  border-top: 1px solid #eef0f3;
  display: flex; flex-wrap: wrap; gap: 6px;
}
.aic-action-btn {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 6px 12px; border-radius: 16px;
  background: #f0fdf4; border: 1px solid #c6f0d5;
  color: #05396b; font-size: 12px; font-weight: 500;
  cursor: pointer; transition: all 0.15s; white-space: nowrap;
}
.aic-action-btn:hover {
  background: #5cdb94; color: #fff; border-color: #5cdb94;
}
.aic-action-btn:hover i { color: #fff; }
.aic-action-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.aic-action-btn i { font-size: 11px; color: #5cdb94; }

/* User bubble */
.aic-msg--user .aic-msg-bubble {
  background: #05396b; color: #fff; border-radius: 16px 16px 4px 16px;
  padding: 10px 16px; font-size: 14px; line-height: 1.5;
  max-width: 75%; word-wrap: break-word;
}

/* Markdown inside cards */
.aic-md h3 { font-size: 15px; font-weight: 700; color: #05396b; margin: 0 0 10px; border-bottom: 2px solid #e8f4ec; padding-bottom: 6px; }
.aic-md h4 { font-size: 13px; font-weight: 700; color: #374151; margin: 10px 0 4px; }
.aic-md p { margin: 0 0 6px; }
.aic-md p:last-child { margin-bottom: 0; }
.aic-md strong { color: #05396b; }
.aic-md li { margin-bottom: 3px; }
.aic-md code { background: #f1f5f9; padding: 1px 5px; border-radius: 3px; font-size: 12px; }
.aic-md ul { padding-left: 18px; margin: 4px 0 8px; }

.aic-md table { width: 100%; border-collapse: collapse; margin: 8px 0; font-size: 12px; }
.aic-md th {
  background: #f5f7fb; font-weight: 700; color: #4b5563; text-align: left;
  padding: 6px 8px; border-bottom: 2px solid #e5e7eb; font-size: 10px;
  text-transform: uppercase; letter-spacing: 0.3px;
}
.aic-md td { padding: 5px 8px; border-bottom: 1px solid #f0f2f5; color: #374151; }
.aic-md tr:hover td { background: #f9fafb; }

/* Typing dots */
.aic-dots { display: flex; gap: 4px; padding: 4px 0; }
.aic-dots span {
  width: 7px; height: 7px; border-radius: 50%; background: #5cdb94;
  animation: aic-bounce 1.2s ease-in-out infinite;
}
.aic-dots span:nth-child(2) { animation-delay: 0.15s; }
.aic-dots span:nth-child(3) { animation-delay: 0.3s; }
@keyframes aic-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.3; }
  30% { transform: translateY(-5px); opacity: 1; }
}

/* ── Input ────────────────────────────────── */
.aic-input-area { padding: 12px 20px 10px; background: #f4f5f7; }
.aic-input-row {
  display: flex; align-items: flex-end; gap: 8px;
  background: #fff; border: 1.5px solid #dde0e4; border-radius: 12px;
  padding: 4px 4px 4px 14px;
  max-width: 780px; margin: 0 auto; transition: border-color 0.15s;
}
.aic-input-row:focus-within { border-color: #5cdb94; }

.aic-input {
  flex: 1; border: none; outline: none; resize: none;
  font-size: 14px; line-height: 1.5; padding: 6px 0;
  max-height: 100px; font-family: inherit; color: #1f2937; background: transparent;
}
.aic-input::placeholder { color: #a0a8b4; }

.aic-send {
  width: 34px; height: 34px; border-radius: 8px;
  background: #05396b; border: none; color: #fff;
  font-size: 13px; cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: all 0.15s; flex-shrink: 0;
}
.aic-send:hover { background: #0a4a8a; }
.aic-send:disabled { opacity: 0.25; cursor: not-allowed; }
.aic-send.aic-stop { background: #ef4444; }
.aic-send.aic-stop:hover { background: #dc2626; }

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

.aic-fine-print { text-align: center; font-size: 11px; color: #a0a8b4; margin-top: 6px; }

/* ── Top-bar shortcut button ──────────────── */
.clinera-ai-topbar-btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 7px 14px; border-radius: 999px;
  background: linear-gradient(135deg, #5cdb94 0%, #3fc97a 100%);
  color: #05396b;
  font-size: 13px; font-weight: 700; cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s, filter 0.15s;
  text-decoration: none;
  line-height: 1;
  box-shadow: 0 2px 10px rgba(92,219,148,0.35);
  position: relative;
}
.clinera-ai-topbar-btn:hover,
.clinera-ai-topbar-btn:focus {
  color: #05396b;
  text-decoration: none;
  filter: brightness(1.05);
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(92,219,148,0.5);
}
.clinera-ai-topbar-btn .ai-logo-sm {
  display: inline-flex; align-items: center; justify-content: center;
  width: auto; height: auto;
  background: transparent; color: #05396b;
  font-size: 15px;
}
.clinera-ai-topbar-btn .ai-topbar-label { letter-spacing: 0.2px; }

/* Tablet — collapse to icon-only pill */
@media (max-width: 992px) {
  .clinera-ai-topbar-btn .ai-topbar-label { display: none; }
  .clinera-ai-topbar-btn { padding: 7px 11px; gap: 0; }
  .clinera-ai-topbar-btn .ai-logo-sm { font-size: 16px; }
}

/* Mobile — compact circular icon-button, sized to fit alongside language + avatar */
@media (max-width: 767px) {
  .nav.navbar-nav > li.ai-topbar-li { margin: 0 6px 0 0 !important; }
  .navbar-custom-menu .clinera-ai-topbar-btn {
    width: 34px;
    height: 34px;
    padding: 0 !important;
    border-radius: 50%;
    margin-top: 8px !important;
    box-shadow: 0 1px 6px rgba(92,219,148,0.4);
    justify-content: center;
    gap: 0;
  }
  .clinera-ai-topbar-btn .ai-logo-sm { font-size: 14px; }
}

@media (max-width: 768px) {
  .aic-side { position: absolute; z-index: 100; height: 100%; }
  .aic-suggestions { grid-template-columns: 1fr 1fr; }
  .aic-msg { padding: 4px 12px; }
}
