/*
==========================================================================
EYETURN CLOUD - STRABISMUS ASSESSMENT APPLICATION
==========================================================================
Modern, responsive CSS for a medical strabismus assessment web application

TABLE OF CONTENTS:
1. Global Styles & CSS Variables
2. Base Typography & Container Styles  
3. File Upload Components
4. Control Panel & Backend Management
5. Toggle Switches & Status Indicators
6. Model Selection Components
7. Timer & Session Management
8. Buttons & Interactive Elements
9. Progress Indicators
10. Canvas & Image Visualization
11. Results & Data Display
12. Performance Timings
13. Animations & Effects
14. Accessibility Features
15. Mobile Responsive Design (Media Queries)
==========================================================================
*/

/* ==========================================================================
   1. GLOBAL STYLES & CSS VARIABLES
   ========================================================================== */
:root {
  --primary-color: #39D2B4;
  --secondary-color: #34495E;
  --accent-color: #34A7C1;
  --light-gray: #F8F8F8;
  --medium-gray: #999;
  --dark-gray: #333;
  --white: #fff;
  --border-radius: 8px;
  --shadow-light: 0 2px 4px rgba(0, 0, 0, 0.1);
  --shadow-medium: 0 4px 6px rgba(0, 0, 0, 0.1);
  --transition: all 0.3s ease;
  --spacing-xs: 0.5rem;
  --spacing-sm: 1rem;
  --spacing-md: 1.5rem;
  --spacing-lg: 2rem;
  --spacing-xl: 3rem;
}

/* ==========================================================================
   2. BASE TYPOGRAPHY & CONTAINER STYLES
   ========================================================================== */
html {
  font-size: 16px;
}

@media (max-width: 768px) {
  html {
    font-size: 14px;
  }
}

/* Main container improvements */
.container {
  padding-left: var(--spacing-sm);
  padding-right: var(--spacing-sm);
}

@media (max-width: 576px) {
  .container {
    padding-left: var(--spacing-xs);
    padding-right: var(--spacing-xs);
  }
}

/* ==========================================================================
   3. FILE UPLOAD COMPONENTS
   ========================================================================== */
.img-preview {
  width: 100%;
  max-width: 300px;
  height: auto;
  position: relative;
  border: 3px solid var(--light-gray);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-medium);
  margin: var(--spacing-md) auto;
  overflow: hidden;
  background: var(--white);
}

.img-preview > div {
  width: 100%;
  height: 0;
  padding-bottom: 100%;
  background-size: cover;
  background-repeat: no-repeat;
  background-position: center;
  border-radius: calc(var(--border-radius) - 3px);
}

@media (max-width: 576px) {
  .img-preview {
    max-width: 250px;
    margin: var(--spacing-sm) auto;
  }
}

/* Hide the actual file input */
input[type="file"] {
  display: none;
}

/* Enhanced Upload Label */
.upload-label {
  display: inline-block;
  padding: var(--spacing-sm) var(--spacing-lg);
  background: var(--primary-color);
  color: var(--white);
  font-size: 1rem;
  font-weight: 600;
  text-decoration: none;
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-light);
  transition: var(--transition);
  cursor: pointer;
  border: none;
  user-select: none;
}

.upload-label:hover {
  background: var(--secondary-color);
  color: var(--white);
  transform: translateY(-2px);
  box-shadow: var(--shadow-medium);
}

.upload-label:active {
  transform: translateY(0);
  box-shadow: var(--shadow-light);
}

@media (max-width: 576px) {
  .upload-label {
    padding: var(--spacing-xs) var(--spacing-md);
    font-size: 0.9rem;
    width: 100%;
    max-width: 250px;
  }
}

/* Drag and Drop Area */
.drag-drop-area {
  border: 3px dashed var(--medium-gray);
  border-radius: var(--border-radius);
  background: var(--white);
  padding: var(--spacing-xl);
  margin: var(--spacing-md) auto;
  max-width: 500px;
  text-align: center;
  transition: var(--transition);
  cursor: pointer;
  position: relative;
  min-height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.drag-drop-area:hover {
  border-color: var(--primary-color);
  background: #f0fdf8;
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(57, 210, 180, 0.2);
}

.drag-drop-area.drag-over {
  border-color: var(--primary-color);
  background: #f0fdf8;
  border-style: solid;
  box-shadow: 0 0 25px rgba(57, 210, 180, 0.3);
}

/* Image preview state for drag drop area */
.drag-drop-area.has-image {
  border: 3px solid var(--primary-color);
  padding: 0;
  min-height: 300px;
  max-height: 500px;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  background-color: #f8f9fa;
  box-shadow: 0 6px 16px rgba(57, 210, 180, 0.15);
}

.drag-drop-area.has-image:hover {
  transform: none;
  box-shadow: 0 8px 24px rgba(57, 210, 180, 0.25);
}

/* Overlay for image preview */
.drag-drop-image-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: var(--transition);
  z-index: 1;
}

.drag-drop-area.has-image:hover .drag-drop-image-overlay {
  opacity: 1;
}

.drag-drop-overlay-content {
  text-align: center;
  color: var(--white);
  font-weight: 600;
}

.drag-drop-overlay-content .drag-drop-icon {
  color: var(--white);
  font-size: 2rem;
  margin-bottom: var(--spacing-xs);
}

.drag-drop-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--spacing-sm);
  pointer-events: none;
}

.drag-drop-icon {
  font-size: 3rem;
  color: var(--medium-gray);
  transition: var(--transition);
}

.drag-drop-area:hover .drag-drop-icon,
.drag-drop-area.drag-over .drag-drop-icon {
  color: var(--primary-color);
  transform: scale(1.1);
}

.drag-drop-text {
  font-size: 1.1rem;
  color: var(--secondary-color);
  line-height: 1.4;
}

.drag-drop-text strong {
  font-weight: 600;
  color: var(--secondary-color);
}

.drag-drop-formats {
  font-size: 0.85rem;
  color: var(--medium-gray);
  margin-top: var(--spacing-xs);
}

@media (max-width: 576px) {
  .drag-drop-area {
    padding: var(--spacing-lg);
    min-height: 150px;
    max-width: 90%;
    border-width: 4px;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.15);
  }
  
  .drag-drop-area:hover {
    box-shadow: 0 10px 24px rgba(57, 210, 180, 0.25);
  }
  
  .drag-drop-area.has-image {
    border-width: 4px;
    box-shadow: 0 8px 20px rgba(57, 210, 180, 0.2);
  }
  
  .drag-drop-area.has-image:hover {
    box-shadow: 0 10px 28px rgba(57, 210, 180, 0.3);
  }
  
  .drag-drop-icon {
    font-size: 2.5rem;
  }
  
  .drag-drop-text {
    font-size: 1rem;
  }
  
  .drag-drop-formats {
    font-size: 0.8rem;
  }
}

/* Image change hint text */
.image-change-hint {
  font-size: 0.75rem;
  color: var(--medium-gray);
  margin-top: var(--spacing-xs);
  opacity: 0.7;
  font-style: italic;
  transition: var(--transition);
}

.image-change-hint:hover {
  opacity: 1;
}

@media (max-width: 576px) {
  .image-change-hint {
    font-size: 0.7rem;
  }
}

/* ==========================================================================
   4. CONTROL PANEL & BACKEND MANAGEMENT
   ========================================================================== */
.control-panel {
  background: var(--white);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-light);
  padding: var(--spacing-md);
  margin: var(--spacing-md) auto;
  max-width: 600px;
}

/* Unified Control Panel - New Compact Design */
.unified-control-panel {
  background: linear-gradient(135deg, var(--white) 0%, #f8f9fa 100%);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-medium);
  padding: var(--spacing-md);
  margin: var(--spacing-md) auto;
  max-width: 480px;
  border: 1px solid #e3e6ea;
  position: relative;
}

/* Control Panel Title with Icon */
.control-panel-title {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--spacing-xs);
  margin-bottom: var(--spacing-md);
}

.title-icon {
  width: 48px;
  height: 48px;
  object-fit: contain;
  filter: none;
  transition: var(--transition);
}

/* Optional: Add a subtle glow effect to the icon */
.title-icon:hover {
  filter: drop-shadow(0 2px 4px rgba(57, 210, 180, 0.3));
  transform: scale(1.05);
}

@media (max-width: 576px) {
  .title-icon {
    width: 40px;
    height: 40px;
  }
  
  .control-panel-title {
    font-size: 1rem;
    gap: 6px;
  }
}

.control-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--spacing-sm);
  flex-wrap: wrap;
  width: 100%;
}

.control-item {
  display: flex;
  align-items: center;
  gap: var(--spacing-xs);
  flex: 1;
  min-width: 120px;
  max-width: 100%;
  padding: var(--spacing-xs);
  background: rgba(255, 255, 255, 0.7);
  border-radius: calc(var(--border-radius) / 2);
  border: 1px solid #e9ecef;
  transition: var(--transition);
  overflow: hidden;
}

.control-item:hover {
  background: rgba(255, 255, 255, 1);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  transform: translateY(-1px);
}

.status-display {
  display: flex;
  align-items: center;
  gap: var(--spacing-xs);
  font-weight: 600;
  color: var(--secondary-color);
  font-size: 0.85rem;
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

.status-text {
  min-width: 50px;
  max-width: 90px;
  font-size: 0.8rem;
  letter-spacing: 0.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.timer-display-compact {
  display: flex;
  align-items: center;
  gap: var(--spacing-xs);
  font-weight: 700;
  color: var(--accent-color);
  font-size: 0.85rem;
  flex: 1;
}

.timer-icon {
  font-size: 0.9rem;
}

.timer-text {
  min-width: 45px;
  font-family: 'Courier New', monospace;
  font-size: 0.8rem;
}

.reset-btn-compact {
  background: linear-gradient(135deg, var(--primary-color), #2eb89e);
  color: var(--white);
  border: none;
  border-radius: 50%;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
  font-size: 1rem;
  box-shadow: 0 2px 4px rgba(57, 210, 180, 0.2);
  flex-shrink: 0;
}

.reset-btn-compact:hover {
  background: linear-gradient(135deg, var(--secondary-color), #2c3e50);
  transform: scale(1.1) rotate(15deg);
  box-shadow: 0 4px 12px rgba(57, 210, 180, 0.3);
}

.reset-btn-compact:active {
  transform: scale(0.95) rotate(0deg);
  transition: transform 0.1s ease;
}

@media (max-width: 576px) {
  .unified-control-panel {
    margin: var(--spacing-sm);
    padding: var(--spacing-sm);
    max-width: none;
  }
  
  .control-row {
    flex-direction: column;
    gap: var(--spacing-sm);
    align-items: stretch;
  }
  
  .control-item {
    justify-content: space-between;
    min-width: auto;
    background: rgba(255, 255, 255, 0.9);
    padding: var(--spacing-sm);
  }
  
  .status-display,
  .timer-display-compact {
    font-size: 0.8rem;
  }
  
  .status-text,
  .timer-text {
    font-size: 0.75rem;
  }
  
  .reset-btn-compact {
    width: 28px;
    height: 28px;
    font-size: 0.7rem;
  }
}

.status-section {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-sm);
  margin-bottom: var(--spacing-md);
}

.status-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--spacing-sm);
  background: var(--light-gray);
  border-radius: calc(var(--border-radius) / 2);
  border-left: 4px solid var(--primary-color);
}

.status-label {
  font-weight: 600;
  color: var(--secondary-color);
  font-size: 0.95rem;
}

.status-value {
  font-weight: 500;
  color: var(--dark-gray);
}

@media (max-width: 576px) {
  .control-panel {
    margin: var(--spacing-sm);
    padding: var(--spacing-sm);
  }
  
  .status-item {
    flex-direction: column;
    text-align: center;
    gap: var(--spacing-xs);
  }
}

/* ==========================================================================
   5. TOGGLE SWITCHES & STATUS INDICATORS  
   ========================================================================== */
.toggle-container {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: var(--spacing-sm);
  margin: var(--spacing-sm) 0;
}

.toggle-label {
  font-weight: 600;
  color: var(--secondary-color);
  font-size: 0.95rem;
}

/* Status Indicators */
.status-indicator {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: var(--spacing-xs);
}

.status-active {
  background-color: #28a745;
  box-shadow: 0 0 8px rgba(40, 167, 69, 0.5);
}

.status-inactive {
  background-color: #dc3545;
}

.status-loading {
  background-color: #ffc107;
  animation: pulse 1.5s infinite;
}

@media (max-width: 576px) {
  .toggle-container {
    flex-direction: column;
    gap: var(--spacing-xs);
  }
}

/* Modern On/Off Switch - Compact Version */
.onoffswitch {
  position: relative; 
  width: 50px;
  height: 26px;
  flex-shrink: 0;
  flex-grow: 0;
  max-width: 50px;
}

.onoffswitch-checkbox {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.onoffswitch-label {
  display: block; 
  overflow: hidden; 
  cursor: pointer;
  border: 2px solid #ddd;
  border-radius: 20px;
  height: 26px;
  transition: var(--transition);
  background: #f5f5f5;
}

.onoffswitch-label:hover {
  border-color: var(--primary-color);
  background: #fff;
}

.onoffswitch-inner {
  display: block; 
  width: 200%; 
  margin-left: -100%;
  transition: margin 0.3s ease-in-out;
}

.onoffswitch-inner:before,
.onoffswitch-inner:after {
  display: block; 
  float: left; 
  width: 50%; 
  height: 22px; 
  padding: 0; 
  line-height: 22px;
  font-size: 10px; 
  color: var(--white); 
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; 
  font-weight: 700;
  box-sizing: border-box;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.onoffswitch-inner:before {
  content: "ON";
  background: linear-gradient(135deg, #28a745, #20c997);
  color: var(--white);
  padding-left: 4px;
  text-align: left;
}

.onoffswitch-inner:after {
  content: "OFF";
  background: linear-gradient(135deg, #f8d7da, #f5c6cb);
  color: #721c24;
  padding-right: 4px;
  text-align: right;
}

.onoffswitch-switch {
  display: block; 
  width: 18px; 
  height: 18px;
  margin: 2px;
  background: linear-gradient(135deg, var(--white), #f8f9fa);
  position: absolute; 
  top: 0; 
  bottom: 0;
  right: 26px;
  border: 1px solid #ddd;
  border-radius: 50%;
  transition: all 0.3s ease-in-out; 
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.onoffswitch-checkbox:checked + .onoffswitch-label .onoffswitch-inner {
  margin-left: 0;
}

.onoffswitch-checkbox:checked + .onoffswitch-label .onoffswitch-switch {
  right: 2px; 
  background: linear-gradient(135deg, var(--white), #f1f2f6);
  border-color: #28a745;
  box-shadow: 0 2px 6px rgba(40, 167, 69, 0.3);
}

.onoffswitch-checkbox:checked + .onoffswitch-label {
  border-color: #28a745;
  background: #fff;
}

/* Enhanced disabled state */
.onoffswitch-checkbox:disabled + .onoffswitch-label {
  opacity: 0.6;
  cursor: not-allowed;
  background: #f5f5f5;
}

.onoffswitch-checkbox:disabled + .onoffswitch-label .onoffswitch-switch {
  box-shadow: none;
  background: #e9ecef;
}

@media (max-width: 576px) {
  .onoffswitch {
    width: 46px;
    height: 24px;
  }
  
  .onoffswitch-label {
    height: 24px;
  }
  
  .onoffswitch-inner:before,
  .onoffswitch-inner:after {
    height: 20px;
    line-height: 20px;
    font-size: 9px;
  }
  
  .onoffswitch-inner:before {
    padding-left: 3px;
    text-align: left;
  }
  
  .onoffswitch-inner:after {
    padding-right: 3px;
    text-align: right;
  }
  
  .onoffswitch-switch {
    width: 16px;
    height: 16px;
    right: 24px;
  }
  
  .onoffswitch-checkbox:checked + .onoffswitch-label .onoffswitch-switch {
    right: 2px;
  }
}

/* Enhanced Model Selection */
.model-selection-container {
  background: var(--white);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-light);
  padding: var(--spacing-md);
  margin: var(--spacing-md) auto;
  max-width: 400px;
}

.model-selection-dropdown-container {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: var(--spacing-sm);
  flex-wrap: wrap;
}

.model-selection-label {
  font-weight: 600;
  color: var(--secondary-color);
  font-size: 0.95rem;
  white-space: nowrap;
}

#modelSelectionDropdown {
  min-width: 140px;
  padding: var(--spacing-xs) var(--spacing-sm);
  border: 2px solid var(--light-gray);
  border-radius: calc(var(--border-radius) / 2);
  background: var(--white);
  color: var(--dark-gray);
  font-size: 0.95rem;
  font-weight: 500;
  box-shadow: var(--shadow-light);
  transition: var(--transition);
  cursor: pointer;
}

#modelSelectionDropdown:focus {
  border-color: var(--primary-color);
  outline: none;
  box-shadow: 0 0 0 3px rgba(57, 210, 180, 0.1);
}

#modelSelectionDropdown:hover {
  border-color: var(--primary-color);
}

/* Model group styling for unified configuration */
.model-group {
  margin-bottom: var(--spacing-sm);
}

.model-label {
  font-weight: 600;
  color: var(--secondary-color);
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
  display: block;
  text-align: center;
}

/* Radio group styling for staring eye selection */
.radio-group {
  display: flex;
  justify-content: center;
  gap: var(--spacing-md);
  margin-bottom: 0.5rem;
}

.form-check-inline {
  margin-right: 0;
}

.form-check-input {
  margin-top: 0.2rem;
}

.form-check-label {
  font-weight: 500;
  color: var(--secondary-color);
  cursor: pointer;
}

.form-check-input:checked {
  background-color: var(--primary-color);
  border-color: var(--primary-color);
}

/* Inline styles moved from templates/index.html */
.card {
  border: 1px solid #ddd;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.card-title {
  font-weight: bold;
  color: #34495e;
}

.download-btn {
  padding: 10px 20px;
  font-weight: 500;
  border-radius: 6px;
  transition: all 0.3s ease;
  border: 2px solid #007bff;
  background-color: transparent;
  color: #007bff;
}

.download-btn:hover {
  background-color: #007bff;
  color: white;
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0, 123, 255, 0.3);
}

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

#download-section {
  margin-top: 15px;
  padding: 15px;
  background-color: #f8f9fa;
  border-radius: 8px;
  border: 1px solid #e9ecef;
}

.debug-label-toggle-container {
  display: flex;
  align-items: center;
  justify-content: center; /* center label and toggle horizontally */
  gap: 8px; /* small gap to keep label and toggle close */
  width: 100%;
}

.debug-switch {
  transform: scale(0.8);
}

/* Ensure label vertically centers next to the toggle */
.debug-label-toggle-container .model-label {
  display: inline-flex;
  align-items: center;
  margin: 0; /* remove default label margins that can shift vertical alignment */
}

#eyeClippingDropdown {
  min-width: 140px;
  padding: var(--spacing-xs) var(--spacing-sm);
  border: 2px solid var(--light-gray);
  border-radius: calc(var(--border-radius) / 2);
  background: var(--white);
  color: var(--dark-gray);
  font-size: 0.95rem;
  font-weight: 500;
  box-shadow: var(--shadow-light);
  transition: var(--transition);
  cursor: pointer;
}

#eyeClippingDropdown:focus {
  border-color: var(--primary-color);
  outline: none;
  box-shadow: 0 0 0 3px rgba(57, 210, 180, 0.1);
}

#eyeClippingDropdown:hover {
  border-color: var(--primary-color);
}

/* Model timing information styling */
#model-timing-info,
#eye-clipping-info,
#debug-info {
  color: var(--accent-color) !important;
  font-weight: 600;
  font-size: 0.85rem;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

#model-timing-info::before {
  content: "⏱️";
  font-size: 0.9rem;
}

@media (max-width: 576px) {
  .model-selection-container {
    margin: var(--spacing-sm);
    padding: var(--spacing-sm);
  }
  
  .model-selection-dropdown-container {
    flex-direction: column;
    gap: var(--spacing-xs);
  }
  
  #modelSelectionDropdown {
    width: 100%;
    max-width: 200px;
  }
}

/* Timer Section */
.timer-section {
  background: var(--white);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-light);
  padding: var(--spacing-md);
  margin: var(--spacing-md) auto;
  max-width: 400px;
  text-align: center;
}

.timer-display {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--accent-color);
  margin: var(--spacing-sm) 0;
}

.timer-reset-btn {
  background: var(--primary-color);
  color: var(--white);
  border: none;
  padding: var(--spacing-xs) var(--spacing-md);
  border-radius: calc(var(--border-radius) / 2);
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  transition: var(--transition);
  box-shadow: var(--shadow-light);
}

.timer-reset-btn:hover {
  background: var(--secondary-color);
  transform: translateY(-1px);
  box-shadow: var(--shadow-medium);
}

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

@media (max-width: 576px) {
  .timer-section {
    margin: var(--spacing-sm);
    padding: var(--spacing-sm);
  }
  
  .timer-display {
    font-size: 1.25rem;
  }
  
  .timer-reset-btn {
    width: 100%;
    max-width: 150px;
  }
}

/* Enhanced Buttons */
.btn {
  border-radius: var(--border-radius);
  font-weight: 600;
  transition: var(--transition);
  border: none;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  text-align: center;
  box-shadow: var(--shadow-light);
}

.btn-primary {
  background: var(--primary-color);
  border: none;
  color: var(--white);
  padding: var(--spacing-sm) var(--spacing-lg);
  font-size: 1.1rem;
}

.btn-primary:hover:not(:disabled) {
  background: var(--secondary-color);
  border: none;
  transform: translateY(-2px);
  box-shadow: var(--shadow-medium);
}

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

.btn-primary:disabled {
  background: var(--medium-gray);
  cursor: not-allowed;
  opacity: 0.7;
}

/* Backend inactive state for process button */
.btn-primary.backend-inactive {
  background: linear-gradient(135deg, #ffa726, #ff7043);
  border: none;
  cursor: pointer;
  opacity: 1;
}

.btn-primary.backend-inactive:hover {
  background: linear-gradient(135deg, #ff9800, #ff5722);
  border: none;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(255, 152, 0, 0.3);
}

/* Backend active state for process button - green like upload button */
.btn-primary.backend-active {
  background: var(--primary-color);
  border: none;
  cursor: pointer;
  opacity: 1;
}

.btn-primary.backend-active:hover {
  background: var(--secondary-color);
  border: none;
  transform: translateY(-2px);
  box-shadow: var(--shadow-medium);
}

.btn-lg {
  padding: var(--spacing-md) var(--spacing-xl);
  font-size: 1.2rem;
}

@media (max-width: 576px) {
  .btn-lg {
    width: 100%;
    max-width: 280px;
    padding: var(--spacing-sm) var(--spacing-lg);
    font-size: 1rem;
  }
}

/* Enhanced Progress Bar */
.progress {
  background-color: #e9ecef;
  border-radius: var(--border-radius);
  overflow: hidden;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1);
}

.progress-bar {
  background: linear-gradient(45deg, var(--primary-color), var(--accent-color));
  border-radius: var(--border-radius);
  font-weight: 600;
  font-size: 0.9rem;
  transition: width 0.4s ease;
}

@media (max-width: 576px) {
  .progress {
    margin: var(--spacing-sm) 0;
  }
  
  .progress-bar {
    font-size: 0.8rem;
  }
}

/* Enhanced Canvas Section */
.canvas-section {
  background: var(--white);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-light);
  padding: var(--spacing-md);
  margin: var(--spacing-md) 0;
}

.canvas-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--spacing-md);
  justify-items: center;
}

.canvas-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--spacing-sm);
}

.canvas-item canvas {
  border: 2px solid var(--light-gray);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-light);
  max-width: 100%;
  height: auto;
}

.canvas-label {
  font-weight: 600;
  color: var(--secondary-color);
  font-size: 0.9rem;
}

@media (max-width: 768px) {
  .canvas-container {
    grid-template-columns: 1fr;
    gap: var(--spacing-sm);
  }
  
  .canvas-item canvas {
    width: 100%;
    max-width: 320px;
  }
}

@media (max-width: 576px) {
  .canvas-section {
    margin: var(--spacing-sm) 0;
    padding: var(--spacing-sm);
  }
  
  .canvas-item canvas {
    max-width: 280px;
  }
}

/* Enhanced Results Section - Compact Version */
.results-section {
  background: var(--white);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-light);
  padding: var(--spacing-md);
  margin: var(--spacing-md) 0;
  text-align: center;
}

.results-section h5 {
  margin-bottom: var(--spacing-sm);
  font-size: 1.1rem;
}

.result-item {
  background: var(--light-gray);
  border-radius: calc(var(--border-radius) / 2);
  padding: var(--spacing-sm);
  margin: var(--spacing-xs) 0;
  border-left: 3px solid var(--primary-color);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--secondary-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.result-item strong {
  font-size: 0.85rem;
  flex: 1;
  text-align: left;
}

.result-value {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--accent-color);
  font-family: 'Courier New', monospace;
}

@media (max-width: 576px) {
  .results-section {
    margin: var(--spacing-sm) 0;
    padding: var(--spacing-sm);
  }
  
  .results-section h5 {
    font-size: 1rem;
    margin-bottom: var(--spacing-xs);
  }
  
  .result-item {
    font-size: 0.85rem;
    padding: var(--spacing-xs);
    flex-direction: column;
    text-align: center;
    gap: var(--spacing-xs);
  }
  
  .result-item strong {
    font-size: 0.8rem;
    text-align: center;
  }
  
  .result-value {
    font-size: 1rem;
  }
}

/* Enhanced Timings Table */
.timings-section {
  background: var(--white);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-light);
  padding: var(--spacing-lg);
  margin: var(--spacing-lg) 0;
}

.timings-section h4 {
  color: var(--secondary-color);
  margin-bottom: var(--spacing-md);
  font-weight: 700;
}

.timings-table {
  width: 100%;
  border-collapse: collapse;
  border-radius: var(--border-radius);
  overflow: hidden;
  box-shadow: var(--shadow-light);
}

.timings-table th,
.timings-table td {
  padding: var(--spacing-sm);
  text-align: left;
  border-bottom: 1px solid #dee2e6;
}

.timings-table th {
  background: var(--primary-color);
  color: var(--white);
  font-weight: 600;
}

.timings-table tbody tr:hover {
  background: var(--light-gray);
}

@media (max-width: 576px) {
  .timings-section {
    margin: var(--spacing-sm) 0;
    padding: var(--spacing-md);
  }
  
  .timings-table th,
  .timings-table td {
    padding: var(--spacing-xs);
    font-size: 0.9rem;
  }
}

/* Responsive Improvements */
@media (max-width: 576px) {
  .row {
    margin: 0;
  }
  
  .col-md-6 {
    padding: var(--spacing-xs);
  }
  
  h2 {
    font-size: 1.5rem;
    margin-bottom: var(--spacing-md);
  }
  
  h3 {
    font-size: 1.2rem;
  }
  
  h4 {
    font-size: 1.1rem;
  }
}

/* Focus and accessibility improvements */
*:focus {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
}

/* Mobile-first responsive breakpoints */
@media (max-width: 480px) {
  /* Extra small screens (phones in portrait) */
  .container {
    padding-left: var(--spacing-xs);
    padding-right: var(--spacing-xs);
  }
  
  .control-panel,
  .model-selection-container,
  .timer-section {
    margin: var(--spacing-xs);
    padding: var(--spacing-sm);
  }
  
  .canvas-item canvas {
    width: 100%;
    max-width: 260px;
    height: auto;
  }
  
  .btn-lg {
    font-size: 0.95rem;
    padding: var(--spacing-sm) var(--spacing-md);
  }
  
  .timer-display {
    font-size: 1.1rem;
  }
}

@media (min-width: 481px) and (max-width: 768px) {
  /* Small screens (phones in landscape, small tablets) */
  .canvas-container {
    gap: var(--spacing-md);
  }
  
  .canvas-item canvas {
    max-width: 300px;
  }
}

@media (min-width: 769px) {
  /* Medium screens and up (tablets, desktops) */
  .control-panel,
  .model-selection-container,
  .timer-section {
    max-width: 500px;
  }
  
  .canvas-container {
    gap: var(--spacing-lg);
  }
}

/* High DPI/Retina display optimizations */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  .img-preview,
  .canvas-item canvas {
    image-rendering: -webkit-optimize-contrast;
  }
}

/* Dark mode support (if browser/system supports it) */
@media (prefers-color-scheme: dark) {
  :root {
    --light-gray: #2c2c2c;
    --medium-gray: #666;
    --dark-gray: #e0e0e0;
    --white: #1a1a1a;
  }
  
  body {
    background-color: #121212;
    color: #e0e0e0;
  }
  
  .control-panel,
  .model-selection-container,
  .timer-section,
  .canvas-section,
  .results-section,
  .timings-section {
    background-color: #1e1e1e;
    border: 1px solid #333;
  }
}

/* Print styles */
@media print {
  .navbar,
  .control-panel,
  .timer-section,
  #process-button-container,
  #progress-container {
    display: none !important;
  }
  
  .results-section,
  .timings-section {
    page-break-inside: avoid;
  }
}

/* Loading states and animations */
@keyframes pulse {
  0% { opacity: 1; }
  50% { opacity: 0.5; }
  100% { opacity: 1; }
}

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

/* ==========================================================================
   13. ANIMATIONS & EFFECTS
   ========================================================================== */
@keyframes pulse-scale {
  0% { transform: scale(1); }
  50% { transform: scale(1.05); }
  100% { transform: scale(1); }
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

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

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.loading {
  animation: pulse 2s infinite;
}

.slide-in {
  animation: slideInUp 0.5s ease-out;
}

.fade-in {
  animation: fadeIn 0.3s ease-out;
}

/* ==========================================================================
   14. UTILITY CLASSES & HELPER EFFECTS
   ========================================================================== */
.hover-lift:hover {
  transform: translateY(-2px);
  transition: var(--transition);
}

.hover-scale:hover {
  transform: scale(1.02);
  transition: var(--transition);
}

/* ==========================================================================
   15. ACCESSIBILITY FEATURES
   ========================================================================== */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  top: -40px;
  left: 6px;
  background: var(--primary-color);
  color: var(--white);
  padding: 8px;
  text-decoration: none;
  z-index: 1000;
  border-radius: 4px;
}

.skip-link:focus {
  top: 6px;
}

/* ==========================================================================
   FLOATING NOTIFICATION STYLES
   ========================================================================== */
.floating-notification {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 9999;
  max-width: 400px;
  min-width: 300px;
  background: linear-gradient(135deg, #ff6b6b, #ee5a52);
  border-radius: var(--border-radius);
  box-shadow: 0 8px 32px rgba(255, 107, 107, 0.3);
  transform: translateY(-100px);
  opacity: 0;
  transition: all 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
  border: 1px solid rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(10px);
}

/* Type variants */
.floating-notification.notification-error {
  background: linear-gradient(135deg, #ff6b6b, #ee5a52);
  box-shadow: 0 8px 32px rgba(255, 107, 107, 0.3);
}

.floating-notification.notification-warning {
  background: linear-gradient(135deg, #f6d365, #fda085);
  box-shadow: 0 8px 32px rgba(253, 160, 133, 0.3);
}

.floating-notification.notification-success {
  background: linear-gradient(135deg, #42e695, #3bb2b8);
  box-shadow: 0 8px 32px rgba(66, 230, 149, 0.3);
}

.floating-notification.notification-info {
  background: linear-gradient(135deg, #5ee7df, #b490ca);
  box-shadow: 0 8px 32px rgba(94, 231, 223, 0.3);
}

.floating-notification.show {
  transform: translateY(0);
  opacity: 1;
}

.floating-notification.hide {
  transform: translateY(-100px);
  opacity: 0;
}

.notification-content {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  padding: var(--spacing-md);
  color: var(--white);
}

.notification-icon {
  font-size: 1.5rem;
  flex-shrink: 0;
  animation: pulse-scale 2s infinite;
}

.notification-text {
  flex: 1;
  font-weight: 600;
  font-size: 0.95rem;
  line-height: 1.4;
}

.notification-close {
  background: none;
  border: none;
  color: var(--white);
  font-size: 1.5rem;
  font-weight: 700;
  cursor: pointer;
  padding: 0;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: var(--transition);
  flex-shrink: 0;
}

.notification-close:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: scale(1.1);
}

/* Mobile responsive notification */
@media (max-width: 576px) {
  .floating-notification {
    top: 10px;
    right: 10px;
    left: 10px;
    max-width: none;
    min-width: auto;
  }
  
  .notification-content {
    padding: var(--spacing-sm);
  }
  
  .notification-text {
    font-size: 0.85rem;
  }
  
  .notification-icon {
    font-size: 1.2rem;
  }
}

/* ==========================================================================
   BATCH PROCESSING PAGE
   ========================================================================== */
.batch-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: var(--spacing-sm);
  align-items: stretch;
}

.batch-tile {
  position: relative;
  border: 2px dashed var(--light-gray);
  border-radius: var(--border-radius);
  background: var(--white);
  box-shadow: var(--shadow-light);
  padding: var(--spacing-sm);
  min-height: 140px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--spacing-xs);
  text-align: center;
  transition: var(--transition);
}

.batch-tile:hover {
  border-color: var(--primary-color);
  box-shadow: var(--shadow-medium);
  transform: translateY(-2px);
}

.batch-add-tile {
  background: linear-gradient(135deg, #f8f9fa, #ffffff);
  border-style: dashed;
  cursor: pointer;
}

.batch-add-tile.is-dragover {
  border-color: var(--primary-color);
  background: #f0fdf8;
  box-shadow: 0 8px 20px rgba(57, 210, 180, 0.2);
}

.batch-add-plus {
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--primary-color);
  line-height: 1;
}

.batch-add-text {
  font-weight: 600;
  color: var(--secondary-color);
  font-size: 0.9rem;
}

.batch-thumb {
  width: 100%;
  height: 90px;
  object-fit: cover;
  border-radius: calc(var(--border-radius) - 2px);
  border: 1px solid var(--light-gray);
}

.batch-filename {
  font-size: 0.75rem;
  color: var(--secondary-color);
  word-break: break-word;
}

.batch-delete {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: none;
  background: rgba(52, 73, 94, 0.9);
  color: var(--white);
  font-size: 0.75rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.batch-delete:hover {
  background: #2c3e50;
}

.batch-results-table .batch-table-preview {
  width: 54px;
  height: 40px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--light-gray);
}

.batch-cell-link {
  background: none;
  border: none;
  color: var(--accent-color);
  padding: 0;
  cursor: pointer;
  text-decoration: underline;
  font: inherit;
  text-align: left;
}

.batch-preview-clickable {
  cursor: pointer;
}

.batch-preview-clickable:focus {
  outline: 2px solid var(--accent-color);
  outline-offset: 2px;
}

.batch-results-table thead th {
  white-space: nowrap;
}

.batch-results-table thead tr:first-child th:nth-child(1) {
  text-align: left;
}

.batch-results-table thead tr:first-child th:nth-child(2) {
  text-align: center;
}

.batch-results-table thead tr:first-child th:nth-child(3) {
  text-align: left;
}

.batch-results-table tbody td:nth-child(1) {
  text-align: left;
}

.batch-results-table tbody td:nth-child(2) {
  text-align: center;
}

.batch-results-table thead {
  display: table-header-group;
}

.batch-results-table thead tr:first-child th {
  background-color: #e9ecef;
  color: #495057;
  font-weight: 700;
  border-bottom: 1px solid #dee2e6;
}

.batch-results-table tbody td {
  vertical-align: middle;
}

.batch-strabis-cell {
  min-width: 150px;
  font-weight: 600;
}

.batch-preview-action-cell,
.batch-download-action-cell {
  width: 64px;
  text-align: center;
}

.batch-icon-btn {
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  font-size: 1rem;
  line-height: 1;
}

.batch-result-modal {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.batch-result-panel {
  width: min(96vw, 1200px);
  max-height: 92vh;
  overflow: auto;
  background: var(--white);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-medium);
  padding: 16px;
  position: relative;
}

.batch-result-close {
  position: absolute;
  right: 10px;
  top: 10px;
  border: none;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  background: #2c3e50;
  color: var(--white);
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
}

.batch-result-close:hover {
  background: #34495e;
}

.batch-canvas-item {
  border: 1px solid var(--light-gray);
  border-radius: var(--border-radius);
  padding: 10px;
  background: #f8f9fa;
  text-align: center;
}

.batch-canvas-wrap {
  display: grid;
  grid-template-columns: repeat(2, minmax(220px, 1fr));
  gap: 16px;
}

.batch-canvas-label {
  font-weight: 600;
  color: var(--secondary-color);
  margin-bottom: 8px;
}

.batch-canvas-item canvas {
  display: block;
  max-width: 100%;
  border-radius: 6px;
  border: 1px solid #e9ecef;
  image-rendering: auto;
  margin: 0 auto;
}

.batch-image-modal-panel {
  width: min(90vw, 900px);
}

.batch-image-view-wrap {
  display: flex;
  justify-content: center;
}

.batch-image-view-wrap img {
  max-width: 100%;
  max-height: 76vh;
  border-radius: var(--border-radius);
  border: 1px solid #e9ecef;
  object-fit: contain;
}

@media (max-width: 576px) {
  .batch-grid {
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  }

  .batch-thumb {
    height: 80px;
  }

  .batch-canvas-wrap {
    grid-template-columns: 1fr;
  }
}