@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600;700&display=swap");

/* === VARIABLES === */
:root {
  --brand: #7f5cf6;
  --brand-strong: #6b46f2;
  --bg: #f7f7fb;
  --surface: #ffffff;
  --surface-2: #f2f2fa;
  --text: #18122b;
  --muted: #6b6680;
  --border: #e8e7f4;
  --hover: rgba(125, 92, 246, 0.1);
  --shadow: 0 8px 24px rgba(17, 9, 34, 0.08);
}

html[data-theme="dark"] {
  --brand: #9d76f8;
  --brand-strong: #b495ff;
  --bg: #110922;
  --surface: rgba(255, 255, 255, 0.05);
  --surface-2: rgba(255, 255, 255, 0.08);
  --text: #ece8ff;
  --muted: #b7aee5;
  --border: rgba(255, 255, 255, 0.12);
  --hover: rgba(157, 118, 248, 0.16);
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

/* === RESET === */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
  font-family: "Poppins", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

img {
  max-width: 100%;
  display: block;
}

/* === LAYOUT === */
.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1rem;
}

.main {
  padding: 2rem 0;
  min-height: calc(100vh - 80px);
}

/* === HEADER === */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: saturate(140%) blur(10px);
  background: rgba(255, 255, 255, 0.7);
  border-bottom: 1px solid var(--border);
}

html[data-theme="dark"] .header {
  background: rgba(22, 13, 42, 0.6);
}

.header__wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 70px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 700;
  text-decoration: none;
  color: var(--text);
}

.brand__logo {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: radial-gradient(
      110% 110% at 20% 20%,
      var(--brand-strong) 0%,
      var(--brand) 60%,
      transparent 61%
    ),
    linear-gradient(180deg, var(--brand), transparent);
  box-shadow: 0 6px 16px rgba(157, 118, 248, 0.4);
}

.brand-gradient {
  background: linear-gradient(90deg, var(--brand), var(--brand-strong));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.nav {
  display: flex;
  gap: 0.5rem;
}

.nav__link {
  padding: 0.5rem 0.75rem;
  border-radius: 10px;
  color: var(--text);
  text-decoration: none;
  transition: all 0.2s;
}

.nav__link:hover {
  background: var(--hover);
}

.nav__link--active {
  background: var(--hover);
}

.actions {
  display: flex;
  gap: 0.5rem;
}

/* === BUTTONS === */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.55rem 1rem;
  border-radius: 14px;
  border: 1px solid transparent;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  line-height: 1;
  font-family: inherit;
}

.btn svg {
  width: 18px;
  height: 18px;
}

.btn--primary {
  color: #fff;
  background: linear-gradient(90deg, var(--brand), var(--brand-strong));
  box-shadow: 0 10px 20px rgba(125, 92, 246, 0.35);
}

.btn--primary:hover {
  transform: translateY(-1px);
}

.btn--glass {
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.14),
    rgba(255, 255, 255, 0.06)
  );
  border-color: var(--border);
  backdrop-filter: blur(8px);
  color: var(--text);
}

.btn--glass:hover {
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.12);
}

.btn--ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--text);
}

.btn--icon {
  width: 42px;
  height: 42px;
  padding: 0;
  position: relative;
}

.w-full {
  width: 100%;
}

/* === CARD === */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
}

.p-4 {
  padding: 1.5rem;
}

/* === HERO === */
.hero {
  text-align: center;
  padding: 3rem 0;
}

.hero__title {
  font-size: 2.5rem;
  margin: 0 0 1rem;
}

.hero__subtitle {
  font-size: 1.2rem;
  color: var(--muted);
}

/* === PRODUCTS GRID === */
.products {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.5rem;
  margin-top: 2rem;
}

.product-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
  transition: all 0.3s;
  cursor: pointer;
}

.product-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow);
}

.product-card__image {
  width: 100%;
  height: 250px;
  object-fit: cover;
  background: var(--surface-2);
}

.product-card__body {
  padding: 1.25rem;
}

.product-card__title {
  font-size: 1.1rem;
  font-weight: 600;
  margin: 0 0 0.5rem;
}

.product-card__price {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--brand);
  margin: 0.5rem 0;
}

.product-card__stock {
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 1rem;
}

/* === CART SIDEBAR === */
.cart-sidebar {
  position: fixed;
  right: -400px;
  top: 0;
  width: 400px;
  height: 100vh;
  background: var(--surface);
  border-left: 1px solid var(--border);
  z-index: 200;
  transition: right 0.3s;
  display: flex;
  flex-direction: column;
  box-shadow: -4px 0 20px rgba(0, 0, 0, 0.1);
}

.cart-sidebar.active {
  right: 0;
}

.cart-sidebar__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.5rem;
  border-bottom: 1px solid var(--border);
}

.cart-sidebar__body {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem;
}

.cart-empty {
  text-align: center;
  color: var(--muted);
  padding: 2rem 0;
}

.cart-item {
  display: flex;
  gap: 1rem;
  padding: 1rem;
  background: var(--surface-2);
  border-radius: 12px;
  margin-bottom: 1rem;
}

.cart-item__image {
  width: 60px;
  height: 60px;
  object-fit: cover;
  border-radius: 8px;
}

.cart-item__info {
  flex: 1;
}

.cart-item__name {
  font-weight: 600;
  margin: 0 0 0.25rem;
}

.cart-item__price {
  color: var(--brand);
  font-weight: 600;
}

.cart-item__controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.cart-item__qty {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.qty-btn {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.cart-sidebar__footer {
  padding: 1.5rem;
  border-top: 1px solid var(--border);
}

.cart-total {
  display: flex;
  justify-content: space-between;
  font-size: 1.3rem;
  font-weight: 700;
  margin-bottom: 1rem;
}

.cart-total__price {
  color: var(--brand);
}

.cart-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  background: var(--brand);
  color: white;
  border-radius: 10px;
  padding: 2px 6px;
  font-size: 0.7rem;
  font-weight: 700;
}

/* === OVERLAY === */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 150;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}

.overlay.active {
  opacity: 1;
  pointer-events: all;
}

/* === LOADING === */
.loading {
  text-align: center;
  padding: 3rem;
}

.spinner {
  width: 48px;
  height: 48px;
  border: 4px solid var(--border);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 1rem;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* === CHECKOUT === */
.checkout-container {
  max-width: 900px;
}

.checkout-grid {
  display: grid;
  grid-template-columns: 1fr 350px;
  gap: 2rem;
}

.form-group {
  margin-bottom: 1.25rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 500;
  color: var(--muted);
}

.form-group input,
.form-group textarea {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-2);
  color: var(--text);
  font-family: inherit;
}

.order-totals__row {
  display: flex;
  justify-content: space-between;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
}

.order-totals__row--total {
  font-size: 1.2rem;
  font-weight: 700;
  border-bottom: none;
  margin-top: 0.5rem;
}

.alert {
  padding: 1rem;
  border-radius: 12px;
  margin-bottom: 1.5rem;
}

.alert--success {
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: #10b981;
}

.alert--error {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #ef4444;
}

/* === UTILITIES === */
.mb-3 {
  margin-bottom: 1rem;
}
.mb-4 {
  margin-bottom: 1.5rem;
}
.mt-4 {
  margin-top: 1.5rem;
}

/* === RESPONSIVE === */
@media (max-width: 768px) {
  .checkout-grid {
    grid-template-columns: 1fr;
  }

  .cart-sidebar {
    width: 100%;
    right: -100%;
  }

  .products {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  }
}
