/**
 * Delivery Simulator Testbed Styles
 */

:root {
  --primary-color: #ff3008;
  --primary-dark: #c41e00;
  --secondary-color: #1f2937;
  --success-color: #10b981;
  --warning-color: #f59e0b;
  --bg-color: #f3f4f6;
  --card-bg: #ffffff;
  --text-primary: #1f2937;
  --text-secondary: #6b7280;
  --border-color: #e5e7eb;
  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background-color: var(--bg-color);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
}

.container {
  max-width: 800px;
  margin: 0 auto;
  padding: 20px;
}

/* Header */
.header {
  text-align: center;
  margin-bottom: 30px;
  padding: 20px;
  background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
  border-radius: 12px;
  color: white;
}

.header h1 {
  font-size: 2rem;
  margin-bottom: 8px;
}

.subtitle {
  opacity: 0.9;
  font-size: 1rem;
}

/* Sections */
section {
  background: var(--card-bg);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}

section h2 {
  font-size: 1.1rem;
  color: var(--text-secondary);
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--border-color);
}

/* Status Card */
.status-section {
  background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
  border: 2px solid #f59e0b;
}

.status-card {
  background: var(--card-bg);
  border-radius: 12px;
  padding: 24px;
  text-align: center;
  box-shadow: var(--shadow-lg);
  transition: all 0.3s ease;
}

.status-card.updating {
  transform: scale(1.02);
  box-shadow: 0 0 20px rgba(255, 48, 8, 0.3);
}

.status-icon {
  font-size: 3rem;
  margin-bottom: 12px;
}

.status-text {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 12px;
  min-height: 2em;
}

.status-text.terminal {
  color: var(--success-color);
}

.status-meta {
  display: flex;
  justify-content: center;
  gap: 16px;
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.meta-time {
  font-family: 'SF Mono', Monaco, Consolas, monospace;
}

/* Stale Statuses */
.stale-statuses {
  margin-top: 16px;
  padding: 12px;
  background: #fef2f2;
  border: 1px dashed #fca5a5;
  border-radius: 8px;
}

.stale-statuses.hidden {
  display: none;
}

.stale-label {
  font-size: 0.75rem;
  color: #991b1b;
  margin-bottom: 8px;
  font-weight: 600;
}

#stale-list {
  font-size: 0.875rem;
  color: #7f1d1d;
}

#stale-list .stale-item {
  padding: 4px 8px;
  background: rgba(255, 255, 255, 0.5);
  border-radius: 4px;
  margin-bottom: 4px;
  text-decoration: line-through;
  opacity: 0.7;
}

/* Status Buttons */
.status-buttons {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.status-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  background: var(--card-bg);
  border: 2px solid var(--border-color);
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: left;
}

.status-btn:hover {
  border-color: var(--primary-color);
  background: #fff5f5;
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.status-btn:active {
  transform: translateY(0);
}

.status-btn.active {
  border-color: var(--primary-color);
  background: #fef2f2;
  box-shadow: 0 0 0 3px rgba(255, 48, 8, 0.2);
}

.status-btn.terminal {
  border-color: var(--success-color);
}

.status-btn.terminal:hover {
  background: #ecfdf5;
}

.status-btn.terminal.active {
  background: #d1fae5;
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2);
}

.btn-icon {
  font-size: 1.5rem;
}

.btn-text {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-primary);
}

.reset-btn {
  width: 100%;
  padding: 12px;
  background: var(--secondary-color);
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
  transition: background 0.2s;
}

.reset-btn:hover {
  background: #374151;
}

/* Auto-play Controls */
.autoplay-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.interval-input {
  width: 60px;
  padding: 8px;
  border: 2px solid var(--border-color);
  border-radius: 6px;
  font-size: 1rem;
  text-align: center;
}

.interval-input:focus {
  outline: none;
  border-color: var(--primary-color);
}

.autoplay-status {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

#autoplay-state {
  font-weight: 600;
  color: var(--text-secondary);
}

#autoplay-state.active {
  color: var(--success-color);
}

/* Toggle Switches */
.toggle-label,
.option-label {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
}

.toggle-switch,
.option-switch {
  position: relative;
  width: 48px;
  height: 26px;
  background: var(--border-color);
  border-radius: 13px;
  transition: background 0.2s;
  flex-shrink: 0;
}

.toggle-switch::after,
.option-switch::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  background: white;
  border-radius: 50%;
  transition: transform 0.2s;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

input[type="checkbox"]:checked + .toggle-switch,
input[type="checkbox"]:checked + .option-switch {
  background: var(--primary-color);
}

input[type="checkbox"]:checked + .toggle-switch::after,
input[type="checkbox"]:checked + .option-switch::after {
  transform: translateX(22px);
}

input[type="checkbox"] {
  display: none;
}

.toggle-text,
.option-text {
  font-size: 0.9rem;
  color: var(--text-primary);
}

/* Options Grid */
.options-grid {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Noise Section */
.noise-section {
  background: #fffbeb;
  border: 2px dashed #fbbf24;
}

.noise-section.hidden {
  display: none;
}

.noise-description {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-bottom: 16px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.7);
  border-radius: 8px;
}

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

.noise-block {
  background: white;
  padding: 14px;
  border-radius: 8px;
  font-size: 0.85rem;
}

.noise-block h3 {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.noise-block p {
  margin-bottom: 6px;
  color: var(--text-primary);
}

.noise-block.partial-matches {
  background: #fef2f2;
  border: 1px solid #fecaca;
}

.noise-block.partial-matches h3 {
  color: #991b1b;
}

/* Event Log */
.log-section {
  background: var(--secondary-color);
  color: white;
}

.log-section h2 {
  color: rgba(255, 255, 255, 0.7);
  border-bottom-color: rgba(255, 255, 255, 0.2);
}

.log-controls {
  margin-bottom: 12px;
}

.small-btn {
  padding: 6px 12px;
  background: rgba(255, 255, 255, 0.1);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.8rem;
  transition: background 0.2s;
}

.small-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}

.event-log {
  max-height: 200px;
  overflow-y: auto;
  font-family: 'SF Mono', Monaco, Consolas, monospace;
  font-size: 0.8rem;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 8px;
  padding: 12px;
}

.log-entry {
  padding: 6px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  gap: 12px;
}

.log-entry:last-child {
  border-bottom: none;
}

.log-entry.info {
  color: #93c5fd;
}

.log-entry.status {
  color: #86efac;
}

.log-entry.status.terminal {
  color: #fcd34d;
  font-weight: bold;
}

.log-time {
  color: rgba(255, 255, 255, 0.5);
  flex-shrink: 0;
}

.log-message {
  flex: 1;
}

/* Footer */
.footer {
  text-align: center;
  padding: 20px;
  color: var(--text-secondary);
  font-size: 0.875rem;
}

.footer .hint {
  margin-top: 8px;
  padding: 10px;
  background: #dbeafe;
  border-radius: 8px;
  color: #1e40af;
  font-weight: 500;
}

.footer .hint-small {
  margin-top: 8px;
  font-size: 0.75rem;
  color: #9ca3af;
}

.footer .hint-small a {
  color: #6b7280;
  text-decoration: underline;
}

/* Scrollbar */
.event-log::-webkit-scrollbar {
  width: 6px;
}

.event-log::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 3px;
}

.event-log::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.3);
  border-radius: 3px;
}

/* Capture Test Panels */
.capture-test-section {
  background: linear-gradient(135deg, #ecfdf5 0%, #d1fae5 100%);
  border: 2px solid #6ee7b7;
}

.capture-test-desc {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-bottom: 16px;
}

.capture-test-desc code {
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  padding: 1px 6px;
  font-family: 'SF Mono', Monaco, Consolas, monospace;
  font-size: 0.85em;
}

.capture-test-panel {
  background: white;
  border-radius: 8px;
  padding: 14px;
  margin-bottom: 12px;
}

.capture-test-panel:last-child {
  margin-bottom: 0;
}

.capture-test-panel h3 {
  font-size: 0.8rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 10px;
}

.capture-test-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.9rem;
  padding: 4px 0;
}

.capture-test-fee-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.9rem;
  padding: 6px 0;
  border-bottom: 1px solid #f3f4f6;
}

.capture-test-fee-row:last-child {
  border-bottom: none;
}

.capture-test-fee-row s {
  color: #9ca3af;
  margin-left: 6px;
  font-size: 0.85em;
}

.capture-test-total-row {
  font-weight: 700;
  border-top: 2px solid var(--border-color);
  border-bottom: none;
  padding-top: 10px;
  margin-top: 4px;
}

.capture-test-popover-wrap {
  margin-top: 12px;
}

.capture-test-info-btn {
  padding: 8px 14px;
  background: var(--primary-color);
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 500;
  transition: background 0.2s;
}

.capture-test-info-btn:hover {
  background: var(--primary-dark);
}

.capture-test-popover {
  margin-top: 10px;
  padding: 12px;
  background: #fffbeb;
  border: 1px solid #fcd34d;
  border-radius: 8px;
}

.capture-test-popover.hidden {
  display: none;
}

.capture-test-popover-hint {
  margin-top: 8px;
  font-size: 0.75rem;
  color: #9ca3af;
  font-style: italic;
  text-align: right;
}

/* Responsive */
@media (max-width: 600px) {
  .container {
    padding: 12px;
  }

  .header h1 {
    font-size: 1.5rem;
  }

  .status-text {
    font-size: 1.25rem;
  }

  .status-buttons {
    grid-template-columns: 1fr;
  }

  .noise-content {
    grid-template-columns: 1fr;
  }
}

/* Animation for status updates */
@keyframes pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(255, 48, 8, 0.4);
  }
  70% {
    box-shadow: 0 0 0 15px rgba(255, 48, 8, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(255, 48, 8, 0);
  }
}

.status-card.pulse {
  animation: pulse 0.5s ease-out;
}

/* Terminal celebration */
@keyframes celebrate {
  0%, 100% {
    transform: scale(1);
  }
  25% {
    transform: scale(1.05) rotate(-2deg);
  }
  75% {
    transform: scale(1.05) rotate(2deg);
  }
}

.status-card.celebrate {
  animation: celebrate 0.5s ease-out;
  background: linear-gradient(135deg, #d1fae5 0%, #a7f3d0 100%);
}
