/* styles for single-file store */
:root {
  --brand: #0f172a;
  --accent: #080b12;
}
* {
  box-sizing: border-box;
}
body {
  font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, Arial;
  margin: 0;
  background: #f8fafc;
  color: #0b1220;
}
.site-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 20px;
  background: var(--brand);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 40;
}
.site-header .brand {
  font-weight: 700;
  font-size: 1.2rem;
}
.site-header .controls {
  display: flex;
  gap: 10px;
  align-items: center;
}
select {
  padding: 8px;
  border-radius: 6px;
  border: 1px solid #e6eef6;
}
.cart-btn {
  background: #fff;
  color: var(--brand);
  border: none;
  padding: 8px 12px;
  border-radius: 6px;
  cursor: pointer;
}
.container {
  max-width: 1100px;
  margin: 20px auto;
  padding: 0 16px;
}
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 18px;
  padding: 20px 0;
}
.product-card {
  background: #fff;
  padding: 12px;
  border-radius: 10px;
  box-shadow: 0 6px 18px rgba(2, 6, 23, 0.06);
  text-align: center;
}
.product-card img {
  width: 100%;
  height: 180px;
  object-fit: cover;
  border-radius: 8px;
}
.product-card h3 {
  margin: 12px 0 6px;
  font-size: 1.05rem;
}
.product-card p {
  color: #475569;
  font-size: 0.95rem;
  margin: 6px 0;
}
.btn {
  display: inline-block;
  padding: 8px 12px;
  border-radius: 8px;
  border: none;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
}
.view-btn {
  background: #eef2ff;
  color: var(--brand);
  border: 1px solid #dbeafe;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
}

/* product detail */
.hidden {
  display: none;
}
.back-btn {
  background: transparent;
  border: none;
  color: var(--brand);
  padding: 8px 0;
  margin-bottom: 10px;
  cursor: pointer;
}
.product-detail {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}
@media (min-width: 800px) {
  .product-detail {
    grid-template-columns: 1fr 1fr;
  }
}
.product-detail img {
  width: 100%;
  border-radius: 10px;
  object-fit: cover;
  height: 360px;
}
.product-detail .info h1 {
  margin: 0 0 8px;
}

/* cart sidebar */
.cart-sidebar {
  position: fixed;
  right: -420px;
  top: 0;
  width: 380px;
  height: 100%;
  background: #fff;
  box-shadow: -12px 0 30px rgba(2, 6, 23, 0.15);
  transition: right 0.28s ease;
  padding: 16px;
  z-index: 60;
  overflow: auto;
}
.cart-sidebar.open {
  right: 0;
}
.cart-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.close-btn {
  background: #efefef;
  border: none;
  padding: 6px 8px;
  border-radius: 6px;
  cursor: pointer;
}
.cart-items {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.cart-item {
  display: flex;
  gap: 10px;
  align-items: center;
  border-bottom: 1px solid #eef2f7;
  padding-bottom: 8px;
}
.cart-item img {
  width: 70px;
  height: 55px;
  object-fit: cover;
  border-radius: 6px;
}
.cart-footer {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.checkout-btn {
  background: var(--brand);
  color: #fff;
  padding: 10px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
}

/* modal */
.modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 70;
}
.modal.hidden {
  display: none;
}
.modal .modal-content {
  width: 100%;
  max-width: 720px;
  background: #fff;
  padding: 18px;
  border-radius: 10px;
  box-shadow: 0 12px 40px rgba(2, 6, 23, 0.12);
}
.checkout-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: #fff;
  padding: 0;
  border-radius: 8px;
}
.checkout-form input,
.checkout-form textarea,
.checkout-form select {
  width: 100%;
  padding: 8px;
  border: 1px solid #e6eef6;
  border-radius: 6px;
}

/* overlay */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.4);
  z-index: 50;
}
.overlay.hidden {
  display: none;
}

/* small helpers */
.price-row {
  margin-top: 8px;
  font-weight: 700;
  color: #0b84ff;
}
.qty {
  padding: 6px 8px;
  border-radius: 6px;
  border: 1px solid #e6eef6;
  margin-right: 6px;
  cursor: pointer;
}
.qty-input {
  width: 44px;
  padding: 6px;
  border: 1px solid #e6eef6;
  border-radius: 6px;
  text-align: center;
}

#toast-container {
  position: fixed;
  right: calc(20px + env(safe-area-inset-right));
  bottom: calc(20px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 1000;
  pointer-events: none; /* allow clicks through when no toast */
  max-height: 60vh;
  overflow: auto;
  align-items: flex-end; /* stack toasts from bottom-right on large screens */
}

.toast {
  min-width: 220px;
  max-width: 360px;
  width: auto;
  background: #0f172a;
  color: #fff;
  padding: 14px 16px; /* slightly larger for touch */
  border-radius: 12px;
  box-shadow: 0 8px 28px rgba(2, 6, 23, 0.18);
  display: flex;
  gap: 12px;
  align-items: center;
  pointer-events: auto; /* allow interaction with toast */
  transform: translateY(12px) scale(0.98);
  opacity: 0;
  animation: toast-in 260ms ease forwards;
  line-height: 1.15;
  word-break: break-word;
}
.toast .icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}
.toast .content {
  flex: 1;
}
.toast .title {
  font-weight: 700;
  margin-bottom: 2px;
}
.toast .message {
  font-size: 0.92rem;
  color: #e6eef6;
}
.toast.success {
  background: linear-gradient(90deg, #059669, #10b981);
}
.toast.info {
  background: linear-gradient(90deg, #2563eb, #60a5fa);
}
.toast.warning {
  background: linear-gradient(90deg, #f59e0b, #fbbf24);
  color: #0b1220;
}
.toast.error {
  background: linear-gradient(90deg, #ef4444, #f97316);
}

/* Mobile: center toasts, full-width with margins and respect safe-area insets */
@media (max-width: 640px) {
  #toast-container {
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    align-items: center;
    bottom: calc(12px + env(safe-area-inset-bottom));
    padding: 0 8px; /* small horizontal padding so toasts don't touch edges */
  }
  .toast {
    width: calc(100% - 32px);
    max-width: none;
    min-width: 0;
    border-radius: 10px;
    padding: 12px 14px;
    font-size: 0.98rem;
  }
}

/* Accessibility: respect reduced motion preferences */
@media (prefers-reduced-motion: reduce) {
  .toast {
    animation: none !important;
    transition: none !important;
    transform: none !important;
    opacity: 1 !important;
  }
}

@keyframes toast-in {
  from {
    transform: translateY(12px) scale(0.98);
    opacity: 0;
  }
  to {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}

@keyframes toast-out {
  from {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
  to {
    transform: translateY(12px) scale(0.98);
    opacity: 0;
  }
}
