/* ============================================
   HealthUp Design System
   "Serene Health Studio" - Calming, Premium, Trustworthy
   ============================================ */

/* Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Source+Serif+4:ital,opsz,wght@0,8..60,400;0,8..60,600;0,8..60,700;1,8..60,400&family=DM+Sans:ital,opsz,wght@0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;1,9..40,400&display=swap');

/* ============================================
   CSS Variables - Design Tokens
   ============================================ */
:root {
  /* Typography */
  --font-display: 'Source Serif 4', Georgia, 'Times New Roman', serif;
  --font-body: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'SF Mono', 'Fira Code', 'Consolas', monospace;

  /* Font Sizes */
  --text-xs: 0.75rem;
  --text-sm: 0.875rem;
  --text-base: 1rem;
  --text-lg: 1.125rem;
  --text-xl: 1.25rem;
  --text-2xl: 1.5rem;
  --text-3xl: 2rem;
  --text-4xl: 2.5rem;

  /* Colors - Warm, Calming Palette */
  --color-cream: #faf7f2;
  --color-cream-dark: #f5f0e8;
  --color-ivory: #fffdf9;

  /* Sage Green - Primary Accent */
  --color-sage-50: #f0fdf4;
  --color-sage-100: #dcfce7;
  --color-sage-200: #bbf7d0;
  --color-sage-300: #86efac;
  --color-sage-400: #4ade80;
  --color-sage-500: #22c55e;
  --color-sage-600: #16a34a;
  --color-sage-700: #15803d;

  /* Slate - Text & Neutrals */
  --color-slate-50: #f8fafc;
  --color-slate-100: #f1f5f9;
  --color-slate-200: #e2e8f0;
  --color-slate-300: #cbd5e1;
  --color-slate-400: #94a3b8;
  --color-slate-500: #64748b;
  --color-slate-600: #475569;
  --color-slate-700: #334155;
  --color-slate-800: #1e293b;
  --color-slate-900: #0f172a;

  /* Warm Accent - Amber */
  --color-amber-50: #fffbeb;
  --color-amber-100: #fef3c7;
  --color-amber-400: #fbbf24;
  --color-amber-500: #f59e0b;
  --color-amber-600: #d97706;

  /* Status Colors */
  --color-success: #059669;
  --color-success-light: #d1fae5;
  --color-error: #dc2626;
  --color-error-light: #fee2e2;
  --color-warning: #d97706;
  --color-warning-light: #fef3c7;
  --color-info: #0284c7;
  --color-info-light: #e0f2fe;

  /* Semantic Colors */
  --color-bg: var(--color-cream);
  --color-surface: var(--color-ivory);
  --color-surface-elevated: #ffffff;
  --color-text: var(--color-slate-800);
  --color-text-secondary: var(--color-slate-500);
  --color-text-muted: var(--color-slate-400);
  --color-border: var(--color-slate-200);
  --color-border-light: var(--color-slate-100);
  --color-accent: var(--color-sage-600);
  --color-accent-hover: var(--color-sage-700);
  --color-accent-light: var(--color-sage-50);

  /* Spacing */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;

  /* Border Radius */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-2xl: 24px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 4px 6px -1px rgba(15, 23, 42, 0.05), 0 2px 4px -2px rgba(15, 23, 42, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(15, 23, 42, 0.06), 0 4px 6px -4px rgba(15, 23, 42, 0.06);
  --shadow-xl: 0 20px 25px -5px rgba(15, 23, 42, 0.08), 0 8px 10px -6px rgba(15, 23, 42, 0.06);
  --shadow-inner: inset 0 2px 4px 0 rgba(15, 23, 42, 0.04);

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-base: 200ms ease;
  --transition-slow: 300ms ease;

  /* Layout */
  --sidebar-width: 260px;
  --header-height: 64px;
  --content-max-width: 1400px;
}

/* ============================================
   Base Styles
   ============================================ */
*, *::before, *::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: 1.6;
  color: var(--color-text);
  background: var(--color-bg);
  min-height: 100vh;
}

/* ============================================
   Typography
   ============================================ */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.3;
  margin: 0 0 var(--space-4) 0;
  color: var(--color-slate-900);
}

h1 {
  font-size: var(--text-3xl);
  font-weight: 700;
  letter-spacing: -0.02em;
}

h2 {
  font-size: var(--text-2xl);
  letter-spacing: -0.01em;
}

h3 {
  font-size: var(--text-xl);
}

h4 {
  font-size: var(--text-lg);
}

p {
  margin: 0 0 var(--space-4) 0;
}

a {
  color: var(--color-accent);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover {
  color: var(--color-accent-hover);
}

/* ============================================
   App Layout - Sidebar + Main Content
   ============================================ */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background: var(--color-surface-elevated);
  border-right: 1px solid var(--color-border-light);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: transform var(--transition-slow);
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-6);
  border-bottom: 1px solid var(--color-border-light);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-width: 0;
}

.sidebar-logo-icon {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, var(--color-sage-500), var(--color-sage-600));
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: var(--text-xl);
  font-weight: 700;
  font-family: var(--font-display);
  box-shadow: 0 2px 8px rgba(22, 163, 74, 0.25);
}

.sidebar-logo-text {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--color-slate-900);
  letter-spacing: -0.02em;
}

.sidebar-nav {
  flex: 1;
  padding: var(--space-4);
  overflow-y: auto;
}

.nav-section {
  margin-bottom: var(--space-6);
}

.nav-section-title {
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
  padding: var(--space-2) var(--space-3);
  margin-bottom: var(--space-1);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  color: var(--color-text-secondary);
  font-weight: 500;
  font-size: var(--text-sm);
  transition: all var(--transition-fast);
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  text-decoration: none;
}

.nav-item:hover {
  background: var(--color-slate-50);
  color: var(--color-text);
}

.nav-item.active {
  background: var(--color-accent-light);
  color: var(--color-accent);
}

.nav-item.active .nav-icon {
  color: var(--color-accent);
}

.nav-icon {
  font-size: var(--text-lg);
  width: 24px;
  text-align: center;
  flex-shrink: 0;
}

.nav-badge {
  margin-left: auto;
  background: var(--color-error);
  color: white;
  font-size: var(--text-xs);
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  min-width: 20px;
  text-align: center;
}

.sidebar-footer {
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--color-border-light);
}

.sidebar-footer-text {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

/* Main Content Area */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden; /* Prevent horizontal overflow */
  max-width: calc(100vw - var(--sidebar-width));
}

.content-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(250, 247, 242, 0.9);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--color-border-light);
  padding: var(--space-4) var(--space-8);
}

.content-header-inner {
  max-width: var(--content-max-width);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.page-title {
  font-size: var(--text-xl);
  font-weight: 600;
  margin: 0;
}

.content-body {
  flex: 1;
  padding: var(--space-8);
  max-width: var(--content-max-width);
  margin: 0 auto;
  width: 100%;
  box-sizing: border-box;
  overflow-x: hidden; /* Prevent horizontal overflow */
}

/* Mobile Menu Toggle */
.mobile-menu-toggle {
  display: none;
  position: fixed;
  bottom: var(--space-6);
  right: var(--space-6);
  width: 56px;
  height: 56px;
  border-radius: var(--radius-full);
  background: var(--color-accent);
  color: white;
  border: none;
  font-size: var(--text-xl);
  cursor: pointer;
  box-shadow: var(--shadow-lg);
  z-index: 101;
  transition: transform var(--transition-fast), background var(--transition-fast);
}

.mobile-menu-toggle:hover {
  background: var(--color-accent-hover);
  transform: scale(1.05);
}

/* Mobile Overlay */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.4);
  z-index: 99;
  opacity: 0;
  transition: opacity var(--transition-slow);
}

.sidebar-overlay.visible {
  opacity: 1;
}

/* ============================================
   Cards & Containers
   ============================================ */
.card {
  background: var(--color-surface-elevated);
  border-radius: var(--radius-xl);
  border: 1px solid var(--color-border-light);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.card-header {
  padding: var(--space-5) var(--space-6);
  border-bottom: 1px solid var(--color-border-light);
  background: var(--color-slate-50);
}

.card-title {
  font-size: var(--text-lg);
  font-weight: 600;
  margin: 0;
}

.card-subtitle {
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  margin: var(--space-1) 0 0 0;
}

.card-body {
  padding: var(--space-6);
}

.card-footer {
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--color-border-light);
  background: var(--color-slate-50);
}

/* ============================================
   Buttons
   ============================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-5);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 600;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  transition: all var(--transition-fast);
  text-decoration: none;
  white-space: nowrap;
}

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

.btn-primary {
  background: var(--color-accent);
  color: white;
}

.btn-primary:hover:not(:disabled) {
  background: var(--color-accent-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(22, 163, 74, 0.25);
}

.btn-secondary {
  background: var(--color-surface-elevated);
  color: var(--color-text);
  border: 1px solid var(--color-border);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--color-slate-50);
  border-color: var(--color-slate-300);
}

.btn-ghost {
  background: transparent;
  color: var(--color-text-secondary);
}

.btn-ghost:hover:not(:disabled) {
  background: var(--color-slate-100);
  color: var(--color-text);
}

.btn-danger {
  background: var(--color-error);
  color: white;
}

.btn-danger:hover:not(:disabled) {
  background: #b91c1c;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(220, 38, 38, 0.25);
}

.btn-sm {
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-xs);
}

.btn-lg {
  padding: var(--space-4) var(--space-6);
  font-size: var(--text-base);
}

.btn-icon {
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: var(--radius-md);
}

/* ============================================
   Form Elements
   ============================================ */
.form-group {
  margin-bottom: var(--space-5);
}

.form-label {
  display: block;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: var(--space-2);
}

.form-input,
.form-textarea,
.form-select {
  width: 100%;
  padding: var(--space-3) var(--space-4);
  font-family: var(--font-body);
  font-size: var(--text-base);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface-elevated);
  color: var(--color-text);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.form-input:focus,
.form-textarea:focus,
.form-select:focus {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.1);
}

.form-input::placeholder,
.form-textarea::placeholder {
  color: var(--color-text-muted);
}

.form-textarea {
  min-height: 120px;
  resize: vertical;
}

.form-hint {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin-top: var(--space-2);
}

/* File Input */
.file-input-wrapper {
  position: relative;
}

.file-input {
  position: absolute;
  opacity: 0;
  width: 100%;
  height: 100%;
  cursor: pointer;
}

/* ============================================
   Upload Zone
   ============================================ */
.upload-zone {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}

.upload-option {
  position: relative;
  padding: var(--space-8) var(--space-6);
  background: var(--color-surface-elevated);
  border: 2px dashed var(--color-border);
  border-radius: var(--radius-xl);
  text-align: center;
  cursor: pointer;
  transition: all var(--transition-base);
}

.upload-option:hover {
  border-color: var(--color-accent);
  background: var(--color-accent-light);
}

.upload-option.dragging {
  border-color: var(--color-accent);
  background: var(--color-sage-100);
  transform: scale(1.02);
}

.upload-option-icon {
  font-size: 2.5rem;
  margin-bottom: var(--space-3);
  display: block;
}

.upload-option-title {
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: var(--space-2);
}

.upload-option-desc {
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  margin: 0;
}

.upload-hint {
  text-align: center;
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin-top: var(--space-2);
}

/* ============================================
   Tables
   ============================================ */
.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border-light);
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}

.table th,
.table td {
  padding: var(--space-3) var(--space-4);
  text-align: left;
  border-bottom: 1px solid var(--color-border-light);
}

.table th {
  font-weight: 600;
  color: var(--color-text-secondary);
  background: var(--color-slate-50);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.table tbody tr:hover {
  background: var(--color-slate-50);
}

.table tbody tr:last-child td {
  border-bottom: none;
}

/* Table variants */
.table-striped tbody tr:nth-child(even) {
  background: var(--color-cream-dark);
}

.table-compact th,
.table-compact td {
  padding: var(--space-2) var(--space-3);
}

/* ============================================
   Status Badges
   ============================================ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-3);
  font-size: var(--text-xs);
  font-weight: 600;
  border-radius: var(--radius-full);
}

.badge-success {
  background: var(--color-success-light);
  color: var(--color-success);
}

.badge-error {
  background: var(--color-error-light);
  color: var(--color-error);
}

.badge-warning {
  background: var(--color-warning-light);
  color: var(--color-warning);
}

.badge-info {
  background: var(--color-info-light);
  color: var(--color-info);
}

.badge-neutral {
  background: var(--color-slate-100);
  color: var(--color-slate-600);
}

/* ============================================
   Progress Indicators
   ============================================ */
.progress-bar-wrapper {
  position: relative;
  height: 8px;
  background: var(--color-slate-100);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--color-sage-500), var(--color-sage-400));
  border-radius: var(--radius-full);
  transition: width var(--transition-slow);
}

.progress-bar-fill.error {
  background: linear-gradient(90deg, var(--color-error), #ef4444);
}

.progress-bar-fill.completed {
  background: linear-gradient(90deg, var(--color-success), var(--color-sage-400));
}

.progress-text {
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  margin-top: var(--space-2);
}

/* Step Progress */
.steps {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.step {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
}

.step-indicator {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-xs);
  font-weight: 600;
  flex-shrink: 0;
  background: var(--color-slate-100);
  color: var(--color-slate-500);
  border: 2px solid var(--color-slate-200);
}

.step.completed .step-indicator {
  background: var(--color-success-light);
  color: var(--color-success);
  border-color: var(--color-success);
}

.step.active .step-indicator {
  background: var(--color-info-light);
  color: var(--color-info);
  border-color: var(--color-info);
  animation: pulse 2s infinite;
}

.step.error .step-indicator {
  background: var(--color-error-light);
  color: var(--color-error);
  border-color: var(--color-error);
}

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

.step-content {
  flex: 1;
  padding-top: var(--space-1);
}

.step-title {
  font-weight: 600;
  color: var(--color-text);
  font-size: var(--text-sm);
}

.step-desc {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  margin-top: var(--space-1);
}

/* ============================================
   Queue & Results Sections
   ============================================ */
.section {
  margin-bottom: var(--space-8);
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-4);
}

.section-title {
  font-size: var(--text-lg);
  font-weight: 600;
  margin: 0;
}

.section-actions {
  display: flex;
  gap: var(--space-2);
}

/* Queue Table */
.queue-section,
.gmail-section,
.progress-section,
.results-section {
  background: var(--color-surface-elevated);
  border-radius: var(--radius-xl);
  border: 1px solid var(--color-border-light);
  padding: var(--space-6);
  margin-bottom: var(--space-6);
}

.queue-section h3,
.gmail-section h3,
.progress-section h3,
.results-section h3 {
  font-size: var(--text-lg);
  margin: 0 0 var(--space-4) 0;
}

/* Legacy class mapping */
.queue-table,
.selection-table,
.progress-table,
.results-table,
.parameters-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}

.queue-table th,
.queue-table td,
.selection-table th,
.selection-table td,
.progress-table th,
.progress-table td,
.results-table th,
.results-table td,
.parameters-table th,
.parameters-table td {
  padding: var(--space-3) var(--space-4);
  text-align: left;
  border-bottom: 1px solid var(--color-border-light);
}

.queue-table th,
.selection-table th,
.progress-table th,
.results-table th,
.parameters-table th {
  font-weight: 600;
  color: var(--color-text-secondary);
  background: var(--color-slate-50);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.queue-table tbody tr:hover,
.selection-table tbody tr:hover,
.progress-table tbody tr:hover,
.results-table tbody tr:hover,
.parameters-table tbody tr:hover {
  background: var(--color-slate-50);
}

/* ============================================
   Results Summary
   ============================================ */
.results-summary {
  display: flex;
  gap: var(--space-6);
  padding: var(--space-4);
  background: var(--color-slate-50);
  border-radius: var(--radius-lg);
  margin-bottom: var(--space-5);
}

.summary-stat {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
}

.summary-stat strong {
  font-size: var(--text-lg);
  color: var(--color-text);
}

/* ============================================
   Status Cells
   ============================================ */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: 600;
}

.status-completed {
  background: var(--color-success-light);
  color: var(--color-success);
}

.status-failed {
  background: var(--color-error-light);
  color: var(--color-error);
}

.status-duplicate,
.status-updated {
  background: var(--color-info-light);
  color: var(--color-info);
}

.status-processing {
  background: var(--color-amber-100);
  color: var(--color-amber-600);
}

/* ============================================
   Gmail Section Styles
   ============================================ */
.gmail-subsection {
  margin-bottom: var(--space-6);
}

.gmail-subsection:last-child {
  margin-bottom: 0;
}

.gmail-subsection h3 {
  font-size: var(--text-base);
  margin-bottom: var(--space-4);
}

#auth-status-message {
  padding: var(--space-4);
  background: var(--color-slate-50);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-4);
}

.step-list {
  list-style: none;
  padding: 0;
  margin: var(--space-4) 0;
}

.step-list li {
  padding: var(--space-2) 0;
  color: var(--color-text-muted);
  font-size: var(--text-sm);
}

.step-list li.completed {
  color: var(--color-success);
}

.step-list li.active {
  color: var(--color-info);
  font-weight: 500;
}

.selection-actions {
  display: flex;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
  flex-wrap: wrap;
}

/* ============================================
   Upload Source Buttons (Legacy Support)
   ============================================ */
.upload-source-selector {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}

.upload-source-button {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-8) var(--space-6);
  background: var(--color-surface-elevated);
  border: 2px dashed var(--color-border);
  border-radius: var(--radius-xl);
  cursor: pointer;
  transition: all var(--transition-base);
}

.upload-source-button:hover {
  border-color: var(--color-accent);
  background: var(--color-accent-light);
}

.upload-source-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.upload-source-button .icon {
  font-size: 2.5rem;
}

.upload-source-button .label {
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--color-text);
}

/* ============================================
   Primary/Secondary Buttons (Legacy)
   ============================================ */
.primary-button,
.analyze-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-5);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 600;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  transition: all var(--transition-fast);
  background: var(--color-accent);
  color: white;
}

.primary-button:hover:not(:disabled),
.analyze-button:hover:not(:disabled) {
  background: var(--color-accent-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(22, 163, 74, 0.25);
}

.primary-button:disabled,
.analyze-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.secondary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-5);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 600;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  background: var(--color-surface-elevated);
  color: var(--color-text);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.secondary-button:hover:not(:disabled) {
  background: var(--color-slate-50);
  border-color: var(--color-slate-300);
}

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

.danger-button {
  background: var(--color-error);
  color: white;
}

.danger-button:hover:not(:disabled) {
  background: #b91c1c;
}

.view-button {
  display: inline-flex;
  align-items: center;
  padding: var(--space-2) var(--space-3);
  background: var(--color-accent);
  color: white;
  text-decoration: none;
  border-radius: var(--radius-md);
  font-size: var(--text-xs);
  font-weight: 600;
  transition: all var(--transition-fast);
}

.view-button:hover {
  background: var(--color-accent-hover);
  color: white;
}

/* Prevent wrapping in status and action columns */
.results-table td:nth-child(2),
.results-table td:nth-child(3) {
  white-space: nowrap;
}

/* ============================================
   Help Text
   ============================================ */
.help-text {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin: 0;
  line-height: 1.5;
}

/* ============================================
   Messages & Alerts
   ============================================ */
.message {
  padding: var(--space-4);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  margin-bottom: var(--space-4);
}

.message[data-state="error"] {
  background: var(--color-error-light);
  color: var(--color-error);
  border: 1px solid rgba(220, 38, 38, 0.2);
}

.message[data-state="success"] {
  background: var(--color-success-light);
  color: var(--color-success);
  border: 1px solid rgba(5, 150, 105, 0.2);
}

.message[data-state="loading"] {
  background: var(--color-info-light);
  color: var(--color-info);
  border: 1px solid rgba(2, 132, 199, 0.2);
}

/* ============================================
   Parameters Table (Lab Results)
   ============================================ */
.parameters-table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius-lg);
}

.parameters-table td[data-missing='true'] {
  color: var(--color-error);
  font-weight: 600;
}

.parameters-table td[data-out-of-range='true'] {
  outline: 2px solid var(--color-error);
  outline-offset: -2px;
  border-radius: var(--radius-sm);
}

.parameters-table__row--flagged {
  background: var(--color-error-light) !important;
}

.parameters-table__row--flagged td:first-child {
  font-weight: 600;
  color: var(--color-error);
}

/* ============================================
   Plot Visualization
   ============================================ */
.plot-visualization-container {
  display: grid;
  grid-template-columns: 200px 1fr;
  grid-template-rows: auto auto;
  gap: var(--space-5);
  margin-top: var(--space-5);
}

.parameter-selector-panel {
  width: 200px;
  min-width: 180px;
  flex-shrink: 0;
  background: var(--color-slate-50);
  padding: var(--space-4);
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border-light);
}

.parameter-selector-panel__title {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text-secondary);
  margin: 0 0 var(--space-3) 0;
}

.parameter-selector-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.parameter-selector-item {
  display: flex;
  align-items: center;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  cursor: pointer;
  font-size: var(--text-sm);
  transition: background-color var(--transition-fast);
}

.parameter-selector-item:hover {
  background: var(--color-slate-100);
}

.parameter-selector-item input[type="radio"] {
  margin-right: var(--space-2);
  cursor: pointer;
  accent-color: var(--color-accent);
}

.parameter-selector-item:has(input[type="radio"]:checked) {
  background: var(--color-accent-light);
  font-weight: 600;
}

.plot-container {
  background: var(--color-surface-elevated);
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
}

.parameter-table-container {
  grid-column: 1 / -1;
  grid-row: 2;
  margin-top: var(--space-4);
}

.plot-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-3);
}

.plot-toolbar__hint {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

.plot-toolbar__button {
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  background: var(--color-surface-elevated);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-accent);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.plot-toolbar__button:hover:not(:disabled) {
  background: var(--color-accent-light);
  border-color: var(--color-accent);
}

#plot-canvas,
#resultChart {
  width: 100% !important;
  height: 400px !important;
  max-height: 400px;
}

/* ============================================
   Modal
   ============================================ */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: var(--space-4);
  backdrop-filter: blur(4px);
}

.modal-content {
  background: var(--color-surface-elevated);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  max-width: 500px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  padding: var(--space-6);
}

.modal-close {
  position: absolute;
  top: var(--space-4);
  right: var(--space-4);
  width: 32px;
  height: 32px;
  border: none;
  background: var(--color-slate-100);
  border-radius: var(--radius-full);
  font-size: var(--text-xl);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-secondary);
  transition: all var(--transition-fast);
}

.modal-close:hover {
  background: var(--color-slate-200);
  color: var(--color-text);
}

.modal-actions {
  display: flex;
  gap: var(--space-3);
  justify-content: flex-end;
  margin-top: var(--space-6);
}

/* ============================================
   Empty & Loading States
   ============================================ */
.empty-state {
  text-align: center;
  padding: var(--space-12) var(--space-6);
  color: var(--color-text-muted);
}

.empty-state-icon {
  font-size: 3rem;
  margin-bottom: var(--space-4);
  opacity: 0.5;
}

.empty-state-title {
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--color-text-secondary);
  margin-bottom: var(--space-2);
}

.empty-state-desc {
  font-size: var(--text-sm);
  margin: 0;
}

.loading-state {
  text-align: center;
  padding: var(--space-8);
  color: var(--color-text-secondary);
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--color-slate-200);
  border-top-color: var(--color-accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto var(--space-4);
}

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

/* ============================================
   Report View UI
   ============================================ */
#report-view-ui {
  padding: var(--space-6);
  background: var(--color-surface-elevated);
  border-radius: var(--radius-xl);
  border: 1px solid var(--color-border-light);
}

.result-details {
  padding: var(--space-5);
  border-radius: var(--radius-lg);
  background: var(--color-slate-50);
  border: 1px solid var(--color-border-light);
}

.result-details__row {
  display: flex;
  justify-content: space-between;
  padding: var(--space-2) 0;
}

.result-details__label {
  font-weight: 500;
  color: var(--color-text-secondary);
}

.result-details__value {
  font-weight: 600;
  color: var(--color-text);
}

.result-details__value--missing {
  color: var(--color-error);
}

.result-details__divider {
  height: 1px;
  background: var(--color-border-light);
  margin: var(--space-3) 0;
}

.progress {
  margin: var(--space-6) 0;
}

.progress-steps {
  margin-top: var(--space-4);
}

.progress-step {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-2) 0;
}

.progress-step__badge {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: var(--text-xs);
  background: var(--color-slate-100);
  color: var(--color-text-muted);
  border: 2px solid var(--color-slate-200);
  flex-shrink: 0;
}

.progress-step[data-status='completed'] .progress-step__badge {
  background: var(--color-success-light);
  border-color: var(--color-success);
  color: var(--color-success);
}

.progress-step[data-status='in_progress'] .progress-step__badge {
  background: var(--color-info-light);
  border-color: var(--color-info);
  color: var(--color-info);
}

.progress-step[data-status='failed'] .progress-step__badge {
  background: var(--color-error-light);
  border-color: var(--color-error);
  color: var(--color-error);
}

.progress-step__content {
  flex: 1;
}

.progress-step__label {
  font-weight: 600;
  font-size: var(--text-sm);
}

.progress-step__message {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  margin-top: var(--space-1);
}

.progress-step[data-status='failed'] .progress-step__message {
  color: var(--color-error);
}

/* Action Buttons */
.action-buttons {
  display: flex;
  gap: var(--space-3);
  margin: var(--space-4) 0;
}

.btn-secondary {
  background: var(--color-slate-600);
  color: white;
  padding: var(--space-3) var(--space-4);
  border: none;
  border-radius: var(--radius-md);
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--color-slate-700);
}

/* ============================================
   Responsive Design
   ============================================ */
@media (max-width: 1024px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .main-content {
    margin-left: 0;
  }

  .mobile-menu-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .sidebar-overlay {
    display: block;
  }
}

@media (max-width: 768px) {
  :root {
    --space-8: 1.5rem;
  }

  .content-body {
    padding: var(--space-4);
  }

  .upload-source-selector {
    grid-template-columns: 1fr;
  }

  .results-summary {
    flex-direction: column;
    gap: var(--space-3);
  }

  .selection-actions {
    flex-direction: column;
  }

  .selection-actions button {
    width: 100%;
  }

  .plot-visualization-container {
    grid-template-columns: 1fr;
  }

  .parameter-selector-panel {
    width: 100%;
  }

  #plot-canvas,
  #resultChart {
    height: 300px !important;
    max-height: 300px;
  }

  .modal-content {
    margin: var(--space-4);
    max-height: calc(100vh - 2rem);
  }
}

/* ============================================
   Print Styles
   ============================================ */
@media print {
  .sidebar,
  .mobile-menu-toggle,
  .content-header {
    display: none !important;
  }

  .main-content {
    margin-left: 0;
  }

  .content-body {
    padding: 0;
  }
}

/* ============================================
   Reduced Motion
   ============================================ */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ============================================
   Container (Legacy support for existing markup)
   ============================================ */
.container {
  /* When used without app-layout, provide reasonable defaults */
  max-width: var(--content-max-width);
  margin: 0 auto;
  padding: var(--space-8);
}

/* Admin link in header */
.admin-link {
  color: var(--color-accent);
  font-weight: 500;
  font-size: var(--text-sm);
}

.admin-link:hover {
  color: var(--color-accent-hover);
}

/* Breadcrumb */
.breadcrumb {
  margin-bottom: var(--space-6);
}

.breadcrumb-link {
  color: var(--color-text-secondary);
  font-size: var(--text-sm);
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
}

.breadcrumb-link:hover {
  color: var(--color-accent);
}

/* ============================================
   Reports Browser
   ============================================ */
.reports-filters {
  display: flex;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  align-items: flex-end;
}

.reports-filters .filter-group {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.reports-filters label {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

.reports-filters input[type="date"],
.reports-filters select {
  padding: 0.5rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  min-width: 150px;
  font-family: var(--font-body);
  font-size: var(--text-sm);
  background: var(--color-surface-elevated);
  color: var(--color-text);
}

.reports-filters input[type="date"]:focus,
.reports-filters select:focus {
  outline: none;
  border-color: var(--color-accent);
}

.reports-table {
  width: 100%;
  border-collapse: collapse;
}

.reports-table th,
.reports-table td {
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--color-border-light);
}

.reports-table th {
  background: var(--color-slate-50);
  font-weight: 600;
  color: var(--color-text-secondary);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.reports-table tbody tr:hover {
  background: var(--color-slate-50);
}

.reports-table .actions-cell {
  display: flex;
  gap: 0.5rem;
}

.reports-table .empty-state {
  text-align: center;
  padding: 2rem;
  color: var(--color-text-muted);
}

.reports-table .error-state {
  color: var(--color-error);
}

.reports-table td {
  max-width: 300px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.reports-summary {
  margin-top: 1rem;
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

.btn-small {
  padding: 0.375rem 0.75rem;
  font-size: var(--text-sm);
  border-radius: var(--radius-sm);
  cursor: pointer;
  border: none;
  font-family: var(--font-body);
  transition: background-color 0.15s ease;
}

.btn-small.btn-primary {
  background: var(--color-accent);
  color: white;
}

.btn-small.btn-primary:hover {
  background: var(--color-accent-hover);
}

.btn-small.btn-secondary {
  background: var(--color-slate-100);
  color: var(--color-text);
  border: 1px solid var(--color-border);
}

.btn-small.btn-secondary:hover {
  background: var(--color-slate-200);
}

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

/* ==================== User Menu (PRD v4.4.4) ==================== */
.user-menu {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: auto;
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 2px solid #e0e0e0;
}

.user-name {
  font-size: 14px;
  font-weight: 500;
  color: #333;
}

.btn-logout {
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 500;
  color: #555;
  background: white;
  border: 1px solid #d0d0d0;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-logout:hover {
  background: #e8e8e8;
  border-color: #ccc;
  color: #333;
}

/* ============================================
   PRD v10.0: Job Toast Notifications
   ============================================ */

/* Toast container - fixed position, stacks toasts vertically */
.job-toast-container {
  position: fixed;
  top: 16px;
  right: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 10000;
  pointer-events: none; /* Allow clicks through container gaps */
}

/* Job completion toast notifications */
.job-toast {
  /* No position: fixed - container handles positioning */
  max-width: 320px;
  background: var(--color-surface-elevated, #ffffff);
  border: 1px solid var(--color-border, #e0e0e0);
  border-radius: var(--radius-md, 8px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  animation: toast-slide-in 200ms ease-out;
  pointer-events: auto; /* Re-enable clicks on toast itself */
}

.job-toast-content {
  display: flex;
  align-items: center;
  gap: 8px;
}

.job-toast-icon {
  font-size: 16px;
}

.job-toast-title {
  font-size: var(--text-sm, 14px);
  font-weight: 500;
  color: var(--color-text, #1a1a1a);
}

.job-toast-action {
  align-self: flex-end;
  font-size: 13px;
  color: var(--color-accent, #16a34a);
  text-decoration: none;
}

.job-toast-action:hover {
  text-decoration: underline;
}

.toast-fade-out {
  animation: toast-fade-out 300ms ease-out forwards;
}

@keyframes toast-slide-in {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes toast-fade-out {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
  }
}
