/* ================================================================
   SIMULATION ENGINE — Dark theme styles
   ================================================================ */

.sim-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 16px 40px;
}

/* Header */
.sim-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 12px;
}

.sim-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  margin: 0;
}

.sim-subtitle {
  font-size: 13px;
  color: var(--text-dim);
  margin: 4px 0 0;
}

/* Buttons */
.sim-btn {
  padding: 8px 18px;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}

.sim-btn-primary {
  background: var(--primary);
  color: #fff;
}

.sim-btn-primary:hover {
  background: var(--primary-hover, #00b8d9);
  transform: translateY(-1px);
}

.sim-btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.sim-btn-secondary {
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
}

.sim-btn-secondary:hover {
  background: var(--surface3, var(--surface2));
  border-color: var(--text-dim);
}

.sim-btn-ghost {
  background: transparent;
  color: var(--text-dim);
  padding: 6px 12px;
}

.sim-btn-ghost:hover {
  color: var(--text);
  background: var(--surface2);
}

.sim-btn-small {
  padding: 4px 10px;
  font-size: 11px;
  background: var(--surface2);
  color: var(--primary);
  border: 1px solid var(--border);
  border-radius: 6px;
}

.sim-btn-small:hover {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

/* Form Card */
.sim-form-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-bottom: 20px;
  overflow: hidden;
  animation: simSlideDown 0.3s ease;
}

@keyframes simSlideDown {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

.sim-form-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}

.sim-form-header h3 {
  margin: 0;
  font-size: 15px;
  color: var(--text);
}

.sim-form-close {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 16px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
}

.sim-form-close:hover {
  background: var(--surface2);
  color: var(--text);
}

.sim-form-body {
  padding: 18px;
}

.sim-form-group {
  margin-bottom: 16px;
}

.sim-form-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dim);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.sim-input {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 14px;
  padding: 10px 14px;
  font-family: inherit;
  box-sizing: border-box;
  transition: border-color 0.2s;
  outline: none;
}

.sim-input:focus {
  border-color: var(--primary);
}

.sim-textarea {
  resize: vertical;
  min-height: 80px;
  line-height: 1.5;
}

/* Domain selector grid */
.sim-domain-grid {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.sim-domain-btn {
  padding: 8px 16px;
  background: var(--surface2);
  border: 2px solid var(--border);
  border-radius: 8px;
  color: var(--text-dim);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}

.sim-domain-btn:hover {
  border-color: var(--text-dim);
  color: var(--text);
}

.sim-domain-btn.active {
  border-color: var(--primary);
  color: var(--primary);
  background: rgba(0, 212, 255, 0.08);
}

.sim-form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 8px;
}

/* Progress Card */
.sim-progress-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 20px;
  animation: simSlideDown 0.3s ease;
}

.sim-progress-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.sim-progress-spinner {
  width: 20px;
  height: 20px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: simSpin 0.8s linear infinite;
}

@keyframes simSpin {
  to { transform: rotate(360deg); }
}

#sim-progress-text {
  font-size: 14px;
  color: var(--text);
  font-weight: 500;
}

.sim-progress-bar-wrap {
  height: 6px;
  background: var(--surface2);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 12px;
}

.sim-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), #a855f7);
  border-radius: 3px;
  transition: width 0.5s ease;
}

.sim-progress-agents {
  font-size: 12px;
  color: var(--text-dim);
}

.sim-progress-agent-label {
  padding: 4px 0;
}

/* Results View */
.sim-results-header {
  margin-bottom: 20px;
}

.sim-results-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  margin: 12px 0 8px;
}

.sim-results-info {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.sim-results-date {
  font-size: 12px;
  color: var(--text-dim);
}

.sim-results-desc {
  font-size: 13px;
  color: var(--text-muted, var(--text-dim));
  line-height: 1.5;
  padding: 10px 14px;
  background: var(--surface2);
  border-radius: 8px;
  border-left: 3px solid var(--primary);
}

/* Confidence Ring */
.sim-confidence-card {
  display: flex;
  justify-content: center;
  padding: 20px;
  margin-bottom: 20px;
}

.sim-conf-ring {
  position: relative;
  width: 120px;
  height: 120px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.sim-conf-svg {
  position: absolute;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
}

.sim-conf-value {
  font-size: 28px;
  font-weight: 800;
  color: var(--text);
  z-index: 1;
}

.sim-conf-label {
  font-size: 11px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 1px;
  z-index: 1;
}

/* Report Card */
.sim-report-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-bottom: 24px;
  overflow: hidden;
}

.sim-report-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}

.sim-report-header h3 {
  margin: 0;
  font-size: 15px;
  color: var(--text);
}

.sim-report-body {
  padding: 18px;
  font-size: 14px;
  line-height: 1.7;
  color: var(--text);
}

.sim-report-body h4 {
  font-size: 15px;
  font-weight: 700;
  color: var(--primary);
  margin: 18px 0 8px;
}

.sim-report-body h4:first-child {
  margin-top: 0;
}

.sim-report-body ul {
  padding-left: 20px;
  margin: 8px 0;
}

.sim-report-body li {
  margin-bottom: 4px;
  color: var(--text);
}

.sim-report-body strong {
  color: var(--text);
}

.sim-report-body p {
  margin: 0 0 10px;
}

/* Section Title */
.sim-section-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  margin: 24px 0 12px;
}

/* Agent Cards Grid */
.sim-agents-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.sim-agent-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  transition: border-color 0.2s;
}

.sim-agent-card:hover {
  border-color: var(--text-dim);
}

.sim-agent-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface2);
}

.sim-agent-icon {
  font-size: 22px;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 212, 255, 0.1);
  border-radius: 8px;
}

.sim-agent-role {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.sim-agent-sentiment {
  font-size: 11px;
  color: var(--text-dim);
}

.sim-agent-response {
  padding: 14px 16px;
  font-size: 13px;
  line-height: 1.6;
  color: var(--text);
  max-height: 300px;
  overflow-y: auto;
}

.sim-agent-response h4 {
  font-size: 13px;
  font-weight: 700;
  color: var(--primary);
  margin: 12px 0 4px;
}

.sim-agent-response h4:first-child {
  margin-top: 0;
}

.sim-agent-response ul {
  padding-left: 16px;
  margin: 4px 0;
}

.sim-agent-response li {
  margin-bottom: 2px;
}

.sim-agent-insights {
  padding: 10px 16px 14px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-dim);
}

.sim-agent-insights strong {
  color: var(--text);
  display: block;
  margin-bottom: 4px;
}

.sim-agent-insights ul {
  padding-left: 16px;
  margin: 0;
}

.sim-agent-insights li {
  margin-bottom: 2px;
}

/* History Table */
.sim-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.sim-table th {
  text-align: left;
  padding: 10px 12px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border);
}

.sim-table-row {
  cursor: pointer;
  transition: background 0.15s;
}

.sim-table-row:hover {
  background: var(--surface2);
}

.sim-table td {
  padding: 10px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  color: var(--text);
}

.sim-table-title {
  font-weight: 500;
  max-width: 300px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sim-table-conf {
  font-weight: 600;
  color: var(--primary);
}

/* Domain Badge */
.sim-domain-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
}

/* Status */
.sim-status {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
}

.sim-status-done {
  background: rgba(76, 175, 80, 0.15);
  color: #4caf50;
}

.sim-status-running {
  background: rgba(0, 212, 255, 0.15);
  color: #00d4ff;
  animation: simPulse 1.5s ease infinite;
}

@keyframes simPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.sim-status-failed {
  background: rgba(244, 67, 54, 0.15);
  color: #f44336;
}

.sim-status-pending {
  background: rgba(158, 158, 158, 0.15);
  color: #9e9e9e;
}

/* Templates Grid */
.sim-templates-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}

.sim-template-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  transition: border-color 0.2s;
}

.sim-template-card:hover {
  border-color: var(--text-dim);
}

.sim-template-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
}

.sim-template-icon {
  font-size: 24px;
}

.sim-template-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.sim-template-domain {
  font-size: 11px;
  color: var(--text-dim);
}

.sim-template-roles {
  padding: 8px 14px 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.sim-role-chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 3px 8px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 11px;
  color: var(--text-dim);
}

/* Empty state */
.sim-empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-dim);
  font-size: 14px;
}

/* Error */
.sim-error {
  padding: 10px 14px;
  background: rgba(244, 67, 54, 0.1);
  border: 1px solid rgba(244, 67, 54, 0.3);
  border-radius: 8px;
  color: #f44336;
  font-size: 13px;
}

/* Scrollbar for agent responses */
.sim-agent-response::-webkit-scrollbar {
  width: 4px;
}

.sim-agent-response::-webkit-scrollbar-track {
  background: transparent;
}

.sim-agent-response::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 2px;
}

/* Mobile responsive */
@media (max-width: 768px) {
  .sim-agents-grid {
    grid-template-columns: 1fr;
  }

  .sim-templates-grid {
    grid-template-columns: 1fr;
  }

  .sim-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .sim-table {
    font-size: 12px;
  }

  .sim-table th:nth-child(5),
  .sim-table td:nth-child(5) {
    display: none;
  }
}
