@tailwind base;
@tailwind components;
@tailwind utilities;

/* Modern Healthcare Design System - Apple Inspired */

/* CSS Custom Properties for Healthcare Design Tokens */
:root {
  /* Core Colors - Minimal Black & White */
  --background: 255 255 255; /* Pure White */
  --foreground: 0 0 0; /* Pure Black */
  --card: 255 255 255;
  --card-foreground: 0 0 0;
  --popover: 255 255 255;
  --popover-foreground: 0 0 0;
  
  /* Healthcare Accent Colors - Minimal */
  --primary: 0 122 255; /* Apple Blue for primary actions */
  --primary-foreground: 255 255 255;
  --secondary: 142 142 147; /* Subtle Gray */
  --secondary-foreground: 255 255 255;
  --accent: 52 199 89; /* Apple Green for success */
  --accent-foreground: 255 255 255;
  
  /* Neutral Colors - Clean Grays */
  --muted: 248 248 250; /* Very Light Gray */
  --muted-foreground: 142 142 147; /* Medium Gray */
  --border: 229 229 234; /* Light Border */
  --input: 248 248 250;
  --ring: 0 122 255;
  
  /* Healthcare Status Colors */
  --health-success: 52 199 89; /* Green for success */
  --health-warning: 255 149 0; /* Orange for warnings */
  --health-error: 255 59 48; /* Red for errors */
  --health-info: 0 122 255; /* Blue for info */
  
  /* Border Radius - Apple Style */
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  
  /* Shadows - Subtle and Layered */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.08), 0 1px 2px -1px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.12), 0 4px 6px -4px rgba(0, 0, 0, 0.08);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.15), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
  
  /* Spacing - Generous */
  --spacing-xs: 4px;
  --spacing-sm: 8px;
  --spacing-md: 16px;
  --spacing-lg: 24px;
  --spacing-xl: 32px;
  --spacing-2xl: 48px;
  --spacing-3xl: 64px;
  
  /* Typography - Healthcare Optimized */
  --font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'SF Pro Text', 'Helvetica Neue', Arial, system-ui, sans-serif;
  --font-size-xs: 0.75rem; /* 12px */
  --font-size-sm: 0.875rem; /* 14px */
  --font-size-base: 1rem; /* 16px */
  --font-size-lg: 1.125rem; /* 18px */
  --font-size-xl: 1.25rem; /* 20px */
  --font-size-2xl: 1.5rem; /* 24px */
  --font-size-3xl: 1.875rem; /* 30px */
  --font-size-4xl: 2.25rem; /* 36px */
  --font-size-5xl: 3rem; /* 48px */
  
  /* Line Heights - Readable */
  --line-height-tight: 1.2;
  --line-height-normal: 1.5;
  --line-height-relaxed: 1.7;
  
  /* Transitions - Smooth */
  --transition-fast: 150ms cubic-bezier(0.25, 0.1, 0.25, 1);
  --transition-normal: 250ms cubic-bezier(0.25, 0.1, 0.25, 1);
  --transition-slow: 350ms cubic-bezier(0.25, 0.1, 0.25, 1);
}

/* Base Styles */
* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  font-family: var(--font-family);
}

body {
  background-color: rgb(var(--background));
  color: rgb(var(--foreground));
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  line-height: var(--line-height-normal);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: 'rlig' 1, 'calt' 1;
}

/* Typography Scale - Healthcare Optimized */
.text-xs { font-size: var(--font-size-xs); line-height: 1.4; }
.text-sm { font-size: var(--font-size-sm); line-height: 1.5; }
.text-base { font-size: var(--font-size-base); line-height: 1.6; }
.text-lg { font-size: var(--font-size-lg); line-height: 1.5; }
.text-xl { font-size: var(--font-size-xl); line-height: 1.4; }
.text-2xl { font-size: var(--font-size-2xl); line-height: 1.3; }
.text-3xl { font-size: var(--font-size-3xl); line-height: 1.2; }
.text-4xl { font-size: var(--font-size-4xl); line-height: 1.1; }
.text-5xl { font-size: var(--font-size-5xl); line-height: 1.1; }

/* Font Weights - Healthcare Readable */
.font-light { font-weight: 300; }
.font-normal { font-weight: 400; }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }
.font-extrabold { font-weight: 800; }

/* Apple-style Focus States */
.focus-ring:focus {
  outline: 2px solid transparent;
  outline-offset: 2px;
  box-shadow: 0 0 0 2px rgb(var(--ring) / 0.5);
}

/* Modern Healthcare Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  font-weight: 500;
  font-size: var(--font-size-base);
  transition: all var(--transition-fast);
  cursor: pointer;
  border: none;
  outline: none;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  letter-spacing: -0.01em;
}

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

.btn-primary {
  background-color: rgb(var(--primary));
  color: rgb(var(--primary-foreground));
  padding: 14px 28px;
  font-size: var(--font-size-base);
  font-weight: 600;
}

.btn-primary:hover:not(:disabled) {
  background-color: rgb(var(--primary) / 0.9);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.btn-secondary {
  background-color: rgb(var(--secondary));
  color: rgb(var(--secondary-foreground));
  padding: 14px 28px;
  font-size: var(--font-size-base);
  font-weight: 600;
}

.btn-secondary:hover:not(:disabled) {
  background-color: rgb(var(--secondary) / 0.9);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.btn-ghost {
  background-color: transparent;
  color: rgb(var(--foreground));
  padding: 14px 28px;
  font-size: var(--font-size-base);
  font-weight: 500;
}

.btn-ghost:hover:not(:disabled) {
  background-color: rgb(var(--muted));
}

/* Modern Healthcare Cards */
.card {
  background-color: rgb(var(--card));
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  border: 1px solid rgb(var(--border));
  transition: all var(--transition-normal);
  overflow: hidden;
}

.card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.card-glass {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

/* Modern Healthcare Inputs */
.input {
  background-color: rgb(var(--input));
  border: 1px solid rgb(var(--border));
  border-radius: var(--radius);
  padding: 14px 18px;
  font-size: var(--font-size-base);
  transition: all var(--transition-fast);
  outline: none;
  font-weight: 400;
}

.input:focus {
  border-color: rgb(var(--ring));
  box-shadow: 0 0 0 3px rgb(var(--ring) / 0.1);
}

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

/* Modern Healthcare Tables */
.table {
  width: 100%;
  border-collapse: collapse;
  background-color: rgb(var(--card));
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.table th {
  background-color: rgb(var(--muted));
  padding: 20px 24px;
  text-align: left;
  font-weight: 600;
  color: rgb(var(--foreground));
  border-bottom: 1px solid rgb(var(--border));
  font-size: var(--font-size-sm);
  letter-spacing: -0.01em;
}

.table td {
  padding: 20px 24px;
  border-bottom: 1px solid rgb(var(--border) / 0.5);
  font-size: var(--font-size-base);
}

.table tr:hover {
  background-color: rgb(var(--muted) / 0.5);
}

/* Modern Healthcare Animations */
@keyframes fadeIn {
  from { 
    opacity: 0; 
    transform: translateY(20px); 
  }
  to { 
    opacity: 1; 
    transform: translateY(0); 
  }
}

@keyframes slideIn {
  from { 
    opacity: 0; 
    transform: translateX(-30px); 
  }
  to { 
    opacity: 1; 
    transform: translateX(0); 
  }
}

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

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

@keyframes bounce {
  0%, 20%, 53%, 80%, 100% {
    transform: translate3d(0,0,0);
  }
  40%, 43% {
    transform: translate3d(0, -8px, 0);
  }
  70% {
    transform: translate3d(0, -4px, 0);
  }
  90% {
    transform: translate3d(0, -2px, 0);
  }
}

.animate-fade-in {
  animation: fadeIn var(--transition-normal);
}

.animate-slide-in {
  animation: slideIn var(--transition-normal);
}

.animate-scale-in {
  animation: scaleIn var(--transition-normal);
}

.animate-pulse {
  animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

.animate-bounce {
  animation: bounce 1s infinite;
}

/* Loading States */
.loading-spinner {
  width: 24px;
  height: 24px;
  border: 2px solid rgb(var(--border));
  border-top: 2px solid rgb(var(--primary));
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

.loading-skeleton {
  background: linear-gradient(
    90deg,
    rgb(var(--muted)) 25%,
    rgb(var(--border)) 50%,
    rgb(var(--muted)) 75%
  );
  background-size: 200% 100%;
  animation: loading 1.5s infinite;
  border-radius: var(--radius-sm);
}

@keyframes loading {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: rgb(var(--muted));
  border-radius: 4px;
}

::-webkit-scrollbar-thumb {
  background: rgb(var(--border));
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgb(var(--muted-foreground));
}

/* Healthcare Status Colors */
.status-success {
  color: rgb(var(--health-success));
}

.status-warning {
  color: rgb(var(--health-warning));
}

.status-error {
  color: rgb(var(--health-error));
}

.status-info {
  color: rgb(var(--health-info));
}

/* Healthcare Badge Styles */
.badge {
  display: inline-flex;
  align-items: center;
  border-radius: var(--radius-sm);
  font-size: var(--font-size-xs);
  font-weight: 500;
  padding: 4px 8px;
  line-height: 1;
}

.badge-success {
  background-color: rgb(var(--health-success) / 0.1);
  color: rgb(var(--health-success));
}

.badge-warning {
  background-color: rgb(var(--health-warning) / 0.1);
  color: rgb(var(--health-warning));
}

.badge-error {
  background-color: rgb(var(--health-error) / 0.1);
  color: rgb(var(--health-error));
}

.badge-info {
  background-color: rgb(var(--health-info) / 0.1);
  color: rgb(var(--health-info));
}

/* Healthcare Form Styles */
.form-group {
  margin-bottom: var(--spacing-lg);
}

.form-label {
  display: block;
  font-size: var(--font-size-sm);
  font-weight: 500;
  color: rgb(var(--foreground));
  margin-bottom: var(--spacing-sm);
}

.form-input {
  width: 100%;
  background-color: rgb(var(--input));
  border: 1px solid rgb(var(--border));
  border-radius: var(--radius);
  padding: 14px 18px;
  font-size: var(--font-size-base);
  transition: all var(--transition-fast);
  outline: none;
  font-weight: 400;
}

.form-input:focus {
  border-color: rgb(var(--ring));
  box-shadow: 0 0 0 3px rgb(var(--ring) / 0.1);
}

.form-select {
  width: 100%;
  background-color: rgb(var(--input));
  border: 1px solid rgb(var(--border));
  border-radius: var(--radius);
  padding: 14px 18px;
  font-size: var(--font-size-base);
  transition: all var(--transition-fast);
  outline: none;
  font-weight: 400;
  cursor: pointer;
}

.form-select:focus {
  border-color: rgb(var(--ring));
  box-shadow: 0 0 0 3px rgb(var(--ring) / 0.1);
}

/* Healthcare Modal Styles */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--spacing-lg);
}

.modal-content {
  background-color: rgb(var(--card));
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  border: 1px solid rgb(var(--border));
  max-width: 90vw;
  max-height: 90vh;
  overflow-y: auto;
  animation: scaleIn var(--transition-normal);
}

/* Healthcare Layout Styles */
.page-container {
  min-height: 100vh;
  background-color: rgb(var(--background));
}

.main-content {
  flex: 1;
  padding: var(--spacing-lg);
  background-color: rgb(var(--background));
}

.sidebar {
  width: 280px;
  background-color: rgb(var(--card));
  border-right: 1px solid rgb(var(--border));
  transition: width var(--transition-normal);
}

.sidebar.collapsed {
  width: 80px;
}

.header {
  height: 80px;
  background-color: rgb(var(--card));
  border-bottom: 1px solid rgb(var(--border));
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

/* Healthcare Grid System */
.grid-cols-1 { grid-template-columns: repeat(1, minmax(0, 1fr)); }
.grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

@media (max-width: 768px) {
  .grid-cols-2,
  .grid-cols-3,
  .grid-cols-4 {
    grid-template-columns: repeat(1, minmax(0, 1fr));
  }
}

@media (min-width: 768px) and (max-width: 1024px) {
  .grid-cols-4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* Utility Classes */
.text-balance {
  text-wrap: balance;
}

.safe-area-inset {
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
}

/* Responsive Design */
@media (max-width: 768px) {
  :root {
    --spacing-lg: 16px;
    --spacing-xl: 24px;
    --spacing-2xl: 32px;
    --spacing-3xl: 48px;
  }
  
  .card {
    border-radius: var(--radius);
  }
  
  .btn {
    padding: 12px 24px;
    font-size: var(--font-size-sm);
  }
  
  .main-content {
    padding: var(--spacing-md);
  }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  :root {
    --border: 0 0 0;
    --muted: 128 128 128;
  }
}

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