/*
  DORAi Chat Widget — v5
  Uses Figtree (loaded via 00-global-styles.html).
  Outer chrome (border, rounded corners, header bar) is handled by
  .ai-widget-frame / .ai-widget-bar in 10-ai-agent.html — this file
  styles only the inner widget content.
*/

/* ── Google Fonts fallback if loaded standalone ── */
@import url("https://fonts.googleapis.com/css2?family=Figtree:wght@400;500;600;700&display=swap");

.dac-chat {
  /* colour tokens */
  --dac-bg:             #07111b;
  --dac-surface-user:   #2b4beb;
  --dac-surface-asst:   rgba(255, 255, 255, 0.07);
  --dac-border-asst:    rgba(255, 255, 255, 0.09);
  --dac-text-user:      #ffffff;
  --dac-text-asst:      #c6dff5;
  --dac-input-bg:       rgba(255, 255, 255, 0.06);
  --dac-input-border:   rgba(255, 255, 255, 0.1);
  --dac-input-text:     #daeeff;
  --dac-accent:         #2b4beb;
  --dac-mute:           rgba(160, 195, 230, 0.45);
  --dac-sep:            rgba(255, 255, 255, 0.07);

  background: var(--dac-bg);
  color: var(--dac-text-asst);
  font-family: "Figtree", ui-sans-serif, system-ui, sans-serif;
  font-size: 14.5px;
  line-height: 1.58;
  -webkit-font-smoothing: antialiased;

  /* no border/radius — outer .ai-widget-inner handles the shape */
  border: none;
  border-radius: 0;
  box-shadow: none;
  max-width: 100%;
  overflow: hidden;
}

/* ── Hide the plugin-generated header — outer ai-widget-bar handles branding ── */
.dac-chat__header {
  display: none;
}

/* ── Scrollable message list ── */
.dac-chat__messages {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 400px;
  overflow-y: auto;
  padding: 20px 16px 12px;
  scrollbar-color: rgba(255, 255, 255, 0.1) transparent;
  scrollbar-width: thin;
}

.dac-chat__messages::-webkit-scrollbar       { width: 3px; }
.dac-chat__messages::-webkit-scrollbar-track { background: transparent; }
.dac-chat__messages::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.12);
  border-radius: 99px;
}

/* ── Greeting / welcome text (first assistant message) ── */
.dac-chat__messages > .dac-chat__message--assistant:first-child {
  background: transparent;
  border: none;
  color: rgba(180, 210, 240, 0.6);
  font-size: 13.5px;
  font-style: italic;
  padding: 0 4px 6px;
  border-bottom: 1px solid var(--dac-sep);
  border-radius: 0;
  margin-bottom: 6px;
  max-width: 100%;
  align-self: stretch;
}

/* ── Individual message bubbles ── */
.dac-chat__message {
  animation: dac-rise 0.2s cubic-bezier(0.2, 0.8, 0.2, 1) both;
  border-radius: 18px;
  font-size: 14px;
  line-height: 1.6;
  max-width: 84%;
  padding: 11px 15px;
  white-space: pre-wrap;
  word-break: break-word;
}

@keyframes dac-rise {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}

/* Assistant bubble — glassy dark */
.dac-chat__message--assistant {
  align-self: flex-start;
  background: var(--dac-surface-asst);
  border: 1px solid var(--dac-border-asst);
  border-bottom-left-radius: 4px;
  color: var(--dac-text-asst);
}

/* User bubble — brand blue */
.dac-chat__message--user {
  align-self: flex-end;
  background: var(--dac-surface-user);
  background-image: linear-gradient(135deg, #3d5ef5, #2b4beb);
  border-bottom-right-radius: 4px;
  box-shadow:
    0 4px 16px rgba(43, 75, 235, 0.4),
    0 1px 3px rgba(0, 0, 0, 0.3);
  color: var(--dac-text-user);
}

/* ── Sender label above message ── */
.dac-chat__message--user::before,
.dac-chat__message--assistant::before {
  content: attr(data-role);
  display: none; /* hidden unless plugin adds data-role attr */
}

/* ── Token / usage bar ── */
.dac-chat__meta {
  display: flex;
  justify-content: center;
  padding: 6px 16px 8px;
  border-top: 1px solid var(--dac-sep);
}

.dac-chat__tokens {
  background: rgba(43, 75, 235, 0.12);
  border: 1px solid rgba(43, 75, 235, 0.22);
  border-radius: 999px;
  color: rgba(140, 175, 230, 0.8);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.025em;
  padding: 3px 12px;
}

/* ── Input form ── */
.dac-chat__form {
  align-items: center;
  background: rgba(0, 0, 0, 0.25);
  border-top: 1px solid var(--dac-sep);
  display: flex;
  gap: 8px;
  padding: 12px 14px 14px;
}

.dac-chat__form--with-turnstile {
  flex-wrap: wrap;
}

/* Text input */
.dac-chat__input {
  background: var(--dac-input-bg);
  border: 1px solid var(--dac-input-border);
  border-radius: 14px;
  color: var(--dac-input-text);
  flex: 1;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.4;
  min-height: 46px;
  padding: 0 14px;
  transition:
    border-color 0.18s ease,
    background  0.18s ease,
    box-shadow  0.18s ease;
}

.dac-chat__input::placeholder {
  color: var(--dac-mute);
}

.dac-chat__input:focus {
  background: rgba(255, 255, 255, 0.09);
  border-color: rgba(43, 75, 235, 0.6);
  box-shadow: 0 0 0 3px rgba(43, 75, 235, 0.18);
  outline: none;
}

.dac-chat__input:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

/* Send button */
.dac-chat__send {
  align-items: center;
  background: var(--dac-accent);
  background-image: linear-gradient(135deg, #3d5ef5, #2040d4);
  border: none;
  border-radius: 14px;
  box-shadow: 0 4px 14px rgba(43, 75, 235, 0.38);
  color: #fff;
  cursor: pointer;
  display: flex;
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 700;
  gap: 7px;
  justify-content: center;
  letter-spacing: 0.01em;
  min-height: 46px;
  padding: 0 20px;
  transition:
    filter     0.18s ease,
    box-shadow 0.18s ease,
    transform  0.14s ease;
}

/* Inline send arrow icon */
.dac-chat__send::after {
  content: "→";
  font-size: 15px;
  font-weight: 400;
  transition: transform 0.2s ease;
}

.dac-chat__send:hover {
  box-shadow: 0 6px 22px rgba(43, 75, 235, 0.5);
  filter: brightness(1.1);
  transform: translateY(-1px);
}

.dac-chat__send:hover::after {
  transform: translateX(3px);
}

.dac-chat__send:active {
  transform: translateY(0);
}

.dac-chat__send:disabled {
  cursor: not-allowed;
  opacity: 0.45;
  box-shadow: none;
  transform: none;
  filter: none;
}

.dac-chat__turnstile {
  flex-basis: 100%;
}

/* ── Typing indicator (class added by plugin if supported) ── */
.dac-chat__message--typing {
  align-self: flex-start;
  background: var(--dac-surface-asst);
  border: 1px solid var(--dac-border-asst);
  border-bottom-left-radius: 4px;
  display: flex;
  gap: 5px;
  padding: 14px 16px;
}

.dac-chat__message--typing span {
  animation: dac-bounce 1.2s ease-in-out infinite;
  background: var(--dac-mute);
  border-radius: 50%;
  display: block;
  height: 6px;
  width: 6px;
}

.dac-chat__message--typing span:nth-child(2) { animation-delay: 0.2s; }
.dac-chat__message--typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes dac-bounce {
  0%, 80%, 100% { transform: translateY(0);    opacity: 0.4; }
  40%           { transform: translateY(-5px); opacity: 1;   }
}

/* ── Mobile ── */
@media (max-width: 640px) {
  .dac-chat__messages {
    max-height: 320px;
    padding: 16px 12px 10px;
  }

  .dac-chat__message {
    max-width: 92%;
    padding: 10px 13px;
  }

  .dac-chat__form {
    flex-wrap: wrap;
    padding: 10px 12px 12px;
  }

  .dac-chat__send {
    width: 100%;
  }
}
