/* ===========================
   kwiKKirana DESIGN SYSTEM
   White & Black + Green Theme
   =========================== */

/* --- CSS Variables --- */
:root {
  /* Primary Colors */
  --primary: #0C831F;
  --primary-light: #E8F5E9;
  --primary-lighter: #F0F9F1;
  --primary-dark: #0A6B19;
  --primary-rgb: 12, 131, 31;
  
  /* Accent */
  --accent: #B9E515;
  --accent-dark: #9BC711;
  
  /* Backgrounds */
  --bg: #FFFFFF;
  --bg-secondary: #F4F6F4;
  --bg-tertiary: #E8F0E8;
  --bg-overlay: rgba(0, 0, 0, 0.5);
  --bg-glass: rgba(255, 255, 255, 0.85);
  
  /* Text */
  --text-primary: #1A1A2E;
  --text-secondary: #6B7280;
  --text-tertiary: #9CA3AF;
  --text-inverse: #FFFFFF;
  
  /* Borders */
  --border: #E8E8E8;
  --border-light: #F0F0F0;
  --border-focus: var(--primary);
  
  /* Status Colors */
  --danger: #E23744;
  --danger-light: #FDE8EA;
  --success: #60B246;
  --success-light: #EDF7EA;
  --warning: #FF9800;
  --warning-light: #FFF3E0;
  --info: #2196F3;
  --info-light: #E3F2FD;
  
  /* Shadows */
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.12);
  --shadow-xl: 0 16px 48px rgba(0, 0, 0, 0.16);
  --shadow-green: 0 4px 16px rgba(12, 131, 31, 0.25);
  
  /* Radius */
  --radius-xs: 4px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 9999px;
  
  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-normal: 250ms ease;
  --transition-slow: 400ms ease;
  --transition-bounce: 300ms cubic-bezier(0.34, 1.56, 0.64, 1);
  
  /* Spacing */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-2xl: 48px;
  --space-3xl: 64px;
  
  /* Typography */
  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-xs: 0.75rem;
  --font-sm: 0.8125rem;
  --font-base: 0.9375rem;
  --font-md: 1rem;
  --font-lg: 1.125rem;
  --font-xl: 1.25rem;
  --font-2xl: 1.5rem;
  --font-3xl: 1.875rem;
  --font-4xl: 2.25rem;
  --font-5xl: 3rem;

  /* Layout */
  --navbar-height: 72px;
  --max-width: 1280px;
  --sidebar-width: 240px;
}

/* --- Reset & Base --- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

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

body {
  font-family: var(--font-family);
  font-size: var(--font-base);
  line-height: 1.6;
  color: var(--text-primary);
  background-color: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

a {
  color: inherit;
  text-decoration: none;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  font-size: inherit;
}

input, select, textarea {
  font-family: inherit;
  font-size: inherit;
}

ul, ol {
  list-style: none;
}

/* --- Utility Classes --- */
.container {
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--space-md);
}

.hidden { display: none !important; }
.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-xs { gap: var(--space-xs); }
.gap-sm { gap: var(--space-sm); }
.gap-md { gap: var(--space-md); }
.gap-lg { gap: var(--space-lg); }
.text-center { text-align: center; }
.text-right { text-align: right; }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }
.text-sm { font-size: var(--font-sm); }
.text-xs { font-size: var(--font-xs); }
.text-lg { font-size: var(--font-lg); }
.text-secondary { color: var(--text-secondary); }
.text-primary-color { color: var(--primary); }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.w-full { width: 100%; }

/* --- Scrollbar --- */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: var(--bg-secondary);
}
::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-tertiary);
}

/* --- Loading Screen --- */
.loading-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  gap: var(--space-lg);
}

.loading-logo {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  animation: pulse 2s ease-in-out infinite;
}

.loading-logo .logo-icon {
  font-size: 2.5rem;
}

.loading-logo .logo-text {
  font-size: var(--font-3xl);
  font-weight: 800;
  color: var(--primary);
  letter-spacing: -0.02em;
}

.loading-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* --- Skeleton Loading --- */
.skeleton {
  background: linear-gradient(90deg, var(--bg-secondary) 25%, var(--bg-tertiary) 50%, var(--bg-secondary) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
  border-radius: var(--radius-sm);
}

.skeleton-text {
  height: 14px;
  margin-bottom: 8px;
  border-radius: var(--radius-xs);
}

.skeleton-text.short { width: 60%; }
.skeleton-text.medium { width: 80%; }

.skeleton-image {
  width: 100%;
  aspect-ratio: 1;
  border-radius: var(--radius-md);
}

.skeleton-card {
  padding: var(--space-md);
  border-radius: var(--radius-md);
  background: var(--bg);
}

/* --- Animations --- */
@keyframes spin {
  to { transform: rotate(360deg); }
}

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

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

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

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

@keyframes fadeInDown {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

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

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

@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

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

@keyframes bounceIn {
  0% { transform: scale(0.3); opacity: 0; }
  50% { transform: scale(1.1); }
  70% { transform: scale(0.9); }
  100% { transform: scale(1); opacity: 1; }
}

@keyframes cartBounce {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.2); }
}

@keyframes countUp {
  0% { transform: translateY(100%); opacity: 0; }
  100% { transform: translateY(0); opacity: 1; }
}

@keyframes checkmark {
  0% { stroke-dashoffset: 100; }
  100% { stroke-dashoffset: 0; }
}

@keyframes confetti {
  0% { transform: translateY(0) rotate(0deg); opacity: 1; }
  100% { transform: translateY(-200px) rotate(720deg); opacity: 0; }
}

/* Animation utility classes */
.animate-fade-in { animation: fadeIn var(--transition-normal) ease forwards; }
.animate-fade-in-up { animation: fadeInUp var(--transition-slow) ease forwards; }
.animate-fade-in-down { animation: fadeInDown var(--transition-normal) ease forwards; }
.animate-slide-right { animation: slideInRight var(--transition-slow) ease forwards; }
.animate-slide-left { animation: slideInLeft var(--transition-slow) ease forwards; }
.animate-scale-in { animation: scaleIn var(--transition-normal) ease forwards; }
.animate-bounce-in { animation: bounceIn 0.5s ease forwards; }

/* Stagger children animations */
.stagger-children > *:nth-child(1) { animation-delay: 0ms; }
.stagger-children > *:nth-child(2) { animation-delay: 50ms; }
.stagger-children > *:nth-child(3) { animation-delay: 100ms; }
.stagger-children > *:nth-child(4) { animation-delay: 150ms; }
.stagger-children > *:nth-child(5) { animation-delay: 200ms; }
.stagger-children > *:nth-child(6) { animation-delay: 250ms; }
.stagger-children > *:nth-child(7) { animation-delay: 300ms; }
.stagger-children > *:nth-child(8) { animation-delay: 350ms; }
.stagger-children > *:nth-child(9) { animation-delay: 400ms; }
.stagger-children > *:nth-child(10) { animation-delay: 450ms; }
.stagger-children > *:nth-child(11) { animation-delay: 500ms; }
.stagger-children > *:nth-child(12) { animation-delay: 550ms; }

/* --- Toast Notifications --- */
.toast-container {
  position: fixed;
  top: calc(var(--navbar-height) + var(--space-md));
  right: var(--space-md);
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  background: var(--text-primary);
  color: var(--text-inverse);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  font-size: var(--font-sm);
  font-weight: 500;
  pointer-events: auto;
  animation: slideInRight var(--transition-normal) ease, fadeIn var(--transition-fast) ease;
  max-width: 360px;
}

.toast.toast-success { background: var(--success); }
.toast.toast-error { background: var(--danger); }
.toast.toast-warning { background: var(--warning); }
.toast.toast-info { background: var(--info); }

.toast-icon { font-size: 1.2em; flex-shrink: 0; }

.toast.fade-out {
  animation: fadeOutRight 0.3s ease forwards;
}

@keyframes fadeOutRight {
  to { opacity: 0; transform: translateX(100%); }
}

/* --- Floating Cart Button --- */
.floating-cart {
  position: fixed;
  bottom: var(--space-lg);
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--primary);
  color: var(--text-inverse);
  border-radius: var(--radius-md);
  padding: var(--space-sm) var(--space-md);
  min-width: 340px;
  max-width: 480px;
  box-shadow: var(--shadow-green);
  z-index: 900;
  cursor: pointer;
  transition: all var(--transition-normal);
  animation: slideUp var(--transition-slow) ease;
}

.floating-cart:hover {
  transform: translateX(-50%) translateY(-2px);
  box-shadow: 0 8px 32px rgba(12, 131, 31, 0.35);
}

.floating-cart:active {
  transform: translateX(-50%) scale(0.98);
}

.floating-cart-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.floating-cart-count {
  font-size: var(--font-sm);
  font-weight: 500;
  opacity: 0.9;
}

.floating-cart-total {
  font-size: var(--font-lg);
  font-weight: 700;
}

.floating-cart-action {
  font-weight: 600;
  font-size: var(--font-base);
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}

.floating-cart.cart-bounce {
  animation: cartBounce 0.4s ease;
}

/* --- Page Transitions --- */
.page-enter {
  animation: fadeInUp 0.3s ease forwards;
}

.page-exit {
  animation: fadeIn 0.15s ease reverse forwards;
}

/* --- Responsive --- */
@media (max-width: 768px) {
  :root {
    --navbar-height: 60px;
    --font-base: 0.875rem;
  }
  
  .container {
    padding: 0 var(--space-sm);
  }
  
  .floating-cart {
    min-width: auto;
    left: var(--space-md);
    right: var(--space-md);
    transform: none;
    max-width: none;
  }
  
  .floating-cart:hover {
    transform: translateY(-2px);
  }
  
  .floating-cart:active {
    transform: scale(0.98);
  }
  
  .toast-container {
    left: var(--space-md);
    right: var(--space-md);
  }
  
  .toast {
    max-width: 100%;
  }
}

@media (max-width: 480px) {
  :root {
    --space-lg: 20px;
    --space-xl: 28px;
  }
}
