/* Noah Wire Editorial — Ask Noah Wire
   All classes prefixed da- to avoid collision with host page CSS.
   Dark editorial theme matching noahwire.com */

/* Design tokens */
:root {
  --da-accent: #0d9488;
  --da-bg: #0a0a0a;
  --da-surface: #18181b;
  --da-border: rgba(255,255,255,0.08);
  --da-text: #e6edf3;
  --da-text-muted: #8b949e;
  --da-text-inv: #0a0a0a;
  --da-user-bg: rgba(13,148,136,0.15);
  --da-assistant-bg: #1c1c20;
  --da-error-bg: rgba(239,68,68,0.1);
}

/* Floating action button */
.da-fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--da-accent);
  color: #fff;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(13,148,136,0.35);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  transition: transform 0.15s, box-shadow 0.15s;
  font-family: var(--font-body, 'Lato'), -apple-system, BlinkMacSystemFont, sans-serif;
  line-height: 1;
}
.da-fab:hover {
  transform: scale(1.06);
  box-shadow: 0 6px 24px rgba(13,148,136,0.4);
}
.da-fab.da-fab-open {
  background: var(--da-surface);
}
.da-fab svg {
  width: 22px;
  height: 22px;
  fill: currentColor;
}

/* Overlay (backdrop) */
.da-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  z-index: 250;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
}
.da-overlay.da-open {
  opacity: 1;
  pointer-events: auto;
}

/* Drawer */
.da-drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: 420px;
  height: 100vh;
  height: 100dvh;
  background: #111113;
  border-left: 1px solid var(--da-border);
  box-shadow: -4px 0 24px rgba(0,0,0,0.3);
  z-index: 300;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.25s cubic-bezier(0.4,0,0.2,1);
  font-family: var(--font-body, 'Lato'), -apple-system, BlinkMacSystemFont, sans-serif;
}
.da-drawer.da-open {
  transform: translateX(0);
}

/* Header */
.da-header {
  background: var(--da-bg);
  color: var(--da-text);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  border-bottom: 1px solid var(--da-border);
}
.da-header-title {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.da-close {
  background: none;
  border: none;
  color: var(--da-text-muted);
  font-size: 22px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
  transition: color 0.15s;
}
.da-close:hover {
  color: var(--da-text);
}

/* Intro (shown before first message) */
.da-intro {
  padding: 20px 20px 8px;
  flex-shrink: 0;
}
.da-intro-text {
  font-size: 12px;
  color: var(--da-text-muted);
  line-height: 1.55;
  margin-bottom: 12px;
}

/* Suggested prompts */
.da-suggestions {
  padding: 4px 20px 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  flex-shrink: 0;
}
.da-suggestion {
  font-size: 11.5px;
  padding: 7px 12px;
  background: transparent;
  border: 1px solid var(--da-accent);
  border-radius: 20px;
  cursor: pointer;
  color: var(--da-accent);
  font-family: inherit;
  line-height: 1.35;
  transition: all 0.15s;
}
.da-suggestion:hover {
  background: rgba(13,148,136,0.15);
  color: #fff;
}

/* Messages area */
.da-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Message bubbles */
.da-msg {
  max-width: 92%;
  animation: da-fadein 0.2s ease;
}
.da-msg-user {
  margin-left: auto;
  background: var(--da-user-bg);
  padding: 10px 14px;
  border-radius: 12px 12px 2px 12px;
  font-size: 13px;
  color: var(--da-text);
  line-height: 1.5;
}
.da-msg-assistant {
  margin-right: auto;
  background: var(--da-assistant-bg);
  border: 1px solid var(--da-border);
  padding: 12px 14px;
  border-radius: 12px 12px 12px 2px;
  font-size: 13px;
  color: var(--da-text);
  line-height: 1.65;
  word-wrap: break-word;
}
.da-msg-error {
  margin-right: auto;
  background: var(--da-error-bg);
  border: 1px solid rgba(239,68,68,0.15);
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 12px;
  color: var(--da-text-muted);
  line-height: 1.55;
}

@keyframes da-fadein {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Loading dots */
.da-loading {
  display: inline-flex;
  gap: 5px;
  padding: 10px 14px;
  margin-right: auto;
}
.da-loading-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--da-text-muted);
  animation: da-pulse 1.2s infinite;
}
.da-loading-dot:nth-child(2) { animation-delay: 0.2s; }
.da-loading-dot:nth-child(3) { animation-delay: 0.4s; }

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

/* Input row */
.da-input-row {
  padding: 12px 16px;
  border-top: 1px solid var(--da-border);
  display: flex;
  gap: 8px;
  flex-shrink: 0;
  background: var(--da-bg);
}
.da-input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--da-border);
  border-radius: 8px;
  font-size: 13px;
  font-family: inherit;
  color: var(--da-text);
  outline: none;
  background: var(--da-surface);
  transition: border-color 0.15s;
}
.da-input:focus {
  border-color: var(--da-accent);
}
.da-input::placeholder {
  color: var(--da-text-muted);
}
.da-send {
  padding: 10px 16px;
  background: var(--da-accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: opacity 0.15s;
  white-space: nowrap;
}
.da-send:hover {
  opacity: 0.88;
}
.da-send:disabled {
  opacity: 0.45;
  cursor: default;
}

/* "Develop this story" source links in assistant messages */
.da-develop {
  color: var(--da-accent);
  text-decoration: underline;
  font-size: 0.8rem;
}
.da-develop:hover {
  opacity: 0.8;
}

/* Assistant message inner formatting */
.da-msg-assistant h4 {
  font-size: 13px;
  font-weight: 700;
  margin: 0 0 4px 0;
  color: var(--da-text);
}
.da-msg-assistant ul {
  margin: 4px 0;
  padding-left: 18px;
}
.da-msg-assistant li {
  margin-bottom: 2px;
}
.da-msg-assistant a {
  color: var(--da-accent);
  text-decoration: underline;
}
.da-msg-assistant a:hover {
  opacity: 0.8;
}

/* Mobile: full-width sheet */
@media (max-width: 600px) {
  .da-drawer {
    width: 100vw;
    border-left: none;
  }
  .da-fab {
    bottom: 16px;
    right: 16px;
    width: 48px;
    height: 48px;
  }
  .da-fab svg {
    width: 20px;
    height: 20px;
  }
  .da-messages {
    padding: 10px 16px;
  }
  .da-suggestions {
    padding: 4px 16px 10px;
  }
  .da-input-row {
    padding: 10px 12px;
  }
}

/* Print: hide assistant */
@media print {
  .da-fab, .da-drawer, .da-overlay { display: none !important; }
}
