/* Agentia — Premium Modern Amazon-Inspired UI/UX */

:root {
  /* Amazon Design Language (Modern Premium) */
  --bg-base: #f7fafa;
  --bg-sidebar: #131921; /* Darker more premium */
  --bg-nav: #0f1111;
  --bg-surface: #ffffff;
  --bg-card: #ffffff;
  
  --border: #d5d9d9;
  --border-subtle: #e7e7e7;
  
  --text-primary: #0f1111;
  --text-secondary: #565959;
  --text-muted: #888888;
  
  --amazon-orange: #ffb81c; /* Optimized for modern digital */
  --amazon-yellow: #ffd814;
  --amazon-yellow-hover: #f7ca00;
  --amazon-yellow-border: #fcd200;
  
  --accent: #131921;
  --accent-cta: #ff9900;
  --amazon-smile: #ff9900;
  
  --green: #007185;
  --yellow: #ff9900;
  --red: #c40000;
  --cyan: #007185;
  
  --font-body: "Outfit", ui-sans-serif, system-ui, sans-serif;
  --font-mono: "JetBrains Mono", "Fira Code", ui-monospace, monospace;
  
  /* Modern radii */
  --radius-xs: 4px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-full: 999px;

  /* Premium Shadows */
  --shadow-sm: 0 1px 2px rgba(15,17,17,.1);
  --shadow-md: 0 2px 5px rgba(15,17,17,.15);
  --shadow-lg: 0 4px 12px rgba(15,17,17,.15);
  --shadow-inner: inset 0 2px 4px rgba(0,0,0,0.06);

  /* Backgrounds */
  --bg-primary: #f7fafa;
  --bg-secondary: #ffffff;
  --bg-overlay: rgba(19, 25, 33, 0.4);
  
  --surface: #ffffff;
  --surface2: #f0f2f2; /* Used for table headers in Firewall */
}

.dark {
  --bg-base: #0f1111;
  --bg-sidebar: #131921;
  --bg-nav: #0f1111;
  --bg-surface: #1e1e1e;
  --bg-card: #1e1e1e;
  --bg-primary: #121212;
  --bg-secondary: #1e1e1e;
  --bg-overlay: rgba(0, 0, 0, 0.7);
  
  --surface: #1e1e1e;
  --surface2: #2a2a2a;
  
  --border: #333333;
  --border-subtle: #222222;
  
  --text-primary: #f3f3f3;
  --text-secondary: #aeb9c7;
  --text-muted: #767676;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  padding: 0;
  background: var(--bg-base);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg-base); }
::-webkit-scrollbar-thumb { background: #ced4da; border-radius: 99px; border: 2px solid var(--bg-base); }
::-webkit-scrollbar-thumb:hover { background: #adb5bd; }

/* ── App Shell ── */
#app {
  display: grid;
  grid-template-columns: 260px 1fr;
  grid-template-rows: 100vh;
  height: 100vh;
  overflow: hidden;
}

/* ── Sidebar (Amazon Shop Left Nav style) ── */
#sidebar {
  background: var(--bg-sidebar);
  color: white;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 100;
  border-right: 1px solid rgba(255,255,255,0.05);
}

#sidebar-header {
  padding: 16px 20px;
  background: var(--bg-nav);
  flex-shrink: 0;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: white;
  font-weight: 700;
  font-size: 22px;
  letter-spacing: -0.02em;
  position: relative;
}

.logo-icon {
  color: var(--amazon-orange);
  font-size: 24px;
}

.logo::after {
  content: "";
  position: absolute;
  bottom: -4px;
  left: 32px;
  width: 40px;
  height: 3px;
  background: var(--amazon-smile);
  border-radius: 50%;
  transform: rotate(-2deg);
}

.new-chat-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  margin-top: 16px;
  padding: 10px 16px;
  background: linear-gradient(180deg, #f7dfa5 0%, #f0c14b 100%);
  color: #111;
  border: 1px solid #a88734;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 1px 0 rgba(255,255,255,.4) inset, 0 1px 2px rgba(0,0,0,0.1);
}

.new-chat-btn:hover { 
  background: linear-gradient(180deg, #f5d78e 0%, #eeb933 100%);
  border-color: #9c7e31;
}

#sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 20px 0;
}

.nav-section-label {
  padding: 0 20px 10px;
  font-size: 11.5px;
  font-weight: 800;
  text-transform: uppercase;
  color: #adb1b8;
  letter-spacing: 0.08em;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  color: #aeb9c7;
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  border-radius: 8px;
  transition: all 0.2s;
  margin: 1px 12px;
  width: auto;
}

.nav-link:hover {
  background: rgba(255,255,255,0.06);
  color: white;
}

.nav-link.active {
  background: rgba(255,255,255,0.08);
  color: white;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.nav-link .icon {
  width: 20px;
  opacity: 0.85;
}

.session-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  cursor: pointer;
  color: #d1d4da;
  font-size: 14px;
}

.session-item:hover { background: rgba(255,255,255,0.06); color: white; }
.session-item.active { background: rgba(255,255,255,0.1); color: white; border-left: 3px solid var(--amazon-orange); padding-left: 17px; }

/* ── Global Top Bar (User Profile) ── */
#user-widget {
  position: fixed;
  top: 16px;
  right: 24px;
  z-index: 1000;
  display: flex;
  align-items: center;
  gap: 12px;
}

#sidebar-footer {
  display: none; /* Removed as requested */
}

.user-chip-mini {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: white;
  border: 1px solid #d5d9d9;
  border-radius: var(--radius-full);
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0,0,0,0.05);
  transition: all 0.2s;
  color: #111;
}

.user-chip-mini:hover {
  border-color: #adb1b8;
  box-shadow: 0 4px 16px rgba(0,0,0,0.1);
  transform: translateY(-1px);
}

.avatar-mini {
  width: 24px;
  height: 24px;
  background: var(--amazon-orange);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 11px;
}

.dropdown {
  position: absolute;
  background: white;
  border: 1px solid #d5d9d9;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.12), 0 2px 4px rgba(0,0,0,0.08);
  display: none;
  flex-direction: column;
  z-index: 1100;
  overflow: hidden;
  animation: dropdownEnter 0.2s cubic-bezier(0, 0, 0.2, 1);
}

.dropdown.open {
  display: flex;
}

@keyframes dropdownEnter {
  from { opacity: 0; transform: translateY(-8px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.dropdown-item {
  display: block;
  width: 100%;
  padding: 12px 16px;
  text-decoration: none;
  color: var(--text-primary);
  font-size: 13.5px;
  transition: background 0.15s;
  cursor: pointer;
  border: none;
  background: none;
  text-align: left;
}

.dropdown-item:hover {
  background: #f0f2f2;
}

.dropdown-item.danger {
  color: var(--red);
}

.dropdown-divider {
  height: 1px;
  background: #e7e7e7;
  margin: 4px 0;
}

/* ── Main Content ── */
#main {
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  background: var(--bg-base);
  flex: 1;
}

/* ── Main Header (Unified Premium) ── */
.main-header {
  background: var(--bg-nav);
  padding: 0 24px;
  height: 56px;
  min-height: 56px;
  border-bottom: 2px solid var(--amazon-orange);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  color: white;
  z-index: 200;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
  flex-shrink: 0;
}

.header-left {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.header-title {
  font-size: 14px;
  font-weight: 800;
  color: #eeeeee;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin: 0;
  line-height: 1.2;
}

.header-breadcrumb {
  font-size: 11px;
  color: #adb1b8;
  margin-top: 2px;
  font-weight: 500;
}

.header-breadcrumb a {
  color: #adb1b8;
  text-decoration: none;
}

.header-breadcrumb a:hover {
  color: var(--amazon-orange);
  text-decoration: underline;
}

.header-breadcrumb .separator {
  margin: 0 4px;
  opacity: 0.5;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-right: 140px; /* Space for fixed user widget */
}

/* Legacy support/Keep ID if needed for JS */
#chat-header {
  background: inherit;
  padding: 0;
  border-bottom: none;
  box-shadow: none;
  height: 100%;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* ── Chat Messages (Premium Cards) ── */
#chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 32px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.msg-group {
  max-width: 900px;
  width: 100%;
  margin: 0 auto;
}

.msg {
  display: flex;
  gap: 20px;
  padding: 20px 28px;
  background: transparent;
  border: none;
  border-radius: 0;
  box-shadow: none;
  transition: background 0.15s;
  border-bottom: 1px solid rgba(0,0,0,0.04);
}

.msg:hover {
  background: rgba(0,0,0,0.014);
  border-color: rgba(0,0,0,0.06);
}

.msg-user {
  background: #fdfcfb;
}

.msg-avatar {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.03em;
  background: white;
  border: 1px solid #d5d9d9;
  box-shadow: 0 1px 3px rgba(0,0,0,0.07);
  margin-top: 1px;
}

.msg-avatar.user-av { background: #e7f4f5; color: #007185; }
.msg-avatar.ai-av   { background: #fff8e7; color: #c87400; }

.msg-body { flex: 1; min-width: 0; }

.msg-role {
  font-size: 11px;
  font-weight: 800;
  color: var(--text-muted);
  margin-bottom: 5px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

/* ── Message action bar ── */
.msg-actions {
  display: flex;
  gap: 4px;
  margin-top: 10px;
  opacity: 1;
  pointer-events: auto;
}

.msg-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  background: #fff;
  color: var(--text-secondary);
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  font-family: var(--font-body);
  line-height: 1;
}
.msg-action-btn svg { flex-shrink: 0; }
.msg-action-btn:hover {
  background: #f1f5f9;
  border-color: #cbd5e1;
  color: #111;
}
.msg-action-btn--done {
  background: #f0fdf4;
  border-color: #86efac;
  color: #16a34a;
}
.msg-action-btn--done:hover {
  background: #dcfce7;
  border-color: #86efac;
  color: #16a34a;
}

.msg-content {
  color: #1a1a1a;
  line-height: 1.78;
  font-size: 15px;
  letter-spacing: 0.01em;
  word-break: break-word;
}

/* AI messages slightly warmer tone */
.msg:not(.msg-user) .msg-content {
  color: #111827;
}

/* User message text */
.msg-user .msg-content {
  color: #374151;
  font-size: 14.5px;
}

/* Links */
.msg-content a:not(.file-download-link) {
  color: #0066c0;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}
.msg-content a:not(.file-download-link):hover {
  color: #c45500;
}

/* ── Markdown prose ── */
.msg-content p {
  margin: 0 0 0.9em;
}
.msg-content p:last-child { margin-bottom: 0; }

.msg-content .md-h1,
.msg-content .md-h2,
.msg-content .md-h3,
.msg-content .md-h4,
.msg-content .md-h5,
.msg-content .md-h6 {
  font-weight: 700;
  line-height: 1.3;
  margin: 1.25em 0 0.4em;
  color: #111;
}
.msg-content .md-h1 { font-size: 1.5em; border-bottom: 2px solid #e9ecef; padding-bottom: 0.25em; }
.msg-content .md-h2 { font-size: 1.25em; border-bottom: 1px solid #f0f0f0; padding-bottom: 0.2em; }
.msg-content .md-h3 { font-size: 1.1em; }
.msg-content .md-h4 { font-size: 1em; }
.msg-content .md-h5,
.msg-content .md-h6 { font-size: 0.9em; color: var(--text-secondary); }

.msg-content ul,
.msg-content ol {
  margin: 0.5em 0 0.85em 1.5em;
  padding: 0;
}
.msg-content li { margin: 0.2em 0; }
.msg-content li > ul,
.msg-content li > ol { margin: 0.2em 0 0.2em 1.2em; }

.msg-content strong { font-weight: 700; }
.msg-content em { font-style: italic; color: #444; }

.msg-content .md-hr {
  border: none;
  border-top: 1px solid #e9ecef;
  margin: 1.2em 0;
}

.msg-content .md-blockquote {
  border-left: 3px solid var(--amazon-orange, #e47911);
  margin: 0.8em 0;
  padding: 0.5em 1em;
  background: #fffbf5;
  border-radius: 0 6px 6px 0;
  color: #555;
  font-style: italic;
}
.msg-content .md-blockquote p { margin: 0; }

/* ── Tables ── */
.msg-content .md-table-wrap {
  overflow-x: auto;
  margin: 0.9em 0;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
}
.msg-content .md-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.msg-content .md-table th {
  background: #f8f9fa;
  font-weight: 700;
  text-align: left;
  padding: 8px 14px;
  border-bottom: 2px solid #dee2e6;
  white-space: nowrap;
}
.msg-content .md-table td {
  padding: 7px 14px;
  border-bottom: 1px solid #f1f3f5;
}
.msg-content .md-table tr:last-child td { border-bottom: none; }
.msg-content .md-table tr:hover td { background: #f8f9fa; }

/* ── Code blocks ── */
.msg-content pre {
  position: relative;
  background: #1e1e2e;
  border: 1px solid #2d2d3f;
  border-radius: 8px;
  padding: 36px 16px 14px 16px;
  margin: 0.9em 0;
  overflow-x: auto;
}

.msg-content pre code {
  background: none;
  padding: 0;
  color: inherit;
  font-size: 13px;
  border-radius: 0;
}

.msg-content code {
  font-family: var(--font-mono);
  font-size: 13px;
  background: #f1f3f5;
  padding: 2px 6px;
  border-radius: 4px;
  color: #c92a2a;
}

/* Language label */
.code-lang-label {
  position: absolute;
  top: 8px;
  left: 14px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(255,255,255,0.35);
  pointer-events: none;
  font-family: var(--font-mono);
  user-select: none;
}

/* Copy button */
.code-copy-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 5px;
  color: rgba(255,255,255,0.6);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.18s;
  font-family: var(--font-mono);
}
.code-copy-btn:hover {
  background: rgba(255,255,255,0.16);
  color: #fff;
}
.code-copy-btn.copied {
  background: rgba(52, 199, 89, 0.2);
  border-color: rgba(52, 199, 89, 0.4);
  color: #34c759;
}

/* ── Media previews ── */
.media-preview {
  display: inline-block;
  margin: 0.6em 0;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid #e2e8f0;
  background: #f8f9fa;
  max-width: 100%;
}

.media-preview-img img {
  display: block;
  max-width: min(540px, 100%);
  max-height: 420px;
  object-fit: contain;
  cursor: zoom-in;
  transition: max-height 0.3s ease;
}
.media-preview-img.media-preview--zoom img {
  max-height: 90vh;
  max-width: 90vw;
  cursor: zoom-out;
}

.media-preview-audio {
  padding: 12px 16px;
  min-width: 280px;
}
.media-preview-audio audio {
  display: block;
  width: 100%;
  margin-top: 6px;
}

.media-preview-video video {
  display: block;
  max-width: min(600px, 100%);
  max-height: 360px;
}

.media-preview-caption {
  font-size: 12px;
  color: var(--text-muted);
  padding: 5px 10px;
  background: #f8f9fa;
  border-top: 1px solid #e9ecef;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.media-preview-audio .media-preview-caption {
  border-top: none;
  padding: 0 0 4px;
  font-weight: 600;
  color: var(--text-secondary);
}

/* ── File Download Links in AI responses ── */
.file-download-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px 5px 8px;
  background: linear-gradient(135deg, #f0f7ff 0%, #e8f4ff 100%);
  border: 1px solid #bbd6f7;
  border-radius: 20px;
  color: #1a56a7;
  font-size: 13.5px;
  font-weight: 600;
  text-decoration: none;
  transition: all 0.22s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 1px 3px rgba(26, 86, 167, 0.1);
  vertical-align: middle;
  white-space: nowrap;
  max-width: 340px;
  overflow: hidden;
}

.file-download-link:hover {
  background: linear-gradient(135deg, #1a56a7 0%, #1e63b3 100%);
  border-color: #1a56a7;
  color: #fff;
  box-shadow: 0 4px 16px rgba(26, 86, 167, 0.25);
  transform: translateY(-1px);
  text-decoration: none;
}

.file-download-link .dl-icon {
  font-size: 15px;
  flex-shrink: 0;
  line-height: 1;
}

.file-download-link .dl-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}

.file-download-link .dl-badge {
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  padding: 2px 7px;
  border-radius: 12px;
  background: rgba(26, 86, 167, 0.12);
  color: #1a56a7;
  border: 1px solid rgba(26, 86, 167, 0.2);
  flex-shrink: 0;
  transition: all 0.22s;
}

.file-download-link:hover .dl-badge {
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.3);
}

/* Storage link inside chat — subtle "go to storage" pill */
.msg-content a[href="/storage"] {
  color: var(--text-muted);
  font-size: 12px;
  text-decoration: underline;
}
.msg-content a[href="/storage"]:hover {
  color: var(--amazon-orange);
}

/* ── Chat Input (Floating Pro Grade) ── */
#chat-input-area {
  padding: 12px 32px 32px;
  background: var(--bg-base);
  position: relative;
  z-index: 10;
}

#chat-input-area::before {
  content: "";
  position: absolute;
  top: -30px;
  left: 0;
  right: 0;
  height: 30px;
  background: linear-gradient(to top, var(--bg-base), transparent);
  pointer-events: none;
}

.input-wrapper {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  background: #ffffff;
  border: 1px solid #d5d9d9;
  border-radius: var(--radius-lg);
  padding: 10px 14px;
  max-width: 860px;
  margin: 0 auto;
  box-shadow: 0 8px 24px rgba(0,0,0,0.06), 0 2px 4px rgba(0,0,0,0.02);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.input-wrapper:focus-within {
  border-color: var(--amazon-orange);
  box-shadow: 0 8px 32px rgba(255,153,0,0.1), 0 2px 4px rgba(0,0,0,0.02);
  transform: translateY(-1px);
}

#chat-input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-size: 15.5px;
  padding: 6px 0;
  min-height: 24px;
  resize: none;
}

.send-btn {
  background: linear-gradient(180deg, #f7dfa5 0%, #f0c14b 100%);
  width: 38px;
  height: 38px;
  border-radius: 6px;
  border: 1px solid #a88734;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #111;
  box-shadow: 0 1px 0 rgba(255,255,255,.4) inset, 0 1px 2px rgba(0,0,0,0.1);
}

.send-btn:hover:not(:disabled) {
  background: linear-gradient(180deg, #f5d78e 0%, #eeb933 100%);
  border-color: #9c7e31;
}

.send-btn:disabled { opacity: 0.5; color: #888; border-color: #ccc; background: #eee; box-shadow: none; cursor: not-allowed; }

/* ── Input icon buttons (attach / mic) ── */
.input-icon-btn {
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  border-radius: 6px;
  border: 1px solid transparent;
  background: none;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.input-icon-btn:hover {
  background: var(--bg-base);
  border-color: var(--border);
  color: var(--text-primary);
}

/* Mic recording state */
.input-icon-btn.mic-recording {
  color: #c40000;
  background: #fff0f0;
  border-color: #f5c6c6;
  animation: pulse-mic 1.2s ease-in-out infinite;
}
@keyframes pulse-mic {
  0%, 100% { box-shadow: 0 0 0 0 rgba(196,0,0,0.25); }
  50%       { box-shadow: 0 0 0 5px rgba(196,0,0,0); }
}

/* ── Attached file chips (in input area) ── */
.file-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: #f0f2f2;
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  padding: 3px 10px 3px 8px;
  font-size: 12px;
  color: var(--text-primary);
  max-width: 200px;
}
.file-chip-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 140px;
}
.file-chip-remove {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 11px;
  padding: 0 0 0 2px;
  line-height: 1;
}
.file-chip-remove:hover { color: var(--red); }

/* ── File chips in user messages ── */
.msg-files {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 6px;
}
.msg-file-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: rgba(255,153,0,0.08);
  border: 1px solid rgba(255,153,0,0.25);
  border-radius: var(--radius-full);
  padding: 3px 10px 3px 8px;
  font-size: 12px;
  color: var(--text-primary);
  max-width: 220px;
}
.msg-file-icon { font-size: 14px; }
.msg-file-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 150px;
  color: var(--green);
  text-decoration: none;
}
.msg-file-name:hover { text-decoration: underline; }

/* ── Pages ── */
.page-content {
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 40px 20px;
}

.card {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 32px;
  margin-bottom: 32px;
  box-shadow: var(--shadow-sm);
}

.card-title {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 24px;
}

/* ── Form Elements (Amazon Style) ── */
.form-input {
  border: 1px solid #888c8c;
  border-radius: var(--radius-xs);
  padding: 9px 12px;
  box-shadow: 0 1px 2px rgba(15,17,17,.15) inset;
  transition: all 0.2s;
  font-family: inherit;
  font-size: 14px;
}

.form-input:focus {
  border-color: #007185;
  box-shadow: 0 0 0 3px rgba(15,113,131,0.2), 0 1px 2px rgba(15,17,17,0.15) inset;
  outline: none;
}

/* ── Buttons (Premium Amazon Gradient) ── */
.btn {
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid var(--border);
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  box-shadow: 0 4px 6px rgba(0,0,0,0.05);
}

.btn-primary {
  background: linear-gradient(180deg, #f7dfa5 0%, #f0c14b 100%);
  border-color: #a88734;
  color: #111;
}

.btn-primary:hover {
  background: linear-gradient(180deg, #f5d78e 0%, #eeb933 100%);
  border-color: #9c7e31;
}

.btn-ghost {
  background: linear-gradient(180deg, #fefefe 0%, #f7fafa 100%);
  border-color: #adb1b8;
  color: #111;
}

.btn-ghost:hover { background: #f0f2f2; border-color: #888c8c; }

.btn-danger {
  background: linear-gradient(180deg, #fff 0%, #fdfdfd 100%);
  border-color: #adb1b8;
  color: var(--red);
}
.btn-danger:hover {
  background: #fdf5f5;
  border-color: var(--red);
}

/* ── Data Table ── */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.data-table th {
  text-align: left;
  padding: 14px 16px;
  color: var(--text-muted);
  font-weight: 800;
  border-bottom: 1px solid var(--border);
  text-transform: uppercase;
  font-size: 10.5px;
  letter-spacing: 0.1em;
  background: var(--surface2);
}

.data-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-subtle);
}

/* ── Modal (Premium Dialog) ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(19, 25, 33, 0.4);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal-overlay.active { opacity: 1; visibility: visible; }

.modal-card {
  background: white;
  width: 100%;
  max-width: 480px;
  border-radius: var(--radius-lg);
  box-shadow: 0 24px 48px rgba(0,0,0,0.15);
  overflow: hidden;
  transform: scale(0.95) translateY(20px);
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-overlay.active .modal-card { transform: scale(1) translateY(0); }

.modal-header {
  padding: 20px 28px;
  background: #f0f2f2;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h3 { margin: 0; font-size: 18px; font-weight: 700; color: #111; }

.modal-body { padding: 32px 28px; font-size: 15px; color: #111; }

.modal-footer {
  padding: 20px 28px;
  background: #f7fafa;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  gap: 12px;
  justify-content: flex-end;
}

/* ── Trace Viewer Premium Styles ── */
.trace-modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  background: var(--bg-overlay);
  backdrop-filter: blur(8px);
  padding: 40px;
}

.trace-container {
  background: var(--bg-secondary);
  width: 100%;
  max-width: 1000px;
  height: 90vh;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: 0 24px 64px rgba(0,0,0,0.4);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: modalScaleUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalScaleUp {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

.trace-header {
  padding: 24px 32px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}

.trace-body {
  flex: 1;
  overflow-y: auto;
  padding: 32px;
  background: var(--bg-primary);
}

.trace-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

.trace-stat-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.trace-stat-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.trace-stat-value {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}

.event-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius-sm);
  margin-bottom: 12px;
  overflow: hidden;
  transition: all 0.2s;
}

.event-card:hover {
  border-color: var(--amazon-orange);
  box-shadow: var(--shadow-md);
}

.event-header {
  padding: 12px 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 16px;
  user-select: none;
}

.event-icon {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  background: var(--bg-primary);
  font-size: 16px;
}

.event-info {
  flex: 1;
}

.event-name {
  font-weight: 600;
  font-size: 14px;
  color: var(--text-primary);
}

.event-meta {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  gap: 12px;
}

.event-content {
  padding: 0 20px 20px 68px;
  display: none;
}

.event-card.open .event-content {
  display: block;
}

.event-data-grid {
  display: grid;
  gap: 8px;
  font-size: 13px;
  margin-bottom: 16px;
}

.event-data-row {
  display: flex;
  gap: 12px;
}

.event-data-key {
  color: var(--text-muted);
  font-weight: 500;
  min-width: 100px;
}

.event-data-val {
  color: var(--text-primary);
  word-break: break-all;
}

.event-raw {
  background: var(--bg-nav);
  color: #aeb9c7;
  padding: 16px;
  border-radius: 6px;
  font-family: var(--font-mono);
  font-size: 11px;
  margin-top: 12px;
  border: 1px solid rgba(255,255,255,0.1);
  overflow-x: auto;
}

/* ── Toasts ── */
.toast {
  background: #ffffff;
  border: 1px solid #007185;
  border-left-width: 8px;
  color: #111;
  padding: 20px;
  border-radius: var(--radius-sm);
  box-shadow: 0 8px 32px rgba(0,0,0,0.12);
  min-width: 340px;
  font-weight: 500;
}

.toast-error { border-color: #c40000; }

.input-hint {
  margin-top: 12px;
  font-size: 12px;
  color: #767676;
  text-align: center;
  width: 100%;
}

/* ── Suggestions (Pro Grade) ── */
.suggestion-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-top: 32px;
  width: 100%;
}

.suggestion-card {
  background: white;
  border: 1px solid #d5d9d9;
  padding: 24px;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
  text-align: left;
}

.suggestion-card:hover {
  border-color: var(--amazon-orange);
  box-shadow: 0 4px 16px rgba(255,153,0,0.12);
  transform: translateY(-2px);
}

.suggestion-card .sg-title {
  font-weight: 700;
  font-size: 15px;
  margin-bottom: 8px;
  color: #007185;
}

/* ── Auth Redesign ── */
.auth-shell { background: white; }
.auth-card { border: 1px solid #ddd; padding: 28px 32px; border-radius: 8px; box-shadow: none; max-width: 350px; }
.auth-title { font-size: 28px; font-weight: 500; margin-bottom: 20px; }

/* ── Status Indicator ── */
.pulse-dot { 
  width: 8px; 
  height: 8px; 
  background: var(--amazon-orange); 
  border-radius: 50%; 
  display: inline-block;
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(255, 184, 28, 0.7); }
  70% { transform: scale(1); box-shadow: 0 0 0 10px rgba(255, 184, 28, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(255, 184, 28, 0); }
}

/* ── Activity Log (msg-events) ── */
.msg-events {
  margin: 8px 0 16px;
  background: #fdfdfd;
  border: 1px solid #e7e7e7;
  border-radius: var(--radius-sm);
  padding: 12px;
  font-size: 13px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.02);
  transition: all 0.2s;
}

.msg-events:hover {
  border-color: #d5d9d9;
  box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}

.event-line {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-secondary);
  padding: 2px 0;
}

.event-status { color: var(--text-muted); font-style: italic; }
.event-tool { color: var(--green); font-family: var(--font-mono); font-size: 12px; }
.event-routing { color: #5d3fd3; font-weight: 500; }

/* ── Global Header Enhancements ── */
#chat-header {
  padding: 10px 24px;
}

.header-status-area {
  display: flex;
  align-items: center;
  gap: 16px;
  background: rgba(255,255,255,0.05);
  padding: 4px 12px;
  border-radius: var(--radius-full);
  border: 1px solid rgba(255,255,255,0.1);
}

/* ── Background Job Pill (Floating Pro) ── */
.job-indicator-container {
  position: fixed;
  top: 16px;
  right: 180px; /* To the left of the user widget */
  z-index: 1001;
}

.job-pill {
  background: #131921;
  border: 1px solid rgba(255,255,255,0.2);
  padding: 6px 16px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  gap: 10px;
  color: white;
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  animation: slideInDown 0.4s ease-out;
}

.job-pill:hover {
  background: #1e252e;
  border-color: var(--amazon-orange);
  transform: translateY(-2px);
}

.job-pill.waiting {
  background: #c45500;
  border-color: #ff9900;
}

@keyframes slideInDown {
  from { transform: translateY(-20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.job-pill-info {
  display: flex;
  flex-direction: column;
}

.job-pill-label {
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  opacity: 0.7;
}

.job-pill-desc {
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Chat Header Cleanups ── */
.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

#status-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255,184,28,0.1);
  padding: 4px 12px;
  border-radius: var(--radius-full);
  border: 1px solid rgba(255,184,28,0.2);
  color: var(--amazon-orange);
  font-weight: 600;
  font-size: 12px;
}

/* ── Tabs (Amazon Account style) ── */
.tab-btn {
  padding: 12px 20px;
  font-size: 14px;
  font-weight: 500;
  color: #565959;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  margin-bottom: -1px;
  transition: all 0.2s;
}

.tab-btn:hover { color: #111; }
.tab-btn.active { 
  color: #c45500; 
  border-bottom-color: #e47911; 
  font-weight: 700;
}

/* ── Pills (Search Filter Style) ── */
.pill, .filter-pill {
  padding: 6px 16px;
  font-size: 13px;
  font-weight: 500;
  border-radius: 20px;
  border: 1px solid #d5d9d9;
  background: #f0f2f2;
  color: #111;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
  margin-bottom: 4px;
}

.pill:hover, .filter-pill:hover { 
  background: #e3e6e6; 
  border-color: #adb1b8;
}

.pill.active, .filter-pill.active { 
  background: #333d47; 
  color: #fff; 
  border-color: #333d47;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* ── Firewall & Background Jobs ── */
.firewall-prompt {
  background: #ffffff;
  border: 2px solid #ffb81c;
  border-radius: var(--radius-md);
  padding: 20px;
  margin: 16px 0;
  box-shadow: 0 12px 24px rgba(231,118,0,0.12);
  animation: slideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
  overflow: hidden;
}

.firewall-prompt::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0; height: 4px;
  background: linear-gradient(90deg, #ffb81c, #e47911);
}

.fw-header { 
  font-weight: 800; 
  color: #111; 
  font-size: 14px; 
  margin-bottom: 8px; 
  display: flex;
  align-items: center;
  gap: 8px;
}
.fw-body { font-size: 14px; color: #565959; margin-bottom: 16px; line-height: 1.5; }
.fw-actions { display: flex; gap: 10px; }

@keyframes slideUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
