/* ── Frankenbot Dark Theme v2 ──────────────────────────────────────────────── */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  --bg-base:        #080b12;
  --bg-surface:     #0f1320;
  --bg-elevated:    #181d2e;
  --bg-hover:       #1f2640;
  --bg-glass:       rgba(15,19,32,.7);
  --accent:         #7c6fff;
  --accent-light:   #a89eff;
  --accent-dim:     #4a45a0;
  --accent-glow:    rgba(124,111,255,.3);
  --accent2:        #06d6a0;
  --accent2-glow:   rgba(6,214,160,.25);
  --success:        #06d6a0;
  --warning:        #fbbf24;
  --danger:         #f43f5e;
  --info:           #38bdf8;
  --text-primary:   #e8eaf6;
  --text-secondary: #94a3b8;
  --text-muted:     #4e5a72;
  --border:         rgba(255,255,255,.07);
  --border-accent:  rgba(124,111,255,.35);
  --shadow:         0 8px 32px rgba(0,0,0,.5);
  --shadow-sm:      0 2px 12px rgba(0,0,0,.3);
  --radius:         14px;
  --radius-sm:      9px;
  --radius-xs:      6px;
  --transition:     .18s cubic-bezier(.4,0,.2,1);
}

/* ── Reset & Base ─────────────────────────────────────────────────────────── */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
  min-height: 100vh;
  background: var(--bg-base);
  background-image:
    radial-gradient(ellipse 80% 50% at 50% -10%, rgba(124,111,255,.12) 0%, transparent 60%),
    radial-gradient(ellipse 40% 30% at 90% 80%, rgba(6,214,160,.06) 0%, transparent 50%);
  color: var(--text-primary);
  font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
  font-size: .9375rem;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

/* ── Scrollbar ────────────────────────────────────────────────────────────── */

::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bg-hover); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent-dim); }

/* ── Navbar ───────────────────────────────────────────────────────────────── */

.navbar {
  background: var(--bg-glass) !important;
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  padding: .6rem 0;
  position: sticky;
  top: 0;
  z-index: 1000;
}

.navbar-brand {
  font-weight: 700;
  font-size: 1rem;
  color: var(--text-primary) !important;
  letter-spacing: -.02em;
  display: flex;
  align-items: center;
  gap: .5rem;
  text-decoration: none;
}

.navbar-brand .brand-icon {
  width: 28px;
  height: 28px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .75rem;
  box-shadow: 0 0 16px var(--accent-glow);
  animation: brand-pulse 3s ease-in-out infinite;
}

@keyframes brand-pulse {
  0%, 100% { box-shadow: 0 0 16px var(--accent-glow); }
  50%       { box-shadow: 0 0 28px var(--accent-glow), 0 0 8px var(--accent2-glow); }
}

.nav-link {
  color: var(--text-muted) !important;
  font-size: .8125rem;
  font-weight: 500;
  padding: .4rem .7rem !important;
  border-radius: var(--radius-xs);
  transition: color var(--transition), background var(--transition);
  letter-spacing: .01em;
  display: flex;
  align-items: center;
  gap: .35rem;
  white-space: nowrap;
}

.nav-link:hover,
.nav-link.active {
  color: var(--text-primary) !important;
  background: rgba(124,111,255,.12);
}

.nav-link.active {
  color: var(--accent-light) !important;
  background: rgba(124,111,255,.18);
}

.navbar-toggler {
  border-color: var(--border);
  padding: .3rem .5rem;
}
.navbar-toggler-icon { filter: invert(.7); }

/* ── Page Header ──────────────────────────────────────────────────────────── */

.page-header {
  padding: 1.75rem 0 1.25rem;
  margin-bottom: 1.75rem;
  border-bottom: 1px solid var(--border);
  position: relative;
}

.page-header::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 0;
  width: 60px;
  height: 2px;
  background: linear-gradient(90deg, var(--accent), transparent);
  border-radius: 99px;
}

.page-header h1 {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -.03em;
  margin-bottom: .2rem;
  background: linear-gradient(135deg, var(--text-primary), var(--text-secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.page-header p {
  color: var(--text-muted);
  font-size: .8125rem;
  margin: 0;
}

/* ── Cards ────────────────────────────────────────────────────────────────── */

.card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  color: var(--text-primary);
  transition: border-color var(--transition), box-shadow var(--transition), transform var(--transition);
  overflow: hidden;
}

.card:hover {
  border-color: rgba(124,111,255,.2);
  box-shadow: var(--shadow);
}

.card-header {
  background: var(--bg-elevated) !important;
  border-bottom: 1px solid var(--border) !important;
  color: var(--text-primary) !important;
  padding: .85rem 1.25rem;
  font-weight: 600;
  font-size: .9rem;
}

.card-header.bg-primary  { background: linear-gradient(135deg, rgba(79,70,229,.8), rgba(124,111,255,.8)) !important; border-bottom-color: rgba(124,111,255,.3) !important; }
.card-header.bg-success  { background: linear-gradient(135deg, rgba(5,150,105,.8), rgba(6,214,160,.8)) !important; border-bottom-color: rgba(6,214,160,.3) !important; color: #fff !important; }
.card-header.bg-dark     { background: linear-gradient(135deg, #10141f, #1a2035) !important; }
.card-header.bg-warning  { background: linear-gradient(135deg, rgba(180,100,0,.85), rgba(251,191,36,.85)) !important; color: #fff !important; border-bottom-color: rgba(251,191,36,.3) !important; }
.card-header.bg-info     { background: linear-gradient(135deg, rgba(2,132,199,.8), rgba(56,189,248,.8)) !important; border-bottom-color: rgba(56,189,248,.3) !important; }
.card-header.bg-secondary{ background: linear-gradient(135deg, #1e2640, #242e48) !important; }
.card-header.bg-danger   { background: linear-gradient(135deg, rgba(185,28,28,.8), rgba(244,63,94,.8)) !important; border-bottom-color: rgba(244,63,94,.3) !important; }

.card-body { padding: 1.25rem; }

.card-footer {
  background: var(--bg-elevated) !important;
  border-top: 1px solid var(--border) !important;
  padding: .65rem 1.25rem;
}

/* Agent cards */
.agent-card {
  transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
  cursor: default;
}
.agent-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 12px 40px rgba(124,111,255,.2);
  border-color: var(--accent);
}

/* ── Stat Cards ───────────────────────────────────────────────────────────── */

.stat-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem 1.25rem;
  text-align: center;
  transition: border-color var(--transition), transform var(--transition), box-shadow var(--transition);
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  opacity: 0;
  transition: opacity var(--transition);
}

.stat-card:hover {
  border-color: var(--border-accent);
  transform: translateY(-3px);
  box-shadow: 0 8px 32px rgba(124,111,255,.15);
}
.stat-card:hover::before { opacity: 1; }

.stat-card .stat-number {
  font-size: 2.2rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--accent-light), var(--accent2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1;
  margin-bottom: .4rem;
}

.stat-card .stat-label {
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--text-muted);
  font-weight: 600;
}

/* ── Buttons ──────────────────────────────────────────────────────────────── */

.btn {
  border-radius: var(--radius-sm);
  font-weight: 500;
  font-size: .8125rem;
  padding: .45rem 1rem;
  transition: all var(--transition);
  border: none;
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  letter-spacing: .01em;
  cursor: pointer;
  text-decoration: none;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), #6058d0);
  color: #fff;
  box-shadow: 0 2px 12px rgba(124,111,255,.3);
}
.btn-primary:hover {
  background: linear-gradient(135deg, var(--accent-light), var(--accent));
  box-shadow: 0 4px 20px rgba(124,111,255,.45);
  transform: translateY(-1px);
  color: #fff;
}

.btn-success {
  background: linear-gradient(135deg, #059669, var(--success));
  color: #fff;
  box-shadow: 0 2px 12px rgba(6,214,160,.25);
}
.btn-success:hover {
  background: linear-gradient(135deg, #06d6a0, #059669);
  box-shadow: 0 4px 20px rgba(6,214,160,.4);
  transform: translateY(-1px);
  color: #fff;
}

.btn-danger {
  background: linear-gradient(135deg, #be123c, var(--danger));
  color: #fff;
}
.btn-danger:hover {
  background: linear-gradient(135deg, var(--danger), #be123c);
  transform: translateY(-1px);
  color: #fff;
}

.btn-secondary {
  background: var(--bg-elevated);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}
.btn-secondary:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: rgba(124,111,255,.3);
}

.btn-info {
  background: linear-gradient(135deg, #0284c7, var(--info));
  color: #fff;
}
.btn-info:hover {
  background: linear-gradient(135deg, var(--info), #0284c7);
  transform: translateY(-1px);
  color: #fff;
}

.btn-warning {
  background: linear-gradient(135deg, #d97706, var(--warning));
  color: #0f1117;
}
.btn-warning:hover {
  background: linear-gradient(135deg, var(--warning), #d97706);
  transform: translateY(-1px);
}

.btn-outline-primary {
  background: transparent;
  border: 1px solid var(--accent-dim);
  color: var(--accent-light);
}
.btn-outline-primary:hover {
  background: rgba(124,111,255,.15);
  border-color: var(--accent);
  color: var(--accent-light);
}

.btn-outline-secondary {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
}
.btn-outline-secondary:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--text-muted);
}

.btn-sm { padding: .28rem .65rem; font-size: .76rem; border-radius: var(--radius-xs); }
.btn-lg { padding: .65rem 1.5rem; font-size: .9375rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none !important; }

/* ── Forms ────────────────────────────────────────────────────────────────── */

.form-control,
.form-select {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: .55rem .9rem;
  font-size: .875rem;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.form-control:focus,
.form-select:focus {
  background: var(--bg-elevated);
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
  color: var(--text-primary);
  outline: none;
}

.form-control::placeholder { color: var(--text-muted); }
.form-label {
  color: var(--text-secondary);
  font-size: .76rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .07em;
  margin-bottom: .4rem;
}
.form-select option { background: var(--bg-elevated); }
textarea.form-control { resize: vertical; min-height: 80px; }

/* ── Tables ───────────────────────────────────────────────────────────────── */

.table {
  color: var(--text-primary);
  margin-bottom: 0;
  border-collapse: separate;
  border-spacing: 0;
}

.table th {
  border-top: none;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-muted);
  padding: .75rem 1rem;
  background: rgba(0,0,0,.2);
}

.table td {
  border-bottom: 1px solid var(--border);
  padding: .75rem 1rem;
  vertical-align: middle;
  color: var(--text-secondary);
  font-size: .875rem;
}

.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover td {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.table-striped > tbody > tr:nth-of-type(odd) > * {
  background: rgba(255,255,255,.015);
}

/* ── Badges ───────────────────────────────────────────────────────────────── */

.badge {
  padding: .28em .65em;
  border-radius: 5px;
  font-size: .68rem;
  font-weight: 600;
  letter-spacing: .05em;
  text-transform: uppercase;
}

.bg-primary   { background: rgba(124,111,255,.25) !important; color: var(--accent-light) !important; border: 1px solid rgba(124,111,255,.3); }
.bg-success   { background: rgba(6,214,160,.2) !important; color: #34d399 !important; border: 1px solid rgba(6,214,160,.3); }
.bg-warning   { background: rgba(251,191,36,.2) !important; color: #fbbf24 !important; border: 1px solid rgba(251,191,36,.3); }
.bg-danger    { background: rgba(244,63,94,.2) !important; color: #f87171 !important; border: 1px solid rgba(244,63,94,.3); }
.bg-info      { background: rgba(56,189,248,.2) !important; color: #38bdf8 !important; border: 1px solid rgba(56,189,248,.3); }
.bg-secondary { background: var(--bg-elevated) !important; color: var(--text-muted) !important; border: 1px solid var(--border); }
.bg-dark      { background: rgba(0,0,0,.4) !important; color: var(--text-secondary) !important; border: 1px solid var(--border); }

/* ── Alerts ───────────────────────────────────────────────────────────────── */

.alert {
  border-radius: var(--radius-sm);
  border: 1px solid;
  font-size: .875rem;
  padding: .9rem 1.1rem;
  backdrop-filter: blur(8px);
}

.alert-success  { background: rgba(6,214,160,.08); border-color: rgba(6,214,160,.25); color: #34d399; }
.alert-danger   { background: rgba(244,63,94,.08); border-color: rgba(244,63,94,.25); color: #f87171; }
.alert-warning  { background: rgba(251,191,36,.08); border-color: rgba(251,191,36,.25); color: #fbbf24; }
.alert-info     { background: rgba(56,189,248,.08); border-color: rgba(56,189,248,.25); color: #7dd3fc; }

.alert-dismissible .btn-close { filter: invert(1) opacity(.5); }

/* ── Chat ─────────────────────────────────────────────────────────────────── */

.chat-container {
  max-height: 560px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: .5rem 0;
}

.chat-message {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1rem 1.1rem;
  border-left: 3px solid var(--accent);
  transition: border-color var(--transition);
}
.chat-message:hover { border-left-color: var(--accent2); }

.chat-prompt {
  background: rgba(0,0,0,.25);
  border-radius: var(--radius-xs);
  padding: .55rem .85rem;
  margin-bottom: .6rem;
  color: var(--text-primary);
  font-size: .875rem;
  border-left: 2px solid var(--text-muted);
}

.chat-response {
  background: linear-gradient(135deg, rgba(124,111,255,.1), rgba(6,214,160,.05));
  border: 1px solid rgba(124,111,255,.2);
  border-radius: var(--radius-xs);
  padding: .65rem .85rem;
  color: var(--text-primary);
  font-size: .875rem;
  white-space: pre-wrap;
  line-height: 1.7;
}

.chat-timestamp {
  color: var(--text-muted);
  font-size: .72rem;
  margin-bottom: .5rem;
  display: flex;
  align-items: center;
  gap: .5rem;
}

/* ── List Group ───────────────────────────────────────────────────────────── */

.list-group-item {
  background: var(--bg-surface);
  border: none;
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
  padding: .85rem 1.1rem;
  transition: background var(--transition);
}
.list-group-item:last-child { border-bottom: none; }
.list-group-item-action:hover { background: var(--bg-hover); color: var(--text-primary); }
.list-group-flush .list-group-item { border-radius: 0 !important; }

/* ── Modal ────────────────────────────────────────────────────────────────── */

.modal-content {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  box-shadow: 0 24px 80px rgba(0,0,0,.6);
}

.modal-header {
  border-bottom: 1px solid var(--border);
  background: var(--bg-elevated);
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 1rem 1.25rem;
}

.modal-footer {
  border-top: 1px solid var(--border);
  background: var(--bg-elevated);
  border-radius: 0 0 var(--radius) var(--radius);
}

.modal-backdrop { backdrop-filter: blur(4px); }
.btn-close { filter: invert(1) opacity(.6); }

/* ── Footer ───────────────────────────────────────────────────────────────── */

footer {
  margin-top: 60px;
  padding: 18px 0;
  background: var(--bg-surface);
  border-top: 1px solid var(--border);
  text-align: center;
  color: var(--text-muted);
  font-size: .76rem;
}

/* ── File Items ───────────────────────────────────────────────────────────── */

.file-item {
  display: flex;
  align-items: center;
  gap: .7rem;
  padding: .7rem .9rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  transition: background var(--transition), border-color var(--transition), transform var(--transition);
  margin-bottom: .5rem;
}
.file-item:last-child { margin-bottom: 0; }
.file-item:hover { background: var(--bg-hover); border-color: rgba(124,111,255,.25); transform: translateX(2px); }
.file-icon { font-size: 1.1rem; flex-shrink: 0; }
.file-name { flex: 1; font-size: .875rem; color: var(--text-primary); font-weight: 500; word-break: break-all; }
.file-meta { font-size: .72rem; color: var(--text-muted); white-space: nowrap; }
.file-actions { display: flex; gap: .35rem; flex-shrink: 0; }

/* ── Status / Email Log ───────────────────────────────────────────────────── */

.status-replied  { color: var(--success); font-weight: 600; }
.status-skipped  { color: var(--text-muted); }
.status-error    { color: var(--danger); font-weight: 600; }
.badge-agent     { font-size: .68rem; }
.log-table td    { vertical-align: middle; }
.response-preview {
  font-size: .8rem;
  color: var(--text-secondary);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 70px;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
}

/* ── Typography ───────────────────────────────────────────────────────────── */

h1, h2, h3, h4 { letter-spacing: -.02em; }
h1 { font-size: 1.5rem; font-weight: 700; }
h3 { font-size: 1rem; font-weight: 600; color: var(--text-secondary); }

/* ── Misc Utilities ───────────────────────────────────────────────────────── */

.text-muted    { color: var(--text-muted) !important; }
.text-secondary{ color: var(--text-secondary) !important; }
.bg-light      { background: var(--bg-elevated) !important; color: var(--text-primary) !important; }
pre, code      { background: var(--bg-elevated); color: #a5f3fc; border-radius: var(--radius-xs); padding: .15em .45em; font-family: 'JetBrains Mono', monospace; font-size: .82em; }
pre            { padding: 1rem 1.1rem; overflow-x: auto; line-height: 1.6; }
hr             { border-color: var(--border); opacity: 1; }

.font-monospace { font-family: 'JetBrains Mono', 'Fira Code', monospace !important; font-size: .83rem !important; }

/* ── Live streaming indicator ─────────────────────────────────────────────── */

.streaming-dot {
  display: inline-block;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--accent2);
  animation: blink 1s infinite;
  margin-left: .4rem;
  vertical-align: middle;
}
@keyframes blink { 0%,100%{opacity:1;} 50%{opacity:.2;} }

/* ── Progress / skeleton ──────────────────────────────────────────────────── */

.skeleton {
  background: linear-gradient(90deg, var(--bg-elevated) 25%, var(--bg-hover) 50%, var(--bg-elevated) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-xs);
}
@keyframes shimmer { 0%{background-position:200% 0;} 100%{background-position:-200% 0;} }

/* ── Inline editor ────────────────────────────────────────────────────────── */

.inline-editor {
  width: 100%;
  min-height: 320px;
  background: var(--bg-base);
  border: 1px solid var(--border-accent);
  border-radius: var(--radius-sm);
  color: #a5f3fc;
  font-family: 'JetBrains Mono', monospace;
  font-size: .83rem;
  padding: 1rem;
  line-height: 1.6;
  resize: vertical;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.inline-editor:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

/* ── Hero section ─────────────────────────────────────────────────────────── */

.hero-section {
  background: linear-gradient(135deg, rgba(124,111,255,.1), rgba(6,214,160,.05));
  border: 1px solid rgba(124,111,255,.15);
  border-radius: var(--radius);
  padding: 2rem;
  margin-bottom: 1.75rem;
  position: relative;
  overflow: hidden;
}

.hero-section::before {
  content: '';
  position: absolute;
  top: -50%; right: -20%;
  width: 300px; height: 300px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(124,111,255,.08) 0%, transparent 70%);
  pointer-events: none;
}

/* ── Responsive adjustments ───────────────────────────────────────────────── */

@media (max-width: 768px) {
  .page-header { padding: 1.25rem 0 1rem; }
  .hero-section { padding: 1.25rem; }
  .stat-card .stat-number { font-size: 1.75rem; }
  .file-actions { flex-direction: column; }
}
