/* Asclepius Wellness App Styles - Mobile First */

:root {
  --blue: #002147;
  --gold: #FFD700;
  --white: #FFFFFF;
  --green: #006400;
  --black: #000000;
  --accent: #0052cc;
  --text: #1f2937;
  --text-muted: #6b7280;
  --background-start: #f9fafb;
  --background-end: #f3f4f6;
  --card-bg: #ffffff;
  --card-border: #e5e7eb;
  --card-shadow: 0 4px 6px -1px rgba(0,0,0,0.05), 0 2px 4px -1px rgba(0,0,0,0.03);
  --card-shadow-hover: 0 10px 15px -3px rgba(0,0,0,0.07), 0 4px 6px -2px rgba(0,0,0,0.05);
  --input-border: #e5e7eb;
  --table-header-bg: #f8fafc;
  --section-bg: #ffffff;
  --error: #dc2626;
  --error-bg: #fee2e2;
  --success: #059669;
  --success-bg: #d1fae5;
  --warning: #d97706;
  --warning-bg: #fed7aa;
  --info: #0891b2;
  --info-bg: #cffafe;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: 'Montserrat', system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px;
  color: var(--text);
  background-color: var(--background-start);
  background-image: linear-gradient(180deg, var(--background-start) 0%, var(--background-end) 100%);
  transition: background .3s ease, color .3s ease;
}

.container {
  width: 95%;
  max-width: 1100px;
  margin: 0 auto;
}

main.container {
  padding-top: 2rem;
  padding-bottom: 2rem;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--card-bg) 90%, transparent);
  backdrop-filter: saturate(180%) blur(10px);
  border-bottom: 1px solid var(--card-border);
  box-shadow: 0 2px 10px rgba(0,0,0,0.05);
  transition: box-shadow 0.3s ease;
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
}
.brand {
  color: var(--blue);
  font-weight: 700;
  text-decoration: none;
}
/* Mobile Menu Button */
.mobile-menu-button {
  display: flex;
  flex-direction: column;
  justify-content: space-around;
  width: 30px;
  height: 30px;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0;
  z-index: 60;
  position: relative; /* For z-index to work */
}
.mobile-menu-button .line {
  display: block;
  width: 100%;
  height: 3px;
  background-color: var(--text);
  transition: all 0.3s ease-in-out;
}
.mobile-menu-button.is-active .line:nth-child(1) {
  transform: translateY(11px) rotate(45deg);
}
.mobile-menu-button.is-active .line:nth-child(2) {
  opacity: 0;
}
.mobile-menu-button.is-active .line:nth-child(3) {
  transform: translateY(-11px) rotate(-45deg);
}

/* Navigation */
.nav-wrapper {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--background-start);
  overflow-y: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.35s ease, visibility 0.35s ease;
  z-index: 55;
}
.nav-wrapper.is-active {
  opacity: 1;
  visibility: visible;
}
.nav {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
}
.nav-profile-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.nav-profile-link img {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  flex-shrink: 0;
  object-fit: cover;
}
.nav a {
  font-size: 1.5rem;
  font-weight: 600;
  text-decoration: none;
  color: var(--text);
}

/* Desktop Navigation Styles */
@media (min-width: 768px) {
  .mobile-menu-button {
    display: none;
  }
  .nav-wrapper {
    position: static;
    width: auto;
    height: auto;
    background: none;
    opacity: 1;
    visibility: visible;
  }
  .nav {
    flex-direction: row;
    align-items: center;
    gap: 0; /* Reset gap */
  }
  .nav a {
    margin-left: 12px;
    font-size: 1rem; /* Reset font size */
    transition: color 0.2s ease;
    position: relative;
  }
  .nav a:hover {
    color: var(--gold);
  }
  .nav a::after {
    content: '';
    position: absolute;
    width: 100%;
    transform: scaleX(0);
    height: 2px;
    bottom: -4px;
    left: 0;
    background-color: var(--gold);
    transform-origin: bottom right;
    transition: transform 0.25s ease-out;
  }
  .nav a:hover::after {
    transform: scaleX(1);
    transform-origin: bottom left;
  }
}
.btn, .btn-outline {
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  border: 2px solid transparent;
  cursor: pointer;
}
.btn:hover, .btn-outline:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 10px rgba(0,0,0,0.1);
}
.btn:active, .btn-outline:active {
  transform: translateY(0);
  box-shadow: none;
}
.btn {
  background: var(--accent);
  color: var(--white);
  padding: 12px 20px;
  border-radius: 8px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  text-decoration: none;
}
.btn-outline {
  border-color: var(--accent);
  color: var(--accent);
  background: transparent;
  padding: 10px 18px;
  border-radius: 8px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  text-decoration: none;
}

.hero {
  display: grid;
  grid-template-columns: 1fr;
  gap: 24px;
  align-items: center;
  padding: 2rem 0;
}
.hero h1 {
  font-size: 42px;
  font-weight: 700;
  margin: 0 0 12px;
  line-height: 1.2;
}
.hero p {
  font-size: 1.1rem;
  color: var(--text-muted);
}
.card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 16px;
  padding: 24px;
  box-shadow: var(--card-shadow);
  transition: transform .3s ease, box-shadow .3s ease, background .3s ease, border-color .3s ease;
}
.card:hover {
  transform: translateY(-5px);
  box-shadow: var(--card-shadow-hover);
}

.grid {
  display: grid;
  gap: 24px;
}

.grid.cols-2 { grid-template-columns: 1fr; }
.grid.cols-3 { grid-template-columns: 1fr; }

.kpi {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 1.5rem;
}
.kpi strong {
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--accent);
  line-height: 1;
}
.kpi span {
  font-size: 1rem;
  margin-top: 0.5rem;
  color: var(--text-muted);
}

.feature-card {
  padding: 2rem;
  text-align: center;
}
.feature-card .icon {
  display: inline-block;
  padding: 1rem;
  background-color: color-mix(in srgb, var(--accent) 15%, transparent);
  border-radius: 50%;
  margin-bottom: 1rem;
}
.feature-card .icon i {
  width: 32px;
  height: 32px;
  color: var(--accent);
}

section.my-4 {
  padding: 2rem;
  background-color: var(--section-bg);
  border-radius: 16px;
  border: 1px solid var(--card-border);
}

/* Spacing utilities */
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.ml-2 { margin-left: 8px; }
.my-1 { margin-top: 6px; margin-bottom: 6px; }
.my-4 { margin-top: 20px; margin-bottom: 20px; }

/* General utilities */
.d-none { display: none !important; }
.w-full { width: 100%; }
.rounded-lg { border-radius: 12px; }
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }

label { display:block; margin: 10px 0 6px; font-weight: 600; }
input, select, textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--input-border);
  border-radius: 10px;
  font-family: inherit;
  background-color: var(--background-end);
  color: var(--text);
}
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px; border-bottom: 1px solid var(--card-border); text-align: left; }
th { background: var(--table-header-bg); }

.badge {
  display: inline-block;
  background: var(--green);
  color: var(--white);
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 12px;
}

.progress {
  height: 10px;
  background: var(--card-border);
  border-radius: 999px;
  overflow: hidden;
}
.progress > span { display:block; height:100%; background: var(--gold); width: 0; transition: width .4s ease; }

.motivation {
  background: linear-gradient(135deg, var(--blue), #00356a);
  color: var(--white);
  border-radius: 14px;
  padding: 16px;
}
.motivation .btn-outline { border-color: var(--white); color: var(--white); }
.motivation .btn { background: var(--gold); color: var(--black); }

.site-footer { padding: 24px 0; color: var(--text-muted); }

/* Achievement card states */
.achievement-locked {
  filter: grayscale(1);
  opacity: 0.7;
}

/* Animations */
.fade-in { opacity: 0; transform: translateY(8px); animation: fadeIn .6s ease forwards; }
@keyframes fadeIn { to { opacity: 1; transform: none; } }

/* Tabs / button groups */
.tabs { display: flex; flex-wrap: wrap; gap: 8px; }

/* Ensure buttons in tab group have consistent height and spacing */
.tabs .btn, .tabs .btn-outline { line-height: 1; padding-top: 10px; padding-bottom: 10px; }

/* Small screens: stack filter under tabs */
@media (max-width: 640px) {
  .tabs { margin-bottom: 8px; }
}

/* Responsive */
@media (min-width: 768px) {
  .hero { grid-template-columns: 1.1fr 0.9fr; }
  .grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
  .grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
  .grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
  .hero h1 { font-size: 36px; }
}

/* Dark Mode Palette */
body.dark-mode {
  --text: #e5e7eb;
  --text-muted: #9ca3af;
  --background-start: #111827;
  --background-end: #1f2937;
  --card-bg: #374151;
  --card-border: #4b5563;
  --card-shadow: 0 10px_20px rgba(0,0,0,0.1);
  --card-shadow-hover: 0 12px 24px rgba(0,0,0,0.15);
  --input-border: #4b5563;
  --table-header-bg: #4b5563;
}

/* Dashboard Layout */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

@media (min-width: 1024px) {
  .dashboard-grid {
    grid-template-columns: 2fr 1fr; /* 2/3 for main, 1/3 for sidebar */
  }
}

/* Alert/Notification Styles */
.alert {
  padding: 16px 20px;
  border-radius: 12px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  animation: slideIn 0.3s ease;
  position: relative;
  overflow: hidden;
}

.alert::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
}

.alert-error {
  background: var(--error-bg);
  color: var(--error);
}

.alert-error::before {
  background: var(--error);
}

.alert-success {
  background: var(--success-bg);
  color: var(--success);
}

.alert-success::before {
  background: var(--success);
}

.alert-warning {
  background: var(--warning-bg);
  color: var(--warning);
}

.alert-warning::before {
  background: var(--warning);
}

.alert-info {
  background: var(--info-bg);
  color: var(--info);
}

.alert-info::before {
  background: var(--info);
}

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

/* Form Validation Styles */
.form-group {
  margin-bottom: 20px;
}

.form-error {
  color: var(--error);
  font-size: 0.875rem;
  margin-top: 4px;
  display: none;
}

input.error, select.error, textarea.error {
  border-color: var(--error);
  animation: shake 0.3s ease;
}

input.error:focus, select.error:focus, textarea.error:focus {
  outline-color: var(--error);
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.1);
}

input.success, select.success, textarea.success {
  border-color: var(--success);
}

input.success:focus, select.success:focus, textarea.success:focus {
  outline-color: var(--success);
  box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.1);
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
  20%, 40%, 60%, 80% { transform: translateX(5px); }
}

/* Enhanced Form Styles */
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0, 82, 204, 0.1);
  transition: all 0.2s ease;
}

/* Button Loading State */
.btn-loading {
  position: relative;
  color: transparent !important;
  pointer-events: none;
}

.btn-loading::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  width: 20px;
  height: 20px;
  margin: -10px 0 0 -10px;
  border: 2px solid #ffffff;
  border-radius: 50%;
  border-top-color: transparent;
  animation: spin 0.8s linear infinite;
}

/* Loader */
.loader {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--background-start);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  transition: opacity 0.5s ease, visibility 0.5s ease;
}

.loader.hidden {
  opacity: 0;
  visibility: hidden;
}

.spinner {
  width: 50px;
  height: 50px;
  border: 5px solid var(--card-border);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

/* Quick Links */
.quick-link {
  display: flex;
  align-items: center;
  gap: 16px;
  text-decoration: none;
  color: var(--text);
}
.quick-link:hover {
  border-color: var(--gold);
}
.quick-link i.feather {
  width: 24px;
  height: 24px;
  color: var(--blue);
  flex-shrink: 0;
}
.quick-link p {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* Modern Card Enhancements */
.card {
  position: relative;
  overflow: hidden;
}

.card::after {
  content: '';
  position: absolute;
  top: -2px;
  left: -2px;
  right: -2px;
  bottom: -2px;
  background: linear-gradient(45deg, var(--accent), var(--gold));
  border-radius: 16px;
  opacity: 0;
  z-index: -1;
  transition: opacity 0.3s ease;
}

.card:hover::after {
  opacity: 0.1;
}

/* Glass Effect Cards */
.glass-card {
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.18);
}

/* Dark mode glass effect */
body.dark-mode .glass-card {
  background: rgba(55, 65, 81, 0.7);
  border: 1px solid rgba(75, 85, 99, 0.3);
}

/* Enhanced KPI Cards */
.kpi {
  position: relative;
  overflow: hidden;
}

.kpi-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
}

.kpi-text {
  text-align: left;
}

.kpi-text span {
  display: block;
  font-size: 0.875rem;
  margin-bottom: 4px;
}

.kpi-text strong {
  font-size: 1.5rem;
  display: block;
}

/* Skeleton Loading */
.skeleton {
  background: linear-gradient(90deg, var(--card-border) 25%, var(--background-end) 50%, var(--card-border) 75%);
  background-size: 200% 100%;
  animation: loading 1.5s infinite;
  border-radius: 4px;
}

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

.skeleton-text {
  height: 16px;
  margin-bottom: 8px;
}

.skeleton-title {
  height: 24px;
  width: 60%;
  margin-bottom: 12px;
}

/* Improved Mobile Experience */
@media (max-width: 768px) {
  .container {
    width: 100%;
    padding: 0 16px;
  }
  
  .hero h1 {
    font-size: 28px;
  }
  
  .card {
    padding: 16px;
  }
  
  .btn, .btn-outline {
    width: 100%;
    margin-bottom: 8px;
  }
  
  .ml-2 {
    margin-left: 0;
  }
  
  table {
    font-size: 14px;
  }
  
  th, td {
    padding: 8px 4px;
  }
  
  /* Stack form elements on mobile */
  .form-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
  }
}

/* Tooltip Styles */
.tooltip {
  position: relative;
  cursor: help;
}

.tooltip-text {
  visibility: hidden;
  position: absolute;
  z-index: 1;
  bottom: 125%;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: var(--white);
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 0.875rem;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.3s;
}

.tooltip-text::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  margin-left: -5px;
  border-width: 5px;
  border-style: solid;
  border-color: var(--text) transparent transparent transparent;
}

.tooltip:hover .tooltip-text {
  visibility: visible;
  opacity: 1;
}

/* Smooth Scroll Behavior */
html {
  scroll-padding-top: 80px; /* Account for sticky header */
}

/* Focus Visible - Better Accessibility */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Skip to main content link */
.skip-link {
  position: absolute;
  top: -40px;
  left: 0;
  background: var(--accent);
  color: white;
  padding: 8px 16px;
  text-decoration: none;
  border-radius: 0 0 8px 0;
  z-index: 100;
}

.skip-link:focus {
  top: 0;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  :root {
    --card-shadow: 0 0 0 2px var(--text);
    --card-shadow-hover: 0 0 0 3px var(--text);
  }
  
  .card {
    border: 2px solid var(--text);
  }
  
  .btn, .btn-outline {
    border-width: 2px;
  }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  
  .loader {
    display: none;
  }
}

/* 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-width: 0;
}

/* Ensure interactive elements have minimum size */
button, a, input, select, textarea {
  min-height: 44px;
  min-width: 44px;
}

/* Better color contrast for dark mode */
body.dark-mode {
  --text: #f3f4f6;
  --text-muted: #d1d5db;
  --accent: #3b82f6;
  --gold: #fbbf24;
}

/* Print Styles */
@media print {
  .site-header, .site-footer, .btn, .btn-outline, .mobile-menu-button {
    display: none !important;
  }
  
  body {
    background: white;
    color: black;
  }
  
  .card {
    box-shadow: none;
    border: 1px solid #000;
  }
}
