/* === AI Brain diamond + slide-out drawer === */

:root {
  --brain-purple: #8b5cf6;
  --brain-teal: #14b8a6;
  --brain-orange: #f97316;
  --brain-blue: #3b82f6;
  --brain-pink: #ec4899;
  --brain-green: #22c55e;
}

.ai-diamond-root {
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  z-index: 360;
  pointer-events: none;
}
.ai-diamond-root > * { pointer-events: auto; }

/* Diamond button — rotated square with counter-rotated icon inside */
.ai-diamond-btn {
  width: 3rem;
  height: 3rem;
  border: none;
  background: transparent;
  cursor: pointer;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.18s ease, filter 0.18s ease;
  filter: drop-shadow(0 6px 14px color-mix(in srgb, var(--brain-color) 45%, transparent));
}
.ai-diamond-btn:hover { transform: scale(1.06); }
.ai-diamond-btn:active { transform: scale(0.94); }
.ai-diamond-btn:focus-visible { outline: 2px solid var(--brain-color); outline-offset: 3px; border-radius: 4px; }

.ai-diamond-shape {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  background: linear-gradient(135deg, var(--brain-color), color-mix(in srgb, var(--brain-color) 60%, #fff 30%));
  transform: rotate(45deg);
  border-radius: 0.25rem;
  color: #fff;
  font-size: 1rem;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brain-color) 20%, transparent);
}
.ai-diamond-shape > i { transform: rotate(-45deg); display: inline-block; }
.ai-diamond-shape--sm { width: 1.75rem; height: 1.75rem; font-size: .85rem; }

/* Backdrop shown while drawer is open */
.ai-diamond-backdrop {
  position: fixed;
  inset: 0;
  z-index: 340;
  background: rgba(15, 18, 32, 0);
  backdrop-filter: blur(0);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, backdrop-filter 0.2s ease;
}
.ai-diamond-root.is-open .ai-diamond-backdrop {
  opacity: 1;
  pointer-events: auto;
  background: rgba(15, 18, 32, 0.35);
  backdrop-filter: blur(2px);
}

/* Right-side slide-in drawer */
.ai-diamond-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(420px, 100vw);
  z-index: 350;
  background: #ffffff;
  color: #0f1220;
  transform: translateX(100%);
  transition: transform 0.24s cubic-bezier(.2,.7,.2,1);
  box-shadow: -20px 0 40px rgba(15, 18, 32, 0.14);
  display: flex;
  flex-direction: column;
  padding: 1rem 1.1rem 1.1rem;
  gap: .75rem;
}
.ai-diamond-root.is-open .ai-diamond-drawer { transform: translateX(0); }

.ai-diamond-drawer__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
}
.ai-diamond-drawer__title {
  display: flex;
  align-items: center;
  gap: .5rem;
}
.ai-diamond-drawer__title h3 {
  font-size: 1rem;
  margin: 0;
  font-weight: 700;
}
.ai-diamond-drawer__actions {
  display: flex;
  align-items: center;
  gap: .35rem;
}
.ai-diamond-drawer__gear,
.ai-diamond-drawer__close {
  width: 2rem;
  height: 2rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: rgba(0,0,0,0.04);
  color: #334155;
  cursor: pointer;
  border-radius: .5rem;
  text-decoration: none;
  font-size: .95rem;
}
.ai-diamond-drawer__gear:hover,
.ai-diamond-drawer__close:hover {
  background: rgba(0,0,0,0.08);
}
.ai-diamond-drawer__gear { color: var(--brain-color); }

.ai-diamond-drawer__desc {
  margin: 0;
  color: #64748b;
  font-size: .85rem;
  line-height: 1.35;
}

.ai-diamond-drawer__body {
  flex: 1 1 auto;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: .5rem;
  padding: .25rem 0;
}
.ai-diamond-msg {
  padding: .55rem .7rem;
  border-radius: .65rem;
  font-size: .9rem;
  line-height: 1.4;
  max-width: 92%;
}
.ai-diamond-msg--brain {
  background: color-mix(in srgb, var(--brain-color) 10%, #fff);
  color: #0f1220;
  align-self: flex-start;
}
.ai-diamond-msg--brain strong { color: var(--brain-color); }
.ai-diamond-msg--user {
  background: #0f172a;
  color: #fff;
  align-self: flex-end;
}
.ai-diamond-msg--error {
  background: rgba(239, 68, 68, 0.1);
  color: #b91c1c;
  align-self: flex-start;
}

.ai-diamond-insights {
  border: 1px solid rgba(0,0,0,0.08);
  background: color-mix(in srgb, var(--brain-color) 6%, #fff);
  border-radius: .65rem;
  padding: .65rem .75rem;
  font-size: .85rem;
  line-height: 1.4;
  max-height: 40vh;
  overflow-y: auto;
}
.ai-diamond-insights__headline {
  font-weight: 700;
  color: #0f172a;
  margin-bottom: .5rem;
}
.ai-diamond-insights__group { margin-top: .5rem; }
.ai-diamond-insights__label {
  text-transform: uppercase;
  font-size: .7rem;
  letter-spacing: .05em;
  color: var(--brain-color);
  font-weight: 700;
  margin-bottom: .2rem;
}
.ai-diamond-insights__list {
  list-style: disc;
  padding-left: 1.1rem;
  margin: 0;
  color: #1e293b;
}
.ai-diamond-insights__list li { margin-bottom: .15rem; }
.ai-diamond-insights__footer {
  margin-top: .5rem;
  font-size: .72rem;
  color: #64748b;
  font-style: italic;
}

.ai-diamond-drawer__form {
  display: flex;
  align-items: stretch;
  gap: .5rem;
  border-top: 1px solid rgba(0,0,0,0.06);
  padding-top: .65rem;
}
.ai-diamond-drawer__input {
  flex: 1 1 auto;
  padding: .5rem .65rem;
  border: 1px solid rgba(0,0,0,0.14);
  border-radius: .5rem;
  font-family: inherit;
  font-size: .9rem;
  resize: none;
}
.ai-diamond-drawer__input:focus {
  outline: 2px solid var(--brain-color);
  outline-offset: 0;
}
.ai-diamond-drawer__send {
  border: none;
  background: var(--brain-color);
  color: #fff;
  padding: 0 .9rem;
  border-radius: .5rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  font-weight: 600;
  font-size: .88rem;
}
.ai-diamond-drawer__send:hover { filter: brightness(1.05); }
.ai-diamond-drawer__send:disabled { opacity: 0.5; cursor: not-allowed; }

@media (max-width: 640px) {
  .ai-diamond-root {
    bottom: 5rem; /* clear mobile viobar */
  }
  .ai-diamond-drawer {
    width: 100vw;
  }
}
