/* PI - Price Intelligence AI - Enhanced Styles */

/* CSS Custom Properties for Dynamic Theming */
:root {
  --primary-50: #eef2ff;
  --primary-100: #e0e7ff;
  --primary-200: #c7d2fe;
  --primary-300: #a5b4fc;
  --primary-400: #818cf8;
  --primary-500: #6366f1;
  --primary-600: #4f46e5;
  --primary-700: #4338ca;
  --primary-800: #3730a3;
  --primary-900: #312e81;
  
  --glass-bg: rgba(255, 255, 255, 0.25);
  --glass-border: rgba(255, 255, 255, 0.18);
  --shadow-glow: 0 0 40px rgba(99, 102, 241, 0.15);
}

/* Enhanced Custom Scrollbar */
::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-track {
  background: rgba(241, 245, 249, 0.8);
  backdrop-filter: blur(10px);
}

::-webkit-scrollbar-thumb {
  background: linear-gradient(135deg, var(--primary-500), var(--primary-700));
  border-radius: 8px;
}

::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(135deg, var(--primary-600), var(--primary-800));
}

/* Modern CSS Reset & Base Styles */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* Enhanced Button System */
.btn-modern {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.875rem 2rem;
  font-weight: 600;
  border-radius: 1rem;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  transform-origin: center;
  outline: none;
  cursor: pointer;
}

.btn-modern:hover {
  transform: translateY(-2px) scale(1.02);
}

.btn-modern:active {
  transform: translateY(0) scale(0.98);
}

.btn-modern:focus-visible {
  outline: 2px solid var(--primary-500);
  outline-offset: 2px;
}

/* Advanced Glass Morphism System */
.glass-ultra {
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: 
    0 8px 32px rgba(0, 0, 0, 0.1),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.glass-card {
  background: rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(15px) saturate(200%);
  -webkit-backdrop-filter: blur(15px) saturate(200%);
  border: 1px solid rgba(255, 255, 255, 0.25);
  box-shadow: 
    0 8px 32px rgba(0, 0, 0, 0.12),
    0 2px 8px rgba(0, 0, 0, 0.08),
    inset 0 1px 0 rgba(255, 255, 255, 0.15);
}

.glass-nav {
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(12px) saturate(150%);
  -webkit-backdrop-filter: blur(12px) saturate(150%);
  border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

/* Modern Gradient System */
.gradient-mesh-1 {
  background: 
    radial-gradient(at 40% 20%, hsla(228,100%,74%,0.7) 0px, transparent 50%),
    radial-gradient(at 80% 0%, hsla(189,100%,56%,0.7) 0px, transparent 50%),
    radial-gradient(at 0% 50%, hsla(355,100%,93%,0.7) 0px, transparent 50%),
    radial-gradient(at 80% 50%, hsla(340,100%,76%,0.7) 0px, transparent 50%),
    radial-gradient(at 0% 100%, hsla(22,100%,77%,0.7) 0px, transparent 50%),
    radial-gradient(at 80% 100%, hsla(242,100%,70%,0.7) 0px, transparent 50%);
}

.gradient-text-primary {
  background: linear-gradient(135deg, var(--primary-600), var(--primary-800));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.gradient-border {
  background: linear-gradient(135deg, var(--primary-500), var(--primary-700));
  padding: 2px;
  border-radius: 1rem;
}

.gradient-border > * {
  background: white;
  border-radius: calc(1rem - 2px);
}

/* Card hover effects */
.card-hover:hover {
  transform: translateY(-4px);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
}

/* Loading spinner */
.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid #f3f3f3;
  border-top: 4px solid #3b82f6;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

/* Upload area styles */
.upload-area {
  border: 2px dashed #d1d5db;
  transition: all 0.3s ease;
}

.upload-area:hover {
  border-color: #3b82f6;
  background-color: #f8fafc;
}

.upload-area.dragover {
  border-color: #3b82f6;
  background-color: #eff6ff;
}

/* Analysis result cards */
.analysis-card {
  background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
  border: 1px solid #e2e8f0;
  transition: all 0.3s ease;
}

.analysis-card:hover {
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
  transform: translateY(-2px);
}

/* Price display */
.price-display {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  font-weight: 700;
  font-feature-settings: 'tnum';
}

/* Status badges */
.status-active {
  @apply bg-green-100 text-green-800;
}

.status-inactive {
  @apply bg-red-100 text-red-800;
}

.status-pending {
  @apply bg-yellow-100 text-yellow-800;
}

/* Condition badges */
.condition-new {
  @apply bg-green-100 text-green-800;
}

.condition-like-new {
  @apply bg-green-50 text-green-600;
}

.condition-good {
  @apply bg-blue-100 text-blue-800;
}

.condition-fair {
  @apply bg-yellow-100 text-yellow-800;
}

.condition-poor {
  @apply bg-red-100 text-red-800;
}

/* Subscription tier colors */
.tier-free {
  @apply bg-gray-100 text-gray-800;
}

.tier-basic {
  @apply bg-blue-100 text-blue-800;
}

.tier-pro {
  @apply bg-purple-100 text-purple-800;
}

.tier-business {
  @apply bg-indigo-100 text-indigo-800;
}

.tier-enterprise {
  @apply bg-pink-100 text-pink-800;
}

/* Mobile responsive helpers */
@media (max-width: 768px) {
  .mobile-center {
    text-align: center;
  }
  
  .mobile-full-width {
    width: 100%;
  }
  
  .mobile-hidden {
    display: none;
  }
  
  .mobile-stack {
    flex-direction: column;
  }
  
  .mobile-no-padding {
    padding: 0;
  }
}

/* Dark mode support (future enhancement) */
@media (prefers-color-scheme: dark) {
  :root {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --text-primary: #f8fafc;
    --text-secondary: #cbd5e1;
  }
}

/* Animation for elements entering viewport */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.fade-in-up {
  animation: fadeInUp 0.6s ease-out forwards;
}

/* Pulse animation for loading states */
@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

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

/* Image placeholder styles */
.image-placeholder {
  background: linear-gradient(45deg, #f1f5f9 25%, transparent 25%), 
              linear-gradient(-45deg, #f1f5f9 25%, transparent 25%), 
              linear-gradient(45deg, transparent 75%, #f1f5f9 75%), 
              linear-gradient(-45deg, transparent 75%, #f1f5f9 75%);
  background-size: 20px 20px;
  background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
}

/* Toast notification styles */
.toast {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 1000;
  min-width: 300px;
  padding: 16px;
  border-radius: 8px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
  transform: translateX(400px);
  transition: transform 0.3s ease;
}

.toast.show {
  transform: translateX(0);
}

.toast-success {
  @apply bg-green-50 border border-green-200 text-green-800;
}

.toast-error {
  @apply bg-red-50 border border-red-200 text-red-800;
}

.toast-warning {
  @apply bg-yellow-50 border border-yellow-200 text-yellow-800;
}

.toast-info {
  @apply bg-blue-50 border border-blue-200 text-blue-800;
}

/* Custom focus styles for accessibility */
.focus-visible:focus {
  outline: 2px solid #3b82f6;
  outline-offset: 2px;
}

/* Print styles */
@media print {
  .no-print {
    display: none !important;
  }
  
  .print-break {
    page-break-before: always;
  }
  
  .print-keep {
    page-break-inside: avoid;
  }
}

/* Selection styles */
::selection {
  background-color: rgba(59, 130, 246, 0.2);
  color: #1e40af;
}

/* Custom checkbox styles */
.custom-checkbox {
  appearance: none;
  width: 20px;
  height: 20px;
  border: 2px solid #d1d5db;
  border-radius: 4px;
  background-color: white;
  cursor: pointer;
  position: relative;
  transition: all 0.2s ease;
}

.custom-checkbox:checked {
  background-color: #3b82f6;
  border-color: #3b82f6;
}

.custom-checkbox:checked::after {
  content: '✓';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: white;
  font-size: 14px;
  font-weight: bold;
}

/* Camera capture styles */
.camera-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
}

.camera-frame {
  width: 280px;
  height: 280px;
  border: 3px solid white;
  border-radius: 12px;
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
}

/* Marketplace logos */
.marketplace-logo {
  width: 24px;
  height: 24px;
  object-fit: contain;
  border-radius: 4px;
}

/* Analysis progress bar */
.progress-bar {
  width: 100%;
  height: 6px;
  background-color: #e5e7eb;
  border-radius: 3px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #3b82f6, #1d4ed8);
  border-radius: 3px;
  transition: width 0.3s ease;
}

/* Responsive grid helpers */
.grid-responsive {
  display: grid;
  gap: 1.5rem;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}

.grid-responsive-sm {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

/* Utility classes for common patterns */
.text-shadow {
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.backdrop-blur {
  backdrop-filter: blur(10px);
}

.border-gradient {
  border: 2px solid;
  border-image: linear-gradient(45deg, #3b82f6, #8b5cf6) 1;
}

/* Loading skeleton */
.skeleton {
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: loading 1.5s infinite;
}

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

/* Error boundary styles */
.error-boundary {
  padding: 2rem;
  text-align: center;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 8px;
  color: #991b1b;
}

/* Feature flag styles */
.feature-new::after {
  content: 'NEW';
  position: absolute;
  top: -8px;
  right: -8px;
  background: #ef4444;
  color: white;
  font-size: 10px;
  font-weight: bold;
  padding: 2px 6px;
  border-radius: 4px;
}

.feature-beta::after {
  content: 'BETA';
  position: absolute;
  top: -8px;
  right: -8px;
  background: #f59e0b;
  color: white;
  font-size: 10px;
  font-weight: bold;
  padding: 2px 6px;
  border-radius: 4px;
}

/* Enhanced Animation Keyframes */
@keyframes fadeInDown {
  from {
    opacity: 0;
    transform: translateY(-30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeInLeft {
  from {
    opacity: 0;
    transform: translateX(-30px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes fadeInRight {
  from {
    opacity: 0;
    transform: translateX(30px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.8);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

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

@keyframes glow {
  0%, 100% {
    box-shadow: 0 0 5px rgba(99, 102, 241, 0.5);
  }
  50% {
    box-shadow: 0 0 20px rgba(99, 102, 241, 0.8);
  }
}

@keyframes float {
  0%, 100% {
    transform: translateY(0px);
  }
  50% {
    transform: translateY(-10px);
  }
}

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

/* Animation Classes */
.animate-fade-in-down {
  animation: fadeInDown 0.6s ease-out;
}

.animate-fade-in-left {
  animation: fadeInLeft 0.6s ease-out;
}

.animate-fade-in-right {
  animation: fadeInRight 0.6s ease-out;
}

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

.animate-slide-in-up {
  animation: slideInUp 0.6s ease-out;
}

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

.animate-float {
  animation: float 3s ease-in-out infinite;
}

.animate-shimmer {
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.4), transparent);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
}

/* Enhanced 3D Effects */
.transform-3d {
  transform-style: preserve-3d;
  perspective: 1000px;
}

.card-3d {
  transition: transform 0.3s ease;
  transform-style: preserve-3d;
}

.card-3d:hover {
  transform: rotateY(5deg) rotateX(5deg) translateZ(20px);
}

.tilt-effect:hover {
  transform: perspective(1000px) rotateX(10deg) rotateY(-10deg) rotateZ(2deg);
}

.depth-shadow {
  box-shadow: 
    0 1px 3px rgba(0,0,0,0.12),
    0 1px 2px rgba(0,0,0,0.24),
    0 4px 8px rgba(0,0,0,0.12),
    0 8px 16px rgba(0,0,0,0.08);
}

/* Enhanced Mobile-First Responsive Design */
@media (max-width: 480px) {
  .mobile-text-sm {
    font-size: 0.875rem;
  }
  
  .mobile-text-xs {
    font-size: 0.75rem;
  }
  
  .mobile-p-2 {
    padding: 0.5rem;
  }
  
  .mobile-p-4 {
    padding: 1rem;
  }
  
  .mobile-m-2 {
    margin: 0.5rem;
  }
  
  .mobile-mb-4 {
    margin-bottom: 1rem;
  }
  
  .mobile-gap-2 {
    gap: 0.5rem;
  }
  
  .mobile-rounded {
    border-radius: 0.5rem;
  }
}

@media (max-width: 640px) {
  .sm-hidden {
    display: none;
  }
  
  .sm-block {
    display: block;
  }
  
  .sm-flex {
    display: flex;
  }
  
  .sm-grid {
    display: grid;
  }
  
  .sm-text-center {
    text-align: center;
  }
  
  .sm-text-left {
    text-align: left;
  }
  
  .sm-w-full {
    width: 100%;
  }
  
  .sm-h-auto {
    height: auto;
  }
  
  .sm-flex-col {
    flex-direction: column;
  }
  
  .sm-justify-center {
    justify-content: center;
  }
  
  .sm-items-center {
    align-items: center;
  }
}

@media (max-width: 768px) {
  .md-hidden {
    display: none;
  }
  
  .md-block {
    display: block;
  }
  
  .md-text-sm {
    font-size: 0.875rem;
  }
  
  .md-p-4 {
    padding: 1rem;
  }
  
  .md-px-4 {
    padding-left: 1rem;
    padding-right: 1rem;
  }
  
  .md-py-2 {
    padding-top: 0.5rem;
    padding-bottom: 0.5rem;
  }
  
  .md-gap-4 {
    gap: 1rem;
  }
  
  .md-grid-cols-1 {
    grid-template-columns: repeat(1, minmax(0, 1fr));
  }
  
  .md-grid-cols-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* Accessibility Enhancements */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  
  .animate-float,
  .animate-glow,
  .animate-shimmer {
    animation: none;
  }
}

.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;
}

.skip-link {
  position: absolute;
  top: -40px;
  left: 6px;
  background: #000;
  color: #fff;
  padding: 8px;
  text-decoration: none;
  border-radius: 4px;
  z-index: 9999;
}

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

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
  .glass-ultra,
  .glass-card,
  .glass-nav {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    border: 2px solid #000;
  }
  
  .btn-modern {
    border: 2px solid currentColor;
  }
}

/* Enhanced Glass Morphism Variants */
.glass-subtle {
  background: rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.glass-intense {
  background: rgba(255, 255, 255, 0.25);
  backdrop-filter: blur(25px) saturate(200%);
  -webkit-backdrop-filter: blur(25px) saturate(200%);
  border: 1px solid rgba(255, 255, 255, 0.3);
  box-shadow: 
    0 12px 40px rgba(0, 0, 0, 0.15),
    inset 0 2px 0 rgba(255, 255, 255, 0.3);
}

.glass-dark {
  background: rgba(0, 0, 0, 0.1);
  backdrop-filter: blur(15px);
  -webkit-backdrop-filter: blur(15px);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Enhanced Gradient System */
.gradient-purple-blue {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.gradient-ocean {
  background: linear-gradient(135deg, #667db6 0%, #0082c8 25%, #0082c8 75%, #667db6 100%);
}

.gradient-sunset {
  background: linear-gradient(135deg, #fa709a 0%, #fee140 100%);
}

.gradient-forest {
  background: linear-gradient(135deg, #134e5e 0%, #71b280 100%);
}

.gradient-royal {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

/* Interactive Elements */
.interactive-hover {
  transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
  cursor: pointer;
}

.interactive-hover:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
}

.interactive-hover:active {
  transform: translateY(0);
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

/* Loading States */
.loading-dots::after {
  content: '';
  animation: loading-dots 1.5s infinite;
}

@keyframes loading-dots {
  0%, 20% { content: '.'; }
  40% { content: '..'; }
  60%, 100% { content: '...'; }
}

/* Performance Optimizations */
.gpu-accelerated {
  transform: translateZ(0);
  backface-visibility: hidden;
  perspective: 1000px;
}

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

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

/* Container Queries Support (Future Enhancement) */
@container (max-width: 400px) {
  .container-sm {
    font-size: 0.875rem;
    padding: 0.5rem;
  }
}

/* Focus Management */
.focus-trap {
  outline: none;
}

.focus-trap:focus-within {
  outline: 2px solid var(--primary-500);
  outline-offset: 2px;
}

/* Print Optimizations */
@media print {
  .glass-ultra,
  .glass-card,
  .glass-nav,
  .glass-subtle,
  .glass-intense,
  .glass-dark {
    background: white !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    border: 1px solid #ccc !important;
    box-shadow: none !important;
  }
  
  .gradient-mesh-1,
  .gradient-purple-blue,
  .gradient-ocean,
  .gradient-sunset,
  .gradient-forest,
  .gradient-royal {
    background: white !important;
  }
}