/**
 * Enhanced Habit Tracker - Custom Styles
 * Mobile-first responsive design with dark mode and accessibility
 */

/* Custom font and base styles */
* {
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Touch improvements for mobile */
button, [role="button"] {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

/* Custom scrollbar for webkit browsers */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
  background: #c1c1c1;
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: #a8a8a8;
}

/* Custom animations */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

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

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

.animate-slide-up {
  animation: slideUp 0.4s ease-out;
}

/* Progress bar animations */
.progress-bar {
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Button press effects */
.btn-press:active {
  transform: scale(0.96);
  transition: transform 0.1s ease-in-out;
}

/* Safe area adjustments for notched devices */
@supports (padding: max(0px)) {
  .safe-area-top {
    padding-top: max(1rem, env(safe-area-inset-top));
  }
  
  .safe-area-bottom {
    padding-bottom: max(1rem, env(safe-area-inset-bottom));
  }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  .border-gray-300 {
    border-color: #000000;
  }
  
  .text-gray-600 {
    color: #000000;
  }
}

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

/* Focus styles for accessibility */
.focus-ring:focus {
  outline: 2px solid #10B981;
  outline-offset: 2px;
}

/* Dark mode styles */
.dark {
  color-scheme: dark;
}

.dark body {
  background-color: #111827;
  color: #f9fafb;
}

/* Enhanced animations for user feedback */
@keyframes bounce-celebration {
  0%, 100% { 
    transform: scale(1) rotate(0deg); 
  }
  25% { 
    transform: scale(1.15) rotate(5deg); 
  }
  50% { 
    transform: scale(1.3) rotate(-5deg); 
  }
  75% { 
    transform: scale(1.15) rotate(5deg); 
  }
}

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

@keyframes pulse-success {
  0%, 100% { 
    transform: scale(1); 
    opacity: 1; 
  }
  50% { 
    transform: scale(1.05); 
    opacity: 0.9; 
  }
}

@keyframes glow-achievement {
  0%, 100% { 
    box-shadow: 0 0 5px rgba(16, 185, 129, 0.5), 0 0 10px rgba(16, 185, 129, 0.3); 
  }
  50% { 
    box-shadow: 0 0 20px rgba(16, 185, 129, 0.8), 0 0 30px rgba(16, 185, 129, 0.6), 0 0 40px rgba(16, 185, 129, 0.4); 
  }
}

@keyframes confetti {
  0% { 
    transform: scale(0.8) rotate(0deg); 
    opacity: 1; 
  }
  25% { 
    transform: scale(1.2) rotate(90deg); 
    opacity: 0.9; 
  }
  50% { 
    transform: scale(1.4) rotate(180deg); 
    opacity: 0.8; 
  }
  75% { 
    transform: scale(1.2) rotate(270deg); 
    opacity: 0.9; 
  }
  100% { 
    transform: scale(1) rotate(360deg); 
    opacity: 1; 
  }
}

@keyframes counter-reset {
  0% { 
    transform: scale(1); 
    background-color: currentColor; 
  }
  25% { 
    transform: scale(1.05); 
    background-color: #3B82F6; 
  }
  50% { 
    transform: scale(1.1); 
    background-color: #10B981; 
  }
  75% { 
    transform: scale(1.05); 
    background-color: #8B5CF6; 
  }
  100% { 
    transform: scale(1); 
    background-color: currentColor; 
  }
}

@keyframes bounce {
  0%, 20%, 53%, 80%, 100% {
    animation-timing-function: cubic-bezier(0.215, 0.610, 0.355, 1.000);
    transform: translate3d(0,0,0);
  }
  40%, 43% {
    animation-timing-function: cubic-bezier(0.755, 0.050, 0.855, 0.060);
    transform: translate3d(0, -10px, 0);
  }
  70% {
    animation-timing-function: cubic-bezier(0.755, 0.050, 0.855, 0.060);
    transform: translate3d(0, -5px, 0);
  }
  90% {
    transform: translate3d(0,-1px,0);
  }
}

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

@keyframes celebration {
  0% { transform: scale(1) rotate(0deg); }
  25% { transform: scale(1.1) rotate(5deg); }
  50% { transform: scale(1.2) rotate(-5deg); }
  75% { transform: scale(1.1) rotate(5deg); }
  100% { transform: scale(1) rotate(0deg); }
}

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

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

.animate-bounce-celebration {
  animation: bounce-celebration 0.6s ease-in-out;
}

.animate-shake-warning {
  animation: shake-warning 0.5s ease-in-out;
}

.animate-pulse-success {
  animation: pulse-success 1s ease-in-out infinite;
}

.animate-glow-achievement {
  animation: glow-achievement 2s ease-in-out infinite;
}

.animate-confetti {
  animation: confetti 0.8s ease-out;
}

.animate-counter-reset {
  animation: counter-reset 1s ease-in-out;
}

/* Loading spinner styles */
.loading-spinner {
  border: 2px solid #f3f3f3;
  border-top: 2px solid #10B981;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

/* Emoji and icon enhancements */
.emoji-large {
  font-size: 2rem;
  line-height: 1;
  display: inline-block;
}

.emoji-bounce:hover {
  animation: bounce 0.5s ease-in-out;
}

/* Progress bar glow effect */
.progress-bar-glow {
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.5);
}

/* Custom scrollbar for dark mode */
.dark ::-webkit-scrollbar-track {
  background: #374151;
}

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

.dark ::-webkit-scrollbar-thumb:hover {
  background: #9ca3af;
}

/* Improved button transitions */
.btn-enhanced {
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  will-change: transform;
}

.btn-enhanced:active {
  transform: scale(0.95);
}

.btn-enhanced:hover {
  transform: translateY(-1px);
}

/* Glass morphism effect */
.glass {
  backdrop-filter: blur(16px) saturate(180%);
  -webkit-backdrop-filter: blur(16px) saturate(180%);
  background-color: rgba(255, 255, 255, 0.75);
  border: 1px solid rgba(209, 213, 219, 0.3);
}

.dark .glass {
  background-color: rgba(17, 24, 39, 0.75);
  border: 1px solid rgba(75, 85, 99, 0.3);
}