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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #edf3eb;
  height: 100vh;
  overflow: hidden;
}

/* Top Header */
.top-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 50px;
  background: #008080;
  color: white;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  z-index: 1000;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.header-left,
.header-right {
  flex: 0 0 auto;
}

.header-center {
  flex: 1;
  display: flex;
  justify-content: center;
}

.client-selector-compact {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
}

.client-selector-compact label {
  margin: 0;
  font-weight: 500;
}

.client-selector-compact select {
  padding: 4px 8px;
  border: 1px solid #008080;
  border-radius: 4px;
  background: white;
  color: #008080;
  font-size: 13px;
}

.divider {
  color: #7f8c8d;
  font-weight: bold;
}

.main-container {
  display: flex;
  height: 100vh;
  margin-top: 50px; /* Account for fixed header */
}

/* Sidebar */
.sidebar {
  width: 630px;
  background: #ffffff;
  border-right: 2px solid #008080;
  overflow-y: auto;
  flex-shrink: 0;
}

.sidebar-header {
  padding: 20px;
  border-bottom: 2px solid #008080;
  background: linear-gradient(135deg, #008080 0%, #006666 100%);
  color: white;
}

.sidebar-header h1 {
  font-size: 1.5rem;
  margin-bottom: 5px;
}

.sidebar-header p {
  opacity: 0.9;
  font-size: 0.9rem;
}

.sidebar-content {
  padding: 20px;
}

/* Preview Area */
.preview-area {
  flex: 1;
  background: #ffffff;
  display: flex;
  flex-direction: column;
}

/* Preview URLs Panel */
.preview-urls-panel {
  background: #f8f9fa;
  border-bottom: 1px solid #e0e0e0;
  padding: 15px;
  max-height: 200px;
  overflow-y: auto;
}

.preview-urls-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.preview-urls-header h4 {
  margin: 0;
  color: #333;
  font-size: 14px;
  font-weight: 600;
}

.preview-urls-content {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 10px;
}

.preview-url-item {
  background: white;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  padding: 10px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.preview-url-variant {
  font-weight: 600;
  color: #333;
  min-width: 80px;
  font-size: 12px;
}

.preview-url-link {
  flex: 1;
  font-family: monospace;
  font-size: 11px;
  color: #666;
  background: #f8f9fa;
  padding: 4px 8px;
  border-radius: 4px;
  border: 1px solid #e0e0e0;
  word-break: break-all;
}

.preview-url-actions {
  display: flex;
  gap: 5px;
}

.preview-url-actions button {
  padding: 4px 8px;
  font-size: 11px;
  border: 1px solid #ddd;
  background: white;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s;
}

.preview-url-actions button:hover {
  background: #f8f9fa;
  border-color: #007bff;
}

.preview-url-actions .btn-copy {
  color: #007bff;
}

.preview-url-actions .btn-preview {
  color: #28a745;
}

.preview-url-actions .btn-edit {
  color: #ffc107;
}

.preview-header {
  background: #edf3eb;
  padding: 15px 20px;
  border-bottom: 2px solid #008080;
  display: flex;
  align-items: center;
  gap: 15px;
}

.preview-url {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid #008080;
  border-radius: 6px;
  font-size: 14px;
}

.preview-frame {
  flex: 1;
  border: none;
  background: white;
}

/* Form Sections */
.form-section {
  margin-bottom: 20px;
  background: #ffffff;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid #008080;
}

.section-header {
  background: linear-gradient(to right, #edf3eb, #d4e6d4);
  padding: 12px 16px;
  font-weight: 600;
  color: #008080;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  user-select: none;
  transition: all 0.2s;
}

.section-header:hover {
  background: linear-gradient(to right, #d4e6d4, #c1d9c1);
}

.section-header .chevron {
  transition: transform 0.2s;
  font-size: 12px;
}

.section-header.collapsed .chevron {
  transform: rotate(-90deg);
}

.section-content {
  padding: 16px;
  display: block;
  background: white;
}

.section-content.collapsed {
  display: none;
}

/* Form Elements */
.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  margin-bottom: 6px;
  font-weight: 500;
  color: #374151;
  font-size: 14px;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 14px;
  transition: all 0.2s;
  font-family: inherit;
}

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

.form-group textarea {
  min-height: 120px;
  resize: vertical;
  font-family: "Monaco", "Menlo", "Ubuntu Mono", monospace;
  font-size: 13px;
}

.form-row {
  display: flex;
  gap: 12px;
}

.form-row .form-group {
  flex: 1;
}

/* Experiment Name Special */
.experiment-name-row {
  display: flex;
  gap: 0;
}

.experiment-name-row select {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
  border-right: none;
  width: 120px;
  flex-shrink: 0;
}

.experiment-name-row input {
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
  flex: 1;
}

/* Variant Container */
.variant-container {
  border: 1px solid #e1e5e9;
  border-radius: 8px;
  margin-bottom: 16px;
  background: white;
  overflow: hidden;
}

.variant-header {
  padding: 12px 16px;
  background: linear-gradient(to right, #f9fafb, #f3f4f6);
  border-bottom: 1px solid #e1e5e9;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.variant-title {
  font-weight: 600;
  color: #374151;
}

.variant-type {
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: white;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
}

.variant-type.control {
  background: linear-gradient(135deg, #10b981, #059669);
}

.variant-content {
  padding: 16px;
}

/* Buttons */
.btn {
  background: linear-gradient(135deg, #008080, #006666);
  color: white;
  border: none;
  padding: 10px 18px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 128, 128, 0.3);
}

.btn-secondary {
  background: linear-gradient(135deg, #666666, #333333);
}

.btn-secondary:hover {
  box-shadow: 0 4px 12px rgba(102, 102, 102, 0.3);
}

.btn-danger {
  background: linear-gradient(135deg, #ef4444, #dc2626);
}

.btn-danger:hover {
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

.btn-success {
  background: linear-gradient(135deg, #ff6f00, #e65100);
}

.btn-info {
  background: linear-gradient(135deg, #008080, #006666);
}

.btn-info:hover {
  box-shadow: 0 4px 12px rgba(0, 128, 128, 0.3);
}

.btn-outline-secondary {
  background: transparent;
  border: 1px solid #666666;
  color: #666666;
}

.btn-outline-secondary:hover {
  background: #666666;
  color: white;
}

.btn-small {
  padding: 6px 10px;
  font-size: 12px;
}

.add-variant {
  text-align: center;
  margin-top: 12px;
}

/* Code editors styling */
.code-editor {
  background: #1e293b;
  color: #e2e8f0;
  border: 1px solid #334155;
  font-family: "Monaco", "Menlo", "Ubuntu Mono", monospace;
  font-size: 13px;
}

.code-editor:focus {
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* URL Targeting */
.url-rule {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}

.url-rule select {
  width: auto;
  min-width: 120px;
}

.url-rule input {
  flex: 1;
}

/* Preview Controls */
.preview-controls {
  display: flex;
  gap: 10px;
  align-items: center;
}

.variant-selector {
  padding: 6px 12px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 14px;
}

/* Status indicator */
.status-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
}

.status-indicator.connected {
  background: #d1fae5;
  color: #065f46;
}

.status-indicator.disconnected {
  background: #fee2e2;
  color: #991b1b;
}

/* Loading spinner */
.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(102, 126, 234, 0.3);
  border-radius: 50%;
  border-top-color: #667eea;
  animation: spin 0.8s linear infinite;
}

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

/* Toast notifications */
.toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  padding: 16px 20px;
  background: white;
  border-radius: 8px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
  display: flex;
  align-items: center;
  gap: 12px;
  animation: slideIn 0.3s ease;
  z-index: 1000;
}

.toast.success {
  border-left: 4px solid #10b981;
}

.toast.error {
  border-left: 4px solid #ef4444;
}

.toast.info {
  border-left: 4px solid #3b82f6;
}

/* Preview Actions (above preview) */
.preview-actions {
  display: flex;
  gap: 10px;
  padding: 15px 20px;
  background: #edf3eb;
  border-bottom: 2px solid #008080;
  align-items: center;
}

.preview-actions .btn {
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 500;
}

/* Code Expand Button */
.code-expand-btn {
  background: none;
  border: none;
  font-size: 16px;
  color: #666;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  transition: all 0.2s;
  margin-left: auto;
}

.code-expand-btn:hover {
  background: #f0f0f0;
  color: #333;
}

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

@keyframes slideIn {
  from {
    transform: translateX(100%);
    opacity: 0;
  }

  to {
    transform: translateX(0);
    opacity: 1;
  }
}

/* Responsive */
@media (max-width: 1024px) {
  .sidebar {
    width: 380px;
  }
}

@media (max-width: 768px) {
  .main-container {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    height: 60vh;
  }

  .preview-area {
    height: 40vh;
  }
}
