@layer base, component;

/* ============================================
GLOBAL STYLES & RESET
Clean, Minimalist E-commerce Theme
============================================ */

@import url('variables.css');

/* ============================================
SVG ICON SYSTEM
Ensures all SVG icons have consistent sizing
============================================ */
.icon,
.icon svg {
  display: inline-block;
  width: 1em;
  height: 1em;
  vertical-align: middle;
  flex-shrink: 0;
}

.icon-sm {
  width: 16px;
  height: 16px;
}
.icon-md {
  width: 20px;
  height: 20px;
}
.icon-lg {
  width: 24px;
  height: 24px;
}
.icon-xl {
  width: 32px;
  height: 32px;
}

/* Category and feature icons */
.category-icon svg,
.feature-icon svg,
.bb-category-icon svg {
  width: 28px;
  height: 28px;
}

/* Button icons */
.btn svg,
button svg {
  width: 1.2em;
  height: 1.2em;
  margin-right: 0.25em;
}

/* Empty state icons */
.empty-cart-icon svg,
.empty-icon svg {
  width: 48px;
  height: 48px;
  opacity: 0.5;
}

/* Rating stars */
.rating-stars svg,
.star-rating svg,
.bb-browse-rating-stars svg {
  width: 14px;
  height: 14px;
}

/* Nav icons */
.nav-icon svg,
.seller-nav-icon svg,
.admin-menu-icon svg {
  width: 18px;
  height: 18px;
}

/* Dashboard icons */
.dv-order-icon svg,
.dv-empty-icon svg,
.dv-stat-icon svg,
.admin-stat-icon svg,
.seller-stat-icon svg {
  width: 24px;
  height: 24px;
}

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

html {
  scroll-behavior: smooth;
  font-size: 16px;
}

body {
  font-family:
    -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  font-size: var(--text-base);
  line-height: var(--line-normal);
  color: var(--neutral-900);
  background-color: var(--bg-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Typography - Clean & Bold, Best Buy Style */
h1,
h2,
h3,
h4,
h5,
h6 {
  font-weight: 700;
  line-height: 1.15;
  margin-bottom: var(--space-md);
  color: var(--neutral-800);
  letter-spacing: -0.01em;
}

h1 {
  font-size: clamp(2.25rem, 4vw, 3rem);
}

h2 {
  font-size: clamp(1.75rem, 3vw, 2.25rem);
}

h3 {
  font-size: var(--text-xl);
}

h4 {
  font-size: var(--text-lg);
}

p {
  margin-bottom: var(--space-md);
  line-height: 1.6;
  color: var(--neutral-700);
}

a {
  color: var(--primary);
  text-decoration: none;
  transition: color 0.15s ease;
}

a:hover {
  color: var(--primary-hover);
  text-decoration: underline;
}

/* App Container */
.app-container {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Main Content */
#main-content {
  flex: 1;
  width: 100%;
}

/* Container */
.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 var(--space-xl);
}

@media (max-width: 768px) {
  .container {
    padding: 0 var(--space-md);
  }
}

/* Loading Screen */
#loading-screen {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--bg-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.loading-spinner {
  text-align: center;
}

.loading-dots {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  justify-content: center;
  margin: 0 auto var(--space-md);
}

.loading-dot {
  width: 0.75rem;
  height: 0.75rem;
  border-radius: 50%;
  background: var(--primary);
  animation: bounce 1s infinite;
}

.loading-dot:nth-child(2) {
  animation-delay: 0.2s;
}

.loading-dot:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes bounce {
  0%,
  100% {
    transform: translateY(-25%);
    animation-timing-function: cubic-bezier(0.8, 0, 1, 1);
  }
  50% {
    transform: translateY(0);
    animation-timing-function: cubic-bezier(0, 0, 0.2, 1);
  }
}

.loading-spinner p {
  color: var(--neutral-600);
  font-size: var(--text-sm);
}

/* Utility Classes */
.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;
}

.text-center {
  text-align: center;
}

.text-left {
  text-align: left;
}

.text-right {
  text-align: right;
}

.mt-1 {
  margin-top: var(--space-sm);
}
.mt-2 {
  margin-top: var(--space-md);
}
.mt-3 {
  margin-top: var(--space-lg);
}
.mt-4 {
  margin-top: var(--space-xl);
}

.mb-1 {
  margin-bottom: var(--space-sm);
}
.mb-2 {
  margin-bottom: var(--space-md);
}
.mb-3 {
  margin-bottom: var(--space-lg);
}
.mb-4 {
  margin-bottom: var(--space-xl);
}

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

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

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

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

::-webkit-scrollbar-track {
  background: var(--neutral-100);
}

::-webkit-scrollbar-thumb {
  background: var(--neutral-300);
  border-radius: 0;
}

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

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

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

/* Footer Styles */
.footer-container {
  max-width: 80rem;
  margin: 0 auto;
  padding: 0 1rem;
}

/* Newsletter Section */
.footer-newsletter {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 2rem;
  padding-bottom: 2rem;
  border-bottom: 1px solid var(--neutral-200);
}

.footer-newsletter-content {
  flex: 1;
  min-width: 300px;
}

.footer-newsletter-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--neutral-900);
  margin: 0;
}

.footer-newsletter-form-wrapper {
  flex: 1;
  min-width: 300px;
}

.footer-newsletter-form {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.footer-input-wrapper {
  position: relative;
  flex: 1;
  min-width: 250px;
}

.footer-input-icon {
  width: 1.5rem;
  height: 1.5rem;
  color: var(--neutral-400);
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
}

.footer-newsletter-input {
  width: 100%;
  min-height: 44px;
  padding: 0.625rem 1rem 0.625rem 3rem;
  color: var(--neutral-500);
  background: var(--bg-primary);
  outline: none;
  border: 1px solid var(--neutral-200);
  border-radius: 0.5rem;
  font-size: 0.875rem;
}

.footer-newsletter-btn {
  padding: 0.625rem 1.25rem;
  min-height: 44px;
  font-weight: 600;
  font-size: 0.875rem;
  color: #ffffff;
  background: var(--primary);
  border: none;
  border-radius: 0.5rem;
  cursor: pointer;
  transition: background 0.2s;
}

.footer-newsletter-btn:hover {
  background: var(--primary-hover);
}

/* Footer Links Section */
.footer-links-section {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 2rem;
  padding: 2.5rem 0 2rem;
}

.footer-brand-col {
  flex: 1;
  min-width: 200px;
}

.footer-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.footer-brand-icon {
  width: 2rem;
  height: 2rem;
  border-radius: 0.5rem;
}

.footer-brand-name {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--neutral-900);
}

.footer-description {
  color: var(--neutral-500);
  font-size: 0.875rem;
  line-height: 1.6;
  max-width: 16rem;
}

.footer-links-col {
  flex: 1;
  min-width: 150px;
}

.footer-links-title {
  font-weight: 600;
  color: var(--neutral-900);
  margin-bottom: 1rem;
  font-size: 0.875rem;
}

.footer-links-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.footer-link {
  color: var(--neutral-500);
  text-decoration: none;
  font-size: 0.875rem;
  transition: color 0.2s;
}

.footer-link:hover {
  color: var(--primary);
}

/* Footer Bottom */
.footer-bottom {
  max-width: 80rem;
  margin: 0 auto;
  padding: 1.5rem 0;
  border-top: 1px solid var(--neutral-200);
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.footer-copyright {
  color: var(--neutral-500);
  font-size: 0.875rem;
  margin: 0;
}

.footer-social {
  display: flex;
  gap: 1.5rem;
}

.footer-social-link {
  color: var(--neutral-400);
  transition: color 0.2s;
  width: 1.5rem;
  height: 1.5rem;
}

.footer-social-link:hover {
  color: var(--neutral-500);
}

.footer-social-link svg {
  width: 100%;
  height: 100%;
}

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

  h1 {
    font-size: var(--text-3xl);
  }

  h2 {
    font-size: var(--text-2xl);
  }

  .footer-container {
    padding: 0 1.25rem;
  }

  .footer-newsletter {
    flex-direction: column;
    align-items: flex-start;
  }

  .footer-newsletter-content,
  .footer-newsletter-form-wrapper {
    min-width: 0;
  }

  .footer-newsletter-form {
    flex-direction: column;
    align-items: stretch;
  }

  .footer-input-wrapper {
    min-width: 0;
  }

  .footer-links-section {
    flex-direction: column;
  }

  .footer-links-col {
    min-width: 0;
  }

  .footer-brand-col {
    min-width: 0;
  }

  .footer-bottom {
    flex-direction: column;
    text-align: center;
  }
}

/* Phones (<= 480px): collapse the footer link columns to 2-up so the
   footer doesn't dominate every page, and bump the small footer links
   to a 44px touch target (Apple HIG) without changing typography. */
@media (max-width: 480px) {
  .footer-links-section {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem 1rem;
  }
  /* On a 2-up grid the brand column should span both columns and sit
     at the top so the link columns read as a tidy 2x2 block below. */
  .footer-brand-col {
    grid-column: 1 / -1;
  }
  .footer-links-col {
    min-width: 0;
  }
  /* 14px-tall <a> tags are the smallest hit area in the app. Inflate
     the hit area with vertical padding while keeping the text size. */
  .footer-link {
    display: inline-block;
    padding: 0.65rem 0;
    min-height: 44px;
    line-height: 1.2;
  }
  .footer-links-list {
    gap: 0;
  }
}

/* ============================================
   DARK MODE OVERRIDES
   ============================================ */
[data-theme='dark'] {
  --heading-color: var(--neutral-800);
}

[data-theme='dark'] ::-webkit-scrollbar-track {
  background: var(--neutral-100);
}

[data-theme='dark'] ::-webkit-scrollbar-thumb {
  background: var(--neutral-300);
}

[data-theme='dark'] ::-webkit-scrollbar-thumb:hover {
  background: var(--neutral-400);
}

[data-theme='dark'] ::selection {
  background: var(--primary);
  color: #ffffff;
}

[data-theme='dark'] ::-moz-selection {
  background: var(--primary);
  color: #ffffff;
}
