body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  margin: 0;
  padding: 20px;
  background: #f5f5f7;
}
.container {
  max-width: 1400px;
  margin: 0 auto;
  background: white;
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
  overflow: hidden;
}
.header {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.session-info {
  display: flex;
  align-items: center;
  gap: 15px;
  flex-wrap: wrap; /* Allow wrapping on small screens */
}
.status-badge {
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: bold;
  text-transform: uppercase;
}
.status-draft {
  background: #8e8e93;
}
.status-starting {
  background: #ff9500;
}
.status-in-call {
  background: #34c759;
}
.status-ringing {
  background: #ff9500;
}
.status-completed {
  background: #007aff;
}
.status-failed {
  background: #ff3b30;
}

/* Multi-step workflow */
.workflow-steps {
  display: flex;
  background: #f8f9fa;
  border-bottom: 1px solid #e5e5e7;
  padding: 0;
}
.step {
  flex: 1;
  padding: 15px 20px;
  text-align: center;
  border-right: 1px solid #e5e5e7;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
}
.step:last-child {
  border-right: none;
}
.step.active {
  background: #007aff;
  color: white;
}
.step.completed {
  background: #34c759;
  color: white;
}
.step.completed::after {
  content: "";
  position: absolute;
  right: 10px;
  top: 15px;
}

.step-content {
  display: none;
  padding: 30px;
  min-height: 500px;
}
.step-content.active {
  display: block;
}

/* Step 1: Initialize Call */
.form-group {
  margin-bottom: 20px;
}
.form-group label {
  display: block;
  margin-bottom: 5px;
  font-weight: 600;
  color: #333;
}
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 12px 16px;
  border: 2px solid #e5e5e7;
  border-radius: 8px;
  font-size: 16px;
  transition: border-color 0.2s;
  box-sizing: border-box; /* Ensure padding doesn't overflow width */
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: #007aff;
}
.checkbox-wrapper {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  cursor: pointer;
  padding: 10px;
  border: 1px solid #e5e5e7;
  border-radius: 8px;
  background: white;
  transition: all 0.2s;
}
.checkbox-wrapper:hover {
  border-color: #007aff;
  background: #f0f7ff;
}
.checkbox-wrapper input[type="checkbox"] {
  width: 20px;
  height: 20px;
  margin-top: 2px;
  flex-shrink: 0;
}
.checkbox-content {
  flex: 1;
}
.checkbox-title {
  font-weight: 500;
  color: #333;
  margin-bottom: 2px;
}
.checkbox-desc {
  font-size: 13px;
  color: #666;
  line-height: 1.4;
}
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

/* Step 2: Review & Edit */
.prompt-preview {
  background: #f8f9fa;
  border: 1px solid #e5e5e7;
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 20px;
}
.prompt-preview textarea {
  width: 100%;
  height: 300px;
  resize: vertical;
  font-family: "SF Mono", Monaco, monospace;
  font-size: 14px;
  line-height: 1.5;
  box-sizing: border-box;
}
.debtor-info {
  background: #e3f2fd;
  border: 1px solid #2196f3;
  border-radius: 8px;
  padding: 15px;
  margin-bottom: 20px;
}

/* Step 3: Start Call */
.phone-input-section {
  background: #fff3cd;
  border: 1px solid #ffc107;
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 20px;
}
.phone-input {
  font-size: 18px;
  text-align: center;
  letter-spacing: 1px;
}

/* Step 4: Monitor Call */
.monitor-layout {
  display: grid;
  grid-template-columns: 2fr 1fr;
  height: 600px;
  gap: 20px;
}

.transcription-panel {
  display: flex;
  flex-direction: column;
}

.transcription-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
}

.transcription-feed {
  flex: 1;
  background: #f8f9fa;
  border: 1px solid #e5e5e7;
  border-radius: 8px;
  padding: 15px;
  overflow-y: auto;
  font-family: "SF Mono", Monaco, monospace;
  font-size: 14px;
  line-height: 1.5;
  max-height: 500px; /* Fixed height with scroll */
}

.message {
  margin-bottom: 12px;
  padding: 8px 12px;
  border-radius: 8px;
  position: relative;
}

.message.ai {
  background: #e3f2fd;
  border-left: 4px solid #2196f3;
}

.message.debtor {
  background: #f3e5f5;
  border-left: 4px solid #9c27b0;
}

.message.agent {
  background: #e8f5e8;
  border-left: 4px solid #4caf50;
}

.message.system {
  background: #fff3e0;
  border-left: 4px solid #ff9800;
  font-style: italic;
}

.message .speaker {
  font-weight: bold;
  color: #333;
  margin-bottom: 4px;
}

.message .timestamp {
  font-size: 11px;
  color: #666;
  position: absolute;
  right: 8px;
  top: 8px;
}

.control-panel {
  background: #fafafa;
  border-radius: 8px;
  padding: 20px;
  overflow-y: auto; /* Allow scrolling if controls get too tall */
}

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

.control-section h3 {
  margin: 0 0 15px 0;
  color: #333;
  font-size: 16px;
}

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

.btn {
  padding: 12px 20px;
  border: none;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 14px;
}

.btn:hover:not(:disabled) {
  transform: translateY(-1px);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.btn-primary {
  background: #007aff;
  color: white;
}
.btn-primary:hover:not(:disabled) {
  background: #0056cc;
}

.btn-warning {
  background: #ff9500;
  color: white;
}
.btn-warning:hover:not(:disabled) {
  background: #cc7700;
}

.btn-danger {
  background: #ff3b30;
  color: white;
}
.btn-danger:hover:not(:disabled) {
  background: #cc2e26;
}

.btn-success {
  background: #34c759;
  color: white;
}
.btn-success:hover:not(:disabled) {
  background: #2aa048;
}

.btn-secondary {
  background: #8e8e93;
  color: white;
}
.btn-secondary:hover:not(:disabled) {
  background: #6d6d73;
}

.btn-large {
  padding: 15px 30px;
  font-size: 16px;
}

/* Microphone and status indicators */
.mic-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
}

.status-indicator {
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: bold;
}

.status-recording {
  background: #ff3b30;
  color: white;
  animation: pulse 1s infinite;
}

.status-off {
  background: #e5e5e7;
  color: #8e8e93;
}

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

.audio-controls {
  background: white;
  border: 1px solid #e5e5e7;
  border-radius: 8px;
  padding: 15px;
}

.volume-control {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 15px;
}

.volume-slider {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  border-radius: 2px;
  background: #e5e5e7;
  outline: none;
}

.volume-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #007aff;
  cursor: pointer;
}

.audio-status {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: #666;
}

.connection-status {
  margin-top: 20px;
  padding: 15px;
  background: white;
  border: 1px solid #e5e5e7;
  border-radius: 8px;
}

.connection-item {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
  font-size: 12px;
}

.connection-status h4 {
  margin: 0 0 10px 0;
  font-size: 14px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.status-connected {
  background: #34c759;
}
.status-connecting {
  background: #ff9500;
}
.status-disconnected {
  background: #ff3b30;
}

.loading {
  text-align: center;
  padding: 40px;
  color: #666;
}

.error {
  background: #ffebee;
  border: 1px solid #f44336;
  color: #c62828;
  padding: 15px;
  border-radius: 8px;
  margin-bottom: 20px;
}

.success {
  background: #e8f5e8;
  border: 1px solid #4caf50;
  color: #2e7d32;
  padding: 15px;
  border-radius: 8px;
  margin-bottom: 20px;
}

/* =========================================
   Responsive Design & Media Queries
   ========================================= */

@media (max-width: 992px) {
  .monitor-layout {
    grid-template-columns: 1fr; /* Stack transcription and controls */
    height: auto;
  }

  .transcription-panel {
    min-height: 400px;
  }

  .control-panel {
    margin-top: 20px;
  }
}

@media (max-width: 768px) {
  body {
    padding: 10px;
  }

  .container {
    border-radius: 8px;
  }

  .header {
    flex-direction: column;
    align-items: flex-start;
    gap: 15px;
  }

  .session-info {
    flex-direction: column;
    align-items: flex-start;
    gap: 5px;
  }

  .session-info h1 {
    font-size: 1.5rem;
    margin: 0 0 10px 0;
  }

  .workflow-steps {
    flex-wrap: wrap;
  }

  .step {
    flex-basis: 50%; /* 2 steps per row on mobile */
    border-bottom: 1px solid #e5e5e7;
    border-right: 1px solid #e5e5e7;
    padding: 10px;
  }

  .step:nth-child(2n) {
    border-right: none;
  }

  .step-content {
    padding: 15px;
  }

  .form-row {
    grid-template-columns: 1fr; /* Stack form fields */
    gap: 15px;
  }

  .prompt-preview textarea {
    height: 300px; /* Keep height but maybe adjust if needed */
  }

  .btn-large {
    width: 100%; /* Full width buttons on mobile */
  }

  /* Buttons in reviewing step */
  #step2 > div[style*="flex"] {
    flex-direction: column;
  }

  #step2 .btn {
    width: 100%;
  }

  /* Step 3 buttons */
  #step3 > div[style*="flex"] {
    flex-direction: column;
  }

  #step3 .btn {
    width: 100%;
  }
}

@media (max-width: 480px) {
  .step {
    flex-basis: 100%; /* 1 step per row on very small screens */
    border-right: none;
  }

  .message {
    font-size: 13px;
  }
}
