/* 
 * Modern Design System for Chest X-Ray Disease Detection
 * Premium medical-themed interface with glassmorphism and smooth animations
 */

/* ============================================
   CSS Variables & Design Tokens
   ============================================ */
:root {
  /* Color Palette - Medical Theme */
  --primary-blue: #00a8e8;
  --primary-dark: #007ea7;
  --accent-teal: #00d9ff;
  --accent-purple: #7b2cbf;
  --success-green: #06d6a0;
  --warning-orange: #ff9f1c;
  --danger-red: #ef476f;
  
  /* Neutral Colors */
  --bg-dark: #0a0e27;
  --bg-darker: #050816;
  --surface: rgba(255, 255, 255, 0.05);
  --surface-hover: rgba(255, 255, 255, 0.08);
  --text-primary: #ffffff;
  --text-secondary: #b8c5d6;
  --text-muted: #7a8ba0;
  
  /* Gradients */
  --gradient-primary: linear-gradient(135deg, #00a8e8 0%, #7b2cbf 100%);
  --gradient-accent: linear-gradient(135deg, #00d9ff 0%, #00a8e8 100%);
  --gradient-success: linear-gradient(135deg, #06d6a0 0%, #00a8e8 100%);
  
  /* Spacing */
  --spacing-xs: 0.5rem;
  --spacing-sm: 1rem;
  --spacing-md: 1.5rem;
  --spacing-lg: 2rem;
  --spacing-xl: 3rem;
  
  /* Border Radius */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  
  /* Shadows */
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.1);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.2);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.3);
  --shadow-glow: 0 0 20px rgba(0, 168, 232, 0.3);
  
  /* Transitions */
  --transition-fast: 0.2s ease;
  --transition-normal: 0.3s ease;
  --transition-slow: 0.5s ease;
}

/* ============================================
   Global Styles & Reset
   ============================================ */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-darker);
  color: var(--text-primary);
  line-height: 1.6;
  overflow-x: hidden;
  min-height: 100vh;
}

/* Animated background */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: 
    radial-gradient(circle at 20% 50%, rgba(123, 44, 191, 0.1) 0%, transparent 50%),
    radial-gradient(circle at 80% 80%, rgba(0, 168, 232, 0.1) 0%, transparent 50%);
  z-index: -1;
  animation: backgroundPulse 10s ease-in-out infinite;
}

@keyframes backgroundPulse {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 0.8; }
}

/* ============================================
   Typography
   ============================================ */
h1, h2, h3, h4, h5, h6 {
  font-weight: 700;
  line-height: 1.2;
  margin-bottom: var(--spacing-sm);
}

h1 {
  font-size: 3rem;
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

h2 {
  font-size: 2rem;
  color: var(--text-primary);
}

h3 {
  font-size: 1.5rem;
  color: var(--text-primary);
}

p {
  color: var(--text-secondary);
  margin-bottom: var(--spacing-sm);
}

/* ============================================
   Layout Components
   ============================================ */
.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: var(--spacing-lg);
}

.header {
  text-align: center;
  padding: var(--spacing-xl) 0;
  margin-bottom: var(--spacing-lg);
}

.header-title {
  margin-bottom: var(--spacing-sm);
  animation: fadeInDown 0.8s ease;
}

.header-subtitle {
  font-size: 1.2rem;
  color: var(--text-secondary);
  max-width: 600px;
  margin: 0 auto;
  animation: fadeInUp 0.8s ease 0.2s both;
}

.main-content {
  display: grid;
  grid-template-columns: 1fr 350px;
  gap: var(--spacing-lg);
  margin-bottom: var(--spacing-xl);
}

/* ============================================
   Glass Card Component
   ============================================ */
.glass-card {
  background: var(--surface);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-lg);
  padding: var(--spacing-lg);
  box-shadow: var(--shadow-lg);
  transition: all var(--transition-normal);
}

.glass-card:hover {
  background: var(--surface-hover);
  box-shadow: var(--shadow-lg), var(--shadow-glow);
  transform: translateY(-2px);
}

/* ============================================
   Upload Zone
   ============================================ */
.upload-section {
  animation: fadeIn 0.8s ease 0.4s both;
}

.upload-zone {
  border: 2px dashed rgba(0, 168, 232, 0.5);
  border-radius: var(--radius-lg);
  padding: var(--spacing-xl);
  text-align: center;
  cursor: pointer;
  transition: all var(--transition-normal);
  background: rgba(0, 168, 232, 0.05);
  position: relative;
  overflow: hidden;
}

.upload-zone::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: rgba(0, 168, 232, 0.1);
  transform: translate(-50%, -50%);
  transition: width 0.6s, height 0.6s;
}

.upload-zone:hover::before {
  width: 300px;
  height: 300px;
}

.upload-zone:hover {
  border-color: var(--accent-teal);
  background: rgba(0, 168, 232, 0.1);
  transform: scale(1.02);
}

.upload-zone.drag-over {
  border-color: var(--accent-teal);
  background: rgba(0, 168, 232, 0.15);
  box-shadow: 0 0 30px rgba(0, 168, 232, 0.3);
}

.upload-icon {
  font-size: 4rem;
  margin-bottom: var(--spacing-md);
  opacity: 0.7;
  position: relative;
  z-index: 1;
}

.upload-text {
  position: relative;
  z-index: 1;
}

.upload-text h3 {
  color: var(--primary-blue);
  margin-bottom: var(--spacing-xs);
}

.upload-hint {
  color: var(--text-muted);
  font-size: 0.9rem;
}

#fileInput {
  display: none;
}

/* Image Preview */
.image-preview {
  margin-top: var(--spacing-md);
  display: none;
  animation: fadeIn 0.5s ease;
}

.image-preview.active {
  display: block;
}

.preview-container {
  position: relative;
  border-radius: var(--radius-md);
  overflow: hidden;
  max-width: 400px;
  margin: 0 auto;
}

.preview-image {
  width: 100%;
  height: auto;
  display: block;
  border-radius: var(--radius-md);
}

.remove-image {
  position: absolute;
  top: var(--spacing-sm);
  right: var(--spacing-sm);
  background: rgba(239, 71, 111, 0.9);
  color: white;
  border: none;
  border-radius: 50%;
  width: 36px;
  height: 36px;
  cursor: pointer;
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.remove-image:hover {
  background: var(--danger-red);
  transform: scale(1.1);
}

/* ============================================
   Results Section
   ============================================ */
.results-section {
  display: none;
  animation: fadeIn 0.5s ease;
  margin-top: var(--spacing-lg);
}

.results-section.active {
  display: block;
}

.prediction-result {
  text-align: center;
  padding: var(--spacing-lg);
  background: var(--gradient-primary);
  border-radius: var(--radius-lg);
  margin-bottom: var(--spacing-md);
  animation: scaleIn 0.5s ease;
}

.predicted-class {
  font-size: 2.5rem;
  font-weight: 700;
  margin-bottom: var(--spacing-xs);
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

.confidence-score {
  font-size: 1.5rem;
  opacity: 0.9;
}

/* Confidence Bars */
.confidence-bars {
  margin-top: var(--spacing-md);
}

.confidence-item {
  margin-bottom: var(--spacing-md);
}

.confidence-label {
  display: flex;
  justify-content: space-between;
  margin-bottom: var(--spacing-xs);
  font-size: 0.95rem;
}

.class-name {
  font-weight: 600;
  color: var(--text-primary);
}

.confidence-value {
  color: var(--accent-teal);
  font-weight: 600;
}

.confidence-bar-bg {
  background: rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-sm);
  height: 12px;
  overflow: hidden;
  position: relative;
}

.confidence-bar-fill {
  height: 100%;
  background: var(--gradient-accent);
  border-radius: var(--radius-sm);
  transition: width 1s ease;
  position: relative;
  overflow: hidden;
}

.confidence-bar-fill::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  right: 0;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.3),
    transparent
  );
  animation: shimmer 2s infinite;
}

@keyframes shimmer {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

/* Grad-CAM Visualization */
.gradcam-section {
  margin-top: var(--spacing-lg);
}

.gradcam-container {
  position: relative;
  border-radius: var(--radius-md);
  overflow: hidden;
  max-width: 500px;
  margin: var(--spacing-md) auto 0;
  box-shadow: var(--shadow-lg);
}

.gradcam-image {
  width: 100%;
  height: auto;
  display: block;
}

.gradcam-legend {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: var(--spacing-sm);
  padding: var(--spacing-sm);
  background: rgba(255, 255, 255, 0.05);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: var(--spacing-xs);
}

.legend-color {
  width: 20px;
  height: 12px;
  border-radius: 2px;
}

/* ============================================
   History Sidebar
   ============================================ */
.history-sidebar {
  animation: fadeInRight 0.8s ease 0.6s both;
}

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

.history-items {
  max-height: 600px;
  overflow-y: auto;
  padding-right: var(--spacing-xs);
}

/* Custom Scrollbar */
.history-items::-webkit-scrollbar {
  width: 6px;
}

.history-items::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 3px;
}

.history-items::-webkit-scrollbar-thumb {
  background: rgba(0, 168, 232, 0.5);
  border-radius: 3px;
}

.history-items::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 168, 232, 0.7);
}

.history-item {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-md);
  padding: var(--spacing-sm);
  margin-bottom: var(--spacing-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
  animation: slideInRight 0.3s ease;
}

.history-item:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: var(--primary-blue);
  transform: translateX(-4px);
}

.history-item-content {
  display: flex;
  gap: var(--spacing-sm);
}

.history-thumbnail {
  width: 60px;
  height: 60px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  border: 2px solid rgba(255, 255, 255, 0.1);
}

.history-info {
  flex: 1;
}

.history-class {
  font-weight: 600;
  color: var(--text-primary);
  font-size: 0.9rem;
  margin-bottom: 2px;
}

.history-confidence {
  font-size: 0.85rem;
  color: var(--accent-teal);
  margin-bottom: 2px;
}

.history-time {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.empty-history {
  text-align: center;
  padding: var(--spacing-xl) var(--spacing-sm);
  color: var(--text-muted);
}

.empty-history-icon {
  font-size: 3rem;
  opacity: 0.3;
  margin-bottom: var(--spacing-sm);
}

/* ============================================
   Buttons
   ============================================ */
.btn {
  padding: var(--spacing-sm) var(--spacing-lg);
  border: none;
  border-radius: var(--radius-md);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  display: inline-flex;
  align-items: center;
  gap: var(--spacing-xs);
  text-decoration: none;
}

.btn-primary {
  background: var(--gradient-primary);
  color: white;
  box-shadow: var(--shadow-md);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg), var(--shadow-glow);
}

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

.btn-secondary {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

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

/* ============================================
   Loading States
   ============================================ */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(10, 14, 39, 0.9);
  backdrop-filter: blur(10px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.loading-overlay.active {
  display: flex;
}

.loading-content {
  text-align: center;
}

.spinner {
  width: 60px;
  height: 60px;
  border: 4px solid rgba(0, 168, 232, 0.2);
  border-top-color: var(--primary-blue);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto var(--spacing-md);
}

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

.loading-text {
  font-size: 1.2rem;
  color: var(--text-primary);
  margin-bottom: var(--spacing-xs);
}

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

/* ============================================
   Animations
   ============================================ */
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

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

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

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

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

@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* ============================================
   Responsive Design
   ============================================ */
@media (max-width: 1024px) {
  .main-content {
    grid-template-columns: 1fr;
  }
  
  .history-sidebar {
    order: -1;
  }
  
  .history-items {
    max-height: 400px;
  }
}

@media (max-width: 768px) {
  h1 {
    font-size: 2rem;
  }
  
  .header-subtitle {
    font-size: 1rem;
  }
  
  .container {
    padding: var(--spacing-sm);
  }
  
  .glass-card {
    padding: var(--spacing-md);
  }
  
  .upload-zone {
    padding: var(--spacing-lg);
  }
  
  .predicted-class {
    font-size: 1.8rem;
  }
  
  .confidence-score {
    font-size: 1.2rem;
  }
}

/* ============================================
   Utility Classes
   ============================================ */
.text-center {
  text-align: center;
}

.mt-1 { margin-top: var(--spacing-sm); }
.mt-2 { margin-top: var(--spacing-md); }
.mt-3 { margin-top: var(--spacing-lg); }

.mb-1 { margin-bottom: var(--spacing-sm); }
.mb-2 { margin-bottom: var(--spacing-md); }
.mb-3 { margin-bottom: var(--spacing-lg); }

.hidden {
  display: none !important;
}
