/* === VARIABLES === */
:root {
  --purple: #5B2D8E;
  --purple-mid: #7B3FB5;
  --cyan: #2BBFBF;
  --bg: #0D0D0D;
  --bg-card: #1A1A2E;
  --bg-card-hover: #222240;
  --bg-input: #13132A;
  --text: #FFFFFF;
  --text-secondary: #A0A0B0;
  --text-muted: #6B6B80;
  --success: #22C55E;
  --error: #EF4444;
  --warning: #F59E0B;
  --border: #2A2A45;
  --gradient: linear-gradient(135deg, #5B2D8E, #7B3FB5, #2BBFBF);
  --radius: 12px;
  --radius-sm: 8px;
}

/* === RESET === */
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* === SCROLLBAR === */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--purple-mid); border-radius: 3px; }

/* === HEADER === */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 32px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}
.header-left { display: flex; align-items: center; gap: 12px; }
.logo { display: flex; align-items: center; gap: 12px; }
.logo-icon {
  width: 40px; height: 40px;
  background: var(--gradient);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-family: 'Montserrat', sans-serif;
  font-weight: 800; font-size: 20px;
}
.header h1 {
  font-family: 'Montserrat', sans-serif;
  font-size: 18px; font-weight: 800;
}
.header-subtitle { font-size: 12px; color: var(--text-secondary); }
.header-right { display: flex; align-items: center; gap: 16px; }

.server-status {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; color: var(--text-secondary);
  padding: 6px 14px;
  background: var(--bg); border-radius: 20px;
}
.status-dot {
  width: 8px; height: 8px; border-radius: 50%;
}
.status-dot.online { background: var(--success); box-shadow: 0 0 8px var(--success); }
.status-dot.offline { background: var(--error); }

/* === BUTTONS === */
.btn {
  padding: 8px 20px; border: none; border-radius: var(--radius-sm);
  font-family: 'Inter', sans-serif; font-weight: 600; font-size: 13px;
  cursor: pointer; transition: all 0.2s;
}
.btn-primary {
  background: var(--gradient); color: white;
}
.btn-primary:hover { opacity: 0.9; transform: translateY(-1px); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn-secondary {
  background: var(--bg-card); color: var(--text); border: 1px solid var(--border);
}
.btn-secondary:hover { border-color: var(--purple-mid); }
.btn-full { width: 100%; padding: 12px; font-size: 14px; }
.result-actions {
  display: flex; gap: 10px; margin-top: 16px;
}
.result-actions .btn { flex: 1; text-align: center; text-decoration: none; }
.result-actions .btn-primary { }
.result-actions .btn-secondary { background: var(--bg-card); border: 1px solid var(--border); }
.btn-sm { padding: 5px 12px; font-size: 12px; }

/* === NAV TABS === */
.nav-tabs {
  display: flex; gap: 0;
  padding: 0 32px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
}
.tab {
  padding: 14px 24px;
  background: none; border: none; border-bottom: 2px solid transparent;
  color: var(--text-secondary); font-family: 'Inter', sans-serif;
  font-weight: 500; font-size: 14px; cursor: pointer;
  transition: all 0.2s;
}
.tab:hover { color: var(--text); }
.tab.active {
  color: var(--cyan);
  border-bottom-color: var(--cyan);
}

/* === CONTENT === */
.content { padding: 24px 32px; max-width: 1400px; margin: 0 auto; }
.content.hidden { display: none; }
.section { margin-bottom: 32px; }
.section-title {
  font-family: 'Montserrat', sans-serif;
  font-size: 18px; font-weight: 700;
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

/* === STATS GRID === */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px; margin-bottom: 32px;
}
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px; display: flex; flex-direction: column; gap: 4px;
  transition: border-color 0.2s;
}
.stat-card:hover { border-color: var(--purple-mid); }
.stat-card.accent { border-left: 3px solid var(--cyan); }
.stat-label { font-size: 12px; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.5px; }
.stat-value { font-family: 'Montserrat', sans-serif; font-size: 28px; font-weight: 800; }
.stat-detail { font-size: 12px; color: var(--text-muted); }

/* === AGENTS GRID === */
.agents-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }
.agent-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px; display: flex; align-items: center; gap: 16px;
  transition: all 0.2s;
}
.agent-card:hover { border-color: var(--cyan); transform: translateY(-2px); }
.agent-emoji { font-size: 32px; }
.agent-info h3 { font-size: 15px; font-weight: 600; }
.agent-info p { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }

/* === RUNS LIST === */
.runs-list { display: flex; flex-direction: column; gap: 8px; }
.run-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px 20px;
  display: grid;
  grid-template-columns: auto 1fr auto auto auto auto;
  align-items: center; gap: 16px;
  cursor: pointer; transition: all 0.2s;
}
.run-item:hover { border-color: var(--purple-mid); background: var(--bg-card-hover); }
.run-status {
  width: 10px; height: 10px; border-radius: 50%;
}
.run-status.completed { background: var(--success); }
.run-status.failed { background: var(--error); }
.run-status.running { background: var(--warning); animation: pulse 1.5s infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }
.run-agent { font-weight: 600; font-size: 14px; }
.run-trigger {
  font-size: 11px; padding: 3px 10px;
  background: var(--bg); border-radius: 12px;
  color: var(--text-secondary);
}
.run-tokens { font-size: 12px; color: var(--text-secondary); }
.run-time { font-size: 12px; color: var(--text-muted); white-space: nowrap; }
.run-empty {
  text-align: center; padding: 40px;
  color: var(--text-muted); font-size: 14px;
}

/* === FILTER BAR === */
.filter-bar {
  display: flex; gap: 12px; margin-bottom: 20px; align-items: center;
}
.filter-bar select {
  padding: 8px 16px; background: var(--bg-card); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-family: 'Inter', sans-serif; font-size: 13px;
}

/* === EXECUTE SECTION === */
.execute-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
  gap: 24px;
}
.execute-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}
.execute-header { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.execute-header h3 { font-size: 16px; font-weight: 700; }
.execute-desc { font-size: 13px; color: var(--text-secondary); margin-bottom: 20px; }

/* === FORMS === */
.form-group { margin-bottom: 14px; }
.form-group label {
  display: block; font-size: 12px; font-weight: 600;
  color: var(--text-secondary); margin-bottom: 6px;
  text-transform: uppercase; letter-spacing: 0.3px;
}
.form-group input,
.form-group textarea,
.form-group select {
  width: 100%; padding: 10px 14px;
  background: var(--bg-input); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-family: 'Inter', sans-serif; font-size: 13px;
  transition: border-color 0.2s;
}
.form-group input:focus,
.form-group textarea:focus {
  outline: none; border-color: var(--cyan);
}
.form-group textarea { resize: vertical; }

/* === RESULT BOX === */
.result-box {
  margin-top: 16px; padding: 16px;
  background: var(--bg); border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  font-size: 13px; line-height: 1.6;
  max-height: 400px; overflow-y: auto;
  white-space: pre-wrap; word-break: break-word;
}
.result-box.hidden { display: none; }
.result-box.success { border-left: 3px solid var(--success); }
.result-box.error { border-left: 3px solid var(--error); }
.result-box .result-meta {
  display: flex; gap: 16px; margin-bottom: 12px;
  padding-bottom: 8px; border-bottom: 1px solid var(--border);
  font-size: 11px; color: var(--text-muted);
}

/* === COST TABLE === */
.cost-table-wrapper { overflow-x: auto; }
.cost-table {
  width: 100%; border-collapse: collapse;
  background: var(--bg-card); border-radius: var(--radius);
  overflow: hidden;
}
.cost-table th {
  text-align: left; padding: 12px 16px;
  font-size: 11px; text-transform: uppercase;
  color: var(--text-secondary); letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-input);
}
.cost-table td {
  padding: 12px 16px; font-size: 13px;
  border-bottom: 1px solid var(--border);
}
.cost-table tr:last-child td { border-bottom: none; }
.cost-table tr:hover td { background: var(--bg-card-hover); }

/* === MODAL === */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
}
.modal-overlay.hidden { display: none; }
.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 90%; max-width: 700px; max-height: 80vh;
  display: flex; flex-direction: column;
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 16px; font-weight: 700; }
.modal-close {
  background: none; border: none; color: var(--text-secondary);
  font-size: 24px; cursor: pointer;
}
.modal-close:hover { color: var(--text); }
.modal-body {
  padding: 24px; overflow-y: auto;
  font-size: 13px; line-height: 1.7;
  white-space: pre-wrap; word-break: break-word;
}
.modal-meta {
  display: flex; flex-wrap: wrap; gap: 16px;
  margin-bottom: 16px; padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.modal-meta-item {
  display: flex; flex-direction: column; gap: 2px;
}
.modal-meta-label { font-size: 10px; color: var(--text-muted); text-transform: uppercase; }
.modal-meta-value { font-size: 13px; font-weight: 600; }

/* === STATUS BANNER === */
.status-banner {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 20px; border-radius: var(--radius);
  margin-bottom: 24px; border: 1px solid var(--border);
  background: var(--bg-card);
}
.status-banner.online { border-left: 3px solid var(--success); }
.status-banner.offline { border-left: 3px solid var(--error); }
.status-banner-icon { font-size: 20px; }
.status-banner-text { display: flex; flex-direction: column; gap: 2px; }
.status-banner-text strong { font-size: 14px; }
.status-banner-text span { font-size: 12px; color: var(--text-secondary); }

/* === LOGO === */
.logo-img { height: 36px; width: auto; border-radius: 8px; }

/* === AGENT DETAIL CARDS === */
.agents-detail-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px;
}
.agent-detail-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px;
  transition: border-color 0.2s;
}
.agent-detail-card:hover { border-color: var(--purple-mid); }
.adc-header {
  display: flex; align-items: center; gap: 12px;
  padding-bottom: 12px; margin-bottom: 12px;
  border-bottom: 2px solid var(--border);
}
.adc-title { flex: 1; }
.adc-title h3 { font-size: 15px; font-weight: 700; }
.adc-category {
  font-size: 10px; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.5px;
}
.adc-status-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.adc-status-dot.success { background: var(--success); box-shadow: 0 0 6px var(--success); }
.adc-status-dot.error { background: var(--error); }
.adc-status-dot.idle { background: var(--text-muted); }
.adc-desc { font-size: 12px; color: var(--text-secondary); margin-bottom: 14px; }
.adc-stats {
  display: flex; gap: 0; margin-bottom: 14px;
  background: var(--bg); border-radius: var(--radius-sm); overflow: hidden;
}
.adc-stat {
  flex: 1; padding: 10px; text-align: center;
  border-right: 1px solid var(--border);
}
.adc-stat:last-child { border-right: none; }
.adc-stat-value { display: block; font-size: 16px; font-weight: 700; font-family: 'Montserrat', sans-serif; }
.adc-stat-label { display: block; font-size: 9px; color: var(--text-muted); text-transform: uppercase; margin-top: 2px; }
.adc-footer {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 11px; color: var(--text-muted);
}
.adc-mode {
  padding: 3px 10px; background: var(--bg);
  border-radius: 10px; font-size: 10px;
}

/* === CRON BADGE === */
.cron-badge {
  display: inline-block; padding: 4px 12px; margin-bottom: 12px;
  background: rgba(43,191,191,0.1); color: var(--cyan);
  border: 1px solid rgba(43,191,191,0.3); border-radius: 12px;
  font-size: 11px; font-weight: 600;
}

/* === RUN ITEM ENHANCED === */
.run-cost { font-size: 12px; color: var(--cyan); font-weight: 600; }

/* === STRUCTURED OUTPUT === */
.structured-output { white-space: normal; }
.so-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px; padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.so-header h4 { font-size: 16px; font-weight: 700; }
.so-tag {
  font-size: 11px; padding: 4px 10px;
  background: var(--bg-card); border-radius: 12px;
  color: var(--text-secondary);
}
.so-field { margin-bottom: 12px; font-size: 13px; line-height: 1.5; }
.so-section { margin-bottom: 16px; }
.so-section strong { display: block; margin-bottom: 8px; font-size: 13px; }
.so-step {
  padding: 10px 14px; margin-bottom: 6px;
  background: var(--bg-card); border-radius: var(--radius-sm);
  border-left: 2px solid var(--purple-mid);
  font-size: 13px; line-height: 1.5;
}
.so-step-label {
  display: inline-block; font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.5px;
  color: var(--cyan); margin-bottom: 4px;
}
.so-section ol { padding-left: 20px; }
.so-section li { margin-bottom: 6px; font-size: 13px; }

/* === OUTPUT SECTIONS (modal) === */
.output-section { margin-bottom: 16px; }
.output-label {
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  color: var(--text-muted); margin-bottom: 8px;
}
.output-content {
  background: var(--bg); padding: 12px; border-radius: 8px;
  font-size: 12px; line-height: 1.6; white-space: pre-wrap;
  max-height: 300px; overflow-y: auto;
}
.output-content.input { color: var(--text-secondary); }
.output-content pre { margin: 0; white-space: pre-wrap; }

/* === LOADING SPINNER === */
.spinner {
  display: inline-block; width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  margin-right: 8px; vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* === RESPONSIVE === */
@media (max-width: 768px) {
  .header { padding: 12px 16px; }
  .nav-tabs { padding: 0 16px; overflow-x: auto; }
  .content { padding: 16px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .execute-grid { grid-template-columns: 1fr; }
  .run-item { grid-template-columns: auto 1fr auto; }
  .run-trigger, .run-tokens { display: none; }
}
