:root {
  --bg: #202020;
  --text: #ffffff;
  --accent: #a99c67;
  --muted: #2a2a2a;
  --border: #3a3a3a;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.5;
}

.container {
  max-width: 880px;
  margin: 0 auto;
  padding: 32px 20px 60px;
}

h1, h2 {
  color: var(--accent);
  margin: 0 0 16px;
  font-weight: 600;
}

.card {
  background: var(--muted);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 24px;
}

label {
  display: block;
  margin-bottom: 8px;
  color: var(--accent);
}

textarea {
  width: 100%;
  min-height: 120px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #1b1b1b;
  color: var(--text);
  padding: 12px;
  outline: none;
}

.row {
  display: flex;
  gap: 12px;
  margin-top: 12px;
}

.row.controls {
  align-items: end;
}

.col { flex: 1; }
.btn-col { flex: 0 0 auto; display: flex; align-items: end; }

input[type="text"] {
  width: 100%;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #1b1b1b;
  color: var(--text);
  padding: 10px 12px;
  outline: none;
}

select.select {
  width: 100%;
  appearance: none;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #1b1b1b; /* match text input background */
  color: var(--text);
  padding: 12px 40px 12px 12px;
  outline: none;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.06), 0 6px 16px rgba(0,0,0,0.35);
  transition: border-color .15s ease;
}
select.select:focus { border-color: var(--accent); }

.btn-secondary {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 8px;
  padding: 10px 16px;
  font-weight: 600;
  cursor: pointer;
}
.btn-secondary:hover { background: rgba(169,156,103,0.08); }

button {
  background: var(--accent);
  color: #111;
  border: none;
  border-radius: 8px;
  padding: 10px 16px;
  font-weight: 600;
  cursor: pointer;
}

button:disabled { opacity: 0.6; cursor: not-allowed; }

.status { margin-top: 12px; color: #ccc; min-height: 1.2em; }

.result.hidden { display: none; }
.hidden { display: none !important; }

.result img, .composite-static img {
  display: block;
  max-width: 100%;
  height: auto;
  background: transparent;
}

.mockups { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; align-items: start; }
.mockup.left { justify-self: start; }
.mockup.right { justify-self: end; }

/* Mockup area */
.mockup {
  position: relative;
  width: min(700px, 90vw);
  margin: 16px auto 40px;
}

/* T-shirt 30% bigger than baseline (scale up) */
.mockup.enlarge { width: min(910px, 100%); }
.mockup .tshirt { width: 100%; display: block; }
.mockup .mug { width: 100%; display: block; }

/* Placeholder when SHOW_BACKGROUND is False */
.mockup.no-bg .placeholder {
  width: 100%;
  padding-top: 75%; /* 4:3 area */
  background: #1e1e1e;
  border: 1px dashed var(--border);
  border-radius: 12px;
}

/* Generated design 20% smaller than baseline */
.mockup .design {
  position: absolute;
  width: 60%; /* baseline before scale */
  transform: scale(0.8); /* 20% smaller */
  transform-origin: center;
  object-fit: contain;
  pointer-events: none;
}

/* Centered variant for static composite */
.mockup .design.centered { top: 50%; left: 50%; transform: translate(-50%, -50%) scale(0.8); }

/* Mugs use a slightly larger design than shirts */
.mockup.mug .design.centered { transform: translate(-50%, -50%) scale(1); }

/* Back text overlay (only visible in back view) */
.text-overlay {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 40%;
  height: 60%;
  display: none; /* visible only on back view */
  align-items: center;
  justify-content: center;
  text-align: center;
  font-weight: 800;
  line-height: 1.1;
  overflow: hidden; /* clip visual overflow */
  word-break: keep-all; /* do not break words */
  overflow-wrap: normal; /* wrap only at spaces */
  padding: 4px;
  outline: none; /* testing outline removed */
}

.text-overlay-text {
  display: block;
  width: 100%;
}

/* Fresh canvas overlay; avoids old rules */
.canvas-text-overlay {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 40%;
  height: 60%;
  display: none; /* hidden by default on Front */
  align-items: center;
  justify-content: center;
  pointer-events: none; /* don't block front view interactions */
}

/* Hide background color input in form */
label[for="bg"], #bg { display: none !important; }

.view-toggle { display: inline-flex; gap: 6px; }
.btn-toggle { background: #2a2a2a; color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; cursor: pointer; }
.btn-toggle.active { background: var(--accent); color: #111; border-color: var(--accent); }

/* Controls under each mockup */
.product-card { display: flex; flex-direction: column; }
.controls-bar { display: flex; justify-content: center; align-items: center; gap: 18px; margin-top: 12px; }
.qty { display: flex; align-items: center; gap: 8px; }
.qty input[type="number"] { width: 72px; border: 1px solid var(--border); background: #1b1b1b; color: var(--text); border-radius: 8px; padding: 8px; }
.btn-qty { background: #2a2a2a; color: var(--text); border: 1px solid var(--border); border-radius: 8px; width: 36px; height: 36px; cursor: pointer; }
.btn-qty:hover { background: #333; }
.btn-order { background: var(--accent); color: #111; border: none; border-radius: 8px; padding: 10px 16px; font-weight: 600; cursor: pointer; font-size: 120%; }

/* Modal styling */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,0.55); display: none; align-items: center; justify-content: center; z-index: 999; }
.modal.open { display: flex; }
.modal-content { background: #181818; color: var(--text); border: 1px solid var(--border); border-radius: 12px; padding: 16px; max-width: 90vw; max-height: 90vh; box-shadow: 0 20px 60px rgba(0,0,0,0.6); position: relative; }
.modal-content.image img { max-width: 80vw; max-height: 80vh; display: block; }
.modal-close { position: absolute; top: 8px; right: 10px; background: transparent; color: var(--text); border: 1px solid var(--border); border-radius: 999px; width: 32px; height: 32px; cursor: pointer; }

.order-body { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.order-preview { display: flex; align-items: center; justify-content: center; }
.order-mockup { position: relative; width: min(500px, 40vw); }
.order-mockup img { display: block; width: 100%; height: auto; }
.order-mockup img.fg { position: absolute; top: 50%; left: 50%; width: 60%; transform: translate(-50%, -50%) scale(0.9); transform-origin: center; }
.order-actions { margin-top: 12px; display: flex; gap: 10px; }

/* Responsive: stack to single column on mobile */
@media (max-width: 800px) {
  .mockups { grid-template-columns: 1fr; gap: 16px; }
  .mockup.left, .mockup.right { justify-self: center; }
  .product-card { align-items: center; }
  .mockup { width: 100%; }
}


