/* ── Atlas SideChat ───────────────────────────────────────────────────
   External CSS for the Atlas companion panel.
   Uses shared CSS variables from the host theme.
   No hardcoded colors, sizes, or fonts.
   Supports: language (dir-aware), accessibility (focus, contrast, motion),
             responsive (mobile), theme inheritance.
   ──────────────────────────────────────────────────────────────────── */

/* ── Panel shell ─────────────────────────────────────────────────────── */

.atlas-sidechat {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: var(--atlas-sidechat-width, 380px);
  max-width: 92vw;
  background: var(--gx-panel);
  border-left: 1px solid var(--gx-border);
  box-shadow: -4px 0 24px rgba(0, 0, 0, 0.08);
  display: flex;
  flex-direction: column;
  z-index: 9000;
  transform: translateX(100%);
  transition: transform 0.25s ease;
  font-family: inherit;
  color: var(--gx-ink);
}
.atlas-sidechat--open {
  transform: translateX(0);
}

/* RTL support */
[dir="rtl"] .atlas-sidechat {
  right: auto;
  left: 0;
  border-left: none;
  border-right: 1px solid var(--gx-border);
  transform: translateX(-100%);
}
[dir="rtl"] .atlas-sidechat--open {
  transform: translateX(0);
}

/* ── Header ──────────────────────────────────────────────────────────── */

.atlas-sidechat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--gx-border);
  background: var(--gx-panel2);
  flex-shrink: 0;
}
.atlas-sidechat-title {
  font-weight: 700;
  font-size: var(--gx-font-size-base, 14px);
  color: var(--gx-ink);
}
.atlas-sidechat-close {
  appearance: none;
  background: none;
  border: none;
  font-size: 1.25em;
  cursor: pointer;
  color: var(--gx-muted);
  padding: 4px 8px;
  border-radius: 4px;
  line-height: 1;
}
.atlas-sidechat-close:hover,
.atlas-sidechat-close:focus-visible {
  background: var(--gx-border);
  outline: 2px solid var(--gx-accent);
  outline-offset: 2px;
}

/* ── Message log ─────────────────────────────────────────────────────── */

.atlas-sidechat-log {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px;
}
.atlas-msg {
  margin-bottom: 10px;
  font-size: var(--gx-font-size-base, 14px);
  line-height: var(--gx-line-height-base, 1.5);
  padding: 8px 12px;
  border-radius: 8px;
}
.atlas-msg--atlas {
  background: var(--gx-panel2);
  color: var(--gx-ink);
}
.atlas-msg--user {
  background: var(--gx-accent);
  color: var(--gx-btn-ink, #ffffff);
  text-align: right;
}
[dir="rtl"] .atlas-msg--user {
  text-align: left;
}
.atlas-msg-label {
  font-weight: 600;
  font-size: var(--gx-font-size-xs, 12px);
  margin-bottom: 2px;
  display: block;
}

/* ── Suggestions ─────────────────────────────────────────────────────── */

.atlas-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}
.atlas-suggestion-btn {
  appearance: none;
  background: var(--gx-panel);
  border: 1px solid var(--gx-border);
  border-radius: 16px;
  padding: 4px 12px;
  font-size: var(--gx-font-size-xs, 12px);
  cursor: pointer;
  color: var(--gx-accent);
  font-weight: 600;
  font-family: inherit;
  transition: background 0.15s;
}
.atlas-suggestion-btn:hover,
.atlas-suggestion-btn:focus-visible {
  background: var(--gx-panel2);
  outline: 2px solid var(--gx-accent);
  outline-offset: 2px;
}

/* ── Input row ───────────────────────────────────────────────────────── */

.atlas-sidechat-input-row {
  display: flex;
  gap: 8px;
  padding: 10px 16px;
  border-top: 1px solid var(--gx-border);
  background: var(--gx-panel);
  flex-shrink: 0;
}
.atlas-sidechat-input {
  flex: 1;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--gx-border);
  font-size: var(--gx-font-size-base, 14px);
  font-family: inherit;
  color: var(--gx-ink);
  background: var(--gx-bg);
}
.atlas-sidechat-input:focus {
  outline: none;
  border-color: var(--gx-accent);
  box-shadow: 0 0 0 2px var(--gx-focus-ring, rgba(26, 115, 232, 0.25));
}
.atlas-sidechat-send {
  appearance: none;
  min-width: var(--gx-control-height-sm, 34px);
  height: var(--gx-control-height-sm, 34px);
  border-radius: 8px;
  border: none;
  background: var(--gx-accent);
  color: var(--gx-btn-ink, #ffffff);
  font-size: 1em;
  cursor: pointer;
  flex-shrink: 0;
}
.atlas-sidechat-send:hover {
  opacity: 0.9;
}
.atlas-sidechat-send:focus-visible {
  outline: 2px solid var(--gx-accent);
  outline-offset: 2px;
}

/* ── Accessibility: reduced motion ───────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
  .atlas-sidechat {
    transition: none;
  }
}

/* ── Accessibility: high contrast ────────────────────────────────────── */

@media (forced-colors: active) {
  .atlas-msg--atlas,
  .atlas-msg--user {
    border: 1px solid ButtonText;
  }
  .atlas-suggestion-btn {
    border: 1px solid ButtonText;
  }
}

/* ── Responsive ──────────────────────────────────────────────────────── */

@media (max-width: 600px) {
  .atlas-sidechat {
    width: 100vw;
    max-width: 100vw;
  }
}
