@layer components {
/* ==========================================================================
   BUTTONS (MODERN WEB3 TERMINAL STYLE)
   ========================================================================== */

.modern-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  cursor: pointer;
  transition: all var(--md-transition-standard);
  white-space: nowrap;
  line-height: 1.15;
  background: var(--ui-surface-raised);
  border: 1px solid var(--md-sys-color-outline);
  color: var(--md-sys-color-on-surface);
}

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

.modern-btn:active,
.qty-btn:active,
.overlay-btn:active,
.wishlist-btn:active {
  transform: translateY(0);
}

.modern-btn.primary-btn {
  background: var(--md-sys-color-primary);
  color: #000000;
  border-color: var(--md-sys-color-primary);
  box-shadow: 0 0 15px rgba(0, 255, 102, 0.3);
  font-weight: 800;
}

.modern-btn.primary-btn:hover {
  background: #00ff66;
  color: #000000;
  box-shadow: 0 0 25px rgba(0, 255, 102, 0.6);
}

.modern-btn.primary-btn * { color: #000000; }

.modern-btn.secondary-btn {
  background: var(--md-sys-color-surface-container);
  color: var(--md-sys-color-secondary);
  border-color: var(--md-sys-color-secondary);
  box-shadow: 0 0 10px rgba(0, 240, 255, 0.15);
}

.modern-btn.secondary-btn:hover {
  background: var(--md-sys-color-secondary);
  color: #000000;
  box-shadow: 0 0 20px rgba(0, 240, 255, 0.5);
}

.modern-btn.outline-btn {
  background: transparent;
  color: var(--md-sys-color-on-surface);
  border-color: var(--md-sys-color-outline);
}

.modern-btn.outline-btn:hover {
  border-color: var(--md-sys-color-primary);
  color: var(--md-sys-color-primary);
  box-shadow: 0 0 15px rgba(0, 255, 102, 0.25);
}

.qty-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 255, 102, 0.12);
  color: var(--md-sys-color-primary);
  border: 1px solid var(--md-sys-color-primary);
  cursor: pointer;
  transition: all var(--md-transition-fast);
}

.qty-btn:hover {
  background: var(--md-sys-color-primary);
  color: #000000;
  box-shadow: 0 0 15px rgba(0, 255, 102, 0.6);
}

.qty-btn:hover * { color: #000000; }

.avatar-file-btn {
  background: var(--md-sys-color-primary);
  color: #000000;
  border: none;
  min-width: 160px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  letter-spacing: 0.08em;
  font-weight: 600;
  text-transform: uppercase;
  font-size: 13px;
  box-shadow: 0 0 15px rgba(0, 255, 102, 0.3);
  transition: all var(--md-transition-standard);
  padding: 0 18px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

.avatar-file-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 0 25px rgba(0, 255, 102, 0.5);
  filter: brightness(1.1);
}

.file-input-hidden {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  opacity: 0;
}

/* Material Web Component Resets */
md-filled-button md-icon,
md-outlined-button md-icon,
md-text-button md-icon,
md-icon-button md-icon,
md-filled-button .material-symbols-outlined,
md-outlined-button .material-symbols-outlined {
  overflow: hidden;
  max-width: 1em;
  max-height: 1em;
  font-size: 20px;
  width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  vertical-align: middle;
  line-height: 1;
}

/* ==========================================================================
   FORM INPUTS & CONTROLS
   ========================================================================== */

.form-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.modern-input {
  width: 100%;
  height: 48px;
  padding: 0 44px 0 16px;
  background: var(--ui-surface-raised);
  border: 1px solid var(--ui-border);
  color: var(--md-sys-color-on-surface);
  font-size: 14px;
  outline: none;
  transition: all var(--md-transition-fast);
}

.modern-input:hover {
  border-color: var(--md-sys-color-outline);
}

.modern-input:focus {
  border-color: var(--md-sys-color-secondary);
  box-shadow: var(--ui-focus-ring);
}

textarea.modern-input,
textarea {
  height: auto;
  min-height: 120px;
  padding: 14px 16px;
  line-height: 1.6;
  resize: vertical;
}

.input-wrapper {
  position: relative;
  display: block;
  width: 100%;
}

.input-wrapper > md-icon,
.input-wrapper > .material-symbols-outlined,
.input-wrapper > .material-icons {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 20px;
  color: var(--md-sys-color-outline);
  pointer-events: none;
  z-index: 2;
}

.password-toggle {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--md-sys-color-on-surface-variant);
  cursor: pointer;
  z-index: 4;
}

.password-toggle:hover,
.password-toggle:focus-visible {
  color: var(--md-sys-color-primary);
}

.input-wrapper:has(.password-toggle) > md-icon,
.input-wrapper:has(.password-toggle) > .material-symbols-outlined,
.input-wrapper.has-password-toggle > md-icon,
.input-wrapper.has-password-toggle > .material-symbols-outlined {
  right: 44px;
}

.input-wrapper:has(.password-toggle) .modern-input,
.input-wrapper.has-password-toggle .modern-input,
.modern-input.password-input {
  padding-right: 76px;
}

.modern-input[type="password"]::-ms-reveal,
.modern-input[type="password"]::-ms-clear {
  display: none;
}

.error-message {
  display: flex;
  gap: 8px;
  align-items: center;
  color: var(--md-sys-color-error);
  overflow-wrap: anywhere;
}

.error-message md-icon { font-size: 18px; }

/* Custom Select */
.custom-select-wrapper {
  position: relative;
  width: 100%;
  height: 100%;
  user-select: none;
}

.custom-select-trigger {
  width: 100%;
  height: 100%;
  min-height: 48px;
  background: var(--ui-surface-raised);
  border: 1px solid var(--ui-border);
  color: var(--md-sys-color-on-surface);
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  cursor: pointer;
  font-size: 13px;
  transition: all var(--md-transition-fast);
}

.custom-select-trigger:hover,
.custom-select-wrapper.open .custom-select-trigger {
  border-color: var(--md-sys-color-secondary);
  background: var(--md-sys-color-surface-container-high);
  box-shadow: var(--ui-focus-ring);
}

.custom-select-trigger .trigger-content {
  display: flex;
  align-items: center;
  gap: 10px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.custom-select-trigger md-icon,
.custom-select-trigger .material-symbols-outlined {
  color: var(--md-sys-color-primary);
  font-size: 20px;
  transition: transform var(--md-transition-standard);
  flex-shrink: 0;
}

.custom-select-wrapper.open .custom-select-trigger md-icon.arrow-icon,
.custom-select-wrapper.open .custom-select-trigger .material-symbols-outlined.arrow-icon {
  transform: rotate(180deg);
  color: var(--md-sys-color-secondary);
}

.custom-select-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  width: 100%;
  max-height: min(280px, 50dvh);
  overflow-y: auto;
  background: var(--md-sys-color-surface);
  border: 1px solid var(--md-sys-color-secondary);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.8), 0 0 20px rgba(0, 240, 255, 0.2);
  z-index: 10000;
  display: none;
  flex-direction: column;
  animation: comboboxFadeIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

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

.custom-select-wrapper.open .custom-select-dropdown { display: flex; }

.custom-select-option {
  padding: 12px 16px;
  color: var(--md-sys-color-on-surface);
  font-size: 13px;
  cursor: pointer;
  transition: all var(--md-transition-fast);
  border-bottom: 1px solid var(--md-sys-color-outline-variant);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.custom-select-option:last-child { border-bottom: none; }

.custom-select-option:hover {
  background: rgba(0, 255, 102, 0.1);
  color: var(--md-sys-color-primary);
  padding-left: 22px;
}

.custom-select-option.selected {
  background: rgba(0, 240, 255, 0.15);
  color: var(--md-sys-color-secondary);
  font-weight: 700;
  border-left: 3px solid var(--md-sys-color-secondary);
}

/* Star Ratings & Avatars */
.star-rating {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 16px;
  background: var(--md-sys-color-surface-container-high);
  border: 1px solid var(--md-sys-color-outline-variant);
}

.stars-container { display: flex; gap: 8px; }

.star-button {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
}

.star-button md-icon {
  font-size: 24px;
  color: var(--md-sys-color-outline);
  transition: all var(--md-transition-fast);
}

.star-button.active md-icon, .star-active { color: var(--md-sys-color-primary); }
.star-inactive { color: var(--md-sys-color-outline-variant); }

.avatar-upload-section {
  padding: 16px;
  background: var(--md-sys-color-surface-container);
  border: 1px solid var(--md-sys-color-outline-variant);
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.avatar-upload-section.compact-avatar { padding: 12px; }
.avatar-upload-section.compact-avatar .avatar-placeholder { width: 80px; height: 80px; }

/* ==========================================================================
   CARDS & CONTAINERS
   ========================================================================== */

.card,
.product-card,
.category-card,
.order-card,
.auth-card,
.profile-card,
.profile-edit-card,
.seller-header,
.compact-profile-card,
.category-sidebar {
  border: 1px solid var(--ui-border);
  background: var(--ui-surface);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.16);
  transition: border-color 0.2s ease-in-out, box-shadow 0.2s ease-in-out, transform 0.2s ease-in-out;
  position: relative;
  overflow: hidden;
}

.card:not(.product-card):not(.product-detail-image-card),
.auth-card,
.profile-card,
.profile-edit-card,
.seller-header,
.compact-profile-card {
  padding: clamp(16px, 2.2vw, 28px);
}

.card:hover,
.category-card:hover,
.order-card:hover {
  border-color: var(--md-sys-color-primary);
  box-shadow: 0 0 15px rgba(0, 255, 102, 0.25), inset 0 0 10px rgba(0, 255, 102, 0.05);
  transform: translateY(-2px);
}

.auth-card, .profile-edit-card {
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
}

.auth-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  margin-bottom: 28px;
  gap: 8px;
}

.auth-header .auth-icon {
  font-size: 40px;
  color: var(--md-sys-color-primary);
  margin-bottom: 4px;
}

.profile-edit-card { max-width: 480px; }

/* Product Card Component */
.product-card {
  display: flex;
  flex-direction: column;
  height: 100%;
  cursor: pointer;
  padding: 0;
  min-width: 0;
  isolation: isolate;
}

.product-image {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  background: var(--md-sys-color-surface-container-low);
  overflow: hidden;
  border-bottom: 1px solid var(--md-sys-color-outline-variant);
}

.product-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.product-card:hover .product-image img { transform: scale(1.05); }

.product-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(to top, rgba(8, 8, 10, 0.8) 0%, transparent 50%);
  opacity: 0;
  transition: opacity var(--md-transition-standard);
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  padding: 12px;
}

.product-card:hover .product-overlay { opacity: 1; }

.product-card-body {
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  flex-grow: 1;
  min-width: 0;
}

.product-card-title {
  color: var(--md-sys-color-on-surface);
  font-size: 16px;
  font-weight: 600;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 4px;
  overflow-wrap: anywhere;
}

.product-card .price {
  font-size: 18px;
  margin-top: auto;
}

.wishlist-btn, .cart-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 36px;
  height: 36px;
  background: rgba(13, 14, 18, 0.8);
  border: 1px solid var(--md-sys-color-outline-variant);
  color: var(--md-sys-color-on-surface);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--md-transition-fast);
  z-index: 5;
}

.wishlist-btn:hover, .cart-btn:hover {
  border-color: var(--md-sys-color-tertiary);
  color: var(--md-sys-color-tertiary);
  box-shadow: 0 0 12px rgba(255, 0, 127, 0.4);
  transform: scale(1.1);
}

.wishlist-btn.active {
  color: var(--md-sys-color-error);
  border-color: var(--md-sys-color-error);
  box-shadow: 0 0 12px rgba(255, 0, 80, 0.4);
}

.overlay-btn {
  width: 40px;
  height: 40px;
  background: rgba(8, 8, 10, 0.9);
  border: 1px solid var(--md-sys-color-tertiary);
  color: var(--md-sys-color-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--md-transition-fast);
  box-shadow: 0 0 10px rgba(255, 0, 127, 0.4);
}

.overlay-btn:hover {
  background: var(--md-sys-color-tertiary);
  color: #000000;
  box-shadow: 0 0 20px rgba(255, 0, 127, 0.9);
  transform: scale(1.1);
}

.overlay-btn md-icon { color: inherit; font-size: 20px; }

@keyframes btnPopAnimation {
  0% { transform: scale(1); }
  30% { transform: scale(1.35) rotate(-6deg); }
  60% { transform: scale(0.85) rotate(4deg); }
  100% { transform: scale(1) rotate(0deg); }
}

@keyframes badgePopAnimation {
  0% { transform: scale(1); }
  50% { transform: scale(1.4); }
  100% { transform: scale(1); }
}

.btn-pop-animation {
  animation: btnPopAnimation 0.45s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.badge-pop-animation {
  animation: badgePopAnimation 0.4s ease-out;
}

/* Product Gallery Components (Detail & Cards) */
.product-gallery-card { padding: 0; overflow: hidden; }

.product-gallery-main {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  background: var(--md-sys-color-surface-container);
}

.gallery-slides {
  display: flex;
  width: 100%;
  height: 100%;
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.gallery-slide {
  flex: 0 0 100%;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.gallery-slide img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  user-select: none;
}

.gallery-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 10;
  background: rgba(13, 14, 18, 0.85);
  backdrop-filter: blur(10px);
  border: 1px solid var(--md-sys-color-outline-variant);
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  opacity: 0.85;
  color: #ffffff;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.6);
}

.gallery-nav:hover {
  opacity: 1;
  transform: translateY(-50%) scale(1.1);
  background: var(--md-sys-color-primary);
  border-color: var(--md-sys-color-primary);
  color: #000000;
  box-shadow: 0 0 20px rgba(0, 255, 102, 0.7);
}

.gallery-nav span.material-symbols-outlined {
  font-size: 30px;
  color: inherit;
}

.gallery-prev { left: 16px; }
.gallery-next { right: 16px; }

.gallery-counter {
  position: absolute;
  bottom: 12px;
  right: 12px;
  background: rgba(8, 8, 10, 0.8);
  border: 1px solid var(--md-sys-color-outline-variant);
  color: #fff;
  font-size: 12px;
  padding: 4px 12px;
  font-family: monospace, system-ui;
  pointer-events: none;
}

.gallery-thumbs {
  display: flex;
  gap: 8px;
  padding: 12px;
  overflow-x: auto;
  scrollbar-width: thin;
}

.gallery-thumbs::-webkit-scrollbar { height: 4px; }
.gallery-thumbs::-webkit-scrollbar-track { background: transparent; }
.gallery-thumbs::-webkit-scrollbar-thumb { background: var(--md-sys-color-outline-variant); }

.gallery-thumb {
  flex: 0 0 72px;
  width: 72px;
  height: 72px;
  border: 2px solid var(--md-sys-color-outline-variant);
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.2s, transform 0.15s;
  opacity: 0.65;
}

.gallery-thumb:hover {
  border-color: var(--md-sys-color-primary);
  opacity: 0.9;
  transform: scale(1.05);
}

.gallery-thumb.active {
  border-color: var(--md-sys-color-primary);
  opacity: 1;
  box-shadow: 0 0 10px rgba(0, 255, 102, 0.4);
}

.gallery-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Category Cards */
.category-card {
  padding: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 12px;
  color: var(--md-sys-color-on-surface);
}

.category-card md-icon {
  font-size: 36px;
  color: var(--md-sys-color-primary);
  transition: transform var(--md-transition-standard);
}

.category-card:hover md-icon {
  transform: scale(1.15);
  text-shadow: 0 0 12px rgba(0, 255, 102, 0.5);
}

/* Chips & Badges */
.chip {
  padding: 6px 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-size: 12px;
  text-transform: uppercase;
  transition: all var(--md-transition-fast);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.chip:hover, .chip.active {
  border-color: var(--md-sys-color-secondary);
  background: rgba(0, 240, 255, 0.1);
  color: var(--md-sys-color-secondary);
  box-shadow: 0 0 10px rgba(0, 240, 255, 0.2);
}

.seller-reviews-badges {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.meta-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  background: var(--md-sys-color-surface-container);
  border: 1px solid var(--md-sys-color-outline-variant);
  color: var(--md-sys-color-on-surface);
  font-size: 13px;
  transition: all var(--md-transition-fast);
}

.meta-chip:hover {
  border-color: var(--md-sys-color-primary);
  background: var(--md-sys-color-surface-container-high);
}

.meta-chip .chip-avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
}

.meta-chip .chip-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.badge {
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.badge-primary { background: rgba(0, 255, 102, 0.15); color: var(--md-sys-color-primary); border: 1px solid var(--md-sys-color-primary); }
.badge-secondary { background: rgba(0, 240, 255, 0.15); color: #00f0ff; border: 1px solid #00f0ff; }
.badge-tertiary { background: rgba(255, 0, 127, 0.15); color: #ff007f; border: 1px solid #ff007f; }

/* Modals Frame */
#topUpModal, #withdrawModal, #shipModal { padding: var(--ui-gutter); }

#topUpModal > div, #withdrawModal > div, #shipModal > div {
  max-height: calc(100dvh - (var(--ui-gutter) * 2));
  overflow-y: auto;
}

@media (max-width: 768px), (hover: none) {
  .product-overlay {
    opacity: 1;
    background: linear-gradient(to top, rgba(8, 8, 10, 0.95) 0%, rgba(8, 8, 10, 0.4) 40%, transparent 80%);
    padding: 8px;
  }
  .overlay-btn, .wishlist-btn { width: 36px; height: 36px; min-width: 36px; min-height: 36px; }
  .product-card-body { padding: 10px; gap: 6px; }
  .product-card-title { font-size: 13px; line-height: 1.35; }
  .product-card .price { font-size: 15px; }
  .category-card { padding: 14px 10px; gap: 8px; }
  .category-card md-icon { font-size: 28px; }
  .auth-card, .profile-edit-card { padding: 18px; max-width: 100%; }
}

@media (max-width: 480px) {
  .product-card-body { padding: 8px; gap: 4px; }
  .product-card-title { font-size: 12px; line-height: 1.3; }
  .product-card .price { font-size: 14px; }
  .overlay-btn, .wishlist-btn { width: 32px; height: 32px; min-width: 32px; min-height: 32px; }
}
}

