/* Global Theme Variables and Styles */
:root {
  --transition-colors: color 0.3s cubic-bezier(0.4, 0, 0.2, 1), 
                      background-color 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                      border-color 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                      box-shadow 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Light Theme Variables */
[data-theme="light"] {
  --bg-primary: #f8fafc;
  --bg-secondary: #ffffff;
  --bg-tertiary: #f1f5f9;
  --text-primary: #1e293b;
  --text-secondary: #64748b;
  --text-muted: #94a3b8;
  --border-primary: #e2e8f0;
  --border-secondary: #cbd5e1;
  --accent-primary: #0284c7;
  --accent-secondary: #10b981;
  --accent-muted: rgba(2, 132, 199, 0.1);
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
}

/* Dark Theme Variables */
[data-theme="dark"] {
  --bg-primary: #0f172a;
  --bg-secondary: #1e293b;
  --bg-tertiary: #334155;
  --text-primary: #f1f5f9;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;
  --border-primary: #475569;
  --border-secondary: #64748b;
  --accent-primary: #7dd3fc;
  --accent-secondary: #6ee7b7;
  --accent-muted: rgba(125, 211, 252, 0.1);
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.3);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.3), 0 2px 4px -2px rgb(0 0 0 / 0.3);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.4), 0 4px 6px -4px rgb(0 0 0 / 0.4);
}

/* Base Styles with Theme Variables */
* {
  transition: var(--transition-colors);
}

body {
  background-color: var(--bg-primary);
  color: var(--text-primary);
}

/* Card Components */
.card {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-primary);
  box-shadow: var(--shadow-sm);
  transition: var(--transition-colors), transform 0.2s ease;
}

.card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

/* Button Components */
.btn-primary {
  background-color: var(--accent-primary);
  color: white;
  border: 1px solid var(--accent-primary);
  transition: var(--transition-colors), transform 0.2s ease;
}

.btn-primary:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.btn-secondary {
  background-color: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid var(--border-primary);
  transition: var(--transition-colors), transform 0.2s ease;
}

.btn-secondary:hover {
  background-color: var(--bg-tertiary);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

/* Input Components */
.input {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-primary);
  color: var(--text-primary);
  transition: var(--transition-colors);
}

.input:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px var(--accent-muted);
  outline: none;
}

.input::placeholder {
  color: var(--text-muted);
}

/* Loading Animation Enhancements */
.loading-spinner {
  animation: spin 1s linear infinite;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* Smooth Page Transitions */
.page-transition {
  animation: fadeInUp 0.5s ease-out;
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Enhanced Focus States for Accessibility */
.focus-ring:focus {
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-muted);
}

/* Gradient Text Effects */
.gradient-text {
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  background-size: 200% 200%;
  animation: gradient-shift 3s ease infinite;
}

@keyframes gradient-shift {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}

/* Responsive Design Enhancements */
@media (max-width: 640px) {
  .card {
    margin: 0.5rem;
    border-radius: 0.75rem;
  }
  
  .btn-primary, .btn-secondary {
    min-height: 44px; /* Touch-friendly */
    font-size: 1rem;
  }
  
  .input {
    min-height: 44px; /* Touch-friendly */
    font-size: 1rem;
  }
}

/* Mobile App Feel Enhancements */
/* Disable text selection except for inputs */
* {
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
}

input, textarea, [contenteditable] {
  -webkit-user-select: text;
  -moz-user-select: text;
  -ms-user-select: text;
  user-select: text;
}

/* Disable image dragging */
img {
  -webkit-user-drag: none;
  -khtml-user-drag: none;
  -moz-user-drag: none;
  -o-user-drag: none;
  user-drag: none;
  pointer-events: none;
}

/* Touch feedback for interactive elements */
.touch-active {
  transform: scale(0.98) !important;
  opacity: 0.7 !important;
  transition: all 0.1s ease !important;
}

/* Enhanced button touch targets */
button, .btn, [role="button"], [onclick] {
  min-height: 44px;
  min-width: 44px;
  position: relative;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

/* Remove iOS button styling */
button, input[type="button"], input[type="submit"] {
  -webkit-appearance: none;
  appearance: none;
  border-radius: 8px;
}

/* Enhanced card touch feedback */
.card {
  transition: var(--transition-colors), transform 0.15s ease, box-shadow 0.15s ease;
}

.card:active {
  transform: scale(0.98);
}

/* Mobile-friendly scrollbars */
::-webkit-scrollbar {
  width: 4px;
  height: 4px;
}

::-webkit-scrollbar-track {
  background: var(--bg-tertiary);
  border-radius: 2px;
}

::-webkit-scrollbar-thumb {
  background: var(--border-secondary);
  border-radius: 2px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* Smooth scrolling for the entire app */
html {
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

/* Fix viewport height issues on mobile */
.min-h-screen {
  min-height: 100vh;
  min-height: -webkit-fill-available;
}

/* Enhanced focus styles for mobile */
.focus\:ring-2:focus {
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-muted);
}

/* Mobile app status bar spacing */
@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));
  }
}

/* Prevent bounce scrolling on iOS */
body {
  width: 100%;
  height: 100%;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}

#app {
  min-height: 100vh;
  -webkit-overflow-scrolling: touch;
}

/* Loading states optimized for mobile */
.loading-overlay {
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

/* Enhanced mobile responsiveness */
@media (max-width: 768px) {
  /* Larger touch targets */
  .card {
    margin: 0.75rem;
    border-radius: 1rem;
    padding: 1.25rem;
  }
  
  /* Better spacing for mobile */
  .container {
    padding-left: 1rem;
    padding-right: 1rem;
  }
  
  /* Mobile-optimized typography */
  h1 { font-size: 1.75rem; }
  h2 { font-size: 1.5rem; }
  h3 { font-size: 1.25rem; }
  
  /* Improved button sizing */
  .btn-primary, .btn-secondary {
    min-height: 48px;
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    border-radius: 0.75rem;
  }
  
  /* Mobile input improvements */
  .input, input, textarea, select {
    min-height: 48px;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    border-radius: 0.75rem;
  }
  
  /* Mobile-friendly modals */
  .modal {
    margin: 1rem;
    max-height: calc(100vh - 2rem);
    border-radius: 1.25rem;
  }
}

/* PWA-specific enhancements */
@media (display-mode: standalone) {
  /* Hide browser UI elements when installed as PWA */
  .pwa-only {
    display: block;
  }
  
  .browser-only {
    display: none;
  }
  
  /* Add native app-like header */
  .app-header {
    background: var(--bg-secondary);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-primary);
  }
}

/* Haptic feedback simulation (visual) */
@keyframes haptic-feedback {
  0% { transform: scale(1); }
  50% { transform: scale(0.95); }
  100% { transform: scale(1); }
}

.haptic-feedback {
  animation: haptic-feedback 0.1s ease-out;
}

/* Print Styles */
@media print {
  [data-theme="dark"] {
    --bg-primary: #ffffff;
    --bg-secondary: #ffffff;
    --text-primary: #000000;
    --text-secondary: #666666;
  }
  
  .sidebar, .mobile-menu-btn {
    display: none !important;
  }
  
  /* Reset mobile app styles for printing */
  * {
    -webkit-user-select: text !important;
    user-select: text !important;
  }
  
  body {
    position: static !important;
    height: auto !important;
    overflow: visible !important;
  }
  
  #app {
    height: auto !important;
    overflow: visible !important;
  }
}