/* General */
body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  margin: 0;
  padding: 20px;
  background: #f0f2f5;
  color: #333;
}

/* Containers */
.login-container {
  max-width: 460px;
  margin: 40px auto;
  background: #fff;
  padding: 40px;
  border-radius: 12px;
  border: none;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.08);
  text-align: center;
}

.dashboard-container {
  max-width: 1800px;
  margin: 20px auto;
  background: #fff;
  padding: 40px;
  border-radius: 12px;
  border: none;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.08);
}

/* Titles */
h1 {
  font-size: 2em;
  margin-bottom: 10px;
}

.dashboard-title {
  text-align: center;
  font-size: 2em;
  margin-bottom: 5px;
}

.login-subtitle {
  font-size: 1em;
  color: #666;
  margin-bottom: 30px;
}

.welcome-message {
  text-align: center;
  font-size: 1.2em;
  margin-bottom: 30px;
  font-weight: 500;
}

/* Shown when SQL + MCP metrics are unavailable or request fails */
.dashboard-metrics-warning {
  margin: 0 auto 24px;
  width: 100%;
  padding: 12px 16px;
  border-radius: 8px;
  border: 1px solid #e6a100;
  background: #fff8e6;
  color: #5c4600;
  font-size: 0.95rem;
  text-align: left;
  line-height: 1.45;
  box-sizing: border-box;
}

.dashboard-metrics-warning[hidden] {
  display: none !important;
}

/* Forms */
.form-group { margin-bottom: 20px; text-align: left; }
label { display: block; margin-bottom: 5px; font-weight: 600; }
input {
  width: 100%;
  padding: 12px;
  border: 1px solid #ccc;
  border-radius: 6px;
  font-size: 1em;
  box-sizing: border-box;
}

/* Buttons */
button, .nav-btn {
  padding: 12px 24px;
  font-size: 16px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-weight: bold;
  transition: all 0.2s ease;
}

.login-container button {
  width: 100%;
  background: #0078d4;
  color: white;
}

.login-container button:hover { background: #106ebe; }

.nav-btn {
  display: inline-block;
  background: #0078d4;
  color: white;
  text-decoration: none;
  transform: scale(1);
}

.nav-btn:hover {
  background: #106ebe;
  transform: scale(1.05);
}

/* Messages */
#message, .dashboard-message {
  margin-top: 20px;
  padding: 12px;
  border-radius: 6px;
  font-weight: 500;
}

.success { background: #d4edda; color: #155724; }
.error { background: #f8d7da; color: #721c24; }

/* Stats grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
  margin-bottom: 30px;
}

.stat-card {
  background: #fff;
  padding: 25px;
  border-radius: 12px;
  border: none;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.08);
}

.stat-card h3 { margin-bottom: 10px; color: #555; font-size: 1.1em; }
.stat-card div { font-size: 2em; font-weight: bold; color: #0078d4; }

/* Buttons row */
.button-row {
  display: flex;
  justify-content: center;
  gap: 20px;
  margin-bottom: 30px;
}

/* Logout */
.logout-container {
  text-align: center;
  margin-top: 10px;
}

.logout-container button {
  width: 180px;
  background: #d9534f;
  color: white;
}

.logout-container button:hover { background: #c9302c; }
/* ===== Admin Chat (ADD ONLY) ===== */
.chat-card {
  margin-top: 20px;
  background: #f8f9fa;
  border-radius: 10px;
  padding: 20px;
  text-align: left;
}

.chat-card h3 {
  margin-top: 0;
  margin-bottom: 10px;
  color: #555;
  font-size: 1.1em;
}

.chat-box {
  border: 1px solid #ddd;
  background: #fff;
  border-radius: 8px;
  height: 520px;
  overflow: auto;
  padding: 10px;
  margin-bottom: 12px;
  scroll-behavior: smooth;

  display: flex;
  flex-direction: column;
  gap: 10px;

  /* Slim scrollbar — Firefox */
  scrollbar-width: thin;
  scrollbar-color: #c1c8d4 transparent;
}

/* Slim scrollbar — Chrome / Edge / Safari */
.chat-box::-webkit-scrollbar {
  width: 5px;
}

.chat-box::-webkit-scrollbar-track {
  background: transparent;
}

.chat-box::-webkit-scrollbar-thumb {
  background: #c1c8d4;
  border-radius: 99px;
}

.chat-box::-webkit-scrollbar-thumb:hover {
  background: #a0aab8;
}

.chat-input-row {
  display: flex;
  gap: 10px;
  align-items: center;
}
.chat-input {
  flex: 1;
  padding: 10px;
  border: 1px solid #d0d0d0;
  border-radius: 6px;
  font-size: 14px;
}
.chat-input:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

.chat-input-row input {
  flex: 1;
}

.chat-send-btn {
  width: 140px; /* overrides your global button width:100% */
  background: #0078d4;
  color: white;
}
.chat-send-btn:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

.chat-send-btn:hover {
  background: #106ebe;
}

.chat-line {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.chat-user {
  align-self: flex-end;
  max-width: 92%;
}

.chat-agent {
  align-self: flex-start;
  max-width: 92%;
}

.chat-meta {
  color: #555;
  font-size: 12px;
}

.chat-request {
  color: #555;
  font-weight: 500;
}

.chat-status {
  font-weight: 500;
}

.chat-bubble {
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 10px;
  background: #fff;
  line-height: 1.35;
  word-break: break-word;
}

.chat-paragraph {
  margin: 0;
}

.chat-gap {
  height: 8px;
}

.chat-hr {
  border: 0;
  border-top: 1px solid #ddd;
  margin: 8px 0;
}

.chat-heading {
  margin: 0;
  font-weight: 700;
  color: #333;
}

.chat-h1 { font-size: 18px; margin-top: 2px; }
.chat-h2 { font-size: 16px; margin-top: 6px; }
.chat-h3 { font-size: 14px; margin-top: 6px; }

.chat-list {
  margin: 0;
  padding-left: 18px;
}

/* Nested list spacing/indentation */
.chat-list .chat-list {
  margin-top: 6px;
}

.chat-list li {
  margin: 3px 0;
}

.chat-kv {
  margin: 0;
  display: grid;
  grid-template-columns: 160px 1fr;
  column-gap: 12px;
  row-gap: 6px;
}

.chat-kv dt {
  margin: 0;
  font-weight: 700;
  color: #555;
}

.chat-kv dd {
  margin: 0;
}

.chat-user .chat-bubble {
  background: #f0f2f5;
}

.chat-bubble code {
  background: #f0f2f5;
  padding: 1px 4px;
  border-radius: 4px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 0.95em;
}

.chat-code {
  margin: 6px 0 0 0;
  padding: 10px;
  background: #f0f2f5;
  border-radius: 6px;
  overflow-x: auto;
}

.chat-bubble-error {
  background: #f8d7da;
  color: #721c24;
  border-color: #f8d7da;
}

.chat-bubble-warn {
  background: #f0f2f5;
  border-color: #ddd;
}

.chat-bubble-rate-limit {
  background: #fffbeb;
  color: #92400e;
  border-color: #fde68a;
}

.chat-loading {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.chat-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid #ddd;
  border-top-color: #0078d4;
  border-radius: 50%;
  animation: chatSpin 0.9s linear infinite;
}

@keyframes chatSpin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.chat-json {
  margin: 6px 0 0 0;
  padding: 8px;
  background: #f0f2f5;
  border-radius: 6px;
  overflow-x: auto;
}

.chat-debug {
  margin-top: 10px;
  border: 1px solid #c8d0da;
  background: #fff;
  border-radius: 8px;
  padding: 10px;
}

.chat-debug summary {
  cursor: pointer;
  color: #444;
  font-weight: 600;
  font-size: 13px;
  user-select: none;
}

/* ── System info panel ─────────────────────── */
.debug-system-info {
  margin: 10px 0 6px;
  background: #f4f6f9;
  border: 1px solid #dde2ea;
  border-radius: 6px;
  padding: 10px 12px;
  font-size: 12px;
  color: #333;
}

.debug-sysinfo-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.debug-sysinfo-grid strong {
  display: block;
  margin-bottom: 5px;
  color: #555;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.debug-sysinfo-table {
  border-collapse: collapse;
  width: 100%;
  font-size: 12px;
}

.debug-sysinfo-table td {
  padding: 2px 6px 2px 0;
  vertical-align: top;
}

.debug-sysinfo-table td:first-child {
  color: #777;
  white-space: nowrap;
  padding-right: 10px;
}

.debug-env-ok      { color: #1a7f37; font-weight: 600; }
.debug-env-missing { color: #cf222e; font-weight: 600; }

.notes-modal-textarea {
  width: 100%;
  min-height: 300px;
  resize: vertical;
  padding: 10px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  font: inherit;
  line-height: 1.4;
  box-sizing: border-box;
}

.notes-modal-view {
  white-space: pre-wrap;
  line-height: 1.5;
}
.debug-env-opt     { color: #888; }

/* ── Toolbar (entry count + buttons) ──────── */
.debug-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 6px 0 4px;
}

.debug-entry-count {
  font-size: 11px;
  color: #888;
  flex: 1;
}

.debug-action-btn {
  width: auto;
  padding: 3px 10px;
  font-size: 11px;
  font-weight: 600;
  background: #e8ecf0;
  color: #444;
  border: 1px solid #c8d0da;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.15s;
}

.debug-action-btn:hover {
  background: #d0d7e0;
}

/* ── Log area ──────────────────────────────── */
.chat-debug-log {
  margin: 0;
  max-height: 260px;
  overflow-y: auto;
  background: #1e1e2e;
  border-radius: 6px;
  padding: 8px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Courier New", monospace;
  font-size: 11.5px;
  line-height: 1.6;
  scrollbar-width: thin;
  scrollbar-color: #444 transparent;
}

.chat-debug-log::-webkit-scrollbar      { width: 4px; }
.chat-debug-log::-webkit-scrollbar-track  { background: transparent; }
.chat-debug-log::-webkit-scrollbar-thumb  { background: #444; border-radius: 99px; }

/* ── Log entries ───────────────────────────── */
.debug-entry {
  display: flex;
  gap: 6px;
  padding: 1px 0;
  border-bottom: 1px solid rgba(255,255,255,0.03);
  flex-wrap: wrap;
}

.debug-ts   { color: #6b7280; flex-shrink: 0; }
.debug-lvl  { flex-shrink: 0; font-weight: 700; width: 52px; }
.debug-evt  { flex-shrink: 0; }
.debug-data { color: #9ca3af; word-break: break-all; }

/* Level colours */
.debug-info    .debug-lvl { color: #60a5fa; }
.debug-info    .debug-evt { color: #93c5fd; }
.debug-success .debug-lvl { color: #34d399; }
.debug-success .debug-evt { color: #6ee7b7; }
.debug-warn    .debug-lvl { color: #fbbf24; }
.debug-warn    .debug-evt { color: #fde68a; }
.debug-error   .debug-lvl { color: #f87171; }
.debug-error   .debug-evt { color: #fca5a5; }

/* ===== Markdown Tables ===== */
.chat-table-wrap {
  overflow-x: auto;
  margin: 6px 0;
  border-radius: 6px;
}

.chat-table {
  border-collapse: collapse;
  width: 100%;
  font-size: 13px;
  min-width: 260px;
}

.chat-table th,
.chat-table td {
  border: 1px solid #ddd;
  padding: 6px 10px;
  white-space: nowrap;
  vertical-align: top;
}

.chat-table thead tr {
  background: #eef2f7;
}

.chat-table th {
  font-weight: 700;
  color: #333;
  letter-spacing: 0.02em;
}

.chat-table tbody tr:nth-child(even) {
  background: #fafafa;
}

.chat-table tbody tr:hover {
  background: #f0f7ff;
}

/* ===== Email Response Logs Card (User Story #8) ===== */

/* Card container */
.logs-card {
  background: #fff;
  border-radius: 12px;
  border: none;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.08);
  margin-bottom: 25px;
  text-align: left;
}

/* Header row: title + health bead side-by-side */
.logs-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
}

.logs-card-title {
  margin: 0;
  font-size: 1.1em;
  color: #555;
}

/* Health status indicator */
.logs-health-bead {
  display: flex;
  align-items: center;
  font-size: 14px;
  font-weight: 600;
  color: #555;
  gap: 8px;
}

.health-dot {
  display: inline-block;
  height: 12px;
  width: 12px;
  border-radius: 50%;
  background-color: #ccc; /* default: unknown — overridden by JS */
  flex-shrink: 0;
}

/* Warning banner (SQL unavailable or fetch error) */
.logs-warning-banner {
  margin-bottom: 12px;
  padding: 10px 14px;
  border-radius: 6px;
  border: 1px solid #e6a100;
  background: #fff8e6;
  color: #5c4600;
  font-size: 0.9rem;
  line-height: 1.4;
}

.logs-warning-banner[hidden] {
  display: none !important;
}

/* Table layout */
.logs-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 14px;
}

/* Header row */
.logs-thead-row {
  border-bottom: 2px solid #eee;
}

.logs-th {
  padding: 10px;
  font-weight: 700;
  color: #444;
  white-space: nowrap;
}

/* Data rows */
.logs-row {
  border-bottom: 1px solid #f0f0f0;
  transition: background 0.15s ease;
}

tbody tr:nth-child(even) {
  background: #f2f7fc;
}
tbody tr:nth-child(odd) {
  background: #ffffff;
}

.logs-row:hover {
  background: #f8faff;
}

.logs-td {
  padding: 10px;
  vertical-align: top;
}

.logs-td-muted {
  color: #777;
  white-space: nowrap;
}

.logs-td-bold {
  font-weight: 500;
}

/* Intent summary / response sub-text */
.logs-summary {
  font-weight: 600;
  margin-bottom: 3px;
}

.logs-response {
  font-size: 12px;
  color: #777;
}

/* Category badges */
.logs-badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
}

.logs-badge-correct   { background: #28a745; }  /* green  */
.logs-badge-fallback  { background: #ffc107; color: #333; } /* amber */
.logs-badge-incorrect { background: #6c757d; }  /* gray   */

/* Confidence line below badge */
.logs-confidence {
  font-size: 11px;
  color: #999;
  margin-top: 4px;
}

/* Placeholder / empty-state / error-state cells */
.logs-placeholder {
  padding: 18px;
  text-align: center;
  color: #888;
  font-style: italic;
}

.logs-placeholder-error {
  color: #c0392b;
  font-style: normal;
}

/* ===== Logs Filter Bar ===== */

.logs-filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: flex-end;
  padding: 14px 0 12px;
  border-bottom: 1px solid #f0f0f0;
  margin-bottom: 8px;
  position: relative;
  z-index: 2;
}

.logs-filter-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.logs-filter-grow {
  flex: 1;
  min-width: 200px;
}

.logs-filter-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #aaa;
}

/* Date range pills */
.logs-date-pills {
  display: flex;
  gap: 4px;
}

.logs-pill {
  padding: 5px 13px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid #d4dbe5;
  border-radius: 20px;
  background: #fff;
  color: #555;
  cursor: pointer;
  line-height: 1.4;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  white-space: nowrap;
}

.logs-pill:hover {
  background: #f0f4f9;
  border-color: #b0bac8;
}

.logs-pill-active {
  background: #0078d4;
  color: #fff;
  border-color: #0078d4;
}

.logs-pill-active:hover {
  background: #106ebe;
  border-color: #106ebe;
}

/* Status select */
.logs-status-select {
  padding: 5px 10px;
  border: 1px solid #d4dbe5;
  border-radius: 6px;
  font-size: 13px;
  color: #333;
  background: #fff;
  cursor: pointer;
  height: 32px;
}

.logs-status-select:focus {
  outline: none;
  border-color: #0078d4;
  box-shadow: 0 0 0 2px rgba(0, 120, 212, 0.15);
}

/* Company / email search input */
.logs-company-input {
  padding: 5px 10px;
  border: 1px solid #d4dbe5;
  border-radius: 6px;
  font-size: 13px;
  color: #333;
  background: #fff;
  width: 100%;
  height: 32px;
  box-sizing: border-box;
}

.logs-company-input:focus {
  outline: none;
  border-color: #0078d4;
  box-shadow: 0 0 0 2px rgba(0, 120, 212, 0.15);
}

/* "Showing X of Y" meta line */
.logs-table-meta {
  padding: 4px 0 8px;
}

.logs-showing-count {
  font-size: 12px;
  color: #999;
  font-style: italic;
}

.traces-scroll-window {
  max-height: 600px;
  overflow-y: auto;
  border: 1px solid #eee;
  border-radius: 8px;
  background: #fff;
  margin-bottom: 20px;
}


.evals-scroll-window {
  max-height: 500px;
  overflow-y: auto;
  border: 1px solid #eee;
  border-radius: 8px;
  background: #fff;
  margin-bottom: 20px;
}

/* Keep headers visible while scrolling specific log tables */
.evals-scroll-window thead .logs-th,
.traces-scroll-window thead .logs-th {
  position: sticky;
  top: 0;
  z-index: 5;
  background: #fff;
  box-shadow: 0 1px 0 #e9ecef;
}

.evals-scroll-window thead .logs-th[style*="background-color: #f7faff"] {
  background: #f7faff;
}


.logs-response-container {
  max-width: 250px;
  max-height: 60px;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  font-size: 13px;
  line-height: 1.4;
  color: #555;
  cursor: pointer;
}

/* Modal Styling */
.email-modal {
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  overflow: auto;
  background-color: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
}

.email-modal[hidden] {
  display: none !important;
}

.email-modal-content {
  background-color: #fefefe;
  margin: auto;
  padding: 20px;
  border: 1px solid #888;
  width: 80%;
  max-width: 800px;
  border-radius: 8px;
  box-shadow: 0 4px 8px rgba(0,0,0,0.2);
  position: relative;
  display: flex;
  flex-direction: column;
  max-height: 80vh;
}

.email-modal-close {
  color: #aaa;
  position: absolute;
  top: 15px;
  right: 20px;
  font-size: 28px;
  font-weight: bold;
  cursor: pointer;
}

.email-modal-close:hover,
.email-modal-close:focus {
  color: black;
  text-decoration: none;
  cursor: pointer;
}

.email-modal-body {
  margin-top: 20px;
  overflow-y: auto;
  padding: 15px;
  border: 1px solid #eee;
  border-radius: 4px;
  background: #fafafa;
  font-family: inherit;
  line-height: 1.5;
  color: #333;
}

/* Shake animation for validation errors */
@keyframes shake {
  0%  { transform: translateX(0); }
  20% { transform: translateX(-5px); }
  40% { transform: translateX(5px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
  100%{ transform: translateX(0); }
}
