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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100vh;
  padding: 20px;
  color: #333;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
}

header {
  text-align: center;
  color: white;
  margin-bottom: 40px;
  padding: 20px;
}

header h1 {
  font-size: 2.5em;
  margin-bottom: 10px;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
}

.subtitle {
  font-size: 1.2em;
  opacity: 0.95;
}

.status-card,
.webhooks-card,
.actions-card,
.events-card {
  background: white;
  border-radius: 12px;
  padding: 25px;
  margin-bottom: 20px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
  transition: transform 0.3s ease;
}

.status-card:hover,
.webhooks-card:hover,
.actions-card:hover,
.events-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 15px 40px rgba(0, 0, 0, 0.15);
}

h2 {
  color: #4a5568;
  margin-bottom: 20px;
  font-size: 1.5em;
  display: flex;
  align-items: center;
}

.loading {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #718096;
}

.spinner {
  width: 20px;
  height: 20px;
  border: 3px solid #e2e8f0;
  border-top-color: #667eea;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.button-group {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 15px;
}

/* Two-column layout for webhooks and actions */
.webhooks-actions-container {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 20px;
  margin-bottom: 20px;
}

.webhooks-actions-container .webhooks-card {
  margin-bottom: 0;
}

.webhooks-actions-container .actions-card {
  margin-bottom: 0;
  max-width: 250px;
}

.button-group-vertical {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.button-group-vertical .btn {
  width: 100%;
}

/* Responsive layout for smaller screens */
@media (max-width: 768px) {
  .webhooks-actions-container {
    grid-template-columns: 1fr;
  }

  .webhooks-actions-container .actions-card {
    max-width: none;
  }
}

.btn {
  padding: 12px 24px;
  border: none;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.btn-primary {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
}

.btn-danger {
  background: linear-gradient(135deg, #f56565 0%, #c53030 100%);
  color: white;
}

.btn-secondary {
  background: linear-gradient(135deg, #48bb78 0%, #2f855a 100%);
  color: white;
}

.btn-info {
  background: linear-gradient(135deg, #4299e1 0%, #2b6cb0 100%);
  color: white;
}

.icon {
  font-size: 1.2em;
}

.status-item {
  display: flex;
  justify-content: space-between;
  padding: 10px;
  background: #f7fafc;
  border-radius: 6px;
  margin-bottom: 10px;
}

.status-label {
  font-weight: 600;
  color: #4a5568;
}

.status-value {
  color: #2d3748;
}

.status-value.success {
  color: #48bb78;
  font-weight: 600;
}

.status-value.error {
  color: #f56565;
  font-weight: 600;
}

.webhook-item {
  background: #f7fafc;
  padding: 15px;
  border-radius: 8px;
  margin-bottom: 10px;
  border-left: 4px solid #667eea;
}

.webhook-gid {
  font-family: "Courier New", monospace;
  color: #2d3748;
  font-size: 0.9em;
}

.webhook-target {
  color: #718096;
  font-size: 0.85em;
  margin-top: 5px;
  word-break: break-all;
}

.webhook-status {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 0.8em;
  font-weight: 600;
  margin-top: 8px;
}

.webhook-status.active {
  background: #c6f6d5;
  color: #22543d;
}

.webhook-status.inactive {
  background: #fed7d7;
  color: #742a2a;
}

footer {
  text-align: center;
  color: white;
  margin-top: 40px;
  padding: 20px;
  opacity: 0.9;
}

footer a {
  color: white;
  text-decoration: underline;
}

footer a:hover {
  color: #cbd5e0;
}

/* Replay button */
.replay-button {
  padding: 4px 10px;
  font-size: 0.85em;
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: white;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  transition: all 0.3s ease;
  margin-left: 10px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.replay-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
  background: linear-gradient(135deg, #764ba2, #667eea);
}

.replay-button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.replay-button .spinner-small {
  width: 12px;
  height: 12px;
  border: 2px solid #ffffff;
  border-top: 2px solid transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  padding: 15px 20px;
  background: #2d3748;
  color: white;
  border-radius: 8px;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
  transform: translateY(100px);
  opacity: 0;
  transition: all 0.3s ease;
  z-index: 1000;
  max-width: 400px;
  word-wrap: break-word;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

.toast.success {
  background: #48bb78;
}

.toast.error {
  background: #f56565;
}

.toast.info {
  background: #4299e1;
}

.toast.warning {
  background: #ed8936;
}

/* Response Area Styles */
.response-card {
  background: white;
  border-radius: 12px;
  padding: 25px;
  margin-bottom: 20px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
  transition: transform 0.3s ease;
}

.response-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 15px 40px rgba(0, 0, 0, 0.15);
}

.response-message {
  padding: 15px;
  border-radius: 8px;
  margin-bottom: 10px;
  border-left: 4px solid;
}

.response-message.success {
  background: #f0fdf4;
  border-color: #48bb78;
  color: #22543d;
}

.response-message.error {
  background: #fef2f2;
  border-color: #f56565;
  color: #742a2a;
}

.response-message.info {
  background: #ebf8ff;
  border-color: #4299e1;
  color: #2a4e7c;
}

.response-message.warning {
  background: #fffdf7;
  border-color: #ed8936;
  color: #744210;
}

.response-header {
  font-weight: 600;
  margin-bottom: 8px;
}

.response-details {
  font-size: 0.9em;
  margin: 10px 0;
  padding: 10px;
  background: #f7fafc;
  border-radius: 4px;
  overflow-x: auto;
}

.response-time {
  font-size: 0.8em;
  color: #a0aec0;
  margin-top: 8px;
}

/* Loading button styles */
.btn.loading {
  opacity: 0.7;
  cursor: not-allowed;
}

.spinner-small {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  border-top-color: white;
  animation: spin 0.8s linear infinite;
}

.empty-state {
  text-align: center;
  padding: 40px;
  color: #a0aec0;
}

.empty-state p {
  font-size: 1.1em;
  margin-bottom: 20px;
}

/* Authentication Styles */
#auth-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}

.auth-card {
  background: white;
  border-radius: 12px;
  padding: 40px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
  text-align: center;
  max-width: 400px;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.auth-card h1 {
  color: #2d3748;
  margin-bottom: 10px;
}

.auth-card .subtitle {
  color: #718096;
  margin-bottom: 30px;
}

.btn-large {
  padding: 15px 30px;
  font-size: 1.1em;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 15px;
  color: white;
}

.user-info span {
  font-size: 1em;
  opacity: 0.95;
}

/* Header layout with navigation */
.header-left {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
}

/* Navigation Tabs */
.nav-tabs {
  display: flex;
  gap: 8px;
}

.nav-tab {
  padding: 8px 16px;
  background: rgba(255, 255, 255, 0.2);
  color: white;
  text-decoration: none;
  border-radius: 6px;
  font-weight: 500;
  font-size: 14px;
  transition: all 0.2s ease;
}

.nav-tab:hover {
  background: rgba(255, 255, 255, 0.3);
  text-decoration: none;
}

.nav-tab.active {
  background: rgba(255, 255, 255, 0.95);
  color: #667eea;
}

/* API Event specific styles */
.event-item.event-api {
  border-left-color: #9f7aea;
  background: linear-gradient(to right, rgba(159, 122, 234, 0.05), transparent);
}

.event-email {
  font-size: 0.85em;
  color: #718096;
  font-style: italic;
}

.event-client-code {
  display: inline-block;
  padding: 2px 6px;
  background: rgba(102, 126, 234, 0.15);
  border-radius: 4px;
  font-size: 0.8em;
  font-weight: 600;
  color: #5a67d8;
}

/* Processing status badge for processing state */
.status-badge.status-processing {
  background: rgba(66, 153, 225, 0.2);
  color: #2b6cb0;
}

.btn-small {
  padding: 8px 16px;
  font-size: 14px;
  height: auto;
}

/* Make anchor tags styled as buttons look consistent */
a.btn {
  text-decoration: none;
  display: inline-block;
}

a.btn:hover {
  text-decoration: none;
}

/* Collapsible functionality */
.collapsible-card {
  position: relative;
}

.collapsible-header {
  cursor: pointer;
  user-select: none;
  transition: color 0.3s ease;
}

.collapsible-header:hover {
  color: #667eea;
}

.collapse-icon {
  display: inline-block;
  margin-right: 10px;
  transition: transform 0.3s ease;
  font-size: 0.8em;
}

.collapsible-content {
  max-height: 1000px;
  overflow: hidden;
  transition: max-height 0.3s ease, opacity 0.3s ease;
  opacity: 1;
}

.collapsible-content.collapsed {
  max-height: 0;
  opacity: 0;
}

/* Webhook Events Styles */
.events-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.event-item {
  background: #f8f9fa;
  border-left: 4px solid #e2e8f0;
  padding: 12px 16px;
  margin-bottom: 10px;
  border-radius: 6px;
  transition: all 0.2s ease;
}

.event-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.event-id {
  font-weight: 600;
  color: #4a5568;
  font-size: 0.9em;
}

.event-item:hover {
  background: #f1f3f5;
  transform: translateX(5px);
}

.event-item.event-aidme {
  border-left-color: #667eea;
  background: linear-gradient(to right, rgba(102, 126, 234, 0.05), transparent);
}

.event-item.event-added {
  border-left-color: #48bb78;
  background: linear-gradient(to right, rgba(72, 187, 120, 0.05), transparent);
}

.event-item.event-comment {
  border-left-color: #4299e1;
  background: linear-gradient(to right, rgba(66, 153, 225, 0.05), transparent);
}

.event-item.event-changed {
  border-left-color: #ed8936;
  background: linear-gradient(to right, rgba(237, 137, 54, 0.05), transparent);
}

.event-item.event-handshake {
  border-left-color: #9f7aea;
  background: linear-gradient(to right, rgba(159, 122, 234, 0.05), transparent);
}

.event-summary {
  font-size: 0.95em;
  color: #2d3748;
  margin-bottom: 6px;
  font-weight: 500;
}

.event-task-name {
  font-size: 1em;
  color: #1a202c;
  margin: 8px 0;
  font-weight: 600;
}

.event-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85em;
  color: #718096;
}

.event-type {
  background: #e2e8f0;
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.75em;
  letter-spacing: 0.5px;
}

.event-time {
  font-style: italic;
  cursor: help;
}

.event-processing-time {
  font-size: 0.75em;
  color: #4299e1;
  margin-top: 2px;
  font-style: italic;
  animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

.event-item.event-aidme .event-type {
  background: rgba(102, 126, 234, 0.2);
  color: #5a67d8;
}

.event-item.event-added .event-type {
  background: rgba(72, 187, 120, 0.2);
  color: #2f855a;
}

.event-item.event-comment .event-type {
  background: rgba(66, 153, 225, 0.2);
  color: #2b6cb0;
}

.event-item.event-changed .event-type {
  background: rgba(237, 137, 54, 0.2);
  color: #c05621;
}

.event-item.event-handshake .event-type {
  background: rgba(159, 122, 234, 0.2);
  color: #6b46c1;
}

/* Event status inline badges */
.event-status {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 0.85em;
  font-weight: 500;
  margin-left: 8px;
}

.event-status.processed {
  background: rgba(72, 187, 120, 0.2);
  color: #2f855a;
}

.event-status.ignored {
  background: rgba(203, 213, 224, 0.3);
  color: #718096;
}

.event-status.failed {
  background: rgba(245, 101, 101, 0.2);
  color: #c53030;
}

.event-status.error {
  background: rgba(237, 137, 54, 0.2);
  color: #c05621;
}

.event-status.pending {
  background: rgba(237, 242, 247, 0.5);
  color: #4a5568;
}

.event-status.processing {
  background: rgba(66, 153, 225, 0.2);
  color: #2b6cb0;
  animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.7;
  }
}

.event-status.unknown {
  background: rgba(160, 174, 192, 0.2);
  color: #4a5568;
}

/* Processing Status Badges */
.status-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 0.7em;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-right: 8px;
}

.status-processed {
  background: rgba(72, 187, 120, 0.2);
  color: #2f855a;
}

.status-ignored {
  background: rgba(203, 213, 224, 0.4);
  color: #718096;
}

.status-failed {
  background: rgba(245, 101, 101, 0.2);
  color: #c53030;
}

.status-error {
  background: rgba(237, 137, 54, 0.2);
  color: #c05621;
}

.status-pending {
  background: rgba(237, 242, 247, 0.8);
  color: #4a5568;
}

/* Event status modifiers - support both prefixed and non-prefixed classes */
.event-item.event-processed,
.event-item.processed {
  opacity: 1;
}

.event-item.event-ignored,
.event-item.ignored {
  opacity: 0.7;
}

.event-item.event-failed,
.event-item.failed {
  border-left-color: #f56565;
  background: linear-gradient(to right, rgba(245, 101, 101, 0.05), transparent);
}

.event-item.event-error,
.event-item.error {
  border-left-color: #ed8936;
  background: linear-gradient(to right, rgba(237, 137, 54, 0.05), transparent);
}

.event-item.event-pending,
.event-item.pending {
  border-left-color: #cbd5e0;
  background: linear-gradient(to right, rgba(237, 242, 247, 0.3), transparent);
}

.event-item.event-processing,
.event-item.processing {
  border-left-color: #4299e1;
  background: linear-gradient(to right, rgba(66, 153, 225, 0.1), transparent);
  box-shadow: 0 0 0 1px rgba(66, 153, 225, 0.2);
  animation: processingPulse 2s ease-in-out infinite;
}

@keyframes processingPulse {
  0%, 100% {
    box-shadow: 0 0 0 1px rgba(66, 153, 225, 0.2);
  }
  50% {
    box-shadow: 0 0 0 3px rgba(66, 153, 225, 0.1);
  }
}

/* Comment reply specific style */
.event-item.event-comment-reply {
  border-left-color: #4299e1;
  background: linear-gradient(to right, rgba(66, 153, 225, 0.05), transparent);
}

.event-item.event-comment-reply .event-type {
  background: rgba(66, 153, 225, 0.2);
  color: #2b6cb0;
}

/* Pagination Controls */
.pagination-controls {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 20px;
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid #e2e8f0;
}

.page-info {
  font-size: 0.95em;
  color: #4a5568;
  font-weight: 500;
  min-width: 200px;
  text-align: center;
}

.pagination-controls .btn-small {
  min-width: 100px;
}

.pagination-controls .btn-small:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  background: #cbd5e0;
}

.pagination-controls .btn-small:disabled:hover {
  transform: none;
  box-shadow: none;
}

.pagination-controls .icon {
  font-size: 0.9em;
  margin: 0 2px;
}

/* Events Header and Filter */
.events-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.events-header h2 {
  margin-bottom: 0;
}

.events-filter {
  display: flex;
  align-items: center;
  gap: 10px;
}

.events-filter label {
  font-size: 0.95em;
  color: #4a5568;
  font-weight: 500;
}

.events-filter select {
  padding: 6px 12px;
  border: 1px solid #cbd5e0;
  border-radius: 6px;
  background: white;
  color: #2d3748;
  font-size: 0.9em;
  cursor: pointer;
  transition: all 0.2s ease;
}

.events-filter select:hover {
  border-color: #667eea;
}

.events-filter select:focus {
  outline: none;
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* Event Content with Task Link */
.event-content {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.event-details {
  flex: 1;
}

.task-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  background: rgba(102, 126, 234, 0.1);
  color: #667eea;
  border-radius: 6px;
  text-decoration: none;
  font-size: 0.85em;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.task-link:hover {
  background: rgba(102, 126, 234, 0.2);
  transform: scale(1.05);
}

.replay-btn {
  padding: 4px 8px !important;
  font-size: 0.85em !important;
  margin-left: auto;
}

.task-icon {
  font-size: 1.1em;
}

/* Adjust event item hover when it has a link */
.event-item:has(.task-link) {
  cursor: default;
}

/* Ignored events styling */
.event-item.event-ignored {
  opacity: 0.6;
  background: #f8f9fa;
}

.event-item.event-ignored:hover {
  opacity: 0.8;
}

/* Modal styles */
.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  overflow: auto;
  background-color: rgba(0, 0, 0, 0.4);
  animation: fadeIn 0.3s ease;
}

.modal.show {
  display: block;
}

.modal-content {
  background-color: #fefefe;
  margin: 5% auto;
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  width: 90%;
  max-width: 900px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  animation: slideIn 0.3s ease;
}

.modal-header {
  padding: 20px;
  border-bottom: 1px solid #e0e0e0;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h2 {
  margin: 0;
  font-size: 1.5em;
  color: #333;
}

.modal-close {
  background: none;
  border: none;
  font-size: 28px;
  font-weight: bold;
  color: #aaa;
  cursor: pointer;
  padding: 0;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s;
}

.modal-close:hover,
.modal-close:focus {
  color: #000;
}

.modal-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}

.modal-section {
  margin-bottom: 20px;
}

.modal-section h3 {
  margin: 0 0 10px 0;
  color: #555;
  font-size: 1.1em;
  border-bottom: 1px solid #e0e0e0;
  padding-bottom: 5px;
}

.modal-section pre {
  background: #f5f5f5;
  border: 1px solid #ddd;
  border-radius: 4px;
  padding: 10px;
  overflow-x: auto;
  font-size: 0.9em;
  line-height: 1.4;
  max-height: 300px;
  overflow-y: auto;
}

.modal-section .info-grid {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  font-size: 0.95em;
}

.modal-section .info-label {
  font-weight: 600;
  color: #666;
}

.modal-section .info-value {
  color: #333;
}

.modal-section .usage-stats {
  display: flex;
  gap: 20px;
  margin-top: 10px;
}

.modal-section .usage-stat {
  background: #f0f0f0;
  padding: 8px 12px;
  border-radius: 4px;
  font-size: 0.9em;
}

.modal-section .usage-stat strong {
  color: #333;
}

/* Make events clickable */
.event-item {
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}

.event-item:hover {
  transform: translateX(2px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes slideIn {
  from {
    transform: translateY(-50px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* ==================== TEST MODE STYLES ==================== */

/* Test Section Container */
.test-section {
  background: #fff;
  border-radius: 8px;
  margin-bottom: 20px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  overflow: hidden;
}

.test-section-header {
  padding: 20px;
  background: #f8f9fa;
  border-bottom: 1px solid #e0e0e0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: background 0.2s;
}

.test-section.collapsible .test-section-header {
  cursor: pointer;
}

.test-section.collapsible .test-section-header:hover {
  background: #f0f1f3;
}

.test-section-header h3 {
  margin: 0;
  color: #333;
  font-size: 16px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-toggle-icon {
  transition: transform 0.3s;
  display: inline-block;
}

.section-hint {
  color: #666;
  font-size: 13px;
}

.test-section-content {
  padding: 20px;
  background: #fff;
}

/* Action selector and buttons */
#action-selector {
  width: 100%;
  padding: 12px 24px;
  border: 1px solid #e1e4e8;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 600;
  background: white;
  cursor: pointer;
  margin-bottom: 0;
  height: 48px;
  transition: all 0.3s ease;
  appearance: none;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 16px center;
  background-size: 20px;
  padding-right: 48px;
}

#action-selector:hover {
  border-color: #d0d7de;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

#action-selector:focus {
  outline: none;
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.action-buttons {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* Process section */
.process-section {
  text-align: center;
  padding: 30px 20px;
  background: transparent;
  box-shadow: none;
}

.btn-large {
  padding: 14px 32px;
  font-size: 16px;
  font-weight: 600;
}

/* Code editors */
.code-editor {
  width: 100%;
  height: 350px;
  padding: 12px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-family: "Monaco", "Menlo", "Ubuntu Mono", monospace;
  font-size: 13px;
  line-height: 1.5;
  resize: vertical;
  background: #f9f9f9;
}

.code-editor:focus {
  outline: none;
  border-color: #4caf50;
  background: #fff;
  box-shadow: 0 0 0 2px rgba(76, 175, 80, 0.1);
}

.json-editor {
  color: #2e7d32;
  height: 300px;
}

.markdown-editor {
  color: #1976d2;
  height: 400px;
}

.test-mode-response {
  background: #fff;
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  animation: slideIn 0.3s ease-out;
}

.response-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
  padding-bottom: 10px;
  border-bottom: 1px solid #eee;
}

.response-header h3 {
  margin: 0;
  color: #333;
  font-size: 16px;
  font-weight: 600;
}

.response-content {
  margin-bottom: 15px;
  overflow-wrap: break-word;
  word-wrap: break-word;
  white-space: pre-wrap;
}

#test-response-content {
  max-width: 100%;
  overflow-x: auto;
}

#test-response-content pre {
  white-space: pre-wrap;
  word-wrap: break-word;
  overflow-wrap: break-word;
  max-width: 100%;
}

.test-response-text {
  padding: 15px;
  background: #f5f5f5;
  border-radius: 4px;
  line-height: 1.6;
  color: #333;
  max-height: 500px;
  overflow-y: auto;
}

.test-response-text strong {
  color: #2c3e50;
  font-weight: 600;
}

.test-response-text em {
  font-style: italic;
  color: #555;
}

.test-response-text code {
  background: #e8e8e8;
  padding: 2px 4px;
  border-radius: 3px;
  font-family: "Monaco", "Menlo", monospace;
  font-size: 0.9em;
}

.test-response-text pre {
  background: #2d2d2d;
  color: #f8f8f2;
  padding: 12px;
  border-radius: 4px;
  overflow-x: auto;
  margin: 10px 0;
}

.test-response-text pre code {
  background: transparent;
  padding: 0;
  color: inherit;
}

.response-metadata {
  padding-top: 15px;
  border-top: 1px solid #eee;
}

.metadata-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 10px;
}

.metadata-item {
  background: #f0f0f0;
  padding: 8px 12px;
  border-radius: 4px;
  font-size: 13px;
}

.metadata-item strong {
  color: #666;
  margin-right: 5px;
}

.error-message {
  background: #ffebee;
  color: #c62828;
  padding: 15px;
  border-radius: 4px;
  border-left: 4px solid #f44336;
}

/* Settings grid stays the same */

.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 20px;
  margin-bottom: 20px;
}

.setting-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.setting-group label {
  font-weight: 600;
  color: #333;
  font-size: 14px;
}

.setting-group input[type="number"],
.setting-group select {
  padding: 8px 12px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 14px;
  background: white;
}

.setting-group input[type="range"] {
  width: 100%;
}

.setting-group input:focus,
.setting-group select:focus {
  outline: none;
  border-color: #4caf50;
  box-shadow: 0 0 0 2px rgba(76, 175, 80, 0.1);
}

.setting-group-full {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 20px;
}

.system-prompt-editor {
  width: 100%;
  padding: 12px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-family: -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 14px;
  resize: vertical;
  min-height: 100px;
}

.system-prompt-editor:focus {
  outline: none;
  border-color: #4caf50;
  box-shadow: 0 0 0 2px rgba(76, 175, 80, 0.1);
}

.settings-actions {
  display: flex;
  gap: 10px;
  padding-top: 15px;
  border-top: 1px solid #eee;
}

.setting-hint {
  color: #888;
  font-size: 12px;
  font-style: italic;
}

.error-message strong {
  color: #b71c1c;
}

/* Button states for test mode */
.btn-success {
  background: linear-gradient(135deg, #66bb6a, #4caf50);
  color: white;
}

.btn-success:hover {
  background: linear-gradient(135deg, #4caf50, #388e3c);
  transform: translateY(-1px);
}

.btn-info {
  background: linear-gradient(135deg, #42a5f5, #2196f3);
  color: white;
}

.btn-info:hover {
  background: linear-gradient(135deg, #2196f3, #1976d2);
  transform: translateY(-1px);
}

.btn-diagnostics {
  display: inline-block;
  padding: 8px 16px;
  background: linear-gradient(135deg, #7c3aed, #6d28d9);
  color: white;
  text-decoration: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  margin-top: 10px;
  transition: all 0.2s ease;
}

.btn-diagnostics:hover {
  background: linear-gradient(135deg, #6d28d9, #5b21b6);
  transform: translateY(-1px);
  color: white;
  text-decoration: none;
}

/* Responsive layout for test mode */
@media (max-width: 1024px) {
  .test-mode-editors {
    grid-template-columns: 1fr;
  }

  .code-editor {
    height: 300px;
  }
}

@media (max-width: 768px) {
  .test-mode-controls-bar {
    flex-direction: column;
  }

  #action-selector {
    width: 100%;
  }

  .metadata-grid {
    grid-template-columns: 1fr;
  }
}

/* Test Mode Full Screen Layout */
.test-mode-body {
  margin: 0;
  padding: 0;
  height: 100vh;
  overflow: hidden;
  background: #f5f6f8;
}

.test-mode-action-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 60px;
  background: #fff;
  border-bottom: 2px solid #e0e0e0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 20px;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.action-bar-left,
.action-bar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.action-bar-left #action-selector {
  width: 250px;
}

.test-mode-container {
  position: fixed;
  top: 60px;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  gap: 20px;
  padding: 20px;
  overflow: hidden;
}

.test-mode-left-column,
.test-mode-right-column {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 20px;
  overflow-y: auto;
  height: 100%;
}

.test-panel {
  background: #fff;
  border: 1px solid #e1e4e8;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.test-panel.full-height {
  flex: 1;
  min-height: 0;
}

.test-panel-header {
  padding: 15px 20px;
  background: #f8f9fa;
  border-bottom: 1px solid #e0e0e0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}

.test-panel-header h3 {
  margin: 0;
  color: #333;
  font-size: 16px;
  font-weight: 600;
}

.panel-hint {
  color: #666;
  font-size: 12px;
}

.test-panel-content {
  padding: 20px;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.test-panel-content.settings-content {
  overflow-y: auto;
}

.knowledge-url-input {
  width: 100%;
  padding: 10px 12px;
  font-size: 14px;
  border: 1px solid #e1e4e8;
  border-radius: 6px;
  box-sizing: border-box;
  display: block;
  background: white;
  transition: all 0.2s ease;
}

.knowledge-url-input:focus {
  outline: none;
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.code-editor.full-height-editor {
  flex: 1;
  min-height: 0;
  resize: none;
}

/* Response Modal Overlay */
.test-mode-response-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 40px;
}

.test-mode-response-modal {
  background: #fff;
  border-radius: 12px;
  max-width: 1200px;
  width: 100%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.test-mode-response-modal .response-header {
  padding: 20px;
  border-bottom: 1px solid #e0e0e0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}

.test-mode-response-modal .response-content {
  padding: 20px;
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}

.test-mode-response-modal .response-metadata {
  padding: 20px;
  border-top: 1px solid #e0e0e0;
  flex-shrink: 0;
}

/* Tab styles for response modal */
.response-tabs {
  display: flex;
  border-bottom: 1px solid #e0e0e0;
  background: #f5f5f5;
}

.tab-button {
  flex: 1;
  padding: 12px 20px;
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  color: #666;
  transition: all 0.2s ease;
  border-bottom: 2px solid transparent;
}

.tab-button:hover {
  background: rgba(0, 0, 0, 0.03);
  color: #333;
}

.tab-button.active {
  color: #0066cc;
  background: #fff;
  border-bottom-color: #0066cc;
}

.tab-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.tab-pane {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.tab-pane.active {
  display: flex;
}

/* Styling for request/response content headers */
.response-content h4 {
  margin: 0 0 10px 0;
  color: #333;
  font-size: 14px;
  font-weight: 600;
  padding-bottom: 5px;
  border-bottom: 1px solid #e0e0e0;
}

/* Template Variables Button */
.template-vars-btn {
  background: linear-gradient(135deg, #42a5f5, #2196f3);
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.3s ease;
}

.template-vars-btn:hover {
  background: linear-gradient(135deg, #2196f3, #1976d2);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* Variable Help Popup */
.variable-help-popup {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10000;
}

.popup-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  cursor: pointer;
}

.popup-content {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: white;
  border-radius: 8px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  max-width: 800px;
  width: 90%;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
}

.popup-header {
  padding: 20px;
  border-bottom: 1px solid #e0e0e0;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.popup-header h3 {
  margin: 0;
  color: #333;
  font-size: 20px;
}

.popup-close {
  background: none;
  border: none;
  font-size: 28px;
  color: #999;
  cursor: pointer;
  padding: 0;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: background 0.2s;
}

.popup-close:hover {
  background: #f0f0f0;
  color: #333;
}

.popup-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}

.variable-section {
  margin-bottom: 25px;
}

.variable-section h4 {
  color: #667eea;
  font-size: 16px;
  margin-bottom: 12px;
  font-weight: 600;
}

.variable-item {
  margin-bottom: 12px;
  padding: 10px;
  background: #f8f9fa;
  border-radius: 4px;
  transition: background 0.2s, transform 0.1s;
}

.variable-item:hover {
  background: #e9ecef;
  transform: translateY(-1px);
}

.variable-item code {
  display: inline-block;
  background: #e9ecef;
  padding: 4px 8px;
  border-radius: 3px;
  font-family: "Courier New", monospace;
  font-size: 14px;
  color: #d73502;
  margin-bottom: 4px;
}

.variable-item p {
  margin: 0;
  color: #666;
  font-size: 13px;
  line-height: 1.4;
}

.variable-syntax-note {
  margin-top: 10px;
  padding: 10px;
  background: #fff;
  border: 1px dashed #ccc;
  border-radius: 4px;
  font-size: 12px;
}

.variable-syntax-note strong {
  color: #333;
}

.variable-syntax-note code {
  background: #e9ecef;
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 12px;
  color: #d73502;
}

.variable-syntax-note p {
  margin: 6px 0;
  font-size: 12px;
}

.variable-syntax-note pre {
  margin: 6px 0;
  padding: 8px;
  background: #f5f5f5;
  border-radius: 4px;
  font-size: 11px;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

.variable-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 10px;
}

.variable-item.compact {
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.variable-item.compact code {
  margin-bottom: 2px;
  font-size: 12px;
}

.variable-item.compact span {
  font-size: 11px;
  color: #666;
  line-height: 1.3;
}

.info-box {
  background: #e7f3ff;
  border: 1px solid #b3d9ff;
  padding: 15px;
  border-radius: 4px;
}

.info-box pre {
  background: white;
  padding: 12px;
  border-radius: 4px;
  font-family: "Courier New", monospace;
  font-size: 12px;
  line-height: 1.5;
  margin-top: 8px;
  overflow-x: auto;
  border: 1px solid #d0e5ff;
}

/* Cache Modal Styles */
.cache-status-section {
  margin-bottom: 20px;
}

.cache-actions-section {
  border-top: 1px solid #e0e0e0;
  padding-top: 20px;
}

.status-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 15px;
  margin-bottom: 20px;
}

.status-item {
  display: flex;
  flex-direction: column;
}

.status-item label {
  font-weight: 600;
  color: #666;
  font-size: 12px;
  text-transform: uppercase;
  margin-bottom: 4px;
}

.status-item span {
  color: #333;
  font-size: 14px;
}

.cache-stats-details {
  margin-top: 20px;
  padding: 15px;
  background: #f8f9fa;
  border-radius: 8px;
}

.cache-stats-details h4 {
  margin: 0 0 15px 0;
  color: #333;
  font-size: 14px;
  text-transform: uppercase;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 15px;
  text-align: center;
}

.stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.stat-value {
  font-size: 24px;
  font-weight: bold;
  color: #0066cc;
  margin-bottom: 4px;
}

.stat-label {
  font-size: 11px;
  color: #666;
  text-transform: uppercase;
}

.button-group {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.button-group .btn {
  flex: 1;
  min-width: 150px;
}

.loading-spinner {
  text-align: center;
  padding: 20px;
  color: #666;
  font-style: italic;
}

.alert {
  padding: 12px 16px;
  border-radius: 4px;
  margin-top: 10px;
}

.alert-error {
  background-color: #fee;
  border: 1px solid #fcc;
  color: #c00;
}

.alert-success {
  background-color: #efe;
  border: 1px solid #cfc;
  color: #060;
}

.alert-info {
  background-color: #e7f3ff;
  border: 1px solid #b3d9ff;
  color: #004085;
}
