/* Global Styles */

/* Google Fonts loaded via <link> in index.html for non-blocking rendering */

/* Default CSS Variables - will be overridden by theme files */
:root {
  --primary-color: #497671;
  --primary-hover: #3d635f;
  --secondary-color: #a1b4b5;
  --secondary-hover: #8da3a4;
  --accent-color: #a7ceca;
  --accent-hover: #91b9b5;
  
  --gradient-primary: linear-gradient(360deg, #497671 0%, #a7ceca 100%);
  --gradient-secondary: linear-gradient(135deg, #a1b4b5 0%, #677b78 100%);
  --gradient-hero: linear-gradient(360deg, #497671 0%, #a7ceca 100%);
  
  --text-primary: #1e3c38;
  --text-secondary: #667a77;
  --text-light: #828e8d;
  
  --bg-primary: #ffffff;
  --bg-secondary: #f5f5f5;
  --bg-tertiary: #f0f0f0;
  
  --success-color: #10b981;
  --warning-color: #f59e0b;
  --error-color: #ef4444;
  --info-color: #3b82f6;
  
  --border-color: #d3dad9;
  --border-dark: #677b78;
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.1);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.15);
  --shadow-lg: 0 12px 32px rgba(73, 118, 113, 0.2);

  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-2xl: 48px;
  --space-3xl: 64px;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 13px;
  --radius-xl: 22px;

  --transition-fast: 120ms ease;
  --transition-normal: 180ms ease;
  --transition-slow: 300ms ease;

  /* Typography scale (RC design-system finalization).
     Steps chosen to match the sizes already in wide use across the app
     (button/input sm|md|lg = sm|md|lg here) so most components can adopt
     the tokens by substitution rather than a visual redesign. */
  --font-size-xs: 0.75rem;    /* 12px — captions, badges, meta/helper text */
  --font-size-sm: 0.8125rem;  /* 13px — secondary text, table cells, sm controls */
  --font-size-base: 0.875rem; /* 14px — dense body copy, form labels */
  --font-size-md: 0.9375rem;  /* 15px — default body copy, md controls */
  --font-size-lg: 1rem;       /* 16px — emphasized body, lg controls */
  --font-size-xl: 1.125rem;   /* 18px — card/section titles */
  --font-size-2xl: 1.25rem;   /* 20px — subsection headings */
  --font-size-3xl: 1.5rem;    /* 24px — page/section headings */
  --font-size-4xl: 2rem;      /* 32px — hero / display headings */

  --font-weight-normal: 400;
  --font-weight-medium: 500;
  --font-weight-semibold: 600;
  --font-weight-bold: 700;

  --line-height-tight: 1.2;
  --line-height-normal: 1.5;
  --line-height-relaxed: 1.6;
}

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

*::before,
*::after {
  box-sizing: inherit;
}

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

body {
  font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  font-size: var(--font-size-md);
  font-weight: var(--font-weight-normal);
  line-height: var(--line-height-relaxed);
  color: var(--text-primary);
  background: #f5f5f5;
  min-height: 100vh;
  overflow-x: hidden;

  &.platform-menu-open {
    overflow: hidden;
  }
}

/* Heading scale — page title (h1) down to card/section title (h6). Individual
   pages may still override size for hero/display treatments via the
   --font-size-* tokens directly rather than arbitrary px/rem literals. */
h1 {
  font-size: var(--font-size-4xl);
  font-weight: var(--font-weight-bold);
  line-height: var(--line-height-tight);
}

h2 {
  font-size: var(--font-size-3xl);
  font-weight: var(--font-weight-bold);
  line-height: var(--line-height-tight);
}

h3 {
  font-size: var(--font-size-2xl);
  font-weight: var(--font-weight-semibold);
  line-height: var(--line-height-tight);
}

h4 {
  font-size: var(--font-size-xl);
  font-weight: var(--font-weight-semibold);
  line-height: var(--line-height-tight);
}

h5 {
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-semibold);
  line-height: var(--line-height-tight);
}

h6 {
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-semibold);
  line-height: var(--line-height-tight);
}

p {
  font-size: var(--font-size-md);
  line-height: var(--line-height-normal);
}

small {
  font-size: var(--font-size-xs);
}

img,
svg,
video,
canvas {
  display: block;
  max-width: 100%;
}

/* Smooth Transitions */
a, button, input, textarea, select {
  transition: all var(--transition-slow);
}

/* Responsive Typography */
@media (max-width: 768px) {
  html {
    font-size: 14px;
  }
}

/* Scrollbar Styling */
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 10px;
}

::-webkit-scrollbar-thumb {
  background: var(--gradient-primary);
  border-radius: 10px;
  transition: background 0.3s ease;
}

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

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

/* Screen-reader-only utility: visually hidden but announced by assistive tech */
.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 (WCAG 2.4.1 Bypass Blocks): first focusable element on every
   storefront page, visually hidden until it receives keyboard focus. */
.skip-link {
  position: absolute;
  top: -100px;
  left: 8px;
  z-index: 9999;
  padding: 12px 20px;
  background: var(--primary-color);
  color: #fff;
  border-radius: var(--radius-md);
  text-decoration: none;
  font-weight: 600;
  transition: top 0.2s ease;
}

.skip-link:focus-visible,
.skip-link:focus {
  top: 8px;
}

/* Spinner rotation for app-icon name="spinner" used as a loading indicator */
@keyframes app-icon-spin {
  to { transform: rotate(360deg); }
}

.spin {
  animation: app-icon-spin 1s linear infinite;
}

/* Consistent, animated expander chevron for every native <details>/<summary>
   disclosure in the app, replacing the browser's default triangle marker
   (which renders differently per browser). Matches the Lucide ChevronDown
   path used everywhere else via app-icon, so expanders use the same icon
   family as the rest of the UI without touching every call site. */
details > summary {
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;

  &::-webkit-details-marker {
    display: none;
  }

  &::after {
    content: '';
    flex-shrink: 0;
    width: 16px;
    height: 16px;
    background-color: currentColor;
    mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    mask-repeat: no-repeat;
    mask-position: center;
    mask-size: contain;
    transition: transform 0.2s ease;
  }
}

details[open] > summary::after {
  transform: rotate(180deg);
}

@media (prefers-reduced-motion: reduce) {
  details > summary::after {
    transition: none;
  }
}

/* Respect OS-level reduced-motion preference globally: neutralizes hover
   transforms, card-entrance/skeleton-shimmer animations, and smooth-scroll
   everywhere in one place rather than requiring every component to opt in
   individually (a few already did this locally, e.g. shared/ui/skeleton). */
@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;
  }
}

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

/* Backward-compatible alias while foundation migration is in progress. */
.container {
  max-width: 1280px;
  margin: 0 auto;
  padding: var(--space-lg) var(--space-md);
  width: 100%;
}

.section {
  margin: 0;
  padding-block: clamp(16px, 2.5vw, 32px);
  animation: section-fade-in 320ms ease-out both;
}

.grid {
  display: grid;
  gap: var(--space-md);
}

.card {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition-normal), box-shadow var(--transition-normal);
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.product-card,
.item-card {
  transition: transform var(--transition-normal), box-shadow var(--transition-normal);
}

.product-card:hover,
.item-card:hover {
  transform: translateY(-2px) scale(1.01);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  padding: 0.625rem var(--space-md);
  font-size: var(--font-size-md);
  font-weight: var(--font-weight-semibold);
  line-height: var(--line-height-tight);
  cursor: pointer;
  text-decoration: none;
  transition: transform var(--transition-normal), box-shadow var(--transition-normal), background-color var(--transition-normal), color var(--transition-normal), border-color var(--transition-normal);
}

.btn:hover {
  transform: translateY(-1px);
}

.btn-ghost {
  background: transparent;
  color: var(--text-primary);
  border-color: var(--border-color);
}

.btn-ghost:hover {
  background: rgba(73, 118, 113, 0.08);
  border-color: var(--primary-color);
}

@keyframes section-fade-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.grid-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.grid-4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

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

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

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

// ─── Shared Badge & Tag Styles (from backOffice integration) ───

.item-badge {
  display: inline-block;
  padding: 2px var(--space-xs);
  border-radius: var(--radius-xs);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-semibold);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: #fff;
  line-height: var(--line-height-normal);

  &.badge-new       { background: #4caf50; }
  &.badge-sale       { background: #f44336; }
  &.badge-exclusive  { background: #9c27b0; }
  &.badge-hot        { background: #ff5722; }
  &.badge-limited    { background: #ff9800; }
  &.badge-bestseller { background: #2196f3; }
  &.badge-featured   { background: #607d8b; }
  &.badge-custom     { background: #78909c; }
}

.item-tag {
  display: inline-block;
  padding: 2px var(--space-xs);
  border-radius: var(--radius-full);
  font-size: var(--font-size-xs);
  color: var(--primary-color);
  background: rgba(73, 118, 113, 0.08);
  border: 1px solid rgba(73, 118, 113, 0.15);
}

