/* ══════════════════════════════════════════════════════════════════════════════
   fleet_design_bible.css — OMNIDOMAIN Fleet Layout & Component System
   ══════════════════════════════════════════════════════════════════════════════
   The structural layout CSS for all 56+ fleet domains.
   theme_families.css provides colors/fonts via CSS custom properties.
   This file provides the actual box model, grid, spacing, and component styles.
   
   Version: 1.0.0  |  2026-04-26
   ══════════════════════════════════════════════════════════════════════════════ */

/* ── CSS Custom Properties (Design Tokens) ──────────────────────────────────── */
:root {
  --border-subtle:      rgba(255, 255, 255, 0.08);
  --border-medium:      rgba(255, 255, 255, 0.12);
  --border-strong:      rgba(255, 255, 255, 0.2);
  --text-primary:       rgba(255, 255, 255, 0.92);
  --text-secondary:     rgba(255, 255, 255, 0.7);
  --text-tertiary:      rgba(255, 255, 255, 0.45);
  --accent-color:       var(--theme-accent, #4a9eff);
  --status-value-blue:  #60a5fa;
  --surface-elevated:   rgba(255, 255, 255, 0.04);
  --surface-card:       rgba(255, 255, 255, 0.03);
  --surface-input:      rgba(0, 0, 0, 0.3);
  --shadow-card:        0 4px 16px rgba(0, 0, 0, 0.3);
  --shadow-heavy:       0 8px 32px rgba(0, 0, 0, 0.5);
  --radius-sm:          6px;
  --radius-md:          10px;
  --radius-lg:          14px;
  --radius-xl:          20px;
}

/* ── Reset & Base ───────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
}

body.fleet-console {
  font-family: var(--theme-body-font, 'Source Serif 4', Georgia, serif);
  color: var(--text-primary);
  background: var(--theme-primary, #0a0a0a);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

/* ── Hero Banner ────────────────────────────────────────────────────────────── */
.rat-hero {
  position: relative;
  background-size: cover;
  background-position: center 30%;
  background-repeat: no-repeat;
  min-height: 200px;
  display: flex;
  align-items: flex-end;
  overflow: hidden;
}

.rat-hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    180deg,
    rgba(0, 0, 0, 0.3) 0%,
    var(--theme-overlay, rgba(10, 10, 10, 0.85)) 100%
  );
  z-index: 1;
}

.rat-hero-inner {
  position: relative;
  z-index: 2;
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
  padding: 40px 32px 28px;
  display: flex;
  align-items: flex-end;
}

.rat-hero h1 {
  font-family: var(--theme-heading-font, 'Source Serif 4', serif);
  font-size: clamp(1.75rem, 4vw, 2.75rem);
  font-weight: 700;
  margin: 0 0 6px;
  color: #fff;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.5);
  letter-spacing: -0.02em;
}

.rat-hero .subtitle {
  font-size: 1.15rem;
  color: var(--theme-accent, #c9a84c);
  margin: 0 0 4px;
  font-weight: 500;
  letter-spacing: 0.02em;
}

.rat-hero .subtitle-secondary {
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.5);
  margin: 0;
  letter-spacing: 0.06em;
  text-transform: lowercase;
}

.hero-book-icon {
  display: none; /* Hidden by default — enable per-domain if needed */
}

/* ── Status Bar ─────────────────────────────────────────────────────────────── */
.status-bar {
  max-width: 1400px;
  margin: 0 auto;
  padding: 8px 24px;
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  font-size: 0.78rem;
  color: var(--text-tertiary);
  letter-spacing: 0.03em;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--surface-elevated);
}

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

.status-dot {
  color: #22c55e;
  font-size: 0.65em;
  animation: status-pulse 2s ease-in-out infinite;
}

@keyframes status-pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.4; }
}

.status-bar-clipboard {
  font-size: 0.9em;
}

/* ── Main Layout (Sidebar + Content) ────────────────────────────────────────── */
.main-layout {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 0;
  min-height: 0;
  flex: 1;
  overflow: hidden;
}

@media (max-width: 900px) {
  .main-layout {
    grid-template-columns: 1fr;
  }
}

/* ── Fleet Main (Chat Area) ─────────────────────────────────────────────────── */
.fleet-main {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

/* ── Chat Scroll Area ───────────────────────────────────────────────────────── */
.chat-scroll-area {
  flex: 1;
  overflow-y: auto;
  padding: 24px 28px;
  min-height: 0;
  scroll-behavior: smooth;
  background: var(--surface-card);
  border-radius: var(--radius-md);
  margin: 0;
}

.chat-scroll-area::-webkit-scrollbar {
  width: 6px;
}
.chat-scroll-area::-webkit-scrollbar-track {
  background: transparent;
}
.chat-scroll-area::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.12);
  border-radius: 3px;
}
.chat-scroll-area::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
}

.fleet-chat-anchor {
  display: block;
  height: 0;
  overflow: hidden;
}

/* ── Welcome Card ───────────────────────────────────────────────────────────── */
.welcome-card {
  background: var(--surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 28px 28px 24px;
  margin-bottom: 24px;
}

.welcome-card h2 {
  font-family: var(--theme-heading-font, 'Source Serif 4', serif);
  font-size: 1.5rem;
  font-weight: 650;
  margin: 0 0 12px;
  color: var(--text-primary);
}

.welcome-card p {
  color: var(--text-secondary);
  font-size: 1.05rem;
  line-height: 1.7;
  margin: 0 0 8px;
}

.welcome-brand-line {
  margin-top: 16px;
  font-style: italic;
  color: var(--theme-accent, #c9a84c);
  font-size: 0.95rem;
  opacity: 0.85;
}

.how-it-works {
  margin-top: 12px;
}

.how-it-works summary {
  cursor: pointer;
  color: var(--status-value-blue);
  font-weight: 650;
  font-size: 0.95rem;
  user-select: none;
}

.welcome-guidance {
  margin-top: 10px;
}

.welcome-guidance p {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.6;
  margin: 0 0 10px;
}

.welcome-guidance-label {
  color: var(--theme-accent, #c9a84c);
  font-weight: 650;
}

/* ── Chat Messages ──────────────────────────────────────────────────────────── */
.chat-messages {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.message {
  display: flex;
  max-width: 100%;
}

.message.user {
  justify-content: flex-end;
}

.message.user .message-content {
  background: linear-gradient(135deg, var(--theme-accent, #4a9eff), color-mix(in srgb, var(--theme-accent, #4a9eff) 70%, #000));
  color: #fff;
  border-radius: var(--radius-lg) var(--radius-lg) 4px var(--radius-lg);
  max-width: 75%;
  padding: 14px 18px;
  font-size: 1rem;
  line-height: 1.6;
}

.message.assistant .message-content {
  background: var(--surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 4px var(--radius-lg) var(--radius-lg) var(--radius-lg);
  max-width: 90%;
  padding: 18px 22px;
  font-size: 1.05rem;
  line-height: 1.75;
  color: var(--text-primary);
}

.response-content {
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.response-content strong {
  color: var(--theme-accent, #c9a84c);
}

.response-content em {
  color: var(--text-secondary);
}

/* ── Loading Indicator ──────────────────────────────────────────────────────── */
.loading {
  display: none;
  text-align: center;
  padding: 12px;
  color: var(--text-tertiary);
  font-size: 0.9rem;
  letter-spacing: 0.03em;
}

.loading.active {
  display: block;
  animation: loadPulse 1.5s ease-in-out infinite;
}

@keyframes loadPulse {
  0%, 100% { opacity: 0.4; }
  50%      { opacity: 1; }
}

/* ── Input Area ─────────────────────────────────────────────────────────────── */
.input-area {
  display: flex;
  gap: 10px;
  padding: 16px 20px;
  border-top: 1px solid var(--border-subtle);
  background: var(--surface-elevated);
  flex-shrink: 0;
}

.input-area input[type="text"],
#messageInput {
  flex: 1;
  padding: 12px 16px;
  font-size: 1rem;
  font-family: inherit;
  color: var(--text-primary);
  background: var(--surface-input);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.input-area input[type="text"]:focus,
#messageInput:focus {
  border-color: var(--theme-accent, #4a9eff);
  box-shadow: 0 0 0 3px rgba(74, 158, 255, 0.15);
}

.input-area input::placeholder {
  color: var(--text-tertiary);
}

#sendButton {
  padding: 12px 24px;
  font-size: 0.95rem;
  font-weight: 650;
  font-family: inherit;
  color: #fff;
  background: var(--theme-accent, #4a9eff);
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

#sendButton:hover {
  opacity: 0.88;
}

#sendButton:active {
  transform: scale(0.97);
}

#sendButton:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ── Quick Questions ────────────────────────────────────────────────────────── */
.quick-questions {
  padding: 16px 20px 20px;
  flex-shrink: 0;
}

.quick-questions-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 10px;
}

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

.quick-question-btn {
  padding: 8px 14px;
  font-size: 0.82rem;
  font-family: inherit;
  color: var(--theme-accent, #c9a84c);
  background: transparent;
  border: 1px solid color-mix(in srgb, var(--theme-accent, #c9a84c) 35%, transparent);
  border-radius: var(--radius-xl);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  line-height: 1.4;
  text-align: left;
  max-width: 100%;
}

.quick-question-btn:hover {
  background: color-mix(in srgb, var(--theme-accent, #c9a84c) 12%, transparent);
  border-color: color-mix(in srgb, var(--theme-accent, #c9a84c) 60%, transparent);
  color: #fff;
}

/* ── Fleet Sidebar ──────────────────────────────────────────────────────────── */
.fleet-sidebar {
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--border-subtle);
  background: var(--surface-card);
  overflow-y: auto;
  min-height: 0;
}

@media (max-width: 900px) {
  .fleet-sidebar {
    border-left: none;
    border-top: 1px solid var(--border-subtle);
    max-height: 300px;
  }
}

.fleet-sidebar::-webkit-scrollbar {
  width: 4px;
}
.fleet-sidebar::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
}

.sidebar-header {
  padding: 16px 20px 12px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--theme-accent, #c9a84c);
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.sidebar-body {
  flex: 1;
  padding: 12px 16px;
  overflow-y: auto;
  min-height: 0;
}

/* ── Sidebar Topic Cards ────────────────────────────────────────────────────── */
.sidebar-topic {
  display: block;
  text-decoration: none;
  color: inherit;
  padding: 14px 16px;
  margin-bottom: 10px;
  background: var(--surface-elevated);
  border: 1px solid var(--border-subtle);
  border-left: 3px solid var(--theme-accent, #c9a84c);
  border-radius: var(--radius-sm);
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
  cursor: pointer;
}

.sidebar-topic:hover {
  background: rgba(255, 255, 255, 0.06);
  border-left-color: var(--theme-accent, #c9a84c);
  transform: translateX(2px);
}

.sidebar-topic h3 {
  font-family: var(--theme-heading-font, 'Source Serif 4', serif);
  font-size: 0.92rem;
  font-weight: 650;
  margin: 0 0 4px;
  color: var(--text-primary);
}

.sidebar-topic p {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin: 0;
  line-height: 1.5;
}

/* ── Sidebar Footer ─────────────────────────────────────────────────────────── */
.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.sidebar-copyright {
  font-size: 0.7rem;
  color: var(--text-tertiary);
  letter-spacing: 0.03em;
}

/* ── Site Footer ────────────────────────────────────────────────────────────── */
.site-footer {
  text-align: center;
  padding: 12px 20px;
  font-size: 0.75rem;
  color: var(--text-tertiary);
  border-top: 1px solid var(--border-subtle);
  letter-spacing: 0.03em;
}

/* ── Report Bar (omni-report-bar) ───────────────────────────────────────────── */
#omni-report-bar {
  display: none;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  margin: 10px 0;
  background: var(--surface-elevated);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  flex-wrap: wrap;
  flex-shrink: 0;
}

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

.omb-label {
  font-size: 11px;
  color: var(--text-tertiary);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-right: 4px;
}

.omb-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 12px;
  font-size: 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-weight: 500;
  font-family: inherit;
  transition: opacity 0.15s, transform 0.1s;
  text-decoration: none;
}

.omb-btn:hover { opacity: 0.85; }
.omb-btn:active { transform: scale(0.97); }

.omb-outline {
  background: transparent;
  border: 1px solid var(--theme-accent, #6a8fa8);
  color: var(--theme-accent, #6a8fa8);
}

.omb-solid {
  background: var(--theme-accent, #6a8fa8);
  border: 1px solid var(--theme-accent, #6a8fa8);
  color: #fff;
}

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

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

#omb-email-input {
  flex: 1;
  min-width: 200px;
  padding: 7px 10px;
  font-size: 12px;
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-sm);
  outline: none;
  background: var(--surface-input);
  color: var(--text-primary);
  font-family: inherit;
}

#omb-email-input:focus {
  border-color: var(--theme-accent, #6a8fa8);
}

#omb-send-status {
  font-size: 12px;
  min-height: 18px;
  margin-top: 4px;
  width: 100%;
}

/* ── Sovereign Bar Override — prevent covering chat UI at all sizes ─────────── */
#sovereign-suggestion-bar {
  display: none !important;
}

/* ── Responsive ─────────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  /* ── Hero: compact on mobile ── */
  .rat-hero {
    min-height: 80px;
  }
  .rat-hero-inner {
    padding: 12px 14px 10px;
  }
  .rat-hero h1 {
    font-size: 1.15rem !important;
    margin-bottom: 2px;
  }
  .rat-hero .subtitle {
    font-size: 0.8rem !important;
    margin-bottom: 1px;
  }
  .rat-hero .subtitle-secondary {
    font-size: 0.7rem !important;
  }

  /* ── Status bar: single line ── */
  .status-bar {
    padding: 4px 12px;
    gap: 8px;
    font-size: 0.65rem;
  }

  /* ── Chat area ── */
  .chat-scroll-area {
    padding: 10px 12px;
    padding-bottom: 8px;
  }

  /* ── Welcome card: slim ── */
  .welcome-card {
    padding: 14px 14px 10px;
    min-height: unset;
    margin-bottom: 12px;
  }
  .welcome-card h2 {
    font-size: 1.1rem !important;
    margin-bottom: 6px;
  }
  .welcome-card p {
    font-size: 0.85rem !important;
    line-height: 1.5;
  }
  .welcome-brand-line {
    font-size: 0.8rem;
    margin-top: 8px;
  }
  .how-it-works {
    margin-top: 6px;
  }

  /* ── Input area ── */
  .input-area {
    padding: 8px 10px;
  }
  .input-area input[type="text"],
  #messageInput {
    padding: 8px 10px;
    font-size: 16px; /* prevents iOS zoom */
  }
  #sendButton {
    padding: 8px 14px;
    font-size: 0.85rem;
  }

  /* ── Messages ── */
  .message.user .message-content { max-width: 88%; }
  .message.assistant .message-content { max-width: 95%; }

  /* ── Quick questions: collapsed, show 2 rows max ── */
  .quick-questions {
    padding: 6px 10px 8px;
  }
  .quick-questions-label {
    font-size: 0.65rem;
    margin-bottom: 4px;
  }
  .qq-grid {
    max-height: 52px;
    overflow-y: auto;
    gap: 4px;
  }
  .quick-question-btn {
    font-size: 0.7rem;
    padding: 4px 8px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 48%;
  }

  /* ── Hide overlays on mobile ── */
  #sovereign-suggestion-bar { display: none !important; }
  #sovereign-orb {
    top: 6px; right: 8px;
    padding: 3px 8px 3px 5px;
    font-size: 9px;
  }
  #sovereign-panel {
    width: calc(100vw - 24px);
    right: 12px;
    max-height: 60vh;
    overflow-y: auto;
  }
  #rat-lead-widget.open { bottom: 60px !important; }

  /* ── bake-wrapper: use full height on mobile ── */
  .bake-wrapper {
    height: calc(100vh - 90px) !important;
    min-height: 400px;
    margin: 8px auto;
    border-radius: 8px;
  }

  /* ── Sidebar: hide on mobile (or collapse) ── */
  .fleet-sidebar {
    display: none;
  }
}

@media (max-width: 480px) {
  .rat-hero {
    min-height: 60px;
  }
  .rat-hero h1 {
    font-size: 1rem !important;
  }
  .rat-hero .subtitle {
    font-size: 0.72rem !important;
  }
  .rat-hero .subtitle-secondary {
    display: none;
  }
  .status-bar span:nth-child(n+3) {
    display: none;
  }
  .welcome-card {
    padding: 10px 12px 8px;
  }
  .welcome-card h2 {
    font-size: 0.95rem !important;
  }
  /* quick questions: single scrollable row */
  .qq-grid {
    max-height: 36px;
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
  }
  .quick-question-btn {
    flex-shrink: 0;
    max-width: 200px;
  }
}

/* ── Print Styles ───────────────────────────────────────────────────────────── */
@media print {
  .rat-hero,
  .status-bar,
  .fleet-sidebar,
  .input-area,
  .quick-questions,
  .site-footer,
  #omni-report-bar,
  .loading,
  #sovereign-orb,
  #sovereign-panel,
  #sovereign-suggestion-bar {
    display: none !important;
  }
  
  body.fleet-console {
    background: #fff !important;
    color: #222 !important;
  }
  
  .bake-wrapper {
    height: auto !important;
    border: none !important;
    box-shadow: none !important;
  }
  
  .chat-scroll-area {
    overflow: visible !important;
    border: none !important;
  }
  
  .message.assistant .message-content {
    background: none !important;
    border: none !important;
    color: #222 !important;
  }
}
