/* ===== Diet Coach Custom Premium Styles ===== */

/* Google Fonts Import */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=Poppins:wght@400;500;600;700&display=swap');

:root {
  /* Primary Color Palette - Modern HSL-based */
  --color-primary: hsl(142, 76%, 45%);
  /* Vibrant Green */
  --color-primary-dark: hsl(142, 76%, 35%);
  --color-primary-light: hsl(142, 76%, 55%);

  /* Secondary Colors */
  --color-secondary: hsl(262, 83%, 58%);
  /* Purple */
  --color-accent: hsl(35, 100%, 55%);
  /* Orange */

  /* Neutral Colors */
  --color-dark: hsl(220, 13%, 13%);
  --color-darker: hsl(220, 13%, 8%);
  --color-gray-900: hsl(220, 13%, 18%);
  --color-gray-800: hsl(220, 10%, 25%);
  --color-gray-700: hsl(220, 8%, 35%);
  --color-gray-600: hsl(220, 6%, 45%);
  --color-gray-500: hsl(220, 5%, 55%);
  --color-gray-400: hsl(220, 4%, 65%);
  --color-gray-300: hsl(220, 3%, 75%);
  --color-gray-200: hsl(220, 2%, 85%);
  --color-gray-100: hsl(220, 1%, 93%);
  --color-gray-50: hsl(220, 1%, 98%);
  --color-white: hsl(0, 0%, 100%);

  /* Status Colors */
  --color-success: hsl(142, 76%, 45%);
  --color-warning: hsl(45, 93%, 47%);
  --color-error: hsl(0, 72%, 51%);
  --color-info: hsl(199, 89%, 48%);

  /* Gradients */
  --gradient-primary: linear-gradient(135deg, var(--color-primary) 0%, var(--color-secondary) 100%);
  --gradient-accent: linear-gradient(135deg, var(--color-accent) 0%, hsl(35, 100%, 65%) 100%);
  --gradient-purple: linear-gradient(135deg, hsl(262, 83%, 58%) 0%, hsl(235, 83%, 58%) 100%);

  /* Shadows */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  --shadow-xl: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  --shadow-glow: 0 0 20px rgba(var(--color-primary-rgb), 0.4);

  /* Border Radius */
  --radius-sm: 0.375rem;
  --radius: 0.5rem;
  --radius-md: 0.75rem;
  --radius-lg: 1rem;
  --radius-xl: 1.5rem;
  --radius-full: 9999px;

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

  /* Spacing */
  --spacing-xs: 0.25rem;
  --spacing-sm: 0.5rem;
  --spacing-md: 1rem;
  --spacing-lg: 1.5rem;
  --spacing-xl: 2rem;
  --spacing-2xl: 3rem;
}

/* ===== Base Styles ===== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Inter', sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  background: var(--color-gray-50);
  color: var(--color-gray-900);
  line-height: 1.6;
}

h1,
h2,
h3,
h4,
h5,
h6 {
  font-family: 'Poppins', sans-serif;
  font-weight: 700;
  line-height: 1.3;
}

/* ===== Glassmorphism 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.3);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  transition: transform var(--transition), box-shadow var(--transition);
}

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

.glass-card-dark {
  background: rgba(30, 30, 40, 0.8);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--color-white);
}

/* ===== Gradient Backgrounds ===== */
.bg-gradient-primary {
  background: var(--gradient-primary);
}

.bg-gradient-purple {
  background: var(--gradient-purple);
}

.bg-gradient-accent {
  background: var(--gradient-accent);
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  font-weight: 600;
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
}

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

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

.btn-secondary {
  background: var(--color-gray-200);
  color: var(--color-gray-900);
}

.btn-secondary:hover {
  background: var(--color-gray-300);
}

.btn-ghost {
  background: transparent;
  border: 2px solid var(--color-primary);
  color: var(--color-primary);
}

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

/* ===== Stat Cards ===== */
.stat-card {
  background: white;
  padding: 1.5rem;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  transition: all var(--transition);
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 4px;
  background: var(--gradient-primary);
}

.stat-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}

.stat-value {
  font-size: 2.5rem;
  font-weight: 800;
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.stat-label {
  color: var(--color-gray-600);
  font-size: 0.875rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ===== Progress Rings ===== */
.progress-ring {
  position: relative;
  width: 150px;
  height: 150px;
}

.progress-ring-circle {
  transform: rotate(-90deg);
  transform-origin: 50% 50%;
  transition: stroke-dashoffset var(--transition-slow);
}

/* ===== Badges ===== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.25rem 0.75rem;
  border-radius: var(--radius-full);
  font-size: 0.875rem;
  font-weight: 600;
}

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

.badge-secondary {
  background: var(--color-secondary);
  color: white;
}

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

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

/* ===== Micro Animations ===== */
@keyframes pulse {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.7;
  }
}

@keyframes slideIn {
  from {
    transform: translateY(20px);
    opacity: 0;
  }

  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

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

  to {
    transform: scale(1);
    opacity: 1;
  }
}

@keyframes glow {

  0%,
  100% {
    box-shadow: 0 0 20px rgba(66, 245, 141, 0.3);
  }

  50% {
    box-shadow: 0 0 40px rgba(66, 245, 141, 0.5);
  }
}

.animate-slide-in {
  animation: slideIn 0.4s ease-out;
}

.animate-fade-in {
  animation: fadeIn 0.3s ease-out;
}

.animate-scale-in {
  animation: scaleIn 0.3s ease-out;
}

/* ===== Loading States ===== */
.loading-skeleton {
  background: linear-gradient(90deg,
      var(--color-gray-200) 0%,
      var(--color-gray-300) 50%,
      var(--color-gray-200) 100%);
  background-size: 200% 100%;
  animation: loading 1.5s ease-in-out infinite;
}

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

  100% {
    background-position: -200% 0;
  }
}

.spinner {
  border: 3px solid var(--color-gray-200);
  border-top-color: var(--color-primary);
  border-radius: var(--radius-full);
  width: 40px;
  height: 40px;
  animation: spin 0.6s linear infinite;
}

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

/* ===== Hover Effects ===== */
.hover-lift {
  transition: transform var(--transition), box-shadow var(--transition);
}

.hover-lift:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}

.hover-glow {
  transition: box-shadow var(--transition);
}

.hover-glow:hover {
  box-shadow: 0 0 20px rgba(66, 245, 141, 0.4);
}

/* ===== Chart Containers ===== */
.chart-container {
  position: relative;
  height: 300px;
  padding: 1rem;
  background: white;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

/* ===== Notification Toast ===== */
.toast {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  min-width: 300px;
  padding: 1rem 1.5rem;
  background: white;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  animation: slideIn 0.3s ease-out;
  z-index: 1000;
}

.toast-success {
  border-left: 4px solid var(--color-success);
}

.toast-error {
  border-left: 4px solid var(--color-error);
}

.toast-info {
  border-left: 4px solid var(--color-info);
}

/* ===== Modal ===== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  z-index: 999;
  animation: fadeIn 0.2s ease-out;
}

.modal-content {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  max-width: 500px;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
  background: white;
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  z-index: 1000;
  animation: scaleIn 0.3s ease-out;
}

/* ===== Enhanced Responsive Utilities ===== */
@media (max-width: 768px) {

  /* Typography adjustments */
  h1 {
    font-size: 2rem;
  }

  h2 {
    font-size: 1.5rem;
  }

  .stat-value {
    font-size: 2rem;
  }

  /* Touch-friendly buttons */
  .btn {
    min-height: 44px;
    padding: 0.875rem 1.25rem;
  }

  /* Improved spacing */
  .glass-card {
    padding: 1rem;
  }

  /* Stack layouts */
  .grid.grid-cols-2,
  .grid.grid-cols-3,
  .grid.grid-cols-4 {
    grid-template-columns: 1fr;
  }

  /* Full-width modals on mobile */
  .modal-content {
    width: 100%;
    max-width: 100%;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    top: auto;
    bottom: 0;
    transform: translateX(-50%);
  }

  /* Toasts */
  .toast {
    bottom: 1rem;
    right: 1rem;
    left: 1rem;
    min-width: auto;
  }

  /* Tables - horizontal scroll */
  .overflow-x-auto {
    -webkit-overflow-scrolling: touch;
  }

  /* Charts */
  .chart-container {
    height: 250px;
  }

  /* Navigation improvements */
  nav {
    padding: 0.5rem 1rem;
  }

  /* Form inputs - larger for mobile */
  input[type="text"],
  input[type="email"],
  input[type="password"],
  input[type="number"],
  input[type="date"],
  textarea,
  select {
    font-size: 16px;
    /* Prevents zoom on iOS */
    min-height: 44px;
  }

  /* Image previews */
  .image-preview img {
    max-height: 200px;
  }
}

/* Tablet adjustments */
@media (min-width: 769px) and (max-width: 1024px) {
  .stat-value {
    font-size: 2.25rem;
  }

  .glass-card {
    padding: 1.25rem;
  }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {

  /* Larger click targets */
  a,
  button {
    min-height: 44px;
    min-width: 44px;
  }

  /* Disable hover effects on touch */
  .hover-lift:hover,
  .hover-glow:hover {
    transform: none;
    box-shadow: inherit;
  }

  /* Enable active states instead */
  .hover-lift:active {
    transform: scale(0.98);
  }
}

/* Print styles */
@media print {
  .glass-card {
    background: white;
    box-shadow: none;
    border: 1px solid #ccc;
  }

  .btn,
  nav,
  .toast {
    display: none;
  }
}

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

::-webkit-scrollbar-track {
  background: var(--color-gray-100);
}

::-webkit-scrollbar-thumb {
  background: var(--color-gray-400);
  border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--color-gray-500);
}

/* ===== Accessibility Enhancements ===== */
/* Focus visible for keyboard navigation */
*:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  .glass-card {
    background: white;
    border: 2px solid var(--color-gray-900);
  }

  .btn {
    border: 2px solid currentColor;
  }
}

/* ===== Dark Mode ===== */
html.dark {
  color-scheme: dark;
}

html.dark body {
  background: #111827;
  color: #f3f4f6;
}

html.dark .glass-card {
  background: rgba(31, 41, 55, 0.8);
  border-color: rgba(255, 255, 255, 0.08);
}

html.dark .glass-card:hover {
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.4);
}

html.dark .stat-card {
  background: #1f2937;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
}

html.dark .stat-card::before {
  opacity: 0.8;
}

html.dark .stat-card:hover {
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.5);
}

html.dark .chart-container {
  background: #1f2937;
}

html.dark .toast {
  background: #1f2937;
  color: #f9fafb;
  border-color: #374151;
}

html.dark .modal-backdrop {
  background: rgba(0, 0, 0, 0.75);
}

html.dark .modal-content {
  background: #1f2937;
  color: #f3f4f6;
}

html.dark ::-webkit-scrollbar-track {
  background: #1f2937;
}

html.dark ::-webkit-scrollbar-thumb {
  background: #4b5563;
}

html.dark ::-webkit-scrollbar-thumb:hover {
  background: #6b7280;
}

html.dark .loading-skeleton,
html.dark .skeleton {
  background: linear-gradient(90deg, #374151 0%, #4b5563 50%, #374151 100%);
  background-size: 200% 100%;
}

/* Dark mode icon toggle helpers */
.dark-hidden { display: inline; }
.dark-show { display: none; }
html.dark .dark-hidden { display: none; }
html.dark .dark-show { display: inline; }

/* ===== Page Fade-In Transition ===== */
@keyframes pageFadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

body {
  animation: pageFadeIn 0.25s ease-out;
}

/* ===== Button Loading State ===== */
.btn-loading {
  position: relative;
  pointer-events: none;
  opacity: 0.7;
}

.btn-spinner {
  display: inline-block;
  width: 1em;
  height: 1em;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  margin-right: 0.4em;
  vertical-align: middle;
}

/* ===== Notification Badge ===== */
.notif-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  font-size: 0.625rem;
  font-weight: 700;
  line-height: 1;
  color: white;
  background: #ef4444;
  border-radius: 9999px;
  animation: badgePop 0.3s ease-out;
}

@keyframes badgePop {
  0% { transform: scale(0); }
  70% { transform: scale(1.2); }
  100% { transform: scale(1); }
}

/* ===== Skeleton Loader Utilities ===== */
.skeleton {
  background: linear-gradient(90deg, var(--color-gray-200) 0%, var(--color-gray-100) 50%, var(--color-gray-200) 100%);
  background-size: 200% 100%;
  animation: loading 1.5s ease-in-out infinite;
  border-radius: var(--radius);
}

.skeleton-text { height: 1em; margin-bottom: 0.5em; border-radius: 4px; }
.skeleton-text:last-child { width: 70%; }
.skeleton-title { height: 1.5em; width: 50%; margin-bottom: 0.75em; border-radius: 4px; }
.skeleton-avatar { width: 40px; height: 40px; border-radius: 50%; }
.skeleton-card { height: 120px; border-radius: var(--radius-lg); }
.skeleton-img { height: 200px; border-radius: var(--radius-lg); }

/* ===== Empty State ===== */
.empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
}

.empty-state-icon {
  font-size: 4rem;
  opacity: 0.3;
  margin-bottom: 1rem;
}

.empty-state-title {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--color-gray-700);
  margin-bottom: 0.5rem;
}

html.dark .empty-state-title {
  color: var(--color-gray-300);
}

.empty-state-text {
  color: var(--color-gray-500);
  font-size: 0.9rem;
}

/* ===== Pagination ===== */
.pagination {
  display: flex;
  gap: 0.25rem;
  justify-content: center;
  margin-top: 2rem;
}

.pagination a,
.pagination span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 36px;
  padding: 0 0.75rem;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 500;
  transition: all var(--transition);
}

.pagination a {
  color: var(--color-gray-600);
  background: white;
  border: 1px solid var(--color-gray-200);
}

html.dark .pagination a {
  background: #1f2937;
  border-color: #374151;
  color: #d1d5db;
}

.pagination a:hover {
  background: var(--color-gray-100);
  border-color: var(--color-gray-300);
}

html.dark .pagination a:hover {
  background: #374151;
}

.pagination .active {
  background: var(--gradient-primary);
  color: white;
  border: none;
}

.pagination .disabled {
  opacity: 0.4;
  pointer-events: none;
}

/* ===== Navigation System ===== */

/* iOS safe area padding for bottom bar */
.safe-area-bottom {
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

/* Mobile bottom bar */
.mobile-bottom-bar {
  box-shadow: 0 -4px 20px -4px rgba(0, 0, 0, 0.08);
}

html.dark .mobile-bottom-bar {
  box-shadow: 0 -4px 20px -4px rgba(0, 0, 0, 0.3);
}

/* Toast position adjustment for mobile (above bottom bar) */
@media (max-width: 1023px) {
  .toast {
    bottom: 5.5rem;
  }
}

/* Desktop nav item animated underline */
.nav-item-desktop {
  position: relative;
}

.nav-item-desktop::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  width: 0;
  height: 2px;
  background: linear-gradient(90deg, #7c3aed, #6366f1);
  border-radius: 1px;
  transition: width 0.2s ease, left 0.2s ease;
}

.nav-item-desktop:hover::after {
  width: 60%;
  left: 20%;
}

/* Grid launcher items - staggered fade-in */
.grid-launcher-item {
  opacity: 0;
  animation: gridItemIn 0.3s ease-out forwards;
}

@keyframes gridItemIn {
  from {
    opacity: 0;
    transform: scale(0.9) translateY(4px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

/* Grid launcher item hover lift */
.grid-launcher-item:hover {
  transform: translateY(-2px);
}

.grid-launcher-item:active {
  transform: scale(0.96);
}

/* Grid panel glassmorphism */
.grid-panel {
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

/* Category header gradient underline */
.category-header {
  position: relative;
  display: inline-block;
}

.category-header::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 2rem;
  height: 2px;
  background: linear-gradient(90deg, #7c3aed, #6366f1);
  border-radius: 1px;
}

/* FAB glow effect */
.fab-glow {
  box-shadow:
    0 4px 15px -3px rgba(124, 58, 237, 0.5),
    0 0 0 0 rgba(124, 58, 237, 0);
  transition: box-shadow 0.3s ease, transform 0.2s ease;
}

.fab-glow:hover {
  box-shadow:
    0 6px 20px -3px rgba(124, 58, 237, 0.6),
    0 0 30px -5px rgba(124, 58, 237, 0.3);
}

.fab-glow:active {
  box-shadow:
    0 2px 10px -3px rgba(124, 58, 237, 0.5),
    0 0 0 0 rgba(124, 58, 237, 0);
}

/* Mobile tab active indicator animation */
.tab-active-indicator {
  animation: tabIndicatorIn 0.3s ease-out;
}

@keyframes tabIndicatorIn {
  from {
    width: 0;
    opacity: 0;
  }
  to {
    width: 1.5rem;
    opacity: 1;
  }
}

/* Print: hide mobile bottom bar */
@media print {
  .mobile-bottom-bar {
    display: none;
  }
}