/**
 * Sri Lanka Market Price App - Modern Design System
 * A bold, distinctive e-commerce theme inspired by Sri Lankan markets
 * "Fresh Market Meets Modern E-commerce"
 */

/* ============================================
   DESIGN TOKENS - CSS CUSTOM PROPERTIES
   ============================================ */

:root {
  /* === PRIMARY COLOR PALETTE === */
  /* Sri Lankan Market Inspired Colors */
  --market-deep-green: #1A4D2E;
  --market-fresh-green: #4F7942;
  --papaya-orange: #FF6B35;
  --mango-yellow: #F7B731;
  --coconut-cream: #FFF8E7;
  --cinnamon-brown: #8B4513;

  /* === PRODUCE PALETTE === */
  --tomato-red: #E74C3C;
  --banana-yellow: #FDD835;
  --eggplant-purple: #6A1B9A;
  --carrot-orange: #FF9800;
  --lettuce-green: #AED581;

  /* === NEUTRAL PALETTE === */
  --stone-50: #FAFAF9;
  --stone-100: #F5F5F4;
  --stone-200: #E7E5E4;
  --stone-300: #D6D3D1;
  --stone-400: #A8A29E;
  --stone-500: #78716C;
  --stone-600: #57534E;
  --stone-700: #44403C;
  --stone-800: #292524;
  --stone-900: #1C1917;

  /* === SEMANTIC COLORS === */
  --color-primary: var(--market-deep-green);
  --color-primary-hover: var(--market-fresh-green);
  --color-secondary: var(--papaya-orange);
  --color-accent: var(--mango-yellow);
  --color-success: var(--lettuce-green);
  --color-warning: var(--mango-yellow);
  --color-error: var(--tomato-red);
  --color-info: #3B82F6;

  /* === BACKGROUNDS === */
  --bg-primary: var(--coconut-cream);
  --bg-secondary: var(--stone-50);
  --bg-card: #FFFFFF;
  --bg-overlay: rgba(26, 77, 46, 0.05);

  /* === TEXT COLORS === */
  --text-primary: var(--stone-900);
  --text-secondary: var(--stone-600);
  --text-muted: var(--stone-400);
  --text-inverse: #FFFFFF;

  /* === GRADIENTS === */
  --gradient-primary: linear-gradient(135deg, #1A4D2E 0%, #4F7942 100%);
  --gradient-sunset: linear-gradient(135deg, #FF6B35 0%, #F7B731 100%);
  --gradient-fresh: linear-gradient(to right, #AED581, #4CAF50);
  --gradient-hero: linear-gradient(135deg, #1A4D2E 0%, #4F7942 50%, #FF6B35 100%);
  --gradient-card: linear-gradient(to bottom, rgba(255,255,255,0.9), rgba(255,255,255,1));

  /* === TYPOGRAPHY === */
  /* Font Families */
  --font-display: 'Playfair Display', 'Noto Serif Sinhala', serif;
  --font-body: 'DM Sans', 'Noto Sans Sinhala', 'Noto Sans Tamil', sans-serif;
  --font-mono: 'JetBrains Mono', 'Courier New', monospace;
  --font-accent: 'Space Grotesk', 'Roboto Condensed', sans-serif;

  /* Font Sizes - Fluid Typography */
  --text-xs: clamp(0.75rem, 0.7rem + 0.25vw, 0.875rem);
  --text-sm: clamp(0.875rem, 0.8rem + 0.375vw, 1rem);
  --text-base: clamp(1rem, 0.95rem + 0.25vw, 1.125rem);
  --text-lg: clamp(1.125rem, 1rem + 0.625vw, 1.5rem);
  --text-xl: clamp(1.5rem, 1.2rem + 1.5vw, 2.25rem);
  --text-2xl: clamp(2rem, 1.5rem + 2.5vw, 3rem);
  --text-3xl: clamp(2.5rem, 2rem + 2.5vw, 4rem);

  /* Font Weights */
  --font-normal: 400;
  --font-medium: 500;
  --font-semibold: 600;
  --font-bold: 700;
  --font-extrabold: 800;

  /* Line Heights */
  --leading-tight: 1.25;
  --leading-normal: 1.5;
  --leading-relaxed: 1.75;

  /* === SPACING SYSTEM === */
  /* 8px Base Grid */
  --space-1: 0.25rem;   /* 4px */
  --space-2: 0.5rem;    /* 8px */
  --space-3: 0.75rem;   /* 12px */
  --space-4: 1rem;      /* 16px */
  --space-5: 1.25rem;   /* 20px */
  --space-6: 1.5rem;    /* 24px */
  --space-8: 2rem;      /* 32px */
  --space-10: 2.5rem;   /* 40px */
  --space-12: 3rem;     /* 48px */
  --space-16: 4rem;     /* 64px */
  --space-20: 5rem;     /* 80px */
  --space-24: 6rem;     /* 96px */

  /* === BORDERS === */
  --border-radius-sm: 0.375rem;
  --border-radius-md: 0.5rem;
  --border-radius-lg: 0.75rem;
  --border-radius-xl: 1rem;
  --border-radius-2xl: 1.5rem;
  --border-radius-full: 9999px;

  --border-width: 1px;
  --border-width-2: 2px;
  --border-width-4: 4px;

  --border-color: var(--stone-200);
  --border-color-dark: var(--stone-300);

  /* === SHADOWS === */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  --shadow-2xl: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  --shadow-inner: inset 0 2px 4px 0 rgba(0, 0, 0, 0.06);
  --shadow-glow: 0 0 20px rgba(255, 107, 53, 0.3);

  /* === TRANSITIONS === */
  --transition-fast: 150ms ease-in-out;
  --transition-normal: 300ms ease-in-out;
  --transition-slow: 500ms ease-in-out;
  --transition-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);

  /* === Z-INDEX SCALE === */
  --z-dropdown: 1000;
  --z-sticky: 1020;
  --z-fixed: 1030;
  --z-modal-backdrop: 1040;
  --z-modal: 1050;
  --z-popover: 1060;
  --z-tooltip: 1070;

  /* === BREAKPOINTS === */
  --breakpoint-sm: 640px;
  --breakpoint-md: 768px;
  --breakpoint-lg: 1024px;
  --breakpoint-xl: 1280px;
  --breakpoint-2xl: 1536px;

  /* === GLASSMORPHISM === */
  --glass-bg: rgba(255, 255, 255, 0.7);
  --glass-border: rgba(255, 255, 255, 0.18);
  --glass-blur: blur(10px);
}

/* ============================================
   BASE STYLES
   ============================================ */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  color: var(--text-primary);
  background: var(--bg-primary);
  overflow-x: hidden;
}

/* === TYPOGRAPHY STYLES === */

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: var(--font-bold);
  line-height: var(--leading-tight);
  color: var(--color-primary);
  margin-bottom: var(--space-4);
}

h1 { font-size: var(--text-3xl); }
h2 { font-size: var(--text-2xl); }
h3 { font-size: var(--text-xl); }
h4 { font-size: var(--text-lg); }
h5 { font-size: var(--text-base); }
h6 { font-size: var(--text-sm); }

p {
  margin-bottom: var(--space-4);
}

a {
  color: var(--color-primary);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover {
  color: var(--color-primary-hover);
}

/* Price Display */
.price {
  font-family: var(--font-mono);
  font-weight: var(--font-bold);
  color: var(--color-primary);
}

/* Sinhala & Tamil Text */
[lang="si"], [lang="ta"] {
  font-family: var(--font-body);
}

/* ============================================
   LAYOUT COMPONENTS
   ============================================ */

.container {
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 var(--space-4);
}

.container-fluid {
  width: 100%;
  padding: 0 var(--space-4);
}

/* Grid System */
.grid {
  display: grid;
  gap: var(--space-6);
}

.grid-cols-1 { grid-template-columns: repeat(1, 1fr); }
.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); }

/* Flexbox Utilities */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: var(--space-2); }
.gap-4 { gap: var(--space-4); }
.gap-6 { gap: var(--space-6); }

/* ============================================
   BUTTON COMPONENTS
   ============================================ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-6);
  font-family: var(--font-accent);
  font-size: var(--text-base);
  font-weight: var(--font-semibold);
  border: none;
  border-radius: var(--border-radius-lg);
  cursor: pointer;
  transition: all var(--transition-normal) var(--transition-bounce);
  white-space: nowrap;
  text-decoration: none;
  min-height: 48px;
  -webkit-tap-highlight-color: transparent;
}

.btn:active {
  transform: scale(0.96);
}

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

/* Primary Button */
.btn-primary {
  background: var(--gradient-sunset);
  color: var(--text-inverse);
  box-shadow: var(--shadow-md);
}

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

/* Secondary Button */
.btn-secondary {
  background: transparent;
  color: var(--color-primary);
  border: 2px solid var(--color-primary);
}

.btn-secondary:hover {
  background: var(--color-primary);
  color: var(--text-inverse);
}

/* Ghost Button */
.btn-ghost {
  background: transparent;
  color: var(--color-primary);
}

.btn-ghost:hover {
  background: var(--bg-overlay);
}

/* Icon Button */
.btn-icon {
  width: 48px;
  height: 48px;
  padding: var(--space-3);
  border-radius: var(--border-radius-full);
}

/* Button Sizes */
.btn-sm {
  padding: var(--space-2) var(--space-4);
  font-size: var(--text-sm);
  min-height: 36px;
}

.btn-lg {
  padding: var(--space-4) var(--space-8);
  font-size: var(--text-lg);
  min-height: 56px;
}

/* ============================================
   CARD COMPONENTS
   ============================================ */

.card {
  background: var(--bg-card);
  border-radius: var(--border-radius-xl);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: all var(--transition-normal);
}

.card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-xl);
  border-color: var(--color-primary);
}

.card-header {
  padding: var(--space-6);
  border-bottom: 1px solid var(--border-color);
}

.card-body {
  padding: var(--space-6);
}

.card-footer {
  padding: var(--space-6);
  border-top: 1px solid var(--border-color);
  background: var(--stone-50);
}

/* Price Card */
.price-card {
  position: relative;
  cursor: pointer;
}

.price-card-image {
  width: 100%;
  height: 200px;
  object-fit: cover;
  background: var(--gradient-fresh);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 4rem;
}

.price-card-content {
  padding: var(--space-4);
}

.price-card-title {
  font-family: var(--font-accent);
  font-size: var(--text-lg);
  font-weight: var(--font-semibold);
  margin-bottom: var(--space-2);
  color: var(--text-primary);
}

.price-card-price {
  font-family: var(--font-mono);
  font-size: var(--text-2xl);
  font-weight: var(--font-bold);
  color: var(--color-primary);
  margin-bottom: var(--space-2);
}

.price-card-market {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  margin-bottom: var(--space-3);
}

.price-card-change {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-2);
  border-radius: var(--border-radius-md);
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
}

.price-card-change.up {
  background: rgba(231, 76, 60, 0.1);
  color: var(--tomato-red);
}

.price-card-change.down {
  background: rgba(174, 213, 129, 0.1);
  color: var(--lettuce-green);
}

/* Badge */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-3);
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
  border-radius: var(--border-radius-full);
  background: var(--stone-100);
  color: var(--text-primary);
}

.badge-primary { background: var(--color-primary); color: var(--text-inverse); }
.badge-success { background: var(--color-success); color: var(--text-inverse); }
.badge-warning { background: var(--color-warning); color: var(--stone-900); }
.badge-error { background: var(--color-error); color: var(--text-inverse); }

/* Deal Badge */
.deal-badge {
  position: absolute;
  top: var(--space-4);
  right: var(--space-4);
  padding: var(--space-2) var(--space-4);
  background: var(--gradient-sunset);
  color: var(--text-inverse);
  font-size: var(--text-xs);
  font-weight: var(--font-bold);
  border-radius: var(--border-radius-full);
  box-shadow: var(--shadow-md);
  z-index: 10;
}

/* ============================================
   FORM COMPONENTS
   ============================================ */

.form-group {
  margin-bottom: var(--space-6);
}

.form-label {
  display: block;
  font-size: var(--text-sm);
  font-weight: var(--font-semibold);
  color: var(--text-primary);
  margin-bottom: var(--space-2);
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: var(--space-3) var(--space-4);
  font-family: var(--font-body);
  font-size: var(--text-base);
  color: var(--text-primary);
  background: var(--bg-card);
  border: 2px solid var(--border-color);
  border-radius: var(--border-radius-lg);
  transition: all var(--transition-fast);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(26, 77, 46, 0.1);
}

.form-input::placeholder {
  color: var(--text-muted);
}

/* Search Bar */
.search-bar {
  position: relative;
  width: 100%;
}

.search-input {
  width: 100%;
  padding: var(--space-4) var(--space-6) var(--space-4) var(--space-12);
  font-size: var(--text-lg);
  border: 2px solid var(--border-color);
  border-radius: var(--border-radius-2xl);
  background: var(--bg-card);
  transition: all var(--transition-normal);
}

.search-input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: var(--shadow-xl);
  transform: translateY(-2px);
}

.search-icon {
  position: absolute;
  left: var(--space-4);
  top: 50%;
  transform: translateY(-50%);
  font-size: 1.5rem;
  color: var(--text-muted);
}

/* ============================================
   NAVIGATION
   ============================================ */

.navbar {
  position: sticky;
  top: 0;
  width: 100%;
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  border-bottom: 1px solid var(--glass-border);
  box-shadow: var(--shadow-md);
  z-index: var(--z-sticky);
}

.navbar-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) var(--space-6);
  max-width: 1536px;
  margin: 0 auto;
}

.navbar-brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: var(--font-bold);
  color: var(--color-primary);
  text-decoration: none;
}

.navbar-brand-icon {
  font-size: 2rem;
}

.navbar-nav {
  display: flex;
  align-items: center;
  gap: var(--space-6);
  list-style: none;
}

.navbar-link {
  font-family: var(--font-accent);
  font-size: var(--text-base);
  font-weight: var(--font-medium);
  color: var(--text-primary);
  text-decoration: none;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--border-radius-md);
  transition: all var(--transition-fast);
}

.navbar-link:hover {
  background: var(--bg-overlay);
  color: var(--color-primary);
}

.navbar-link.active {
  background: var(--gradient-primary);
  color: var(--text-inverse);
}

/* Mobile Menu Toggle */
.navbar-toggle {
  display: none;
  font-size: 1.5rem;
  background: none;
  border: none;
  color: var(--color-primary);
  cursor: pointer;
}

/* ============================================
   HERO SECTION
   ============================================ */

.hero {
  position: relative;
  padding: var(--space-16) 0;
  background: var(--gradient-hero);
  color: var(--text-inverse);
  overflow: hidden;
}

.hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><circle cx="50" cy="50" r="1" fill="white" opacity="0.1"/></svg>');
  background-size: 20px 20px;
  opacity: 0.3;
}

.hero-content {
  position: relative;
  text-align: center;
  max-width: 800px;
  margin: 0 auto;
  z-index: 1;
}

.hero-title {
  font-size: var(--text-3xl);
  font-weight: var(--font-extrabold);
  color: var(--text-inverse);
  margin-bottom: var(--space-4);
  animation: fadeInUp 0.8s ease-out;
}

.hero-subtitle {
  font-size: var(--text-lg);
  color: rgba(255, 255, 255, 0.9);
  margin-bottom: var(--space-8);
  animation: fadeInUp 0.8s ease-out 0.2s both;
}

.hero-search {
  max-width: 600px;
  margin: 0 auto;
  animation: fadeInUp 0.8s ease-out 0.4s both;
}

/* ============================================
   ANIMATIONS
   ============================================ */

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

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

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

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

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

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

/* Utility Animation Classes */
.animate-fade-in { animation: fadeIn 0.5s ease-out; }
.animate-fade-in-up { animation: fadeInUp 0.6s ease-out; }
.animate-slide-in-right { animation: slideInRight 0.6s ease-out; }
.animate-scale-in { animation: scaleIn 0.4s ease-out; }

/* Stagger Animation */
.stagger-item {
  opacity: 0;
  animation: fadeInUp 0.6s ease-out forwards;
}

.stagger-item:nth-child(1) { animation-delay: 0.1s; }
.stagger-item:nth-child(2) { animation-delay: 0.2s; }
.stagger-item:nth-child(3) { animation-delay: 0.3s; }
.stagger-item:nth-child(4) { animation-delay: 0.4s; }
.stagger-item:nth-child(5) { animation-delay: 0.5s; }
.stagger-item:nth-child(6) { animation-delay: 0.6s; }

/* ============================================
   UTILITY CLASSES
   ============================================ */

/* Spacing */
.m-0 { margin: 0; }
.m-4 { margin: var(--space-4); }
.mt-4 { margin-top: var(--space-4); }
.mb-4 { margin-bottom: var(--space-4); }
.p-4 { padding: var(--space-4); }
.p-6 { padding: var(--space-6); }

/* Text Alignment */
.text-left { text-align: left; }
.text-center { text-align: center; }
.text-right { text-align: right; }

/* Font Weights */
.font-normal { font-weight: var(--font-normal); }
.font-semibold { font-weight: var(--font-semibold); }
.font-bold { font-weight: var(--font-bold); }

/* Colors */
.text-primary { color: var(--text-primary); }
.text-secondary { color: var(--text-secondary); }
.text-muted { color: --text-muted); }

/* Display */
.hidden { display: none; }
.block { display: block; }
.inline-block { display: inline-block; }

/* ============================================
   RESPONSIVE DESIGN
   ============================================ */

@media (max-width: 1024px) {
  .grid-cols-4 { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 768px) {
  .grid-cols-3,
  .grid-cols-4 { grid-template-columns: repeat(2, 1fr); }

  .navbar-nav {
    display: none;
  }

  .navbar-toggle {
    display: block;
  }

  .hero {
    padding: var(--space-12) 0;
  }

  .hero-title {
    font-size: var(--text-2xl);
  }
}

@media (max-width: 640px) {
  .grid-cols-2,
  .grid-cols-3,
  .grid-cols-4 { grid-template-columns: 1fr; }

  .container {
    padding: 0 var(--space-3);
  }
}

/* ============================================
   LOADING STATES
   ============================================ */

.skeleton {
  background: linear-gradient(
    90deg,
    var(--stone-100) 0%,
    var(--stone-200) 50%,
    var(--stone-100) 100%
  );
  background-size: 200% 100%;
  animation: loading 1.5s ease-in-out infinite;
  border-radius: var(--border-radius-md);
}

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

.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid var(--stone-200);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

/* ============================================
   ACCESSIBILITY
   ============================================ */

/* Focus Visible */
*:focus-visible {
  outline: 3px solid var(--color-primary);
  outline-offset: 2px;
}

/* Skip Link */
.skip-link {
  position: absolute;
  top: -100px;
  left: 0;
  background: var(--color-primary);
  color: var(--text-inverse);
  padding: var(--space-3) var(--space-6);
  border-radius: var(--border-radius-md);
  z-index: var(--z-tooltip);
}

.skip-link:focus {
  top: var(--space-4);
}

/* Screen Reader Only */
.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;
}

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

/* Print Styles */
@media print {
  .navbar,
  .btn,
  .badge,
  .hero {
    display: none;
  }

  body {
    background: white;
    color: black;
  }

  .card {
    border: 1px solid black;
    page-break-inside: avoid;
  }
}
