/* Portfolio photo manager (gallery-manager.js). Self-contained so it looks the
   same inside the studio app and on the website's manage-photos.html. */
.sgm {
  --g-bg: #0B0B0A;
  --g-panel: #141311;
  --g-field: #0F0E0C;
  --g-ink: #F1EEE7;
  --g-soft: #A39C8F;
  --g-accent: #a8432a;
  --g-accent-dim: #722e1d;
  --g-line: #2A2822;
  --g-ok: #6FA86B;
  --g-danger: #E0785A;
  color: var(--g-ink);
  font-family: "Inter", system-ui, sans-serif;
  line-height: 1.5;
  display: grid;
  gap: 20px;
}
.sgm *, .sgm *::before, .sgm *::after { box-sizing: border-box; }
.sgm [hidden] { display: none !important; }
.sgm h2 { font-family: "Fraunces", Georgia, serif; font-size: 1.3rem; font-weight: 600; margin: 0 0 14px; }
.sgm-main { display: grid; gap: 20px; }
.sgm-card, .sgm-login { background: var(--g-panel); border: 1px solid var(--g-line); border-radius: 3px; padding: 20px; min-width: 0; }
.sgm-login { max-width: 400px; margin: 32px auto; display: grid; gap: 8px; width: 100%; }
.sgm label, .sgm-label { font-size: 0.82rem; font-weight: 600; color: var(--g-soft); }
.sgm input[type="text"], .sgm input[type="password"], .sgm select {
  width: 100%; background: var(--g-field); color: var(--g-ink); border: 1px solid var(--g-line);
  border-radius: 2px; padding: 10px 12px; font: inherit; font-size: 16px; /* 16px: no iOS zoom */
}
.sgm input:focus, .sgm select:focus { outline: none; border-color: var(--g-accent); }
.sgm :focus-visible { outline: 2px solid var(--g-accent); outline-offset: 2px; }
.sgm input[type="file"] { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.sgm-row { display: flex; flex-wrap: wrap; gap: 14px; align-items: end; }
.sgm-field { display: grid; gap: 6px; flex: 1 1 220px; min-width: 0; }
.sgm-hint { color: var(--g-soft); font-size: 0.9rem; margin: 12px 0 0; }
.sgm-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin-top: 14px; }
.sgm-btn {
  display: inline-block; border-radius: 2px; padding: 10px 18px; font: inherit; font-weight: 600; font-size: 0.92rem;
  cursor: pointer; border: 1px solid var(--g-line); background: #1B1A17; color: var(--g-ink); white-space: nowrap;
}
.sgm-btn:hover { border-color: var(--g-soft); }
.sgm-btn[disabled], .sgm input[disabled] + .sgm-btn { opacity: 0.55; cursor: default; }
.sgm-primary { background: var(--g-accent); border-color: var(--g-accent); color: #F1EEE7; }
.sgm-primary:hover:not([disabled]) { background: var(--g-accent-dim); border-color: var(--g-accent-dim); }
.sgm-ghost { background: transparent; }
.sgm-danger { background: transparent; border-color: var(--g-danger); color: var(--g-danger); padding: 6px 12px; font-size: 0.84rem; }
.sgm-danger:hover:not([disabled]) { background: rgba(224, 120, 90, 0.12); }
.sgm-msg { font-weight: 600; font-size: 0.9rem; }
.sgm-msg.ok { color: var(--g-ok); }
.sgm-msg.error { color: var(--g-danger); }

/* Upload queue */
.sgm-queue { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 8px; }
.sgm-queue:empty { display: none; }
.sgm-item { display: grid; grid-template-columns: 64px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 8px; background: var(--g-field); border: 1px solid var(--g-line); border-radius: 3px; }
.sgm-item img { width: 64px; height: 64px; object-fit: cover; border-radius: 2px; background: #000; }
.sgm-item-body { display: grid; gap: 4px; min-width: 0; }
.sgm-name { font-size: 0.78rem; color: var(--g-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sgm-status { font-size: 0.84rem; font-weight: 600; color: var(--g-soft); }
.sgm-status:empty { display: none; }
.sgm-item.is-done { border-color: rgba(111, 168, 107, 0.5); }
.sgm-item.is-done .sgm-status { color: var(--g-ok); }
.sgm-item.is-error { border-color: var(--g-danger); }
.sgm-item.is-error .sgm-status { color: var(--g-danger); }
.sgm-bar { height: 4px; border-radius: 2px; background: var(--g-line); overflow: hidden; position: relative; }
.sgm-bar::after { content: ""; position: absolute; inset: 0; width: calc(var(--p, 0) * 100%); background: var(--g-accent); transition: width .15s ease; }
.sgm-x { background: none; border: 1px solid var(--g-line); color: var(--g-soft); width: 34px; height: 34px; border-radius: 2px; cursor: pointer; font: inherit; }
.sgm-x:hover:not([disabled]) { color: var(--g-danger); border-color: var(--g-danger); }

/* Manage grid */
.sgm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin-top: 16px; }
.sgm-photo { margin: 0; background: var(--g-field); border: 1px solid var(--g-line); border-radius: 3px; overflow: hidden; display: flex; flex-direction: column; min-width: 0; }
.sgm-photo a { display: block; aspect-ratio: 4 / 5; background: #000; }
.sgm-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.sgm-photo figcaption { padding: 8px; display: grid; gap: 6px; min-width: 0; font-size: 0.85rem; flex: 1; align-content: space-between; }
.sgm-empty { color: var(--g-soft); grid-column: 1 / -1; margin: 12px 0; }
@media (max-width: 520px) {
  .sgm-card, .sgm-login { padding: 16px; }
  .sgm-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sgm-item { grid-template-columns: 52px minmax(0, 1fr) auto; }
  .sgm-item img { width: 52px; height: 52px; }
}

/* Name + order controls on each photo card */
.sgm-name-row { display: flex; gap: 6px; min-width: 0; }
.sgm .sgm-name-row input[type="text"] { padding: 6px 8px; min-width: 0; }
.sgm-save { padding: 6px 10px; font-size: 0.84rem; background: var(--g-accent); border-color: var(--g-accent); color: #F1EEE7; }
.sgm-move { display: grid; grid-template-columns: 36px minmax(0, 1fr) 36px; gap: 4px; }
.sgm .sgm-move select { padding: 6px 4px; text-align: center; text-align-last: center; min-width: 0; }
.sgm-arrow { height: 36px; background: #1B1A17; border: 1px solid var(--g-line); color: var(--g-ink); border-radius: 2px; cursor: pointer; font: inherit; font-size: 0.8rem; }
.sgm-arrow:hover:not([disabled]) { border-color: var(--g-soft); }
.sgm-arrow[disabled], .sgm-move select[disabled] { opacity: 0.35; cursor: default; }
.sgm-photo .sgm-danger { justify-self: start; }
