/* ─── Custom Styles & Overrides ─────────────────────────────────────── */

/* Color System (matching the PRD design tokens) */
:root {
  --primary: #003657;
  --primary-container: #004d7a;
  --on-primary: #ffffff;
  --secondary: #51606d;
  --tertiary: #522800;
  --tertiary-container: #723b03;
  --surface: #f8f9fd;
  --surface-dim: #d9dade;
  --surface-container: #edeef2;
  --on-surface: #191c1f;
  --on-surface-variant: #41474f;
  --outline: #717880;
  --outline-variant: #c1c7d0;
  --error: #ba1a1a;
  --error-container: #ffdad6;
  --inverse-surface: #2e3134;
  --inverse-primary: #96cbff;
  --surface-container-lowest: #ffffff;
  --surface-container-low: #f3f3f8;
  --surface-container-high: #e7e8ec;
}

/* Tailwind Config Extension */
@tailwind base;
@tailwind components;
@tailwind utilities;

/* ─── Base Styles ───────────────────────────────────────────────────── */
body {
  min-height: 100dvh;
  background-color: var(--surface);
  color: var(--on-surface);
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ─── Typography ────────────────────────────────────────────────────── */
.font-headline {
  font-family: 'Manrope', system-ui, -apple-system, sans-serif;
}

.font-body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

.font-label {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

/* ─── Custom Animations ─────────────────────────────────────────────── */
@keyframes slide-up {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes scale-in {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

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

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

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

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

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

/* ─── Glass Effect ──────────────────────────────────────────────────── */
.glass {
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.glass-dark {
  background: rgba(30, 30, 30, 0.8);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

/* ─── Tonal Layering (Material You inspired) ────────────────────────── */
.tonal-surface {
  background-color: var(--surface-container);
}

.tonal-surface-low {
  background-color: var(--surface-container-low);
}

.tonal-surface-high {
  background-color: var(--surface-container-high);
}

/* ─── Product Card Enhancements ─────────────────────────────────────── */
.product-card {
  will-change: transform;
}

.product-card:hover {
  transform: translateY(-2px);
}

/* ─── Scrollbar Hide (for image carousel) ───────────────────────────── */
.scrollbar-hide::-webkit-scrollbar { display: none; }
.scrollbar-hide { -ms-overflow-style: none; scrollbar-width: none; }

/* ─── Custom Scrollbar ──────────────────────────────────────────────── */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--outline-variant);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--outline);
}

/* ─── Input Focus States ────────────────────────────────────────────── */
input:focus, textarea:focus, select:focus {
  outline: none;
  box-shadow: 0 0 0 2px rgba(0, 54, 87, 0.15);
  border-color: var(--primary);
}

/* ─── Toggle Switch ─────────────────────────────────────────────────── */
.toggle-switch {
  position: relative;
  width: 44px;
  height: 24px;
  background: var(--outline-variant);
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.2s;
}

.toggle-switch.active {
  background: var(--primary);
}

.toggle-switch::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  background: white;
  border-radius: 50%;
  transition: transform 0.2s;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.toggle-switch.active::after {
  transform: translateX(20px);
}

/* ─── Modal ─────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  animation: fade-in 0.2s ease-out;
}

.modal-content {
  background: white;
  border-radius: 1.5rem;
  max-width: 540px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  animation: scale-in 0.25s ease-out;
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.15);
}

/* ─── Line Clamp ────────────────────────────────────────────────────── */
.line-clamp-1 {
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.line-clamp-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ─── Skeleton Loading ──────────────────────────────────────────────── */
.skeleton {
  background: linear-gradient(90deg, #f0f0f0 25%, #e8e8e8 37%, #f0f0f0 63%);
  background-size: 400% 100%;
  animation: shimmer 1.4s ease infinite;
  border-radius: 0.5rem;
}

/* ─── Inquiry Selected State ────────────────────────────────────────── */
.inquiry-selected {
  ring: 2px solid var(--primary);
  ring-offset: 2px;
}

/* ─── Responsive Typography ─────────────────────────────────────────── */
.hero-title {
  font-size: clamp(2rem, 5vw, 3.5rem);
  line-height: 1.1;
  letter-spacing: -0.02em;
}

/* ─── Page Transitions ──────────────────────────────────────────────── */
main {
  animation: fade-in 0.3s ease-out;
}

/* ─── Mobile Sticky Header Fix ──────────────────────────────────────── */
html, body {
  overflow-x: hidden;
}

header.sticky-header {
  position: -webkit-sticky;
  position: sticky;
  top: 0;
  z-index: 50;
}

/* ─── Filter Bar ────────────────────────────────────────────────────── */
#filter-bar {
  position: -webkit-sticky;
  position: sticky;
  top: 0; /* JS overrides this to header height */
}

#filter-container {
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

#filter-container::-webkit-scrollbar {
  display: none;
}

#filter-container .filter-btn {
  flex-shrink: 0;
  white-space: nowrap;
}

/* ─── Mobile Bottom Nav ─────────────────────────────────────────────── */
.mobile-bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 45;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid rgba(0, 0, 0, 0.08);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

/* ─── Seller Portal: hide desktop nav on mobile ─────────────────────── */
@media (max-width: 767px) {
  header.sticky-header nav.hidden {
    display: none !important;
  }
}

/* ─── Print Styles ──────────────────────────────────────────────────── */
@media print {
  header, .no-print, .mobile-bottom-nav {
    display: none !important;
  }
  body {
    background: white;
  }
}
