/* SimAgent — Dark Theme UI */
:root {
  --bg:          #0f1117;
  --bg2:         #161a27;
  --card:        #1e2235;
  --card2:       #252a40;
  --border:      #2d3354;
  --accent:      #7c6ff7;
  --accent-h:    #6a5ee0;
  --accent-glow: rgba(124,111,247,.25);
  --success:     #22c55e;
  --warning:     #f59e0b;
  --danger:      #ef4444;
  --info:        #38bdf8;
  --text:        #dde2f0;
  --text2:       #9aa3c0;
  --muted:       #505878;
  --radius:      10px;
  --radius-sm:   6px;
  --shadow:      0 4px 24px rgba(0,0,0,.4);
  --transition:  .18s ease;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 15px; scroll-behavior: smooth; }

body {
  font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-h); }

/* ── Layout ─────────────────────────────── */
.app-wrap { display: flex; min-height: 100vh; }

.sidebar {
  width: 240px;
  min-width: 240px;
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-logo {
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}
.sidebar-logo .logo-icon {
  width: 36px; height: 36px;
  background: var(--accent);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
}
.sidebar-logo .logo-text { font-size: 1.1rem; font-weight: 700; }
.sidebar-logo .logo-sub  { font-size: .72rem; color: var(--text2); }

.sidebar-nav { flex: 1; padding: 12px 0; }
.nav-section { padding: 8px 14px 4px; font-size: .7rem; text-transform: uppercase;
               letter-spacing: .08em; color: var(--muted); font-weight: 600; }

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 20px;
  color: var(--text2);
  font-size: .88rem;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
  border-radius: 0;
  position: relative;
}
.nav-item:hover { background: var(--card); color: var(--text); }
.nav-item.active {
  background: var(--card);
  color: var(--accent);
}
.nav-item.active::before {
  content: '';
  position: absolute; left: 0; top: 0; bottom: 0;
  width: 3px; background: var(--accent);
  border-radius: 0 2px 2px 0;
}
.nav-item .nav-icon { font-size: 1rem; width: 20px; text-align: center; }

.sidebar-user {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px;
}
.user-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-size: .85rem; font-weight: 700;
  flex-shrink: 0;
}
.user-info .user-name  { font-size: .82rem; font-weight: 600; }
.user-info .user-role  { font-size: .7rem; color: var(--text2); }

.main-content {
  flex: 1;
  overflow-x: hidden;
  display: flex; flex-direction: column;
}

.topbar {
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  padding: 14px 28px;
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 10;
}
.topbar-title { font-size: 1rem; font-weight: 600; }
.topbar-actions { display: flex; gap: 10px; align-items: center; }

.page-body { padding: 28px; flex: 1; }

/* ── Cards ──────────────────────────────── */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}
.card-title { font-size: .95rem; font-weight: 600; }
.card-body  { }

/* ── Stats row ──────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px,1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
}
.stat-label { font-size: .75rem; color: var(--text2); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 8px; }
.stat-value { font-size: 1.8rem; font-weight: 700; }
.stat-meta  { font-size: .75rem; color: var(--muted); margin-top: 4px; }

/* ── Buttons ────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 18px;
  border-radius: var(--radius-sm);
  font-size: .85rem;
  font-weight: 500;
  border: none;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
  white-space: nowrap;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary  { background: var(--accent); color: #fff; }
.btn-primary:hover  { background: var(--accent-h); color: #fff; }
.btn-secondary { background: var(--card2); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); }
.btn-success  { background: var(--success); color: #fff; }
.btn-success:hover  { background: #16a34a; color: #fff; }
.btn-danger   { background: var(--danger); color: #fff; }
.btn-danger:hover   { background: #dc2626; color: #fff; }
.btn-warning  { background: var(--warning); color: #000; }
.btn-warning:hover  { background: #d97706; }
.btn-ghost    { background: transparent; color: var(--text2); border: 1px solid var(--border); }
.btn-ghost:hover    { background: var(--card2); color: var(--text); }
.btn-sm { padding: 5px 12px; font-size: .78rem; }
.btn-lg { padding: 11px 26px; font-size: .95rem; }
.btn-icon { padding: 7px; }

/* ── Forms ──────────────────────────────── */
.form-group { margin-bottom: 18px; }
.form-label { display: block; font-size: .82rem; font-weight: 500; color: var(--text2); margin-bottom: 7px; }
.form-control {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 9px 13px;
  font-size: .88rem;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}
.form-control:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.form-control::placeholder { color: var(--muted); }
textarea.form-control { resize: vertical; min-height: 120px; font-family: inherit; }
select.form-control { cursor: pointer; }

.form-text { font-size: .75rem; color: var(--muted); margin-top: 5px; }
.form-error { font-size: .78rem; color: var(--danger); margin-top: 5px; }
.input-group { display: flex; gap: 0; }
.input-group .form-control { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.input-group .btn { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }

/* ── Checkbox list ──────────────────────── */
.checkbox-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 8px; }
.checkbox-item {
  display: flex; align-items: center; gap: 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
  user-select: none;
}
.checkbox-item:hover { border-color: var(--accent); background: var(--card2); }
.checkbox-item input[type="checkbox"] { accent-color: var(--accent); width: 16px; height: 16px; cursor: pointer; }
.checkbox-item.checked { border-color: var(--accent); background: rgba(124,111,247,.1); }
.checkbox-icon { font-size: 1.1rem; }
.checkbox-name { font-size: .84rem; font-weight: 500; }
.checkbox-desc { font-size: .73rem; color: var(--muted); }

/* ── Tables ─────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .84rem; }
thead th {
  text-align: left; padding: 10px 14px;
  border-bottom: 2px solid var(--border);
  color: var(--text2); font-size: .75rem; text-transform: uppercase; letter-spacing: .06em;
}
tbody tr { border-bottom: 1px solid var(--border); transition: background var(--transition); }
tbody tr:hover { background: var(--card2); }
tbody td { padding: 11px 14px; vertical-align: middle; }
tbody tr:last-child { border-bottom: none; }

/* ── Badges ─────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 9px; border-radius: 20px;
  font-size: .72rem; font-weight: 600;
}
.badge-success  { background: rgba(34,197,94,.15);  color: var(--success); }
.badge-danger   { background: rgba(239,68,68,.15);   color: var(--danger); }
.badge-warning  { background: rgba(245,158,11,.15);  color: var(--warning); }
.badge-info     { background: rgba(56,189,248,.15);  color: var(--info); }
.badge-neutral  { background: var(--card2); color: var(--text2); }
.badge-primary  { background: var(--accent-glow); color: var(--accent); }

/* ── Alert / notice ─────────────────────── */
.alert {
  border-radius: var(--radius-sm);
  padding: 13px 16px;
  font-size: .85rem;
  margin-bottom: 18px;
  display: flex; align-items: flex-start; gap: 10px;
}
.alert-error   { background: rgba(239,68,68,.12);   border: 1px solid rgba(239,68,68,.3); color: #fca5a5; }
.alert-success { background: rgba(34,197,94,.12);   border: 1px solid rgba(34,197,94,.3);  color: #86efac; }
.alert-info    { background: rgba(56,189,248,.1);   border: 1px solid rgba(56,189,248,.3); color: #7dd3fc; }
.alert-warning { background: rgba(245,158,11,.12);  border: 1px solid rgba(245,158,11,.3); color: #fde68a; }

/* ── Progress bar ───────────────────────── */
.progress { height: 6px; background: var(--card2); border-radius: 3px; overflow: hidden; }
.progress-bar { height: 100%; background: var(--accent); border-radius: 3px; transition: width .4s ease; }

/* ── Simulation progress ────────────────── */
.agent-progress-list { display: flex; flex-direction: column; gap: 10px; }
.agent-progress-item {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 13px 16px;
  display: flex; align-items: center; gap: 14px;
}
.agent-progress-icon { font-size: 1.3rem; }
.agent-progress-info { flex: 1; }
.agent-progress-name { font-size: .85rem; font-weight: 600; }
.agent-progress-status { font-size: .75rem; color: var(--text2); }
.agent-progress-state { width: 28px; text-align: center; font-size: 1rem; }
.agent-status-pending  { color: var(--muted); }
.agent-status-running  { color: var(--warning); }
.agent-status-done     { color: var(--success); }
.agent-status-error    { color: var(--danger); }

/* ── Sentiment ──────────────────────────── */
.sentiment-bar { display: flex; align-items: center; gap: 8px; }
.sentiment-dot { width: 10px; height: 10px; border-radius: 50%; }
.sentiment-positive { background: var(--success); }
.sentiment-neutral  { background: var(--warning); }
.sentiment-negative { background: var(--danger); }
.sentiment-score { font-size: .78rem; color: var(--text2); }

/* ── Agent result card ──────────────────── */
.agent-result-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 16px;
  overflow: hidden;
}
.agent-result-header {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 18px;
  background: var(--card2);
  cursor: pointer;
  user-select: none;
}
.agent-result-icon  { font-size: 1.3rem; }
.agent-result-name  { font-size: .92rem; font-weight: 600; flex: 1; }
.agent-result-body  { padding: 18px; border-top: 1px solid var(--border); }
.agent-result-body.collapsed { display: none; }
.agent-reaction { font-size: .86rem; line-height: 1.7; color: var(--text); margin-bottom: 14px; }
.agent-actions-list { list-style: none; }
.agent-actions-list li { padding: 5px 0; font-size: .84rem; color: var(--text2); }
.agent-actions-list li::before { content: '→ '; color: var(--accent); }
.agent-quotes { margin-top: 14px; }
.quote-item {
  background: var(--card2);
  border-left: 3px solid var(--accent);
  padding: 10px 14px;
  margin: 8px 0;
  font-style: italic;
  font-size: .83rem;
  color: var(--text2);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

/* ── Chat interface ─────────────────────── */
.chat-layout { display: flex; height: calc(100vh - 160px); min-height: 500px; gap: 0; }
.chat-agents {
  width: 240px; min-width: 240px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius) 0 0 var(--radius);
  overflow-y: auto;
  display: flex; flex-direction: column;
}
.chat-agents-header { padding: 14px 16px; border-bottom: 1px solid var(--border); font-weight: 600; font-size: .85rem; }
.chat-agent-item {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
  font-size: .83rem;
}
.chat-agent-item:hover { background: var(--card); }
.chat-agent-item.active { background: var(--accent-glow); border-left: 3px solid var(--accent); }
.chat-agent-icon { font-size: 1.2rem; }
.chat-agent-name { flex: 1; font-weight: 500; }

.chat-main {
  flex: 1;
  background: var(--card);
  border: 1px solid var(--border);
  border-left: none;
  border-radius: 0 var(--radius) var(--radius) 0;
  display: flex; flex-direction: column;
}
.chat-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px;
  background: var(--card2);
}
.chat-header-info h3 { font-size: .9rem; font-weight: 600; }
.chat-header-info p  { font-size: .75rem; color: var(--text2); }

.chat-messages {
  flex: 1; overflow-y: auto;
  padding: 20px;
  display: flex; flex-direction: column; gap: 14px;
}
.message { display: flex; gap: 10px; max-width: 80%; }
.message.user    { align-self: flex-end; flex-direction: row-reverse; }
.message.agent   { align-self: flex-start; }
.message-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: .9rem; flex-shrink: 0;
}
.message.user .message-avatar { background: var(--accent); }
.message.agent .message-avatar { background: var(--card2); }
.message-bubble {
  padding: 10px 14px;
  border-radius: 12px;
  font-size: .86rem;
  line-height: 1.6;
}
.message.user .message-bubble { background: var(--accent); color: #fff; border-radius: 12px 3px 12px 12px; }
.message.agent .message-bubble { background: var(--card2); color: var(--text); border-radius: 3px 12px 12px 12px; }
.message-time { font-size: .68rem; color: var(--muted); margin-top: 4px; text-align: right; }
.message.agent .message-time  { text-align: left; }

.chat-empty {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  color: var(--muted); text-align: center; gap: 10px;
}
.chat-empty-icon { font-size: 3rem; }

.chat-input-area {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  display: flex; gap: 10px; align-items: flex-end;
}
.chat-input-area textarea {
  flex: 1; resize: none; max-height: 120px; min-height: 42px;
}
.typing-indicator { padding: 4px 0; font-size: .78rem; color: var(--muted); height: 20px; }

/* ── Login page ─────────────────────────── */
.login-page {
  min-height: 100vh; display: flex;
  align-items: center; justify-content: center;
  background: var(--bg);
  padding: 24px;
}
.login-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 40px 44px;
  width: 100%; max-width: 420px;
  box-shadow: var(--shadow);
}
.login-logo { text-align: center; margin-bottom: 28px; }
.login-logo .logo-big { font-size: 2rem; margin-bottom: 4px; }
.login-logo h1 { font-size: 1.5rem; font-weight: 700; }
.login-logo p  { color: var(--text2); font-size: .85rem; }
.login-footer  { text-align: center; margin-top: 20px; font-size: .78rem; color: var(--muted); }

/* ── Upload area ────────────────────────── */
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 30px;
  text-align: center;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
}
.upload-zone:hover, .upload-zone.dragover {
  border-color: var(--accent);
  background: var(--accent-glow);
}
.upload-zone-icon { font-size: 2rem; margin-bottom: 8px; color: var(--muted); }
.upload-zone-text { font-size: .85rem; color: var(--text2); }
.upload-zone-sub  { font-size: .75rem; color: var(--muted); margin-top: 4px; }

/* ── Reports ────────────────────────────── */
.report-types { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px,1fr)); gap: 14px; }
.report-type-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  text-align: center;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
}
.report-type-card:hover { border-color: var(--accent); background: var(--card2); }
.report-type-icon { font-size: 2rem; margin-bottom: 10px; }
.report-type-name { font-size: .88rem; font-weight: 600; }
.report-type-desc { font-size: .75rem; color: var(--muted); margin-top: 4px; }
.report-actions   { display: flex; gap: 8px; justify-content: center; margin-top: 12px; }

/* ── Tabs ───────────────────────────────── */
.tabs { display: flex; border-bottom: 1px solid var(--border); margin-bottom: 22px; }
.tab {
  padding: 9px 18px;
  font-size: .85rem; font-weight: 500;
  cursor: pointer; color: var(--text2);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: all var(--transition);
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ── Modals ─────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(0,0,0,.7);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  opacity: 0; pointer-events: none;
  transition: opacity var(--transition);
}
.modal-overlay.active { opacity: 1; pointer-events: all; }
.modal {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 28px;
  width: 100%; max-width: 520px;
  max-height: 90vh; overflow-y: auto;
  transform: translateY(16px);
  transition: transform var(--transition);
  box-shadow: var(--shadow);
}
.modal-overlay.active .modal { transform: translateY(0); }
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.modal-title  { font-size: 1rem; font-weight: 700; }
.modal-close  { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 1.2rem; padding: 4px; }
.modal-close:hover { color: var(--text); }
.modal-footer { margin-top: 22px; display: flex; justify-content: flex-end; gap: 10px; }

/* ── Spinner ────────────────────────────── */
.spinner {
  width: 20px; height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Utility ────────────────────────────── */
.flex { display: flex; }
.flex-center { display: flex; align-items: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 14px; }
.mt-4 { margin-top: 22px; }
.mb-3 { margin-bottom: 14px; }
.mb-4 { margin-bottom: 22px; }
.text-sm { font-size: .8rem; }
.text-muted { color: var(--muted); }
.text-2   { color: var(--text2); }
.text-success { color: var(--success); }
.text-danger  { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-accent  { color: var(--accent); }
.font-bold { font-weight: 700; }
.truncate  { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hidden    { display: none !important; }
.w-full    { width: 100%; }
.grid-2    { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3    { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }

/* ── Scrollbar ──────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }

/* ── Mobile ─────────────────────────────── */
@media (max-width: 900px) {
  .sidebar { display: none; }
  .page-body { padding: 16px; }
  .chat-agents { display: none; }
  .chat-main { border-radius: var(--radius); border-left: 1px solid var(--border); }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}

/* ── Spinner animation ──────────────────── */
.pulse { animation: pulse 1.5s ease-in-out infinite; }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.4} }
