/* CSS Variables for theming */
:root {
  --bg-color: #0d1117;
  --bg-gradient: linear-gradient(135deg, #0d1117 0%, #161b22 100%);
  --panel-bg: rgba(33, 38, 45, 0.4);
  --panel-border: rgba(255, 255, 255, 0.08);
  --text-primary: #f0f6fc;
  --text-secondary: #8b949e;
  
  --accent-blob-1: #6366f1;
  --accent-blob-2: #ec4899;
  
  --dropzone-bg: rgba(255, 255, 255, 0.03);
  --dropzone-border: rgba(255, 255, 255, 0.15);
  --dropzone-hover: rgba(99, 102, 241, 0.2);
  --dropzone-hover-border: #6366f1;
  
  --success-color: #2ea043;
  --success-bg: rgba(46, 160, 67, 0.15);
  --warning-color: #d29922;
  --warning-bg: rgba(210, 153, 34, 0.15);
  --danger-color: #f85149;
  --danger-bg: rgba(248, 81, 73, 0.15);

  --btn-bg: #21262d;
  --btn-hover: #30363d;
}

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

body {
  font-family: 'Outfit', sans-serif;
  background: var(--bg-gradient);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  overflow-y: auto;
  position: relative;
}

/* Atmospheric Blobs */
.blob {
  position: fixed;
  filter: blur(80px);
  z-index: -1;
  opacity: 0.5;
  border-radius: 50%;
  animation: float 10s ease-in-out infinite alternate;
}

.blob-1 {
  width: 400px;
  height: 400px;
  background: var(--accent-blob-1);
  top: -100px;
  left: -100px;
}

.blob-2 {
  width: 300px;
  height: 300px;
  background: var(--accent-blob-2);
  bottom: -50px;
  right: -50px;
  animation-delay: -5s;
}

@keyframes float {
  0% { transform: translateY(0) scale(1); }
  100% { transform: translateY(30px) scale(1.1); }
}

.app-container {
  width: 100%;
  max-width: 600px;
  margin: auto;
  padding: 2rem;
  z-index: 10;
}

.glass-panel {
  background: var(--panel-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--panel-border);
  border-radius: 24px;
  padding: 2.5rem;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

header {
  text-align: center;
  margin-bottom: 2rem;
}

h1 {
  font-size: 2rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  background: linear-gradient(to right, #fff, #a5b4fc);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

p {
  color: var(--text-secondary);
  font-weight: 300;
  line-height: 1.5;
}

/* Tabs */
.tabs {
  display: flex;
  gap: 1rem;
  margin-bottom: 2rem;
  padding: 0.5rem;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 12px;
}

.tab-btn {
  flex: 1;
  padding: 0.75rem 1rem;
  background: transparent;
  color: var(--text-secondary);
  border: none;
  border-radius: 8px;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s ease;
}

.tab-btn:hover {
  color: var(--text-primary);
}

.tab-btn.active {
  background: var(--panel-border);
  color: var(--text-primary);
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.tab-content {
  display: none;
  animation: fadeIn 0.5s ease;
}

.tab-content.active {
  display: block;
}

/* Upload Section */
.upload-section {
  display: block;
}

.drop-zone {
  border: 2px dashed var(--dropzone-border);
  border-radius: 16px;
  background: var(--dropzone-bg);
  padding: 3rem 2rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s ease;
  min-height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.drop-zone:hover, .drop-zone.dragover {
  border-color: var(--dropzone-hover-border);
  background: var(--dropzone-hover);
  transform: scale(1.02);
}

.drop-zone-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

.upload-icon {
  width: 48px;
  height: 48px;
  color: var(--text-secondary);
  transition: color 0.3s ease;
}

.drop-zone:hover .upload-icon, .drop-zone.dragover .upload-icon {
  color: var(--dropzone-hover-border);
}

.drop-text {
  font-size: 1.25rem;
  font-weight: 500;
}

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

/* Results Section & Live Camera Section */
.result-section, .live-section {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  animation: fadeIn 0.5s ease;
}

.hidden {
  display: none !important;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.image-preview-container {
  position: relative;
  width: 100%;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--panel-border);
  aspect-ratio: 4 / 3;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
}

#image-preview, #webcam-video {
  max-width: 100%;
  max-height: 100%;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 12px;
}

/* Avoid mirror effect on camera (laparoscopic views aren't mirrored) */
#webcam-video {
  transform: scaleX(1); 
}

.loading-overlay {
  position: absolute;
  inset: 0;
  background: rgba(13, 17, 23, 0.8);
  backdrop-filter: blur(4px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  color: white;
  z-index: 10;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(255,255,255,0.1);
  border-radius: 50%;
  border-top-color: var(--accent-blob-1);
  animation: spin 1s ease-in-out infinite;
}

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

.analysis-results {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.status-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.25rem;
  border-radius: 12px;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  transition: all 0.3s ease;
}

.status-indicator {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--text-secondary);
  box-shadow: 0 0 10px rgba(139, 148, 158, 0.5);
  transition: all 0.3s ease;
}

#result-title, #live-result-title {
  font-size: 1.25rem;
  font-weight: 600;
}

.metric {
  padding: 1rem;
  background: var(--panel-bg);
  border-radius: 12px;
  border: 1px solid var(--panel-border);
}

.metric-label {
  display: block;
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.progress-bar-container {
  width: 100%;
  height: 8px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 0.5rem;
}

.progress-bar {
  height: 100%;
  width: 0%;
  background: var(--accent-blob-1);
  border-radius: 4px;
  transition: width 0.5s cubic-bezier(0.22, 1, 0.36, 1), background-color 0.5s ease;
}

.metric-value {
  font-size: 1.125rem;
  font-weight: 500;
  display: block;
  text-align: right;
  transition: color 0.3s ease;
}

.secondary-btn {
  background: var(--btn-bg);
  color: #fff;
  border: 1px solid var(--panel-border);
  padding: 0.75rem 1.5rem;
  border-radius: 8px;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  margin-top: 0.5rem;
}

.secondary-btn:hover {
  background: var(--btn-hover);
  border-color: rgba(255,255,255,0.2);
}

/* Modifiers for status */
.status-achieved {
  background: var(--success-bg) !important;
  border-color: rgba(46, 160, 67, 0.3) !important;
}

.status-achieved .status-indicator {
  background: var(--success-color);
  box-shadow: 0 0 15px var(--success-color);
}

.status-not-achieved {
  background: var(--danger-bg) !important;
  border-color: rgba(248, 81, 73, 0.3) !important;
}

.status-not-achieved .status-indicator {
  background: var(--danger-color);
  box-shadow: 0 0 15px var(--danger-color);
}
