/* =================================================================
   Blue222 — Ocean AI  |  Design Option 5  |  Modal Overlay Chat UI
   ================================================================= */

/* ── Reset & Base ──────────────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: 'Roboto', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #F5F7FA;
  color: #333;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

h1, h2, h3, h4, h5, h6 {
  font-family: 'Rubik', 'Roboto', sans-serif;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
}

input {
  font-family: inherit;
  border: none;
  outline: none;
}

a {
  text-decoration: none;
  color: inherit;
}

/* Links inside chat replies (e.g. document links) must stand out from the
   black body text — brand blue + underline so they're obviously clickable. */
.chat-msg .msg-bubble a {
  color: #4293CF;
  text-decoration: underline;
}
.chat-msg .msg-bubble a:hover {
  color: #2f6f9e;
}
/* Document links: file-type icon + soft chip so files stand out from plain links */
.chat-msg .msg-bubble a.file-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  margin: 1px 0;
  background: rgba(66, 147, 207, 0.10);
  border: 1px solid rgba(66, 147, 207, 0.25);
  border-radius: 6px;
  text-decoration: none;
}
.chat-msg .msg-bubble a.file-link:hover {
  background: rgba(66, 147, 207, 0.18);
  text-decoration: underline;
}
.chat-msg .msg-bubble .file-icon {
  font-size: 13px;
  line-height: 1;
}

/* ── Utility ───────────────────────────────────────────────────────── */
.hidden {
  display: none !important;
}

/* ================================================================== */
/*  APP SHELL                                                          */
/* ================================================================== */
.app-shell {
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: #fff;
  box-shadow: 0 0 60px rgba(0,0,0,.06);
  padding-bottom: 44px;
}

/* ── Header ────────────────────────────────────────────────────────── */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  height: 56px;
  background: #001F3F;
  color: #fff;
  flex-shrink: 0;
  z-index: 10;
}

.header-left,
.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-text {
  font-family: 'Rubik', sans-serif;
  font-weight: 700;
  font-size: 18px;
  letter-spacing: -0.3px;
}

/* Ask Ocean Button */
.ask-ocean-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 16px;
  background: linear-gradient(135deg, #4293CF, #357ABD);
  color: #fff;
  font-size: 13px;
  font-weight: 500;
  border-radius: 100px;
  transition: box-shadow .2s, transform .15s;
}

.ask-ocean-btn:hover {
  box-shadow: 0 4px 16px rgba(66,147,207,.45);
  transform: translateY(-1px);
}

.kbd-badge {
  display: inline-block;
  padding: 2px 6px;
  font-size: 10px;
  background: rgba(255,255,255,.2);
  border-radius: 4px;
  font-family: 'Roboto Mono', monospace;
  letter-spacing: .3px;
}

/* Notification */
.icon-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background .2s;
  position: relative;
}

.icon-btn:hover {
  background: rgba(255,255,255,.12);
}

.notification-dot {
  width: 8px;
  height: 8px;
  background: #E74C3C;
  border-radius: 50%;
  position: absolute;
  top: 6px;
  right: 6px;
  border: 2px solid #001F3F;
}

/* User Avatar */
.user-avatar {
  width: 34px;
  height: 34px;
  background: linear-gradient(135deg, #4293CF, #357ABD);
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .3px;
}

/* ── App Body ──────────────────────────────────────────────────────── */
.app-body {
  display: flex;
  flex: 1;
  min-height: 0;
}

/* ── Sidebar ───────────────────────────────────────────────────────── */
.sidebar {
  width: 240px;
  background: #fff;
  border-right: 1px solid #E0E0E0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  flex-shrink: 0;
  overflow-y: auto;
}

.sidebar-nav {
  padding: 12px 0;
  display: flex;
  flex-direction: column;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  font-size: 13.5px;
  font-weight: 400;
  color: #555;
  transition: background .15s, color .15s;
  position: relative;
}

.nav-item:hover {
  background: #F0F4F8;
  color: #333;
}

.nav-item.active {
  background: #EAF2FC;
  color: #4293CF;
  font-weight: 500;
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 4px;
  bottom: 4px;
  width: 3px;
  background: #4293CF;
  border-radius: 0 3px 3px 0;
}

.nav-badge {
  margin-left: auto;
  background: #E74C3C;
  color: #fff;
  font-size: 10px;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: 10px;
}

.nav-divider {
  height: 1px;
  background: #E0E0E0;
  margin: 8px 16px;
}

/* Ocean AI sidebar item highlight */
.ocean-nav-item {
  color: #4293CF !important;
  font-weight: 500 !important;
}

.ocean-nav-item:hover {
  background: #EAF2FC !important;
}

/* Role Toggle */
.role-toggle-container {
  padding: 16px;
  border-top: 1px solid #E0E0E0;
}

.role-toggle-label {
  font-size: 11px;
  color: #999;
  text-transform: uppercase;
  letter-spacing: .6px;
  margin-bottom: 8px;
  display: block;
}

.role-toggle {
  display: flex;
  position: relative;
  background: #F0F2F5;
  border-radius: 8px;
  overflow: hidden;
}

.role-btn {
  flex: 1;
  padding: 8px 0;
  font-size: 12px;
  font-weight: 500;
  color: #666;
  text-align: center;
  z-index: 1;
  transition: color .25s;
}

.role-btn.active {
  color: #fff;
}

.role-slider {
  position: absolute;
  top: 2px;
  left: 2px;
  width: calc(33.333% - 2px);
  height: calc(100% - 4px);
  background: linear-gradient(135deg, #4293CF, #357ABD);
  border-radius: 6px;
  transition: transform .25s cubic-bezier(.4,0,.2,1);
}

.role-toggle .role-btn[data-role="vendor"].active ~ .role-slider,
.role-toggle.vendor-active .role-slider {
  transform: translateX(100%);
}

.role-toggle .role-btn[data-role="b222user"].active ~ .role-slider,
.role-toggle.both-active .role-slider {
  transform: translateX(200%);
}

/* ── Main Content ──────────────────────────────────────────────────── */
.main-content {
  flex: 1;
  padding: 24px;
  overflow-y: auto;
  background: #F5F7FA;
}

/* Proactive Banner */
.proactive-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: linear-gradient(135deg, #EAF2FC, #F0F7FF);
  border: 1px solid #C4DDEF;
  border-radius: 10px;
  margin-bottom: 24px;
  transition: box-shadow .2s;
}

.proactive-banner:hover {
  box-shadow: 0 2px 12px rgba(66,147,207,.15);
}

.banner-text {
  flex: 1;
  font-size: 13px;
  color: #333;
  line-height: 1.45;
}

.banner-text strong {
  color: #4293CF;
}

.banner-action {
  padding: 6px 14px;
  background: linear-gradient(135deg, #4293CF, #357ABD);
  color: #fff;
  font-size: 12px;
  font-weight: 500;
  border-radius: 6px;
  white-space: nowrap;
  transition: box-shadow .2s;
}

.banner-action:hover {
  box-shadow: 0 2px 8px rgba(66,147,207,.35);
}

.banner-dismiss {
  font-size: 18px;
  color: #999;
  padding: 4px;
  line-height: 1;
}

.banner-dismiss:hover {
  color: #666;
}

/* Stat Cards */
.stat-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  margin-bottom: 24px;
}

.stat-card {
  background: #fff;
  border: 1px solid #E0E0E0;
  border-radius: 12px;
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: box-shadow .2s, transform .15s;
}

.stat-card:hover {
  box-shadow: 0 4px 16px rgba(0,0,0,.06);
  transform: translateY(-2px);
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.stat-icon.blue   { background: #EAF2FC; }
.stat-icon.orange  { background: #FFF3E0; }
.stat-icon.green   { background: #E8F5E9; }

.stat-number {
  font-family: 'Rubik', sans-serif;
  font-size: 28px;
  font-weight: 700;
  color: #333;
  line-height: 1;
}

.stat-label {
  font-size: 13px;
  color: #666;
  margin-top: 2px;
}

/* Content Card */
.content-card {
  background: #fff;
  border: 1px solid #E0E0E0;
  border-radius: 12px;
  overflow: hidden;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid #E0E0E0;
}

.card-header h2 {
  font-size: 15px;
  font-weight: 600;
  color: #333;
}

.btn-text {
  font-size: 13px;
  color: #4293CF;
  font-weight: 500;
}

.btn-text:hover {
  text-decoration: underline;
}

/* Projects Table */
.projects-table {
  width: 100%;
  border-collapse: collapse;
}

.projects-table th {
  text-align: left;
  padding: 10px 20px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: #999;
  background: #FAFBFC;
}

.projects-table td {
  padding: 12px 20px;
  font-size: 13px;
  border-top: 1px solid #F0F0F0;
  color: #555;
}

.projects-table td strong {
  color: #333;
  font-weight: 500;
}

.status-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 100px;
  font-size: 11px;
  font-weight: 600;
}

.status-badge.active  { background: #E8F5E9; color: #27AE60; }
.status-badge.pending  { background: #FFF3E0; color: #E67E22; }
.status-badge.review   { background: #EAF2FC; color: #4293CF; }
.status-badge.draft    { background: #F0F0F0; color: #999; }

/* Ctrl+K Hint */
.ctrl-k-hint {
  position: fixed;
  bottom: 20px;
  right: 24px;
  font-size: 12px;
  color: #999;
  display: flex;
  align-items: center;
  gap: 4px;
  z-index: 5;
  pointer-events: none;
}

.ctrl-k-hint kbd {
  display: inline-block;
  padding: 2px 6px;
  background: #fff;
  border: 1px solid #DDD;
  border-radius: 4px;
  font-size: 11px;
  font-family: 'Roboto Mono', monospace;
  box-shadow: 0 1px 2px rgba(0,0,0,.06);
}

/* FAB Button */
.fab-btn {
  position: fixed;
  bottom: 24px;
  left: 24px;
  width: 56px;
  height: 56px;
  background: linear-gradient(135deg, #4293CF, #357ABD);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(66,147,207,.4);
  z-index: 100;
  transition: transform .2s, box-shadow .2s;
}

.fab-btn:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 28px rgba(66,147,207,.55);
}

/* ================================================================== */
/*  MODAL OVERLAY                                                      */
/* ================================================================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 15, 30, .45);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 1000;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 10vh;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease;
}

.modal-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.modal-container {
  width: 640px;
  max-height: 80vh;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 24px 80px rgba(0,0,0,.25), 0 0 0 1px rgba(0,0,0,.05);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transform: translateY(12px) scale(.98);
  transition: transform .2s cubic-bezier(.4,0,.2,1);
}

.modal-backdrop.open .modal-container {
  transform: translateY(0) scale(1);
}

/* ── Command Palette Mode ──────────────────────────────────────────── */

/* Search Bar */
.cmd-search-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  border-bottom: 1px solid #E0E0E0;
}

.cmd-search-bar input {
  flex: 1;
  font-size: 15px;
  color: #333;
  background: transparent;
}

.cmd-search-bar input::placeholder {
  color: #AAA;
}

.cmd-mic-btn {
  width: 36px;
  height: 36px;
  border: none;
  background: #F0F2F5;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #666;
  transition: all .2s;
  flex-shrink: 0;
}
.cmd-mic-btn:hover {
  background: #4293CF;
  color: #fff;
}
.cmd-mic-btn.recording {
  background: #E74C3C;
  color: #fff;
  animation: micPulse 1.2s infinite;
}

.esc-hint {
  padding: 3px 8px;
  background: #F0F0F0;
  border-radius: 4px;
  font-size: 10px;
  color: #999;
  font-weight: 500;
}

/* Search Results */
.cmd-search-results {
  display: none;
  max-height: 320px;
  overflow-y: auto;
  border-bottom: 1px solid #E0E0E0;
}

.cmd-search-results.visible {
  display: block;
}

.search-group-label {
  padding: 8px 18px 4px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: #999;
}

.search-result-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 18px;
  cursor: pointer;
  transition: background .1s;
}

.search-result-item:hover,
.search-result-item.highlighted {
  background: #EAF2FC;
}

.search-result-icon {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}

.search-result-text {
  flex: 1;
  font-size: 13px;
  color: #333;
}

.search-result-type {
  font-size: 10px;
  color: #999;
  text-transform: uppercase;
  letter-spacing: .4px;
}

/* Sections */
.cmd-section {
  padding: 14px 18px;
}

.cmd-section + .cmd-section {
  padding-top: 0;
}

.cmd-section-title {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: #999;
  margin-bottom: 10px;
}

/* Quick Actions Grid */
.cmd-actions-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.cmd-action-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: #FAFBFC;
  border: 1px solid #EAEAEA;
  border-radius: 10px;
  cursor: pointer;
  transition: background .15s, border-color .15s, box-shadow .15s;
}

.cmd-action-card:hover {
  background: #fff;
  border-color: #D0D0D0;
  box-shadow: 0 2px 8px rgba(0,0,0,.05);
}

.cmd-action-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
  color: #fff;
}

.cmd-action-icon.blue   { background: linear-gradient(135deg, #4293CF, #357ABD); }
.cmd-action-icon.green  { background: linear-gradient(135deg, #27AE60, #219A52); }
.cmd-action-icon.orange { background: linear-gradient(135deg, #E67E22, #D35400); }
.cmd-action-icon.purple { background: linear-gradient(135deg, #8E44AD, #7D3C98); }
.cmd-action-icon.teal   { background: linear-gradient(135deg, #1ABC9C, #16A085); }
.cmd-action-icon.red    { background: linear-gradient(135deg, #E74C3C, #C0392B); }

.cmd-action-label {
  font-size: 13px;
  font-weight: 500;
  color: #333;
}

.cmd-action-desc {
  font-size: 11px;
  color: #999;
  margin-top: 1px;
}

/* Recent List */
.cmd-recent-list {
  display: flex;
  flex-direction: column;
}

.cmd-recent-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 4px;
  font-size: 13px;
  color: #555;
  cursor: pointer;
  border-radius: 6px;
  transition: background .1s;
}

.cmd-recent-item:hover {
  background: #F0F4F8;
}

.recent-time {
  margin-left: auto;
  font-size: 11px;
  color: #BBB;
}

/* Footer */
.cmd-footer {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 18px;
  border-top: 1px solid #E0E0E0;
  background: #FAFBFC;
}

.cmd-hint {
  font-size: 11px;
  color: #999;
  display: flex;
  align-items: center;
  gap: 4px;
}

.cmd-hint kbd {
  display: inline-block;
  padding: 1px 5px;
  background: #fff;
  border: 1px solid #DDD;
  border-radius: 3px;
  font-size: 10px;
  font-family: 'Roboto Mono', monospace;
}

/* ── Conversation Mode ─────────────────────────────────────────────── */

.chat-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid #E0E0E0;
  background: #fff;
}

.chat-header-btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  color: #666;
  transition: background .15s, color .15s;
}

.chat-header-btn:hover {
  background: #F0F0F0;
  color: #333;
}

.chat-header-info {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.chat-header-title {
  font-family: 'Rubik', sans-serif;
  font-size: 14px;
  font-weight: 600;
  color: #333;
}

.chat-header-status {
  font-size: 11px;
  color: #999;
  display: flex;
  align-items: center;
  gap: 4px;
}

.status-dot {
  width: 6px;
  height: 6px;
  background: #27AE60;
  border-radius: 50%;
  display: inline-block;
}

.chat-header-actions {
  display: flex;
  gap: 4px;
}

#chatMinimizeBtn {
  margin-left: 6px;
  border-left: 1px solid #E0E0E0;
  padding-left: 6px;
}

/* Chat Messages */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: #FAFBFC;
  min-height: 300px;
  max-height: 50vh;
}

.chat-msg {
  display: flex;
  gap: 8px;
  max-width: 85%;
  animation: msgIn .25s ease;
}

@keyframes msgIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.chat-msg.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.chat-msg.assistant {
  align-self: flex-start;
}

.msg-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  flex-shrink: 0;
}

.chat-msg.assistant .msg-avatar {
  background: linear-gradient(135deg, #4293CF, #357ABD);
  color: #fff;
}

.chat-msg.user .msg-avatar {
  background: #E0E0E0;
  color: #555;
}

.msg-bubble {
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 13.5px;
  line-height: 1.6;
  word-wrap: break-word;
  font-family: 'Roboto', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

.msg-meta {
  margin-top: 6px;
  font-size: 11px;
  line-height: 1.2;
  text-align: right;
  color: #7a8699;
}

.timing-breakdown {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
  justify-content: flex-end;
}

.timing-pill {
  display: inline-block;
  padding: 1px 6px;
  background: #F0F4F8;
  color: #5a6a7e;
  border-radius: 3px;
  font-size: 10px;
  font-weight: 500;
  white-space: nowrap;
}

.timing-pill.cache-hit {
  background: #e6f4ea;
  color: #1a7f37;
}

/* Markdown content inside bubbles */
.msg-bubble p { margin: 0 0 8px 0; }
.msg-bubble p:last-child { margin-bottom: 0; }

.msg-bubble h3 { font-size: 14px; font-weight: 600; color: #001F3F; margin: 12px 0 6px; font-family: 'Rubik', sans-serif; }
.msg-bubble h4 { font-size: 13px; font-weight: 600; color: #001F3F; margin: 10px 0 4px; font-family: 'Rubik', sans-serif; }

.msg-bubble strong { font-weight: 600; }
.msg-bubble em { font-style: italic; }
.msg-bubble code {
  background: rgba(0,0,0,.06); padding: 1px 5px; border-radius: 3px;
  font-family: 'Roboto Mono', monospace; font-size: 12px;
}

.msg-bubble ol, .msg-bubble ul {
  margin: 6px 0; padding-left: 20px;
}
.msg-bubble ol li, .msg-bubble ul li {
  margin: 3px 0; padding-left: 2px;
}

.msg-bubble table {
  width: 100%; border-collapse: collapse; margin: 8px 0;
  font-size: 12.5px;
}
.msg-bubble table th {
  text-align: left; padding: 6px 10px;
  background: #F5F7FA; border-bottom: 2px solid #E0E0E0;
  font-weight: 600; color: #001F3F; font-family: 'Rubik', sans-serif;
}
.msg-bubble table td {
  padding: 5px 10px; border-bottom: 1px solid #F0F0F0;
  color: #444;
}
.msg-bubble table tr:last-child td { border-bottom: none; }

.msg-bubble hr {
  border: none; border-top: 1px solid #E8E8E8; margin: 10px 0;
}

/* User bubble overrides for dark bg */
.chat-msg.user .msg-bubble h3,
.chat-msg.user .msg-bubble h4 { color: #fff; }
.chat-msg.user .msg-bubble code { background: rgba(255,255,255,.15); color: #fff; }
.chat-msg.user .msg-bubble table th { background: rgba(255,255,255,.1); color: #fff; border-bottom-color: rgba(255,255,255,.2); }
.chat-msg.user .msg-bubble table td { color: rgba(255,255,255,.9); border-bottom-color: rgba(255,255,255,.1); }

.chat-msg.assistant .msg-bubble {
  background: #fff;
  border: 1px solid #E0E0E0;
  border-bottom-left-radius: 4px;
  color: #333;
}

.chat-msg.user .msg-bubble {
  background: linear-gradient(135deg, #4293CF, #357ABD);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.chat-msg.user.pending .msg-bubble {
  opacity: 0.72;
  font-style: italic;
}

/* Typing Indicator */
.typing-indicator {
  display: flex;
  gap: 4px;
  padding: 10px 14px;
  background: #fff;
  border: 1px solid #E0E0E0;
  border-radius: 12px;
  border-bottom-left-radius: 4px;
  width: fit-content;
}

.typing-indicator span {
  width: 7px;
  height: 7px;
  background: #BBB;
  border-radius: 50%;
  animation: typingBounce 1.2s infinite;
}

.typing-indicator span:nth-child(2) { animation-delay: .2s; }
.typing-indicator span:nth-child(3) { animation-delay: .4s; }

@keyframes typingBounce {
  0%, 60%, 100% { opacity: .3; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-4px); }
}

/* Stream Processing Indicator (shown inside bubble until first token arrives) */
.stream-thinking {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 2px 0;
}

.stream-thinking span {
  width: 7px;
  height: 7px;
  background: #4B7BE5;
  border-radius: 50%;
  animation: typingBounce 1.2s ease-in-out infinite;
}

.stream-thinking span:nth-child(2) { animation-delay: .2s; }
.stream-thinking span:nth-child(3) { animation-delay: .4s; }

.stream-thinking em {
  font-style: normal;
  font-size: 0.82em;
  color: #999;
  margin-left: 2px;
  animation: processingFade 1.8s ease-in-out infinite;
}

@keyframes processingFade {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 1; }
}

.msg-error {
  color: #D32F2F;
  font-size: 0.88em;
}

/* ── Toast notification ─────────────────────────────────────────── */
.ocean-toast {
  position: fixed;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%) translateY(12px);
  background: #1A1A2E;
  color: #fff;
  font-size: 13px;
  font-weight: 500;
  padding: 9px 18px;
  border-radius: 20px;
  pointer-events: none;
  opacity: 0;
  transition: opacity .22s ease, transform .22s ease;
  z-index: 9999;
  white-space: nowrap;
}
.ocean-toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Chat Input Bar */
.chat-input-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 12px;
  border-top: 1px solid #E0E0E0;
  background: #fff;
}

.chat-action-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  color: #888;
  transition: background .15s, color .15s;
  flex-shrink: 0;
}

.chat-action-btn:hover {
  background: #F0F0F0;
  color: #555;
}

.chat-input-bar input {
  flex: 1;
  padding: 9px 14px;
  background: #F5F7FA;
  border: 1px solid #E0E0E0;
  border-radius: 100px;
  font-size: 13.5px;
  color: #333;
  transition: border-color .2s;
}

.chat-input-bar input:focus {
  border-color: #4293CF;
}

.chat-input-bar input::placeholder {
  color: #AAA;
}

.send-btn {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, #4293CF, #357ABD);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: box-shadow .2s, opacity .2s;
}

.send-btn:hover {
  box-shadow: 0 2px 10px rgba(66,147,207,.4);
}

.send-btn:disabled {
  opacity: .5;
  cursor: not-allowed;
}

/* ── Inline Voice Bar (replaces text input during recording) ──────── */
.chat-voice-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-top: 1px solid #E0E0E0;
  background: linear-gradient(90deg, #001F3F, #003055);
  animation: voiceBarIn .25s ease;
}
.chat-voice-bar.hidden { display: none; }
@keyframes voiceBarIn { from { opacity: 0; } to { opacity: 1; } }

.inline-wave {
  display: flex;
  align-items: center;
  gap: 2px;
  height: 28px;
}
.inline-wave span {
  width: 3px;
  background: #4293CF;
  border-radius: 2px;
  animation: inlineWaveBar .8s ease-in-out infinite;
  will-change: transform, opacity;
  contain: strict;
}
.inline-wave span:nth-child(1)  { height: 8px;  animation-delay: 0s; }
.inline-wave span:nth-child(2)  { height: 14px; animation-delay: .06s; }
.inline-wave span:nth-child(3)  { height: 20px; animation-delay: .12s; }
.inline-wave span:nth-child(4)  { height: 26px; animation-delay: .18s; }
.inline-wave span:nth-child(5)  { height: 20px; animation-delay: .24s; }
.inline-wave span:nth-child(6)  { height: 28px; animation-delay: .3s; }
.inline-wave span:nth-child(7)  { height: 22px; animation-delay: .36s; }
.inline-wave span:nth-child(8)  { height: 16px; animation-delay: .42s; }
.inline-wave span:nth-child(9)  { height: 24px; animation-delay: .48s; }
.inline-wave span:nth-child(10) { height: 18px; animation-delay: .54s; }
.inline-wave span:nth-child(11) { height: 12px; animation-delay: .6s; }
.inline-wave span:nth-child(12) { height: 8px;  animation-delay: .66s; }
@keyframes inlineWaveBar {
  0%, 100% { transform: scaleY(.4); opacity: .5; }
  50% { transform: scaleY(1); opacity: 1; }
}
/* Processing state — all bars flatten and pulse amber together */
.inline-wave.processing span {
  animation: inlineWaveProcess .7s ease-in-out infinite !important;
  height: 5px !important;
  background: #F5A623 !important;
  animation-delay: 0s !important;
}
@keyframes inlineWaveProcess {
  0%, 100% { opacity: .3; transform: scaleY(1); }
  50% { opacity: 1; transform: scaleY(1); }
}

.inline-voice-label {
  flex: 1;
  color: rgba(255,255,255,.8);
  font-size: 13px;
}

/* Push the stop/mute/text cluster to the right edge of the inline voice
   bar. With the label now hidden, this prevents the buttons from bunching
   up next to the wave animation on the left. */
.chat-voice-bar .voice-stop-inline-btn {
  margin-left: auto;
}

.voice-stop-inline-btn {
  color: #fff !important;
  background: rgba(231,76,60,.7) !important;
}
.voice-stop-inline-btn:hover {
  background: rgba(231,76,60,.9) !important;
}

.voice-mute-inline-btn {
  color: #fff !important;
  background: rgba(255,255,255,.12) !important;
  position: relative;
}
.voice-mute-inline-btn:hover {
  background: rgba(255,255,255,.2) !important;
}
.voice-mute-inline-btn.muted::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 26px;
  height: 2px;
  background: #E74C3C;
  transform: translate(-50%, -50%) rotate(-45deg);
  border-radius: 1px;
}

.voice-text-inline-btn {
  color: #4293CF !important;
  background: rgba(66,147,207,.15) !important;
}
.voice-text-inline-btn:hover {
  background: rgba(66,147,207,.3) !important;
}

/* ── Voice Mode ────────────────────────────────────────────────────── */
#voiceMode {
  background: linear-gradient(180deg, #001F3F, #003366);
  min-height: 480px;
  display: flex;
}

#voiceMode.hidden {
  display: none !important;
}

.voice-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px;
  gap: 24px;
}

.voice-status {
  font-family: 'Rubik', sans-serif;
  font-size: 18px;
  font-weight: 500;
  color: #fff;
  opacity: .9;
}

/* Mic + Pulse */
.voice-mic-area {
  position: relative;
  width: 120px;
  height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.pulse-ring {
  position: absolute;
  border: 2px solid rgba(66,147,207,.3);
  border-radius: 50%;
  animation: pulseRing 2s infinite;
  will-change: transform, opacity;
}

.ring-1 { width: 100px; height: 100px; animation-delay: 0s; }
.ring-2 { width: 120px; height: 120px; animation-delay: .4s; }
.ring-3 { width: 140px; height: 140px; animation-delay: .8s; }

@keyframes pulseRing {
  0%   { transform: scale(.8); opacity: .6; }
  50%  { transform: scale(1); opacity: .3; }
  100% { transform: scale(1.2); opacity: 0; }
}

.voice-mic-btn {
  width: 80px;
  height: 80px;
  background: linear-gradient(135deg, #4293CF, #357ABD);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 24px rgba(66,147,207,.5);
  z-index: 1;
  transition: transform .15s, box-shadow .15s;
}

.voice-mic-btn:hover {
  transform: scale(1.06);
  box-shadow: 0 6px 32px rgba(66,147,207,.65);
}
.voice-mic-btn.recording {
  background: linear-gradient(135deg, #E74C3C, #C0392B);
  box-shadow: 0 0 0 0 rgba(231,76,60,.5);
  animation: micPulse 1.2s infinite;
}
@keyframes micPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(231,76,60,.5); }
  50% { box-shadow: 0 0 0 16px rgba(231,76,60,0); }
}

/* Waveform */
.voice-waveform {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  height: 40px;
}

.wave-bar {
  width: 3px;
  background: #4293CF;
  border-radius: 2px;
  transform: scaleY(.3);
  opacity: .3;
  transition: transform .2s, opacity .2s;
  will-change: transform, opacity;
  contain: strict;
}
.voice-waveform.active .wave-bar {
  animation: waveAnim 1s ease-in-out infinite;
}

.wave-bar:nth-child(1)  { animation-delay: .0s; height: 10px; }
.wave-bar:nth-child(2)  { animation-delay: .05s; height: 16px; }
.wave-bar:nth-child(3)  { animation-delay: .1s; height: 22px; }
.wave-bar:nth-child(4)  { animation-delay: .15s; height: 28px; }
.wave-bar:nth-child(5)  { animation-delay: .2s; height: 34px; }
.wave-bar:nth-child(6)  { animation-delay: .25s; height: 38px; }
.wave-bar:nth-child(7)  { animation-delay: .3s; height: 40px; }
.wave-bar:nth-child(8)  { animation-delay: .35s; height: 38px; }
.wave-bar:nth-child(9)  { animation-delay: .4s; height: 34px; }
.wave-bar:nth-child(10) { animation-delay: .45s; height: 28px; }
.wave-bar:nth-child(11) { animation-delay: .5s; height: 22px; }
.wave-bar:nth-child(12) { animation-delay: .55s; height: 16px; }
.wave-bar:nth-child(13) { animation-delay: .6s; height: 10px; }
.wave-bar:nth-child(14) { animation-delay: .65s; height: 16px; }
.wave-bar:nth-child(15) { animation-delay: .7s; height: 22px; }
.wave-bar:nth-child(16) { animation-delay: .75s; height: 28px; }
.wave-bar:nth-child(17) { animation-delay: .8s; height: 34px; }
.wave-bar:nth-child(18) { animation-delay: .85s; height: 28px; }
.wave-bar:nth-child(19) { animation-delay: .9s; height: 22px; }
.wave-bar:nth-child(20) { animation-delay: .95s; height: 16px; }

@keyframes waveAnim {
  0%, 100% { transform: scaleY(.4); opacity: .5; }
  50%      { transform: scaleY(1); opacity: 1; }
}

/* Transcript */
.voice-transcript {
  min-height: 40px;
  text-align: center;
}

.transcript-text {
  font-size: 14px;
  color: rgba(255,255,255,.7);
  font-style: italic;
}

/* Voice Controls — button row aligned to the right edge of the voice modal */
.voice-controls {
  display: flex;
  gap: 16px;
  align-self: flex-end;
}

.voice-ctrl-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 18px;
  border-radius: 10px;
  color: rgba(255,255,255,.8);
  font-size: 11px;
  transition: background .15s;
}

.voice-ctrl-btn:hover {
  background: rgba(255,255,255,.1);
}

.voice-ctrl-btn.end-btn {
  color: #E74C3C;
}

.voice-ctrl-btn.end-btn:hover {
  background: rgba(231,76,60,.15);
}
.voice-ctrl-btn.muted {
  background: rgba(255,255,255,.15);
  color: #E74C3C;
}

/* ================================================================== */
/*  SETTINGS PANEL                                                     */
/* ================================================================== */
.settings-panel {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 50;
  background: #fff;
  border-top: 1px solid #E0E0E0;
  box-shadow: 0 -2px 8px rgba(0,0,0,.08);
}

.settings-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 24px;
  width: 100%;
  font-size: 13px;
  color: #666;
  transition: background .15s;
}

.settings-toggle:hover {
  background: #FAFBFC;
}

.settings-toggle .chevron {
  margin-left: auto;
  transition: transform .2s;
}

.settings-panel.open .settings-toggle .chevron {
  transform: rotate(180deg);
}

.settings-body {
  display: none;
  padding: 0 24px 16px;
}

.settings-panel.open .settings-body {
  display: block;
}

.settings-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 0;
}

.settings-row label {
  width: 100px;
  font-size: 12px;
  color: #999;
  flex-shrink: 0;
}

.settings-row input {
  flex: 1;
  padding: 7px 12px;
  background: #F5F7FA;
  border: 1px solid #E0E0E0;
  border-radius: 6px;
  font-size: 12px;
  color: #333;
  transition: border-color .2s;
}

.settings-row input:focus {
  border-color: #4293CF;
}

.settings-row select {
  flex: 1;
  padding: 7px 12px;
  background: #F5F7FA;
  border: 1px solid #E0E0E0;
  border-radius: 6px;
  font-size: 12px;
  color: #333;
  transition: border-color .2s;
}

.settings-row select:focus {
  border-color: #4293CF;
  outline: none;
}

.settings-row input[readonly] {
  color: #999;
  background: #FAFAFA;
}

/* ── Scrollbars ────────────────────────────────────────────────────── */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: #D0D0D0;
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: #BBB;
}

/* ── Responsive ────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .sidebar {
    width: 200px;
  }
  .stat-cards {
    grid-template-columns: 1fr;
  }
  .modal-container {
    width: 95vw;
    max-height: 85vh;
  }
}

@media (max-width: 640px) {
  .sidebar {
    display: none;
  }
  .app-header {
    padding: 0 12px;
  }
  .header-center {
    display: none;
  }
  .main-content {
    padding: 16px;
  }
  .modal-container {
    width: 100vw;
    max-height: 100vh;
    border-radius: 0;
  }
  .modal-backdrop {
    padding-top: 0;
  }
  .cmd-actions-grid {
    grid-template-columns: 1fr;
  }
}

/* Contextual inline "Upload file" button shown inside an assistant message when the
   current turn allows a file upload (replaces the always-visible paperclip). */
.inline-upload-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  background: #4293CF;
  border: none;
  border-radius: 8px;
  cursor: pointer;
}
.inline-upload-btn:hover { background: #2f6f9e; }

/* My Chats — session list in the settings panel */
.session-item {
  text-align: left;
  padding: 6px 8px;
  border: 1px solid #e5e5e5;
  border-radius: 6px;
  background: #fff;
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.session-item:hover { background: #f2f6ff; border-color: #c9d8ff; }
.session-empty { font-size: 11px; color: #888; padding: 4px 2px; }
.session-more {
  align-self: flex-start;
  margin-top: 2px;
  padding: 4px 10px;
  border: 1px solid #c9d8ff;
  border-radius: 6px;
  background: #f2f6ff;
  color: #2f6f9e;
  font-size: 11px;
  cursor: pointer;
}
.session-more:hover { background: #e3ecff; }
/* Recent Conversations items are now clickable (load that session). */
.cmd-recent-item { cursor: pointer; }

/* Shown at the top of the message log while an older page is being fetched
   (scroll-up paging). Sits in the normal flow so the anchor maths stay simple. */
.history-loading {
  text-align: center;
  font-size: 11px;
  color: #888;
  padding: 8px 0;
}
