/* RAT Fleet Design Bible v1.1 — RAT_FLEET_DESIGN_BIBLE2.md */

:root {
  --theme-primary: #0d0d1a;
  --card-bg: #1e1e2e;
  --sidebar-bg: #252535;
  --input-bg: #14141f;
  --accent-color: #c9a84c;
  --accent-hover: #d4b86a;
  --text-primary: #ffffff;
  --text-secondary: rgba(255, 255, 255, 0.7);
  --text-tertiary: rgba(255, 255, 255, 0.45);
  --border-subtle: rgba(201, 168, 76, 0.2);
  --border-medium: rgba(201, 168, 76, 0.4);
  --overlay-dark: rgba(13, 13, 26, 0.82);
  /* Reference “white inset” (CURSOR_FIX_WHITE_INSET.md) */
  --inset-cream: #f5f0e8;
  --inset-cream-hover: #e8dfd0;
  --inset-cream-text: #1a1a2e;
  --hero-title-silver: #b8c4d0;
  --status-value-blue: #5b8fd4;
  --layout-light-band: #f0f0f0;
  --sidebar-divider-blue: rgba(100, 140, 200, 0.25);
  --font-hero-serif: "Garamond Premier Pro", "Cormorant Garamond", Georgia, serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body.fleet-console {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.6;
  background: var(--theme-primary);
  color: var(--text-primary);
  padding: 0;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* Compact hero + taller chat scroller (theme_families.css loads after and widens .rat-hero padding) */
body.fleet-console .rat-hero {
  min-height: clamp(100px, 13vh, 190px);
  padding: 14px 40px 10px;
  flex-shrink: 0;
}

body.fleet-console .hero-book-icon {
  top: 10px;
  left: 32px;
  font-size: 1.85rem;
}

body.fleet-console .rat-hero h1 {
  font-size: clamp(1.25rem, 3vw, 2rem);
  margin: 0 0 0.2rem;
}

body.fleet-console .rat-hero .subtitle {
  font-size: 0.95rem;
  margin: 0 0 0.15rem;
}

body.fleet-console .rat-hero .subtitle-secondary {
  font-size: 0.75rem;
}

body.fleet-console .main-layout {
  padding: 14px 20px 16px;
  gap: 16px;
}

/* One scroll region: guarantee a substantial slice of the viewport */
body.fleet-console .chat-scroll-area {
  flex: 1 1 auto;
  min-height: max(240px, calc(100vh - 270px));
}

@supports (height: 100dvh) {
  body.fleet-console .chat-scroll-area {
    min-height: max(240px, calc(100dvh - 270px));
  }
}

.fleet-chat-anchor {
  display: block;
  scroll-margin-top: 12px;
  height: 0;
  overflow: hidden;
  pointer-events: none;
}

/* ── Hero (text at bottom; parallax). Column + flex-end = reliable bottom anchor vs stray centering. */
.rat-hero {
  background-size: cover;
  background-position: center;
  background-attachment: fixed;
  background-color: var(--theme-primary);
  position: relative;
  min-height: 300px;
  width: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: stretch;
  padding: 40px 48px;
}

.rat-hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to bottom,
    rgba(13, 13, 26, 0.45) 0%,
    rgba(13, 13, 26, 0.82) 100%
  );
  z-index: 0;
}

.hero-book-icon {
  position: absolute;
  top: 28px;
  left: 48px;
  z-index: 3;
  font-size: 2.5rem;
  line-height: 1;
  filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.45));
  pointer-events: none;
}

.rat-hero-inner {
  position: relative;
  z-index: 1;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
}

.rat-hero h1 {
  font-family: var(--font-hero-serif);
  font-size: clamp(2rem, 5vw, 3.2rem);
  font-weight: 500;
  color: var(--hero-title-silver);
  line-height: 1.1;
  letter-spacing: -0.02em;
  margin: 0 0 0.35rem;
}

.rat-hero .subtitle {
  font-style: italic;
  color: rgba(200, 210, 225, 0.55);
  font-size: 1.15rem;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0.01em;
  margin: 0 0 0.25rem;
}

.rat-hero .subtitle-secondary {
  font-family: "Courier New", monospace;
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.5);
  margin: 0;
}

/* ── Status bar ── */
.status-bar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 12px 24px;
  padding: 8px 24px;
  background: rgba(13, 13, 26, 0.95);
  border-bottom: 1px solid var(--border-subtle);
  font-family: "Courier New", monospace;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.6);
  width: 100%;
}

.status-bar .value {
  color: var(--status-value-blue);
  font-weight: bold;
}

.status-dot {
  color: var(--accent-color);
  margin-right: 4px;
}

.status-bar-clipboard {
  margin-right: 4px;
}

/* ── Grid ── */
.main-layout {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 24px;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
  padding: 24px;
  flex: 1;
  min-height: 0;
  align-items: stretch;
  border-top: 3px solid var(--layout-light-band);
}

@media (max-width: 768px) {
  .main-layout {
    grid-template-columns: 1fr;
  }
  .sidebar,
  .fleet-sidebar {
    display: none;
  }
  .rat-hero {
    padding: 28px 20px;
  }
  .hero-book-icon {
    top: 20px;
    left: 20px;
    font-size: 2rem;
  }
  body.fleet-console .rat-hero {
    min-height: clamp(92px, 12vh, 160px);
    padding: 12px 20px 8px;
  }
  body.fleet-console .hero-book-icon {
    top: 8px;
    left: 18px;
    font-size: 1.6rem;
  }
  body.fleet-console .chat-scroll-area {
    min-height: max(200px, calc(100vh - 248px));
  }
  @supports (height: 100dvh) {
    body.fleet-console .chat-scroll-area {
      min-height: max(200px, calc(100dvh - 248px));
    }
  }
  .fleet-main {
    min-height: 0;
  }
}

.fleet-main {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  height: 100%;
  gap: 12px;
}

/* ── Fixed console spec: one scroll region ── */
.chat-scroll-area {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 16px;
  background: rgba(30, 30, 46, 0.55);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  scrollbar-gutter: stable;
  scrollbar-width: thin;
  scrollbar-color: rgba(220, 220, 230, 0.55) rgba(255, 255, 255, 0.12);
}

.chat-scroll-area::-webkit-scrollbar {
  width: 10px;
}
.chat-scroll-area::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
}
.chat-scroll-area::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.38);
  border-radius: 4px;
  border: 2px solid rgba(30, 30, 46, 0.35);
}
.chat-scroll-area::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.52);
}

/* ── Welcome card ── */
.welcome-card {
  background: var(--card-bg);
  border: 1px solid var(--border-subtle);
  border-radius: 0 8px 8px 0;
  border-left: 3px solid var(--accent-color);
  padding: 20px 22px;
  margin-bottom: 20px;
  box-shadow:
    0 0 20px rgba(255, 255, 255, 0.05),
    0 4px 12px rgba(0, 0, 0, 0.35);
}

.chat-messages .welcome-card {
  margin-bottom: 24px;
  flex-shrink: 0;
}

.welcome-card h2 {
  font-family: var(--font-hero-serif);
  font-size: 1.35rem;
  font-weight: 500;
  color: var(--accent-color);
  margin: 0 0 10px;
}

.welcome-card p {
  margin: 0;
  color: var(--text-secondary);
  line-height: 1.65;
}

.welcome-card p + p {
  margin-top: 12px;
}

.welcome-guidance {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--border-subtle);
}

.welcome-guidance p {
  margin: 0 0 10px;
}

.welcome-guidance p:last-child {
  margin-bottom: 0;
}

.welcome-guidance-label {
  color: var(--text-primary);
  font-weight: 600;
}

.welcome-brand-line {
  margin-top: 14px !important;
  color: var(--accent-color);
  font-size: 1rem;
  font-weight: 600;
}

/* ── Chat messages (NOT scroll container; scroll is on .chat-scroll-area) ── */
.chat-messages {
  min-height: 0;
}

.message {
  margin-bottom: 1rem;
}

.message.user .message-content {
  padding: 12px 14px;
  border-radius: 6px;
  background: rgba(20, 20, 31, 0.9);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
}

/* Bible: .assistant-message — alias for chat bubble structure */
.message.assistant .message-content,
.assistant-message {
  border-left: 3px solid #c9a84c;
  padding: 14px 16px;
  background: linear-gradient(135deg, #1e1e2e, #252535);
  border-radius: 0 8px 8px 0;
  line-height: 1.75;
}

.response-content a {
  color: var(--accent-hover);
}

.loading {
  display: none;
  text-align: center;
  color: var(--text-tertiary);
  font-size: 13px;
  padding: 8px;
  font-family: "Courier New", monospace;
  flex-shrink: 0;
}

.loading.active {
  display: block;
}

/* ── Report bar (dropdown + REPORT / Print / Download / Cloud) ── */
.fleet-report-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 12px 0;
  margin-bottom: 0;
  flex-shrink: 0;
  border-top: 1px solid var(--border-subtle);
  border-bottom: 1px solid var(--border-subtle);
}

.fleet-report-bar[hidden] {
  display: none !important;
}

.report-select-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

#reportSelect,
.report-select {
  flex: 1;
  min-width: 200px;
  max-width: 100%;
  background: var(--inset-cream);
  color: var(--inset-cream-text);
  border: 1px solid var(--border-medium);
  border-radius: 6px;
  padding: 10px 16px;
  font-size: 14px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  appearance: auto;
}

.report-select:focus {
  border-color: rgba(201, 168, 76, 0.6);
  outline: none;
  box-shadow: 0 0 0 3px rgba(201, 168, 76, 0.1);
}

.report-btn {
  background: var(--inset-cream);
  color: var(--inset-cream-text);
  border: 1px solid var(--border-medium);
  border-radius: 6px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.report-btn:hover {
  background: var(--inset-cream-hover);
  border-color: var(--accent-color);
  color: var(--inset-cream-text);
}

.report-btn-primary {
  background: #c9a84c;
  color: #0d0d1a;
  -webkit-text-fill-color: #0d0d1a;
  border: 1px solid #c9a84c;
}

.report-btn-primary:hover {
  background: var(--accent-hover);
  color: #0d0d1a;
  -webkit-text-fill-color: #0d0d1a;
  border-color: var(--accent-hover);
}

.rpt-email-form-inline {
  display: none;
  width: 100%;
  flex-basis: 100%;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 8px;
}

.rpt-email-form-inline.open {
  display: flex;
}

.rpt-email-form-inline #rpt-email-input {
  flex: 1;
  min-width: 200px;
  padding: 8px 12px;
  font-size: 13px;
  border-radius: 6px;
  border: 1px solid var(--border-subtle);
  background: var(--input-bg);
  color: var(--text-primary);
}

.input-area {
  display: flex;
  gap: 10px;
  margin-bottom: 0;
  flex-shrink: 0;
}

.quick-questions {
  flex-shrink: 0;
  margin-bottom: 0;
}

#messageInput {
  flex: 1;
  background: var(--input-bg);
  border: 1px solid var(--border-subtle);
  color: #ffffff;
  font-size: 15px;
  padding: 12px 16px;
  border-radius: 6px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

#messageInput:focus {
  border-color: rgba(201, 168, 76, 0.6);
  box-shadow: 0 0 0 3px rgba(201, 168, 76, 0.1);
  outline: none;
}

/* Gold buttons: midnight text only (9:1+ contrast — never white on gold) */
body.fleet-console #sendButton,
body.fleet-console #report-action-bar .rpt-btn-solid {
  background: var(--accent-color);
  color: #0d0d1a;
  -webkit-text-fill-color: #0d0d1a;
  border: none;
}

body.fleet-console #sendButton {
  padding: 12px 24px;
  font-weight: bold;
  border-radius: 6px;
  font-size: 15px;
  cursor: pointer;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body.fleet-console #sendButton:hover,
body.fleet-console #report-action-bar .rpt-btn-solid:hover {
  background: var(--accent-hover);
  color: #0d0d1a;
  -webkit-text-fill-color: #0d0d1a;
}

body.fleet-console #sendButton:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.quick-questions-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-tertiary);
  margin-bottom: 10px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-weight: 600;
}

.qq-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.quick-question-btn {
  background: transparent;
  border: 1px solid rgba(201, 168, 76, 0.35);
  color: rgba(255, 255, 255, 0.75);
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.quick-question-btn:hover {
  border-color: var(--accent-color);
  color: var(--accent-color);
  background: rgba(201, 168, 76, 0.08);
}

/* ── Report bar (Design Bible + console) ── */
#report-action-bar {
  display: none;
  align-items: center;
  gap: 10px;
  padding: 12px 0;
  flex-wrap: wrap;
  border-top: 1px solid var(--border-subtle);
  margin-top: 8px;
}

#report-action-bar.visible {
  display: flex;
}

.report-bar-label {
  font-size: 11px;
  color: var(--text-tertiary);
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-family: "Courier New", monospace;
  margin-right: 4px;
}

.rpt-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  font-size: 13px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
  text-decoration: none;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  border: 1px solid var(--border-medium);
  background: transparent;
  color: var(--accent-color);
}

.rpt-btn:hover {
  border-color: var(--accent-color);
  background: rgba(201, 168, 76, 0.08);
}

.rpt-btn-solid {
  border-color: var(--accent-color);
}

#rpt-email-form {
  display: none;
  width: 100%;
  gap: 8px;
  align-items: center;
  margin-top: 8px;
  flex-wrap: wrap;
}

#rpt-email-form.open {
  display: flex;
}

#rpt-email-input {
  flex: 1;
  min-width: 200px;
  padding: 8px 12px;
  font-size: 13px;
  border-radius: 6px;
  border: 1px solid var(--border-subtle);
  background: var(--input-bg);
  color: var(--text-primary);
  outline: none;
}

#rpt-email-input:focus {
  border-color: rgba(201, 168, 76, 0.5);
}

#rpt-send-status {
  font-size: 12px;
  color: var(--accent-color);
  min-height: 18px;
  width: 100%;
  font-family: "Courier New", monospace;
}

/* ── Sidebar ── */
.fleet-sidebar {
  background: var(--sidebar-bg);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 0;
  overflow: hidden;
  align-self: start;
  max-height: 100%;
  display: flex;
  flex-direction: column;
}

.sidebar-header {
  background: linear-gradient(135deg, #c9a84c, #d4b86a);
  color: #0d0d1a;
  padding: 10px 16px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-weight: 600;
  font-size: 14px;
  letter-spacing: 0.5px;
  border-radius: 0;
  margin: 0;
}

.sidebar-body {
  padding: 20px 18px;
  overflow-y: auto;
  min-height: 0;
}

.sidebar-body > .sidebar-topic ~ .sidebar-topic {
  border-top: 1px solid var(--sidebar-divider-blue);
  padding-top: 16px;
  margin-top: 0;
}

.sidebar-body > .sidebar-topic {
  display: block;
  margin-bottom: 0;
  padding-bottom: 16px;
  text-decoration: none;
  color: inherit;
  transition: opacity 0.15s ease;
}

.sidebar-body > .sidebar-topic:hover {
  opacity: 0.92;
}

.sidebar-topic h3 {
  font-family: var(--font-hero-serif);
  font-size: 1.05rem;
  color: var(--accent-color);
  margin: 0 0 10px;
  font-weight: 500;
}

.sidebar-topic p {
  margin: 0;
  font-size: 13px;
  line-height: 1.65;
  color: var(--text-secondary);
}

.sidebar-body > .sidebar-section ~ .sidebar-section {
  border-top: 1px solid var(--sidebar-divider-blue);
  padding-top: 16px;
  margin-top: 0;
}

.sidebar-body > .sidebar-section {
  margin-bottom: 0;
  padding-bottom: 16px;
}

.sidebar-section h3 {
  font-family: var(--font-hero-serif);
  font-size: 1.05rem;
  color: var(--accent-color);
  margin: 0 0 10px;
  font-weight: 500;
}

.sidebar-section p {
  margin: 0;
  font-size: 13px;
  line-height: 1.65;
  color: var(--text-secondary);
}

.sidebar-details {
  margin-top: 16px;
  border-top: 1px solid var(--border-subtle);
  padding-top: 14px;
}

.sidebar-details summary {
  cursor: pointer;
  font-size: 12px;
  color: var(--accent-color);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.sidebar-details .inner {
  margin-top: 10px;
  font-size: 12px;
  color: var(--text-tertiary);
  line-height: 1.6;
}

.sidebar-footer {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--border-subtle);
  font-size: 11px;
  color: var(--text-tertiary);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
}

.sidebar-copyright {
  margin-bottom: 8px;
  color: var(--text-tertiary);
}

.sidebar-footer a {
  color: var(--accent-color);
}

.site-footer {
  text-align: center;
  padding: 20px 16px 28px;
  font-size: 12px;
  color: var(--text-tertiary);
  font-family: "Courier New", monospace;
  border-top: 1px solid var(--border-subtle);
  width: 100%;
}

@media print {
  #report-action-bar,
  .fleet-report-bar,
  .input-area,
  .quick-questions {
    display: none !important;
  }
  body.fleet-console {
    background: var(--theme-primary) !important;
    padding: 0 !important;
  }
}

/* ── Lock-in: full-viewport navy; gold links; status bar monospace ── */
html:has(body.fleet-console) {
  background-color: var(--theme-primary);
  height: 100%;
}

body.fleet-console {
  background-color: var(--theme-primary) !important;
  color: #ffffff !important;
  display: flex !important;
  flex-direction: column !important;
  min-height: 100vh !important;
}

body.fleet-console .main-layout,
body.fleet-console .fleet-main,
body.fleet-console .quick-questions {
  background-color: transparent !important;
}

/* Do not force #fff on .fleet-main — it can flatten hero-adjacent contrast in some builds */
body.fleet-console .fleet-main .message,
body.fleet-console .fleet-main .input-area,
body.fleet-console .fleet-main #messageInput {
  color: #ffffff !important;
}

body.fleet-console .quick-questions {
  color: #ffffff !important;
}

body.fleet-console .status-bar {
  font-family: "Courier New", Courier, monospace !important;
  color: rgba(255, 255, 255, 0.6) !important;
}

body.fleet-console .status-bar .value {
  color: var(--status-value-blue) !important;
  -webkit-text-fill-color: var(--status-value-blue) !important;
  font-weight: bold !important;
}

body.fleet-console a,
body.fleet-console a:visited {
  color: #c9a84c !important;
  -webkit-text-fill-color: #c9a84c !important;
}

body.fleet-console .welcome-card {
  border-left: 3px solid #c9a84c !important;
}

body.fleet-console .message.assistant .message-content,
body.fleet-console .assistant-message {
  border-left: 3px solid #c9a84c !important;
}

/* ══ CURSOR_FIX_WHITE_INSET — hard lock (survives cache / stray theme CSS) ══ */
body.fleet-console .rat-hero h1 {
  font-family: var(--font-hero-serif) !important;
  font-weight: 500 !important;
  color: var(--hero-title-silver) !important;
  -webkit-text-fill-color: var(--hero-title-silver) !important;
}

body.fleet-console .rat-hero .subtitle {
  color: rgba(200, 210, 225, 0.55) !important;
  -webkit-text-fill-color: rgba(200, 210, 225, 0.55) !important;
}

body.fleet-console .hero-book-icon {
  z-index: 3 !important;
  display: block !important;
}

body.fleet-console .status-dot {
  color: var(--accent-color) !important;
  -webkit-text-fill-color: var(--accent-color) !important;
}

body.fleet-console .main-layout {
  border-top: 3px solid var(--layout-light-band) !important;
}

body.fleet-console .welcome-card {
  box-shadow:
    0 0 20px rgba(255, 255, 255, 0.05),
    0 4px 12px rgba(0, 0, 0, 0.35) !important;
}

body.fleet-console #reportSelect,
body.fleet-console .report-select {
  background: var(--inset-cream) !important;
  color: var(--inset-cream-text) !important;
  -webkit-text-fill-color: var(--inset-cream-text) !important;
  border: 1px solid var(--border-medium) !important;
}

body.fleet-console .fleet-report-bar .report-btn:not(.report-btn-primary) {
  background: var(--inset-cream) !important;
  color: var(--inset-cream-text) !important;
  -webkit-text-fill-color: var(--inset-cream-text) !important;
  border: 1px solid var(--border-medium) !important;
}

body.fleet-console .fleet-report-bar .report-btn:not(.report-btn-primary):hover {
  background: var(--inset-cream-hover) !important;
  border-color: var(--accent-color) !important;
}

body.fleet-console .fleet-report-bar .report-btn-primary {
  background: #c9a84c !important;
  color: #0d0d1a !important;
  -webkit-text-fill-color: #0d0d1a !important;
  border: 1px solid #c9a84c !important;
}
