

/* 🎨 Enhanced Theme Variables with Accessibility */
:root {
  --bg: #f7fafc;        /* gray-50 */
  --card: #ffffff;      /* white */
  --muted: #718096;     /* gray-600 */
  --text: #1f2937;      /* gray-800 */
  --accent: #0ea5a4;    /* teal-500 */
  --accent-dark: #04827f;
  --soft: #f0fdfa;      /* teal-50-ish */

  /* Typography scale */
  --fs-base: 16px;
  --fs-lg: clamp(20px, 3vw, 24px);
  --fs-xl: clamp(28px, 4vw, 34px);
  
  /* Accessibility colors - WCAG AA compliant */
  --focus-color: #2563eb;
  --error-color: #dc2626;
  --success-color: #059669;
  --warning-color: #d97706;
  
  /* Animation preferences */
  --animation-duration: 0.3s;
  --animation-easing: cubic-bezier(0.4, 0, 0.2, 1);
}

/* Respect user's motion preferences */
@media (prefers-reduced-motion: reduce) {
  :root {
    --animation-duration: 0.01ms;
  }
  
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  :root {
    --bg: #ffffff;
    --card: #ffffff;
    --text: #000000;
    --muted: #333333;
    --accent: #0066cc;
    --accent-dark: #004499;
  }
}

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

html, body, #root {
  height: 100%;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial;
  font-size: var(--fs-base);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Layout container */
.container {
  width: 100%;
  max-width: 1800px;
  margin: 0 auto;
  padding: clamp(16px, 3vw, 24px);
}

/* 🌐 Navbar */
.nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 20px;
  background: var(--card);
  border-radius: 10px;
  box-shadow: 0 6px 20px rgba(15, 23, 42, 0.06);
  flex-wrap: wrap;
  gap: 10px;
}

.brand {
  font-weight: 700;
  color: var(--accent);
  font-size: var(--fs-lg);
}

.nav ul {
  display: flex;
  gap: 18px;
  list-style: none;
  flex-wrap: wrap;
}

.nav a {
  color: var(--text);
  text-decoration: none;
  opacity: 0.9;
  font-weight: 600;
}

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

/* 🏆 Hero Section */
.hero {
  text-align: center;
  padding: clamp(40px, 6vw, 64px) 16px;
  background: linear-gradient(90deg, rgba(255, 255, 255, 1) 0%, rgba(224, 253, 250, 1) 100%);
  border-radius: 10px;
  margin-top: 18px;
}

h1 {
  font-size: var(--fs-xl);
  margin-bottom: 12px;
}

.lead {
  color: var(--muted);
  max-width: 820px;
  margin: 0 auto 18px;
  font-size: clamp(14px, 2vw, 16px);
}

/* 🔘 Buttons */
.btn {
  display: inline-block;
  padding: 12px 20px;
  border-radius: 12px;
  text-decoration: none;
  font-weight: 700;
  cursor: pointer;
  border: none;
  background: var(--accent);
  color: #fff;
  transition: background 0.2s ease, transform 0.15s ease;
  box-shadow: 0 8px 20px rgba(14, 165, 164, 0.18);
}

.btn:hover {
  background: var(--accent-dark);
  transform: translateY(-2px);
}

.btn.secondary {
  background: transparent;
  color: var(--accent);
  border: 2px solid rgba(14, 165, 164, 0.2);
}

/* 📦 Sections */
.section {
  margin-top: 28px;
  display: grid;
  gap: 18px;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 18px;
}

.card {
  background: var(--card);
  padding: 18px;
  border-radius: 12px;
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.04);
}

.card h4 {
  margin-bottom: 8px;
  color: var(--accent);
}

.card p {
  color: var(--muted);
  font-size: 0.95rem;
}

/* 📜 Footer */
.footer {
  margin-top: 28px;
  text-align: center;
  color: var(--muted);
  padding: 12px 0;
  font-size: 0.9rem;
}

/* 📊 Dashboard Layout */
.app {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
}

.sidebar {
  flex: 1 1 240px;
  max-width: 280px;
  background: var(--card);
  padding: 18px;
  border-radius: 12px;
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.04);
}

.sidebar h3 {
  color: var(--accent);
  margin-bottom: 12px;
}

.sidebar a {
  display: block;
  padding: 8px 6px;
  color: var(--text);
  text-decoration: none;
  border-radius: 8px;
  margin-bottom: 6px;
  font-weight: 600;
  transition: background 0.2s ease;
}

.sidebar a:hover {
  background: var(--soft);
}

.main {
  flex: 3 1 600px;
  min-width: 0; /* fix overflow in flexbox */
}

.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
  flex-wrap: wrap;
  gap: 12px;
}

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.stat {
  background: var(--card);
  padding: 16px;
  border-radius: 12px;
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.04);
}

.table {
  background: var(--card);
  padding: 14px;
  border-radius: 12px;
  overflow-x: auto; /* scroll on small screens */
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.04);
}

/* Global input styling fix */
input[type="date"] {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  padding: 12px;
  border-radius: 8px;
  border: 1px solid #ccc;
  font-size: 15px;
  width: 100%;
  box-sizing: border-box;
}

/* Optional: hide calendar icon on Chrome/Edge if you want cleaner look */
input[type="date"]::-webkit-calendar-picker-indicator {
  cursor: pointer;
  opacity: 0.7;
  margin-right: 4px;
}

/* 🎯 Enhanced Accessibility Features */

/* Skip link for screen readers */
.skip-link {
  position: absolute;
  top: -40px;
  left: 6px;
  background: var(--text);
  color: var(--bg);
  padding: 8px 16px;
  text-decoration: none;
  z-index: 9999;
  border-radius: 4px;
  font-weight: 600;
  transition: top var(--animation-duration) var(--animation-easing);
}

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

/* Enhanced focus styles */
*:focus {
  outline: 2px solid var(--focus-color);
  outline-offset: 2px;
  border-radius: 4px;
}

/* Remove default focus for mouse users */
*:focus:not(:focus-visible) {
  outline: none;
}

/* Enhanced button focus */
.btn:focus {
  outline: 2px solid var(--focus-color);
  outline-offset: 2px;
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.1);
}

/* Form input enhancements */
input, textarea, select {
  border: 2px solid #e5e7eb;
  border-radius: 8px;
  padding: 12px;
  font-size: 16px;
  transition: border-color var(--animation-duration) var(--animation-easing);
}

input:focus, textarea:focus, select:focus {
  border-color: var(--focus-color);
  outline: none;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

input:invalid {
  border-color: var(--error-color);
}

input:valid {
  border-color: var(--success-color);
}

/* Loading states */
.loading {
  position: relative;
  pointer-events: none;
  opacity: 0.7;
}

.loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 20px;
  height: 20px;
  margin: -10px 0 0 -10px;
  border: 2px solid transparent;
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

/* Error states */
.error {
  color: var(--error-color);
  border-color: var(--error-color) !important;
}

.success {
  color: var(--success-color);
  border-color: var(--success-color) !important;
}

/* Screen reader only content */
.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;
}

/* Image lazy loading optimization */
img {
  max-width: 100%;
  height: auto;
  loading: lazy;
}

img[loading="lazy"] {
  opacity: 0;
  transition: opacity var(--animation-duration) var(--animation-easing);
}

img[loading="lazy"].loaded {
  opacity: 1;
}

/* Performance optimizations */
.will-change-transform {
  will-change: transform;
}

.will-change-opacity {
  will-change: opacity;
}

/* Print styles */
@media print {
  * {
    background: transparent !important;
    color: black !important;
    box-shadow: none !important;
    text-shadow: none !important;
  }
  
  .nav, .sidebar, .btn {
    display: none !important;
  }
  
  .main {
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
  }
  
  a, a:visited {
    text-decoration: underline;
  }
  
  a[href]:after {
    content: " (" attr(href) ")";
  }
}

/* 📱 Enhanced Responsive Design */
@media (max-width: 720px) {
  .nav ul {
    display: none;
  }
  .app {
    flex-direction: column;
  }
  .sidebar {
    width: 100%;
    max-width: 100%;
  }
  h1 {
    font-size: 26px;
  }
  
  /* Touch-friendly buttons on mobile */
  .btn {
    min-height: 44px;
    min-width: 44px;
    padding: 12px 24px;
  }
  
  /* Larger tap targets */
  .nav a, .sidebar a {
    min-height: 44px;
    display: flex;
    align-items: center;
  }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f172a;
    --card: #1e293b;
    --muted: #94a3b8;
    --text: #f1f5f9;
    --accent: #06b6d4;
    --accent-dark: #0891b2;
    --soft: #164e63;
  }
}
