@layer reset, base, utilities;

@layer reset {
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  border-radius: 0;
}

html, body {
  font-family: 'Roboto', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  scroll-behavior: smooth;
  overflow-x: clip;
}

body {
  min-width: 320px;
  min-height: 100vh;
  line-height: 1.5;
  background-color: var(--md-sys-color-background);
  color: var(--md-sys-color-on-background);
  background-image: radial-gradient(circle at 50% 0%, rgba(0, 240, 255, 0.03) 0%, transparent 60%), radial-gradient(circle at 100% 100%, rgba(255, 0, 127, 0.02) 0%, transparent 50%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  transition: background-color var(--md-transition-standard), color var(--md-transition-standard);
  padding-top: 65px;
}

button, input, select, textarea, optgroup,
md-filled-button, md-outlined-button, md-text-button, md-elevated-button, md-filled-tonal-button, md-icon-button, md-chip {
  font-family: inherit;
}

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

button, input, select, textarea, optgroup {
  -webkit-tap-highlight-color: transparent;
}

button {
  border: none;
  background: transparent;
  padding: 0;
  cursor: pointer;
}

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

:focus-visible {
  outline: 2px solid var(--md-sys-color-secondary);
  outline-offset: 2px;
  box-shadow: var(--ui-focus-ring);
}
}

@layer base {
/* Material Icons & Web Components FOUC Prevention */
md-icon:not(:defined),
md-filled-button:not(:defined),
md-outlined-button:not(:defined),
md-text-button:not(:defined),
md-icon-button:not(:defined),
md-elevated-button:not(:defined),
md-filled-tonal-button:not(:defined) {
  visibility: hidden;
  opacity: 0;
}

md-icon,
.material-icons,
.material-symbols-outlined {
  font-family: 'Material Symbols Outlined', monospace;
  font-weight: normal;
  font-style: normal;
  font-size: 24px;
  line-height: 1;
  letter-spacing: normal;
  text-transform: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  word-wrap: normal;
  word-break: keep-all;
  direction: ltr;
  -webkit-font-feature-settings: 'liga';
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  max-width: 1em;
  max-height: 1em;
  flex-shrink: 0;
  vertical-align: middle;
}

/* Global Spin Button Reset */
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  appearance: none;
  margin: 0;
}
input[type="number"] {
  -moz-appearance: textfield;
  appearance: textfield;
}

/* Browser Autofill Styling */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
input:-webkit-autofill:active,
textarea:-webkit-autofill,
select:-webkit-autofill {
  -webkit-box-shadow: 0 0 0 1000px var(--md-sys-color-surface-container) inset, 0 0 5px rgba(0, 255, 102, 0.2);
  box-shadow: 0 0 0 1000px var(--md-sys-color-surface-container) inset, 0 0 5px rgba(0, 255, 102, 0.2);
  -webkit-text-fill-color: var(--md-sys-color-on-surface);
  color: var(--md-sys-color-on-surface);
  border: 1px solid rgba(0, 255, 102, 0.4);
  transition: background-color 5000s ease-in-out 0s;
  caret-color: var(--md-sys-color-primary);
}

input:-webkit-autofill:focus,
textarea:-webkit-autofill:focus,
select:-webkit-autofill:focus {
  -webkit-box-shadow: 0 0 0 1000px var(--md-sys-color-surface-container-high) inset, 0 0 12px rgba(0, 240, 255, 0.3);
  box-shadow: 0 0 0 1000px var(--md-sys-color-surface-container-high) inset, 0 0 12px rgba(0, 240, 255, 0.3);
  border-color: var(--md-sys-color-secondary);
}

/* Typography Hierarchy with Fluid Clamp Scaling */
.display-large { font-size: clamp(2rem, 4vw, 3.55rem); font-weight: 700; line-height: 1.12; letter-spacing: -0.25px; overflow-wrap: anywhere; }
.display-medium { font-size: clamp(1.75rem, 3vw, 2.8rem); font-weight: 700; line-height: 1.15; overflow-wrap: anywhere; }
.display-small { font-size: clamp(1.5rem, 2.5vw, 2.2rem); font-weight: 600; line-height: 1.2; overflow-wrap: anywhere; }

.headline-large { font-size: clamp(1.5rem, 2.25vw, 2rem); font-weight: 700; line-height: 1.25; overflow-wrap: anywhere; }
.headline-medium { font-size: clamp(1.25rem, 2vw, 1.75rem); font-weight: 600; line-height: 1.3; overflow-wrap: anywhere; }
.headline-small { font-size: clamp(1.125rem, 1.7vw, 1.5rem); font-weight: 600; line-height: 1.35; overflow-wrap: anywhere; }

.title-large { font-size: 22px; font-weight: 600; line-height: 28px; overflow-wrap: anywhere; }
.title-medium { font-size: 16px; font-weight: 600; line-height: 24px; letter-spacing: 0.15px; overflow-wrap: anywhere; }
.title-small { font-size: 14px; font-weight: 600; line-height: 20px; letter-spacing: 0.1px; overflow-wrap: anywhere; }

.body-large { font-size: 16px; font-weight: 400; line-height: 24px; letter-spacing: 0.5px; }
.body-medium { font-size: 14px; font-weight: 400; line-height: 20px; letter-spacing: 0.25px; }
.body-small { font-size: 12px; font-weight: 400; line-height: 16px; letter-spacing: 0.4px; }

.label-large { font-size: 14px; font-weight: 600; line-height: 20px; letter-spacing: 0.1px; text-transform: uppercase; }
.label-medium { font-size: 12px; font-weight: 600; line-height: 16px; letter-spacing: 0.5px; text-transform: uppercase; }
.label-small { font-size: 11px; font-weight: 600; line-height: 16px; letter-spacing: 0.5px; text-transform: uppercase; }

.price {
  color: var(--md-sys-color-primary);
  font-weight: 700;
  text-shadow: 0 0 8px rgba(0, 255, 102, 0.4);
}

.secondary-text { color: var(--md-sys-color-on-surface-variant); }

/* Unified Layout Container */
.container {
  width: min(100%, var(--ui-content-max));
  max-width: var(--ui-content-max);
  margin: 0 auto;
  padding: 0 var(--ui-gutter);
}

main.container {
  padding-top: var(--ui-page-space);
  padding-bottom: var(--ui-page-space);
  min-height: calc(100dvh - 220px);
}

:where(.grid, .product-list-layout, .product-detail-grid, .search-bar, .footer-grid,
  .seller-header-inner, .compact-profile-card, .cart-item, .cart-totals,
  .buy-box-actions-row, .buy-box-stock-area, .profile-actions, .seller-dashboard-actions,
  .form-actions, .review-card, .order-header, .order-item-link, .seller-stats) > * {
  min-width: 0;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr));
  gap: var(--ui-gap);
}

@media (max-width: 768px) {
  .grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }
}

/* Alerts & Notifications */
.alert {
  padding: 12px 16px;
  border: 1px solid var(--md-sys-color-outline-variant);
  background: var(--md-sys-color-surface);
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.alert.success {
  border-color: var(--md-sys-color-success);
  color: var(--md-sys-color-on-success-container);
  background: var(--md-sys-color-success-container);
  box-shadow: 0 0 15px rgba(0, 255, 102, 0.2);
}

.alert.error {
  border-color: var(--md-sys-color-error);
  color: var(--md-sys-color-on-error-container);
  background: var(--md-sys-color-error-container);
  box-shadow: 0 0 15px rgba(255, 0, 51, 0.2);
}

.message-container {
  position: fixed;
  top: 80px;
  right: var(--ui-gutter);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 400px;
}

.message-container > div, .message {
  padding: 14px 20px;
  border: 1px solid var(--md-sys-color-outline-variant);
  background: var(--md-sys-color-surface);
  box-shadow: 0 0 15px rgba(0, 240, 255, 0.2);
  color: var(--md-sys-color-on-surface);
  display: flex;
  align-items: center;
  gap: 12px;
  animation: slideInRight 0.3s ease-out;
}

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

/* Breadcrumbs & Pagination */
.breadcrumbs {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.crumb {
  color: var(--md-sys-color-on-surface-variant);
  font-size: 13px;
  transition: color var(--md-transition-fast);
}

.crumb:hover { color: var(--md-sys-color-primary); }

.pagination-container,
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 16px;
  margin-top: 32px;
  width: 100%;
  flex-wrap: wrap;
}

.page-link {
  padding: 8px 14px;
  border: 1px solid var(--md-sys-color-outline-variant);
  background: var(--md-sys-color-surface-container);
  color: var(--md-sys-color-on-surface);
  font-weight: 600;
  transition: all var(--md-transition-fast);
}

.page-link:hover, .page-link.active {
  border-color: var(--md-sys-color-primary);
  background: var(--md-sys-color-primary);
  color: #000000;
  box-shadow: 0 0 12px rgba(0, 255, 102, 0.4);
}

/* Theme Toggle */
.theme-toggle {
  background: transparent;
  border: 1px solid transparent;
  width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--md-sys-color-on-surface);
  cursor: pointer;
  transition: all var(--md-transition-fast);
}

.theme-toggle:hover {
  border-color: var(--md-sys-color-primary);
  background: rgba(0, 255, 102, 0.05);
  color: var(--md-sys-color-primary);
  box-shadow: 0 0 10px rgba(0, 255, 102, 0.2);
}

@media (max-width: 768px) {
  main.container { padding-block: 20px; }
  .message-container { top: 74px; left: var(--ui-gutter); right: var(--ui-gutter); max-width: none; }
}
}

@layer utilities {
  .w-full { width: 100%; }
  .h-full { height: 100%; }
  .max-w-md { max-width: 600px; }
  .max-w-lg { max-width: 800px; }
  .flex { display: flex; }
  .flex-row { display: flex; flex-direction: row; }
  .flex-col { display: flex; flex-direction: column; }
  .flex-align-center, .align-center { display: flex; align-items: center; }
  .flex-center { display: flex; align-items: center; justify-content: center; }
  .flex-between, .justify-between { display: flex; align-items: center; justify-content: space-between; }
  .flex-end { display: flex; justify-content: flex-end; align-items: center; }
  .items-center { align-items: center; }
  .justify-center { justify-content: center; }
  .no-underline { text-decoration: none; display: inline-flex; }

  .gap-xs { gap: 4px; }
  .gap-sm { gap: 8px; }
  .gap-md { gap: 12px; }
  .gap-lg { gap: 16px; }
  .gap-xl { gap: 24px; }

  .m-0 { margin: 0; }
  .mb-xs { margin-bottom: 4px; }
  .mb-sm { margin-bottom: 8px; }
  .mb-md { margin-bottom: 12px; }
  .mb-lg { margin-bottom: 16px; }
  .mb-xl { margin-bottom: 24px; }
  .mt-sm { margin-top: 8px; }
  .mt-md { margin-top: 16px; }
  .mt-lg { margin-top: 24px; }
  .mt-xl { margin-top: 32px; }
  .py-sm { padding-top: 12px; padding-bottom: 12px; }
  .px-xs { padding-left: 8px; padding-right: 8px; }

  .text-center { text-align: center; }
  .text-right { text-align: right; }
  .text-left { text-align: left; }
  .text-primary { color: var(--md-sys-color-primary); }
  .text-secondary { color: var(--md-sys-color-secondary); }
  .text-muted { color: var(--md-sys-color-on-surface-variant); }
  .font-mono { font-family: monospace; }
  .font-bold { font-weight: 700; }
  .uppercase { text-transform: uppercase; }
}

