:root{
  --accent-green: #16a34a;
  --muted: #6b7280;
  --card-bg: #fff;
  --page-bg: #f7faf7;
  --max-width: 900px;
  --gap: 12px;
  --radius: 12px;
  --shadow: 0 6px 18px rgba(0,0,0,0.06);
  --font-weight-strong: 800;
  --purple: #7c3aed;
  --shopee: #ff5a00;

  --card-padding: 12px;
  --card-gap: 12px;

  /* default mobile sizes */
  --thumb-width: 95px;
  --thumb-max-height: 180px;
  --actions-width: 50.4px;

  --filename-size: 1.05rem;
  --sku-size: 0.93rem;
}

/* Page */
html,body{height:100%;margin:0;padding:0;background:var(--page-bg);font-family:system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial;color:#0f172a;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}
.page{max-width:var(--max-width);margin:0 auto;padding:18px 16px 28px;box-sizing:border-box;display:flex;flex-direction:column;gap:14px;min-height:100vh}

/* Header */
header{display:flex;flex-direction:column;align-items:center;gap:6px;margin-bottom:8px;text-align:center}
header h1{margin:0;font-size:1.6rem;color:var(--accent-green);font-weight:var(--font-weight-strong);text-align:center;line-height:1.05}
.unprepared-count{color:var(--muted);font-weight:800;margin-top:6px;font-size:15px;text-align:center}

/* Controls */
.search-row{display:flex;gap:8px;align-items:center;margin-bottom:10px}
.shopee-btn{height:40px;width:48px;min-width:48px;padding:6px 8px;border-radius:10px;border:0;background:var(--shopee);color:#fff;display:inline-flex;align-items:center;justify-content:center;cursor:pointer;font-weight:800;}
.search{flex:1;display:flex;gap:8px;align-items:center;min-width:0}
.search input{flex:1;min-width:0;max-width:calc(100% - 48px - 8px);padding:10px;border-radius:10px;border:1px solid #e6e6e6;font-size:14px;outline:none;background:#fff}
.search button{width:48px;min-width:48px;height:40px;border-radius:10px;border:0;background:var(--accent-green);color:#fff;padding:0 10px;font-weight:700;cursor:pointer}

/* List & card */
.list{display:flex;flex-direction:column;gap:var(--gap)}
.card{
  display:flex;
  gap:var(--card-gap);
  align-items:stretch; /* stretch so actions can center vertically */
  background:var(--card-bg);
  padding:var(--card-padding);
  border-radius:var(--radius);
  box-shadow:var(--shadow);
  box-sizing:border-box;
  overflow:hidden;
  position: relative; /* ensure absolute-positioned camera button references the card edge */
}

/* Thumbnail area: square crop (top of tall images shown) */
.thumb-wrap{
  width: var(--thumb-width);
  min-width: var(--thumb-width);
  display:flex;
  align-items:center;
  justify-content:center;
  box-sizing:border-box;
  background: transparent;
  border-radius:8px;
  overflow:hidden;
  aspect-ratio: 1 / 1;
}
.thumb{
  width:100%;
  height:100%;
  display:block;
  object-fit:cover;
  object-position: top center;
  cursor:pointer;
  border-radius:0;
}
.no-thumb{color:var(--muted);font-size:12px;padding:6px;text-align:center}

/* Meta center, keep centered both axes */
.meta{
  flex:1 1 auto;
  display:flex;
  flex-direction:column;
  gap:6px;
  align-items:center;
  justify-content:center;
  text-align:center;
  padding-right:6px;
}
/* Filename (Tên) — applied sizes/color from index.php (.name) */
.filename{
  font-size: 1.05rem;        /* same as .card .info .name in index.php */
  font-weight: 800;          /* strong */
  line-height: 1.1;
  color: #0b1220;            /* same dark color used in index.php */
  text-align:center;
  cursor:default;
}

/* Notes inside meta (Ghi chú) — apply index.php .sku style (size & red color) */
.meta .order-note{
  color: #c62828;            /* red color (same as index.php sku) */
  font-size: 0.85rem;        /* same as .card .info .sku in index.php */
  line-height: 1.1;
  text-align:center;
  white-space:normal;
  overflow-wrap:break-word;
  word-break:break-word;
  display:block;
  max-width:40ch;
  margin-top:2px;
}

/* Hide time elements in card UI (still available in data-* for modal) */
.time{display:none}

/* Actions column: vertically centered and buttons centered horizontally */
.actions{
  flex:0 0 var(--actions-width);
  max-width:var(--actions-width);
  display:flex;
  flex-direction:column;
  gap:8px;
  align-items:center;
  justify-content:center;
  padding:8px 6px;
  box-sizing:border-box;
  /* NOTE: no position:relative here so .btn-camera absolute positions to .card (parent with position:relative) */
}

/* Buttons */
.btn{height:36px;min-width:100px;padding:0 10px;border-radius:8px;border:0;font-weight:700;font-size:14px;cursor:pointer}
.btn.prepare{ display:none;align-items:center;justify-content:center}

/* Camera button: positioned 12px from card right edge and vertically centered */
.btn-camera {
  position: absolute;
  right: 12px;               /* 12px from card inner edge (matches card padding) */
  top: 50%;
  transform: translateY(-50%);
  height:36px;
  width:36px;
  border-radius:8px;
  border:0;
  background:#9ca3af;
  color:#fff;
  display:flex;
  align-items:center;
  justify-content:center;
  cursor:pointer;
  font-size:18px;
  box-shadow:0 4px 10px rgba(0,0,0,0.12);
  line-height:1;
  padding:0;
  transition:background-color 200ms, box-shadow 200ms;
  z-index: 2;
}
/* prepared state — green background */
.btn-camera.is-prepared {
  background: var(--accent-green);
  box-shadow: 0 6px 18px rgba(22,163,74,0.18);
}
/* view-only (has image but not prepared) — keep slightly darker gray */
.btn-camera.has-image-not-prepared {
  background: #6b7280;
}

/* No red border for notes (user requested) */
.card.has-note{
  border: none;
}

/* Modals: centered and fixed so keyboard doesn't push them out */
.note-modal { position: fixed; inset: 0; display: none; align-items: center; justify-content: center; background: rgba(0,0,0,0.45); z-index: 2147486000; }
.note-modal .panel {
  background: #fff;
  padding: 14px;
  border-radius: 10px;
  width: auto;
  max-width: 560px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.3);
  display:flex;
  gap:8px;
  align-items:center;
  flex-direction:column;
  text-align:center;
  box-sizing:border-box;
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  max-height: calc(100vh - 40px);
  overflow: auto;
}

/* textarea (3-line input), placeholder & content centered */
.note-input-modal {
  width:100%;
  height:84px; /* approx 3 lines */
  resize:none;
  border-radius:8px;
  border:1px solid #e6e6e6;
  font-size:15px;
  box-sizing:border-box;
  padding-left:12px;
  padding-right:12px;
  text-align:center; /* center horizontally */
  line-height:1.2;
  overflow:auto;
  /* symmetric vertical padding to visually center placeholder & content */
  padding-top:18px;
  padding-bottom:18px;
}
.note-input-modal::placeholder { text-align:center; color: #9ca3af; }

/* buttons inside modal */
/* Make modal buttons match Shopee button height and vertical centering.
   Use inline-flex so text is centered both horizontally and vertically.
   Keep existing visual colors. */
.note-btn {
  height: 40px;
  min-height: 40px;
  line-height: 40px;
  padding: 0 12px;
  border-radius: 10px; /* match .shopee-btn radius for visual consistency */
  border: 0;
  cursor: pointer;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
}
.note-ok { background:var(--accent-green); color:#fff; }
.note-cancel { background:#c7c7c7; color:#fff; }
/* red "Chưa soạn" button */
.note-mark-not-prepared { background:#ef4444; color:#fff; } /* red button per request */

/* Ensure when buttons are used with flex:1 inline styles they still keep height */
.note-modal .panel .note-btn { flex: 1 1 auto; }

/* Image modal: when opened, inner area will be sized equal to card width via JS; image will be 100% width */
.modal{position:fixed;inset:0;display:none;align-items:center;justify-content:center;background:rgba(0,0,0,0.92);z-index:2147483000;padding:0;pointer-events:auto}
.modal-inner{width:auto;max-height:calc(100vh - 40px);overflow:auto;-webkit-overflow-scrolling:touch;display:flex;align-items:center;justify-content:center;padding:20px;box-sizing:border-box;pointer-events:auto}
.modal img{width:100%;height:auto;display:block;}

/* Camera overlay */
.camera-overlay { position: fixed; inset: 0; display: none; align-items: center; justify-content: center; background: rgba(0,0,0,0.95); z-index: 2147485000; flex-direction: column; gap: 12px; }
.camera-view { position: relative; width: 100%; max-width: 720px; height: 60vh; background: #000; display:flex;align-items:center;justify-content:center; overflow:hidden; border-radius:8px; }
.camera-view video { width:100%; height:100%; object-fit:cover; }
.camera-controls { display:flex; gap:12px; align-items:center; justify-content:center; }
.camera-btn { background:#ef4444;color:#fff;border:0;padding:10px 14px;border-radius:8px;font-weight:700;cursor:pointer;box-shadow:0 6px 18px rgba(0,0,0,0.18); }

.empty{padding:18px;text-align:center;color:var(--muted);background:transparent}
.visually-hidden{position:absolute!important;width:1px!important;height:1px!important;padding:0!important;margin:-1px!important;overflow:hidden!important;clip:rect(0,0,0,0)!important;border:0!important}

.btn:focus, .btn-camera:focus, .note-input-modal:focus, .search input:focus{outline:3px solid rgba(22,163,74,0.18);outline-offset:2px;border-color:var(--accent-green)}

/* Keep modal buttons same height on small screens too */
@media (max-width: 420px) {
  .note-btn, .shopee-btn, .search button, #refreshBtn {
    height: 40px !important;
    min-height: 40px !important;
    line-height: 40px !important;
  }
}