/* Reset and Base Styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100vh;
  padding: 10px;
  color: #333;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  background: white;
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  overflow: hidden;
}

/* Main Content */
main {
  padding: 10px;
}

section {
  margin-bottom: 8px;
  padding: 10px;
  background: #f8f9fa;
  border-radius: 8px;
}

section h2 {
  margin-bottom: 8px;
  color: #667eea;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 1.1rem;
}

input, select {
  width: 100%;
  padding: 8px;
  font-size: 16px;
  border: 1px solid #ccc;
  border-radius: 4px;
  box-sizing: border-box;
}

label {
  display: block;
  margin-bottom: 5px;
  font-weight: bold;
}

/* Status Section */
.status-section {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 10px;
}

/* Patient Section */
.patient-section {
  background: white;
  padding: 10px;
  border-radius: 8px;
}

.patient-controls {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  flex-wrap: wrap;
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1;
  min-width: 250px;
}

.input-group label {
  font-weight: 500;
  font-size: 0.85rem;
  color: #333;
}

.patient-id-input {
  padding: 8px;
  border: 2px solid #e9ecef;
  border-radius: 6px;
  font-size: 0.9rem;
  background: #f8f9fa;
  color: #333;
}

.status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: 20px;
  background: white;
  font-size: 0.9rem;
}

.status-indicator {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  animation: pulse 2s infinite;
}

.status.loading .status-indicator {
  background: #ffc107;
}

.status.ready .status-indicator {
  background: #28a745;
}

.status.measuring .status-indicator {
  background: #007bff;
}

.status.error .status-indicator {
  background: #dc3545;
}

.status.error .status-text {
  font-size: 1.1rem;
  font-weight: 700;
  color: #dc3545;
}

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

.version {
  font-size: 0.9rem;
  color: #6c757d;
}

/* Video Section */
.video-section {
  background: #000;
  padding: 0;
}

.video-container {
  position: relative;
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
  aspect-ratio: 4/3;
  background: #000;
}

#video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1);
}

/* Measurement Section */
.measurement-controls {
  display: flex;
  display: none;
  gap: 8px;
  justify-content: center;
  margin-top: 8px;
}

/* Progress Section */
.progress-section {
  margin-top: 8px;
  padding: 10px;
  background: white;
  border-radius: 8px;
}

.progress-bar {
  width: 100%;
  height: 20px;
  background: #e9ecef;
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 6px;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
  width: 0%;
  transition: width 1s linear;
}

.time-remaining {
  text-align: center;
  font-weight: 500;
  color: #667eea;
}

/* Results Section */
.results {
  background: white;
  border-radius: 8px;
  padding: 10px;
}

.empty-state {
  text-align: center;
  color: #6c757d;
  padding: 15px;
  font-size: 0.85rem;
}

.result-card {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 12px;
  border-radius: 8px;
}

.result-card h3 {
  margin-bottom: 10px;
  font-size: 1rem;
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 8px;
}

.result-item {
  background: rgba(255, 255, 255, 0.1);
  padding: 8px;
  border-radius: 6px;
}

.result-item label {
  display: block;
  font-size: 0.8rem;
  opacity: 0.9;
  margin-bottom: 3px;
}

.result-item value {
  display: block;
  font-size: 1.2rem;
  font-weight: bold;
}

/* Buttons */
.btn {
  padding: 8px 16px;
  border: none;
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

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

.btn-primary {
  background: #667eea;
  color: white;
}

.btn-primary:hover:not(:disabled) {
  background: #5568d3;
}

.btn-secondary {
  background: #6c757d;
  color: white;
}

.btn-secondary:hover:not(:disabled) {
  background: #5a6268;
}

.btn-success {
  background: #28a745;
  color: white;
}

.btn-success:hover:not(:disabled) {
  background: #218838;
}

.btn-danger {
  background: #dc3545;
  color: white;
}

.btn-danger:hover:not(:disabled) {
  background: #c82333;
}

#warnings-display {
  background: #f8f9fa;
  color: #dc3545;
  text-align: center;
  padding: 8px;
  white-space: pre-line;
  font-size: 0.85rem;
}

#no-patient-selected-warning {
  background: #f8f9fa;
  color: #dc3545;
  text-align: center;
  padding: 8px;
  display: none;
  font-size: 0.85rem;
}

/* Responsive */
@media (max-width: 768px) {
  .container {
    border-radius: 0;
  }

  main {
    padding: 15px;
  }

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