:root {
  --bg: #f5f6f8;
  --card: #ffffff;
  --text: #1f2430;
  --muted: #6b7280;
  --border: #e5e7eb;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --green: #16a34a;
  --red: #dc2626;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.04);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

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

.container {
  width: 100%;
  max-width: 1140px;
  margin: 0 auto;
  padding: 0 20px;
}

/* ---------- Header ---------- */
.site-header {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}
.brand { font-size: 1.25rem; font-weight: 700; }
.nav { display: flex; align-items: center; gap: 20px; }
.nav-link { color: var(--muted); font-weight: 500; }
.nav-link:hover { color: var(--text); }
.cart-link { display: inline-flex; align-items: center; gap: 6px; }
.cart-count {
  background: var(--primary);
  color: #fff;
  border-radius: 999px;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  font-size: 0.75rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.main-content { padding: 28px 20px 48px; }
.page-title { margin: 8px 0 24px; font-size: 1.6rem; }
.empty-note { color: var(--muted); text-align: center; padding: 40px 0; }
.back-link { color: var(--muted); display: inline-block; margin-bottom: 18px; }
.back-link:hover { color: var(--text); }

/* ---------- Grid de produtos (home) ---------- */
.product-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
}
.product-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  display: flex;
  flex-direction: column;
}
.product-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.1);
}
.product-image {
  position: relative;
  aspect-ratio: 1 / 1;
  background: #f0f1f3;
}
.product-image img { width: 100%; height: 100%; object-fit: cover; display: block; }
.no-image {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 0.85rem;
}
.badge {
  position: absolute;
  top: 10px;
  left: 10px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  color: #fff;
}
.badge-out { background: var(--red); }
.product-body { padding: 14px; display: flex; flex-direction: column; gap: 6px; }
.product-name { margin: 0; font-size: 1rem; font-weight: 600; }
.availability { font-size: 0.78rem; font-weight: 600; }
.is-available { color: var(--green); }
.is-out { color: var(--red); }
.product-price { font-size: 1.1rem; font-weight: 700; margin-top: 2px; }

/* ---------- Página do produto ---------- */
.product-detail {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 36px;
  align-items: start;
}
.product-gallery { position: sticky; top: 88px; }

.carousel {
  position: relative;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.carousel-track { position: relative; aspect-ratio: 1 / 1; }
.carousel-slide {
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity 0.25s ease;
  pointer-events: none;
}
.carousel-slide.active { opacity: 1; pointer-events: auto; }
.carousel-slide img { width: 100%; height: 100%; object-fit: contain; background: #fff; }
.carousel-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow);
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
  color: var(--text);
}
.carousel-arrow:hover { background: #fff; }
.carousel-prev { left: 10px; }
.carousel-next { right: 10px; }
.carousel-dots {
  position: absolute;
  bottom: 12px;
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  gap: 8px;
}
.carousel-dots .dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  border: none;
  background: rgba(0, 0, 0, 0.25);
  cursor: pointer;
  padding: 0;
}
.carousel-dots .dot.active { background: var(--primary); }

.product-meta .product-title { margin: 0 0 10px; font-size: 1.8rem; }
.product-price-lg { font-size: 1.8rem; font-weight: 700; margin: 14px 0; }
.product-description { color: #374151; white-space: pre-line; margin: 14px 0 24px; }

.add-row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }

/* ---------- Controle de quantidade ---------- */
.qty-control {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}
.qty-control button {
  width: 38px;
  height: 40px;
  border: none;
  background: #f3f4f6;
  font-size: 1.1rem;
  cursor: pointer;
}
.qty-control button:hover { background: #e5e7eb; }
.qty-control input {
  width: 50px;
  height: 40px;
  border: none;
  text-align: center;
  font-size: 1rem;
  -moz-appearance: textfield;
}
.qty-control input::-webkit-outer-spin-button,
.qty-control input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

/* ---------- Botões ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 10px 18px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  background: #fff;
  color: var(--text);
  transition: background 0.15s ease, opacity 0.15s ease;
}
.btn:hover { background: #f3f4f6; }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); }
.btn-primary.added { background: var(--green); border-color: var(--green); }
.btn-primary:disabled { background: #9ca3af; border-color: #9ca3af; cursor: not-allowed; }
.btn-ghost { background: transparent; border-color: var(--border); }
.btn-block { width: 100%; }
.btn-sm { padding: 6px 12px; font-size: 0.85rem; }
.btn-danger { color: var(--red); border-color: #f1c4c4; }
.btn-danger:hover { background: #fff0f0; }

/* ---------- Lista / carrinho ---------- */
.cart-layout { display: grid; grid-template-columns: 1fr 360px; gap: 32px; align-items: start; }
.cart-items { display: flex; flex-direction: column; gap: 12px; }
.cart-row {
  display: grid;
  grid-template-columns: 64px 1fr auto auto auto;
  align-items: center;
  gap: 14px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
}
.cart-thumb { width: 64px; height: 64px; border-radius: 8px; overflow: hidden; background: #f0f1f3; }
.cart-thumb img { width: 100%; height: 100%; object-fit: cover; }
.cart-info { display: flex; flex-direction: column; gap: 2px; }
.cart-info a { font-weight: 600; }
.cart-unit { color: var(--muted); font-size: 0.82rem; }
.cart-line { font-weight: 700; white-space: nowrap; }
.cart-remove {
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 1.4rem;
  cursor: pointer;
  line-height: 1;
}
.cart-remove:hover { color: var(--red); }

.checkout {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  position: sticky;
  top: 88px;
}
.cart-summary {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 1.15rem;
  padding-bottom: 16px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.cart-summary strong { font-size: 1.4rem; }
.checkout h2 { margin: 0 0 14px; font-size: 1.1rem; }
.checkout form { display: flex; flex-direction: column; gap: 14px; }
.checkout-note { color: var(--muted); font-size: 0.82rem; margin: 4px 0 0; }

label { display: flex; flex-direction: column; gap: 6px; font-weight: 500; font-size: 0.9rem; }
input[type="text"],
input[type="email"],
input[type="tel"],
input[type="password"],
input[type="number"],
textarea {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 0.95rem;
  font-family: inherit;
  background: #fff;
  width: 100%;
}
input:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

/* ---------- Admin ---------- */
.admin-body { background: var(--bg); }
.admin-header {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
}
.admin-header h1 { margin: 0; font-size: 1.25rem; }
.admin-actions { display: flex; gap: 10px; }
.admin-container { max-width: 960px; margin: 0 auto; padding: 28px 24px 60px; }

.admin-login {
  max-width: 360px;
  margin: 10vh auto 0;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: var(--shadow);
}
.admin-login h1 { margin-top: 0; font-size: 1.3rem; }
.admin-login form { display: flex; flex-direction: column; gap: 16px; margin-top: 10px; }

.admin-section {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  margin-bottom: 26px;
}
.section-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.section-head h2 { margin: 0; font-size: 1.15rem; }

.admin-table { width: 100%; border-collapse: collapse; }
.admin-table th, .admin-table td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.admin-table th { font-size: 0.8rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.03em; }
.admin-thumb { width: 44px; height: 44px; border-radius: 6px; object-fit: cover; background: #f0f1f3; display: inline-block; }
.admin-thumb.no-image { display: inline-flex; align-items: center; justify-content: center; color: var(--muted); }
.row-actions { display: flex; gap: 8px; justify-content: flex-end; }

.settings-form, .product-form { display: flex; flex-direction: column; gap: 16px; max-width: 560px; }
.settings-form small, .product-form small { color: var(--muted); font-weight: 400; }
.check { flex-direction: row; align-items: center; gap: 8px; }
.check input { width: auto; }
fieldset { border: 1px solid var(--border); border-radius: 10px; padding: 16px; display: flex; flex-direction: column; gap: 14px; }
legend { font-weight: 600; padding: 0 6px; }
.hint { font-size: 0.82rem; color: var(--muted); margin: 0; }
.hint code { background: #eef0f3; padding: 1px 5px; border-radius: 4px; }

.current-images p { font-weight: 500; font-size: 0.9rem; margin: 0 0 8px; }
.img-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 12px; }
.img-item {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: center;
  font-size: 0.8rem;
  font-weight: 400;
}
.img-item img { width: 100%; aspect-ratio: 1/1; object-fit: cover; border-radius: 6px; }
.img-item span { display: inline-flex; align-items: center; gap: 5px; color: var(--muted); }
.img-item input { width: auto; }

.error { color: var(--red); background: #fef2f2; border: 1px solid #fecaca; padding: 10px 14px; border-radius: 8px; }
.success { color: var(--green); background: #f0fdf4; border: 1px solid #bbf7d0; padding: 10px 14px; border-radius: 8px; margin-bottom: 20px; }

/* ---------- Footer ---------- */
.site-footer {
  border-top: 1px solid var(--border);
  background: var(--card);
  color: var(--muted);
  text-align: center;
  padding: 22px 0;
  font-size: 0.85rem;
}

/* ---------- Responsivo ---------- */
@media (max-width: 980px) {
  .product-grid { grid-template-columns: repeat(3, 1fr); }
  .cart-layout { grid-template-columns: 1fr; }
  .checkout { position: static; }
}
@media (max-width: 760px) {
  .product-grid { grid-template-columns: repeat(2, 1fr); }
  .product-detail { grid-template-columns: 1fr; }
  .product-gallery { position: static; }
}
@media (max-width: 480px) {
  .product-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .cart-row { grid-template-columns: 52px 1fr auto; row-gap: 10px; }
  .cart-row .qty-control { grid-column: 2 / 3; }
  .cart-line { grid-column: 3 / 4; text-align: right; }
}
