/* Gang Sheet Builder - DTF Transfers Now */

:root {
  --brand: #029fda;
  --brand-dark: #0284b8;
  --ink: #141414;
  --bg: #eef2f6;
  --panel: #ffffff;
  --line: #dde4ec;
  --text: #1e293b;
  --muted: #64748b;
  --danger: #dc2626;
  --ok: #16a34a;
  --mid: #d97706;
  --warn: #ea580c;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background: var(--bg);
}

body {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

body.dragging::after {
  content: "Drop your artwork to add it to the sheet";
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(2, 159, 218, 0.16);
  border: 3px dashed var(--brand);
  font-size: 20px;
  font-weight: 600;
  color: var(--brand-dark);
  pointer-events: none;
  z-index: 50;
}

/* ------------------------------------------------------------- header */
#app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 18px;
  height: 52px;
  background: var(--ink);
  color: #fff;
  flex: none;
}

.brand { display: flex; align-items: center; gap: 12px; }
.brand-name { font-weight: 700; letter-spacing: 0.2px; }
.brand-sep { width: 1px; height: 20px; background: rgba(255,255,255,0.3); }
.brand-tool { color: #9adcf5; font-weight: 500; }
.header-note { font-size: 12px; color: #94a3b8; }

/* ------------------------------------------------------------- layout */
#app-main {
  flex: 1;
  display: flex;
  min-height: 0;
}

#sidebar {
  width: 320px;
  flex: none;
  background: var(--panel);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

#upload-box {
  padding: 14px;
  border-bottom: 1px solid var(--line);
}

#drop-hint {
  margin: 10px 2px 0;
  font-size: 12px;
  line-height: 1.5;
  color: var(--muted);
}

#list-wrap {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

#empty-state {
  padding: 28px 14px;
  text-align: center;
  color: var(--muted);
}
#empty-state p { margin: 0 0 8px; font-weight: 600; color: var(--text); }
#empty-state .hint { font-weight: 400; font-size: 12.5px; line-height: 1.55; color: var(--muted); }

/* ---------------------------------------------------------- item rows */
.item-row {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 8px;
  background: #fff;
  cursor: pointer;
}
.item-row:hover { border-color: #b9c6d6; }
.item-row.selected {
  border-color: var(--brand);
  box-shadow: 0 0 0 2px rgba(2, 159, 218, 0.18);
}

.item-thumb {
  width: 46px;
  height: 46px;
  flex: none;
  object-fit: contain;
  border-radius: 6px;
  background:
    linear-gradient(45deg, #e8ecf1 25%, transparent 25%, transparent 75%, #e8ecf1 75%) 0 0 / 12px 12px,
    linear-gradient(45deg, #e8ecf1 25%, transparent 25%, transparent 75%, #e8ecf1 75%) 6px 6px / 12px 12px,
    #fff;
}

.item-meta { flex: 1; min-width: 0; }

.item-name {
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.item-dims {
  display: flex;
  align-items: center;
  gap: 5px;
  margin: 5px 0;
  font-size: 12px;
  color: var(--muted);
}
.item-dims input {
  width: 58px;
  padding: 3px 5px;
  border: 1px solid var(--line);
  border-radius: 5px;
  font-size: 12px;
}
.dim-unit { font-size: 11px; }

.item-badges { display: flex; gap: 5px; flex-wrap: wrap; }

.badge {
  font-size: 10.5px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 20px;
  color: #fff;
}
.badge.ok    { background: var(--ok); }
.badge.mid   { background: var(--mid); }
.badge.warn  { background: var(--warn); }
.badge.bad   { background: var(--danger); }
.badge.count { background: #475569; }

.item-actions {
  display: grid;
  grid-template-columns: repeat(2, auto);
  gap: 5px;
  align-content: center;
}
/* five buttons: the delete button rides alone on the last row, centered */
.item-actions .danger { grid-column: 1 / -1; justify-self: center; }

.icon-btn {
  width: 26px;
  height: 26px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
  font-size: 13px;
  line-height: 1;
  color: var(--muted);
}
.icon-btn:hover:not(:disabled) { border-color: var(--brand); color: var(--brand-dark); }
.icon-btn.danger:hover:not(:disabled) { border-color: var(--danger); color: var(--danger); }
.icon-btn:disabled { opacity: 0.4; cursor: default; }

/* ------------------------------------------------------------ toolbar */
#workspace {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

#toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 10px;
  padding: 9px 14px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  flex: none;
}

.tool-set {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 9px 4px 8px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #f7fafc;
}
.tool-set-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--muted);
  margin-right: 3px;
  user-select: none;
  white-space: nowrap;
}
#zoom-level {
  min-width: 54px;
  padding: 7px 4px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.tool-spacer { flex: 1; }
.tool-label { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.tool-unit { font-size: 12px; color: var(--muted); }
.check-label { font-size: 12.5px; color: var(--text); display: flex; align-items: center; gap: 5px; cursor: pointer; }

#toolbar select,
#toolbar input[type="number"] {
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  font-size: 13px;
  background: #fff;
}
#spacing-input { width: 64px; }
#copies-input { width: 58px; }

.btn {
  padding: 7px 13px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
}
.btn:hover:not(:disabled) { border-color: var(--brand); color: var(--brand-dark); }
.btn:disabled { opacity: 0.45; cursor: default; }

.btn-primary {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}
.btn-primary:hover:not(:disabled) { background: var(--brand-dark); border-color: var(--brand-dark); color: #fff; }

.btn-block { width: 100%; padding: 10px; font-size: 14px; }
.btn-icon { width: 34px; text-align: center; padding: 7px 0; }

/* ------------------------------------------------------------- canvas */
#canvas-scroll {
  flex: 1;
  overflow: auto;
  scrollbar-gutter: stable;
  padding: 24px;
  min-height: 0;
}

#stage-holder {
  margin: 0 auto;
  width: fit-content;
  box-shadow: 0 2px 14px rgba(15, 23, 42, 0.12);
}

#statusbar {
  flex: none;
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 7px 14px;
  font-size: 12.5px;
  color: var(--muted);
  background: var(--panel);
  border-top: 1px solid var(--line);
}
#statusbar.has-warning #status-text { color: var(--warn); font-weight: 600; }
#status-hint { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ------------------------------------------------------------ overlay */
#export-overlay {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(20, 20, 20, 0.72);
  z-index: 100;
}
#export-overlay.show { display: flex; }

.overlay-card {
  background: #fff;
  border-radius: 12px;
  padding: 26px 30px;
  width: min(420px, 90vw);
  text-align: center;
}
.overlay-card h2 { margin: 0 0 6px; font-size: 18px; }
.overlay-card p { margin: 0 0 18px; font-size: 13px; color: var(--muted); }

.progress-track {
  height: 10px;
  border-radius: 6px;
  background: var(--line);
  overflow: hidden;
  margin-bottom: 8px;
}
#progress-fill {
  height: 100%;
  width: 0%;
  background: var(--brand);
  transition: width 0.15s;
}
#progress-text { font-size: 13px; font-weight: 700; margin-bottom: 16px; }

/* -------------------------------------------------------------- toast */
#toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%) translateY(16px);
  background: var(--ink);
  color: #fff;
  font-size: 13px;
  padding: 10px 18px;
  border-radius: 8px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 110;
  max-width: min(560px, 92vw);
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
