/* Packy — DFG internal-tool look (Imgy / Printy). Tokens mirror
   /Users/server/Imgy/src/styles.css + Printy's DFG_Claude_App_UX_Guide.md.
   Do NOT import Personify's customer-facing design-system.css. */
:root {
  --dfg-blue: rgb(51, 102, 204);
  --dfg-blue-hover: rgba(51, 102, 204, 0.8);
  --dark-gray: rgb(38, 38, 38);
  --page-bg: #F5F5F5;
  --card-bg: #ffffff;
  --text-primary: #1a1a1a;
  --text-secondary: #666666;
  --text-on-dark: #ffffff;
  --text-on-dark-secondary: rgba(255, 255, 255, 0.8);
  --success-color: #22c55e;
  --success-bg: rgba(34, 197, 94, 0.1);
  --error-color: #ef4444;
  --error-bg: rgba(239, 68, 68, 0.1);
  --warn-color: #f59e0b;
  --warn-bg: rgba(245, 158, 11, 0.12);
  --border-color: rgba(102, 102, 102, 0.3);
  --border-light: rgba(102, 102, 102, 0.15);
  --radius: 8px;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--page-bg); color: var(--text-primary);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; font-size: 16px; }

/* Top bar: dark gray, white title + short description, blue accent line */
.topbar { background: var(--dark-gray); color: var(--text-on-dark); display: flex; align-items: center;
  justify-content: space-between; padding: 12px 16px; border-bottom: 4px solid var(--dfg-blue); }
.topbar h1 { font-size: 24px; font-weight: 700; margin: 0; }
.topbar .desc { font-size: 14px; color: var(--text-on-dark-secondary); margin-left: 8px; }
.topbar .env { font-size: 12px; padding: 2px 8px; border-radius: 999px; background: var(--dfg-blue); margin-left: 12px; }
.topbar .actions { display: flex; gap: 16px; align-items: center; }
.topbar .actions button, .topbar .actions a { background: none; border: 0; color: var(--text-on-dark); cursor: pointer; font-size: 14px; }

main { max-width: 1100px; margin: 0 auto; padding: 16px; }

.card { background: var(--card-bg); border: 1px solid var(--border-light); border-radius: var(--radius);
  padding: 16px; margin-bottom: 16px; }
.card h2 { font-size: 18px; margin: 0 0 12px; }
.row { display: flex; align-items: center; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--border-light); }
.row:last-child { border-bottom: 0; }
.muted { color: var(--text-secondary); font-size: 14px; }

.btn { background: var(--dfg-blue); color: #fff; border: 0; border-radius: 6px; padding: 12px 20px;
  font-size: 16px; font-weight: 600; cursor: pointer; }
.btn:hover { background: var(--dfg-blue-hover); }
.btn.secondary { background: var(--card-bg); color: var(--text-primary); border: 1px solid var(--border-color); }
.btn.danger { background: var(--error-bg); color: var(--error-color); border: 1px solid var(--error-color); }
.btn.big { padding: 18px 28px; font-size: 20px; }
.btn:disabled { opacity: .5; cursor: default; }

.badge { display: inline-block; padding: 4px 10px; border-radius: 999px; font-size: 13px; font-weight: 600; }
.badge.ready { background: var(--success-bg); color: var(--success-color); }
.badge.hold { background: var(--warn-bg); color: var(--warn-color); }
.badge.problem { background: var(--error-bg); color: var(--error-color); }
.badge.packed { background: var(--success-bg); color: var(--success-color); }

input[type=password], input[type=text] { font: inherit; padding: 12px; border: 1px solid var(--border-color);
  border-radius: 6px; background: #fff; width: 100%; }

/* page title — the name we call each page */
.page-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; margin: 4px 0 12px; }
.page-title { font-size: 22px; font-weight: 700; margin: 0; }

/* Pack Order page */
.order-head { display: flex; gap: 24px; justify-content: space-between; flex-wrap: wrap; }
.order-info { flex: 1; min-width: 280px; }
.order-name { font-size: 28px; font-weight: 700; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.parts { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.part { margin-bottom: 0; }
.part.packed { border-color: var(--success-color); }
.part.problem { border-color: var(--error-color); }
.part.elsewhere { opacity: .7; }
.part-head { display: flex; align-items: center; justify-content: space-between; font-size: 20px; margin: 10px 0 4px; }
.badge.pending { background: #eee; color: var(--text-secondary); }
.proof { width: 100%; aspect-ratio: 1; object-fit: contain; background: #fff; border: 1px solid var(--border-light); border-radius: var(--radius); }
.grid { display: grid; grid-template-columns: repeat(8, 30px); gap: 3px; }
.grid i { height: 30px; background: #ececec; border-radius: 3px; display: flex; align-items: center; justify-content: center;
  font-style: normal; font-size: 13px; font-weight: 700; color: #fff; }
.grid i.other { background: #cfcfcf; }
.grid i.here { background: var(--dfg-blue); }
.grid i.here.packed { background: var(--success-color); }
.grid i.here.problem { background: var(--error-color); }
.kv { font-size: 18px; margin: 6px 0; }
.kv b { font-weight: 700; }
.nav { display: flex; gap: 12px; margin-top: 16px; flex-wrap: wrap; }
.error { color: var(--error-color); font-size: 14px; }

/* order details on the Pack Order page */
.details { display: flex; gap: 32px; flex-wrap: wrap; margin: 12px 0 4px; font-size: 16px; line-height: 1.35; }
.details .label { display: block; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em;
  color: var(--text-secondary); margin-top: 8px; }
.details > div > .label:first-child { margin-top: 0; }
.details .count { font-size: 22px; font-weight: 700; }
.details .count.warn { color: var(--warn-color); }
.note-warn { background: var(--warn-bg); color: #92600a; border-radius: 6px; padding: 8px 12px; margin-top: 8px; font-weight: 600; }
.notray { align-self: center; text-align: center; padding: 16px; border: 1px dashed var(--border-color); border-radius: var(--radius); }
a.btn { text-decoration: none; display: inline-block; }

/* Batches page — one coloured line per batch */
.batch { display: block; text-decoration: none; color: var(--text-primary); border-radius: var(--radius);
  padding: 14px 16px; margin-bottom: 12px; border: 1px solid; border-left-width: 8px; }
.batch.todo    { background: rgba(51, 102, 204, 0.10); border-color: var(--dfg-blue); }
.batch.done    { background: rgba(34, 197, 94, 0.14);  border-color: var(--success-color); }
.batch.problem { background: rgba(239, 68, 68, 0.12);  border-color: var(--error-color); }
.batch-main { display: flex; flex-wrap: wrap; gap: 6px 28px; align-items: baseline; font-size: 20px; font-weight: 600; }
.batch-main .dates { font-weight: 700; min-width: 270px; }
.batch-main .stat b { font-weight: 700; }
.batch-main .stat.alert { color: #c81e1e; }
.batch-sub { margin-top: 6px; font-size: 14px; color: #444; }
.batch-sub .state { font-weight: 700; text-transform: uppercase; letter-spacing: .04em; font-size: 12px; margin-right: 8px; }
.batch.todo .state { color: var(--dfg-blue); } .batch.done .state { color: #15803d; } .batch.problem .state { color: #c81e1e; }

/* Help window */
.help-btn { width: 32px; height: 32px; border-radius: 50%; background: var(--dfg-blue) !important; color: #fff;
  font-size: 18px !important; font-weight: 700; line-height: 1; padding: 0; }
.help { border: 0; border-radius: var(--radius); padding: 0; width: min(720px, calc(100vw - 32px));
  max-height: calc(100vh - 48px); box-shadow: 0 12px 40px rgba(0, 0, 0, .3); color: var(--text-primary); }
.help::backdrop { background: rgba(0, 0, 0, .45); }
.help-head { display: flex; align-items: center; justify-content: space-between; background: var(--dark-gray); color: #fff;
  padding: 12px 16px; border-bottom: 4px solid var(--dfg-blue); position: sticky; top: 0; }
.help-head h2 { margin: 0; font-size: 20px; }
.help-close { background: none; border: 0; color: #fff; font-size: 28px; line-height: 1; cursor: pointer; padding: 0 4px; }
.help-body { padding: 4px 20px 20px; font-size: 16px; line-height: 1.45; }
.help-body h3 { font-size: 17px; margin: 20px 0 6px; }
.help-body p { margin: 8px 0; }
.help-body ol, .help-body ul { margin: 6px 0; padding-left: 22px; }
.help-body li { margin: 5px 0; }
.help-body .legend { list-style: none; padding-left: 0; }
.swatch { display: inline-block; width: 28px; height: 14px; border-radius: 3px; margin-right: 8px; vertical-align: middle; border: 1px solid; }
.swatch.todo { background: rgba(51, 102, 204, 0.10); border-color: var(--dfg-blue); }
.swatch.done { background: rgba(34, 197, 94, 0.14); border-color: var(--success-color); }
.swatch.problem { background: rgba(239, 68, 68, 0.12); border-color: var(--error-color); }

/* Fulfilled (read from Shopify) + Refresh */
.page-actions { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.btn.small { padding: 8px 14px; font-size: 14px; }
.badge.fulfilled { background: var(--success-color); color: #fff; }
.part.fulfilled { border-color: var(--success-color); background: rgba(34, 197, 94, 0.06); }
.grid i.here.fulfilled { background: #15803d; }
.shipped { margin-top: 6px; font-weight: 600; color: #15803d; }

/* Combined shipments */
.note-combined { background: #dc2626; color: #fff; border-radius: 8px; padding: 14px 16px; margin-top: 12px;
  font-size: 20px; font-weight: 600; line-height: 1.3; box-shadow: 0 2px 8px rgba(220, 38, 38, .35); }
.note-combined b { font-weight: 800; text-transform: uppercase; letter-spacing: .02em; }
.note-combined::before { content: '⚠'; font-size: 24px; margin-right: 10px; }
.note-combined div { margin-top: 8px; font-size: 16px; font-weight: 500; }

/* Order list tray on the Pack Order page — slides in and out from the left */
main.wide { max-width: 1440px; }
.pack-layout { display: flex; align-items: flex-start; }
.order-tray { width: 0; flex: none; overflow: hidden; transition: width .25s ease; position: sticky; top: 12px; }
.pack-layout.open .order-tray { width: 276px; }
.order-tray-inner { width: 260px; background: var(--card-bg); border: 1px solid var(--border-light); border-radius: var(--radius);
  max-height: calc(100vh - 24px); overflow-y: auto; transform: translateX(-100%); transition: transform .25s ease; }
.pack-layout.open .order-tray-inner { transform: none; }
.order-tray-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px;
  border-bottom: 1px solid var(--border-light); position: sticky; top: 0; background: var(--card-bg); }
.tray-close { background: none; border: 0; font-size: 26px; line-height: 1; cursor: pointer; color: var(--text-secondary); padding: 0 6px; }
.order-row { display: block; width: 100%; text-align: left; background: none; border: 0; border-bottom: 1px solid var(--border-light);
  border-left: 5px solid transparent; padding: 10px 12px; cursor: pointer; font: inherit; color: inherit; }
.order-row:last-child { border-bottom: 0; }
.order-row:hover { background: #f3f5fa; }
.order-row.current { background: rgba(51, 102, 204, 0.10); border-left-color: var(--dfg-blue); }
.order-row.problem { border-left-color: var(--error-color); }
.order-row.fulfilled { border-left-color: var(--success-color); }
.order-row-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 17px; }
.order-row-top .badge { font-size: 11px; padding: 3px 8px; }
.order-row-sub { display: block; font-size: 13px; color: var(--text-secondary); margin-top: 2px; }
.pack-main { flex: 1; min-width: 0; }
@media (max-width: 900px) { /* small screens: the tray floats over the page instead of pushing it */
  .order-tray { position: fixed; left: 0; top: 0; height: 100vh; z-index: 20; }
  .pack-layout.open .order-tray { width: 276px; box-shadow: 8px 0 24px rgba(0, 0, 0, .25); }
  .order-tray-inner { max-height: 100vh; height: 100vh; border-radius: 0; }
}

/* Closed batches: greyed out, at the bottom of the list; the pack page is read-only */
.batch.closed { background: #efefef; border-color: #c4c4c4; color: #777; }
.batch.closed .batch-sub { color: #888; }
.batch.closed .state { color: #666; }
.note-closed { background: #efefef; border: 1px solid #c4c4c4; color: #444; border-radius: var(--radius); padding: 10px 14px; margin-bottom: 12px; }
/* One tray map per product in the order */
.tray-maps { display: flex; flex-direction: column; gap: 14px; }
.swatch.closed { background: #efefef; border-color: #c4c4c4; }
