/* ══════════════════════════════════════════════════════════════════════
   Gallery Editor — Modal, Image Grids, Drag & Drop
   ══════════════════════════════════════════════════════════════════════ */

/* ── Animations ── */
@keyframes galFadeIn { from { opacity: 0 } to { opacity: 1 } }
@keyframes galSlideUp {
  from { opacity: 0; transform: translateY(16px) }
  to   { opacity: 1; transform: translateY(0) }
}

/* ── Overlay ── */
.gal-overlay {
  position: fixed; inset: 0; z-index: 400;
  background: var(--black-60); backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center;
  animation: galFadeIn .2s ease;
}

/* ── Modal shell ── */
.gal-modal {
  background: var(--bg2); border: 1px solid var(--border2); border-radius: 16px;
  width: 520px; max-width: 92vw; max-height: 80vh;
  display: flex; flex-direction: column;
  position: relative; overflow: hidden;
  box-shadow: 0 24px 80px var(--shadow-lg);
  animation: galSlideUp .25s ease;
}

/* ── Header ── */
.gal-hdr {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 18px 12px; flex-shrink: 0;
  border-bottom: 1px solid var(--border2);
  background: var(--bg2);
}
.gal-hdr h3 {
  font-family: var(--ff-display); font-size: 16px; font-weight: 400;
  color: var(--cream); margin: 0; letter-spacing: .3px;
}
.gal-x {
  background: none; border: none; color: var(--muted); font-size: 20px;
  cursor: pointer; padding: 2px 6px; line-height: 1; border-radius: 6px;
  transition: color .15s, background .15s;
}
.gal-x:hover { color: var(--cream); background: rgba(255,255,255,.06) }

/* ── Scrollable body ── */
.gal-body {
  padding: 14px 16px 16px; overflow-y: auto; flex: 1;
}

/* ── Status badge ── */
.gal-status {
  display: inline-block; padding: 2px 8px; border-radius: 4px;
  font-size: 10px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .6px; margin-left: 10px; vertical-align: middle;
}
.gal-status.published { background: var(--green-bg); color: var(--green) }
.gal-status.draft { background: var(--cream-08); color: var(--muted) }

/* ── Metadata inputs ── */
.gal-meta { margin-bottom: 16px }
.gal-input {
  width: 100%; box-sizing: border-box;
  padding: 8px 10px; margin-bottom: 8px;
  background: var(--bg3); border: 1px solid var(--border2); border-radius: 8px;
  color: var(--cream); font-size: 13px; font-family: var(--ff-body);
  outline: none; transition: border-color .15s;
}
.gal-input::placeholder { color: var(--muted) }
.gal-input:focus { border-color: var(--rose) }
.gal-input.gal-input-error { border-color: var(--red) }
.gal-input-title { font-weight: 500 }

/* ── Section headers ── */
.gal-sec-hdr {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 0 8px; margin-top: 4px;
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .8px; color: var(--muted);
}
.gal-sec-count {
  font-weight: 400; color: var(--dim); font-size: 10px;
}

/* ── Image grids ── */
.gal-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  gap: 8px; margin-bottom: 14px;
}

/* ── Image tile ── */
.gal-tile {
  position: relative; width: 100%; aspect-ratio: 1;
  border-radius: 8px; overflow: hidden; cursor: pointer;
  border: 2px solid transparent;
  transition: border-color .15s, opacity .15s, transform .1s;
}
.gal-tile img {
  width: 100%; height: 100%; object-fit: cover;
  display: block; pointer-events: none;
}
.gal-tile:hover { border-color: var(--border2); transform: translateY(-1px) }

/* ── Remove button (gallery tiles) ── */
.gal-tile-remove {
  position: absolute; top: 3px; right: 3px;
  width: 20px; height: 20px; border-radius: 50%;
  background: rgba(239, 68, 68, .85); color: #fff;
  border: none; cursor: pointer; font-size: 12px; line-height: 20px;
  text-align: center; opacity: 0;
  transition: opacity .15s, background .15s;
}
.gal-tile:hover .gal-tile-remove { opacity: 1 }
.gal-tile-remove:hover { background: var(--red) }

/* ── Add overlay (available tiles) ── */
.gal-tile-add {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0, 0, 0, .5); opacity: 0;
  transition: opacity .15s;
  font-size: 24px; color: #fff; font-weight: 300;
}
.gal-tile:hover .gal-tile-add { opacity: 1 }

/* ── NSFW badge ── */
.gal-nsfw {
  position: absolute; bottom: 3px; left: 3px;
  padding: 1px 5px; border-radius: 3px;
  font-size: 8px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .4px;
  background: rgba(239, 68, 68, .7); color: #fff;
}

/* ── Drag states ── */
.gal-tile.dragging { opacity: .4 }
.gal-tile.drag-over {
  border-color: var(--rose); border-style: dashed;
}

/* ── Empty state ── */
.gal-empty {
  text-align: center; padding: 30px 16px;
  color: var(--muted); font-size: 12px; line-height: 1.5;
}

/* ── Loading ── */
.gal-loading {
  text-align: center; padding: 40px 16px;
  color: var(--muted); font-size: 12px;
}

/* ── Footer ── */
.gal-footer {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; flex-shrink: 0;
  border-top: 1px solid var(--border2);
  background: var(--bg2); gap: 10px;
}

.gal-footer-stats {
  font-size: 11px; color: var(--muted); text-align: center;
  display: flex; gap: 12px; align-items: center;
}
.gal-footer-stats span { white-space: nowrap }

/* ── Delete button ── */
.gal-btn-delete {
  padding: 7px 14px; border-radius: 8px;
  border: 1px solid var(--red-border); background: transparent;
  color: var(--red-light); font-size: 12px; cursor: pointer;
  transition: all .15s; white-space: nowrap;
}
.gal-btn-delete:hover { background: var(--red-bg); color: var(--red) }

/* ── Publish / Unpublish buttons ── */
.gal-btn-publish {
  padding: 7px 18px; border-radius: 8px; border: none;
  background: var(--rose); color: #fff; font-size: 12px; font-weight: 500;
  cursor: pointer; transition: background .15s; white-space: nowrap;
}
.gal-btn-publish:hover { background: var(--rose-d) }
.gal-btn-publish:disabled {
  opacity: .4; cursor: default; pointer-events: none;
}

.gal-btn-unpublish {
  padding: 7px 14px; border-radius: 8px;
  border: 1px solid var(--border2); background: transparent;
  color: var(--muted); font-size: 12px; cursor: pointer;
  transition: all .15s; white-space: nowrap;
}
.gal-btn-unpublish:hover { color: var(--cream); border-color: var(--muted2) }

/* ── Confirm overlay ── */
.gal-confirm {
  position: absolute; inset: 0; z-index: 5;
  background: var(--black-60); border-radius: 16px;
  display: flex; align-items: center; justify-content: center;
  animation: galFadeIn .15s ease;
}
.gal-confirm-box {
  background: var(--bg2); border: 1px solid var(--border2);
  border-radius: 14px; padding: 24px 22px; text-align: center;
  max-width: 280px;
}
.gal-confirm-box p {
  font-size: 14px; color: var(--cream); margin: 0 0 16px;
  font-family: var(--ff-display); font-weight: 400; line-height: 1.4;
}
.gal-confirm-btns { display: flex; gap: 10px; justify-content: center }
.gal-confirm-yes {
  padding: 8px 22px; border-radius: 8px; border: none;
  background: var(--red); color: #fff; font-size: 13px; font-weight: 500;
  cursor: pointer; transition: background .15s;
}
.gal-confirm-yes:hover { background: var(--red-hover) }
.gal-confirm-no {
  padding: 8px 18px; border-radius: 8px;
  border: 1px solid var(--border2); background: transparent;
  color: var(--muted); font-size: 13px; cursor: pointer;
  transition: all .15s;
}
.gal-confirm-no:hover { color: var(--cream); border-color: var(--muted2) }

/* ── Saved indicator ── */
.gal-saved {
  font-size: 10px; color: var(--green); opacity: 0;
  transition: opacity .3s; margin-left: 6px;
}
.gal-saved.visible { opacity: 1 }
