/* ============================================================
   Collections Manager – style.css
   Aesthetic: editorial / refined warm-paper
   ============================================================ */

:root {
  --bg:        #f5f0e8;
  --surface:   #fdfaf4;
  --border:    #d8cfc0;
  --accent:    #b5451b;
  --accent2:   #2d6a4f;
  --text:      #1e1a14;
  --muted:     #7a7060;
  --radius:    6px;
  --shadow:    0 2px 12px rgba(0,0,0,.08);
  --font-head: 'Playfair Display', Georgia, serif;
  --font-body: 'Source Sans 3', system-ui, sans-serif;
  --nav-h:     58px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-weight: 400;
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Header ── */
.site-header {
  background: var(--text);
  color: #f5f0e8;
  position: sticky; top: 0; z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,.25);
}
.site-header__inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
  height: var(--nav-h);
  display: flex;
  align-items: center;
  gap: 32px;
}
.site-logo {
  font-family: var(--font-head);
  font-size: 1.25rem;
  font-weight: 700;
  color: #f5f0e8;
  text-decoration: none;
  letter-spacing: .02em;
  flex-shrink: 0;
}
.site-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
  flex-wrap: wrap;
}
.site-nav a {
  color: #c8bfb0;
  text-decoration: none;
  padding: 6px 14px;
  border-radius: var(--radius);
  font-size: .9rem;
  font-weight: 500;
  transition: color .15s, background .15s;
}
.site-nav a:hover,
.site-nav a.active { color: #fff; background: rgba(255,255,255,.12); }
.site-nav .nav-logout {
  margin-left: 8px;
  border: 1px solid rgba(255,255,255,.2);
  color: #a09080;
}
.site-nav .nav-logout:hover { color: #fff; border-color: rgba(255,255,255,.4); }

/* ── Main ── */
.site-main {
  flex: 1;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 32px 24px 64px;
}

/* ── Footer ── */
.site-footer {
  background: var(--text);
  color: #5a5040;
  font-size: .8rem;
  text-align: center;
  padding: 16px;
}

/* ── Flash messages ── */
.flash {
  padding: 12px 18px;
  border-radius: var(--radius);
  margin-bottom: 24px;
  font-weight: 500;
  border-left: 4px solid;
}
.flash--success { background: #eafaf2; border-color: var(--accent2); color: var(--accent2); }
.flash--error   { background: #fdf0ed; border-color: var(--accent);  color: var(--accent);  }
.flash--info    { background: #edf4ff; border-color: #3a7bd5;        color: #2a5baa;        }

/* ── Page titles ── */
.page-title {
  font-family: var(--font-head);
  font-size: 2rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 24px;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--border);
}
.page-title small {
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 400;
  color: var(--muted);
  margin-left: 8px;
}

/* ── Cards ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
}
.card + .card { margin-top: 20px; }

/* ── Forms ── */
.form-group { margin-bottom: 18px; }
.form-group label {
  display: block;
  font-weight: 600;
  font-size: .88rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: 6px;
}
.form-control {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  color: var(--text);
  font-family: var(--font-body);
  font-size: .95rem;
  transition: border-color .15s, box-shadow .15s;
}
.form-control:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(181,69,27,.12);
}
select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 90px; }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 20px;
  border-radius: var(--radius);
  border: none;
  font-family: var(--font-body);
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: opacity .15s, transform .1s;
}
.btn:active { transform: scale(.98); }
.btn-primary   { background: var(--accent);  color: #fff; }
.btn-secondary { background: var(--text);    color: #fff; }
.btn-success   { background: var(--accent2); color: #fff; }
.btn-danger    { background: #c0392b; color: #fff; }
.btn-ghost     { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-sm        { padding: 5px 12px; font-size: .82rem; }
.btn:hover     { opacity: .86; }

/* ── Toolbar (search + actions row) ── */
.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}
.toolbar .search-input {
  flex: 1;
  min-width: 200px;
}

/* ── Table ── */
.table-wrap { overflow-x: auto; }
table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .92rem;
}
.data-table th {
  background: var(--text);
  color: #e8dfd0;
  font-family: var(--font-head);
  font-weight: 600;
  font-size: .88rem;
  padding: 11px 14px;
  text-align: left;
  white-space: nowrap;
}
.data-table th a { color: inherit; text-decoration: none; }
.data-table th a:hover { text-decoration: underline; }
.data-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: #f0ebe0; }
.data-table .actions { white-space: nowrap; display: flex; gap: 6px; }

/* ── Grid of collection cards ── */
.collection-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 20px;
  margin-top: 8px;
}
.coll-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  text-decoration: none;
  color: var(--text);
  box-shadow: var(--shadow);
  transition: transform .15s, box-shadow .15s;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.coll-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 24px rgba(0,0,0,.12);
}
.coll-card__name {
  font-family: var(--font-head);
  font-size: 1.2rem;
  font-weight: 700;
}
.coll-card__meta { font-size: .83rem; color: var(--muted); }
.coll-card__badge {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  font-size: .72rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 20px;
  letter-spacing: .04em;
  align-self: flex-start;
}

/* ── Tags ── */
.tag-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #e8e0d0;
  border: 1px solid #cfc4b0;
  color: var(--text);
  border-radius: 20px;
  padding: 3px 10px;
  font-size: .8rem;
  font-weight: 500;
  text-decoration: none;
  transition: background .15s;
}
.tag-pill:hover { background: #d8cfc0; }
.tag-pill img { width: 16px; height: 16px; border-radius: 50%; object-fit: cover; }
.tags-wrap { display: flex; flex-wrap: wrap; gap: 6px; }

/* ── Item image ── */
.item-thumb { width: 56px; height: 56px; object-fit: cover; border-radius: 4px; border: 1px solid var(--border); }
.item-image-lg { max-width: 100%; max-height: 360px; border-radius: var(--radius); border: 1px solid var(--border); }

/* ── Login page ── */
.login-wrap {
  min-height: calc(100vh - var(--nav-h));
  display: flex;
  align-items: center;
  justify-content: center;
}
.login-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px 48px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 8px 32px rgba(0,0,0,.1);
}
.login-box h1 {
  font-family: var(--font-head);
  font-size: 2rem;
  margin-bottom: 8px;
}
.login-box p { color: var(--muted); margin-bottom: 28px; font-size: .92rem; }

/* ── Admin sections ── */
.admin-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}
@media (max-width: 700px) { .admin-grid { grid-template-columns: 1fr; } }

/* ── Field builder ── */
#fields-list { list-style: none; margin-bottom: 12px; }
#fields-list li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: #f0ebe0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 8px;
}
#fields-list .field-name { flex: 1; font-weight: 500; }
#fields-list .field-type { font-size: .8rem; color: var(--muted); background: #e0d8c8; padding: 2px 8px; border-radius: 10px; }

/* ── Boolean display ── */
.bool-yes { color: var(--accent2); font-weight: 700; }
.bool-no  { color: var(--muted); }

/* ── Pagination ── */
.pagination { display: flex; gap: 6px; margin-top: 20px; flex-wrap: wrap; }
.pagination a, .pagination span {
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: .88rem;
  text-decoration: none;
  color: var(--text);
  background: var(--surface);
}
.pagination .current { background: var(--accent); color: #fff; border-color: var(--accent); }
.pagination a:hover  { background: var(--bg); }

/* ── Utilities ── */
.mt-0  { margin-top: 0; }
.mt-8  { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.flex  { display: flex; }
.gap-8 { gap: 8px; }
.gap-12{ gap: 12px; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.text-muted { color: var(--muted); font-size: .88rem; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }

/* ── Clickable table rows ── */
.item-row:hover td { background: #e8e0d0 !important; cursor: pointer; }

/* ── Responsive ── */
@media (max-width: 768px) {
  .site-header__inner { flex-wrap: wrap; height: auto; padding: 10px 16px; gap: 8px; }
  .site-nav { margin-left: 0; width: 100%; gap: 4px; }
  .site-nav a { padding: 5px 10px; font-size: .82rem; }
  .site-main { padding: 16px 12px 48px; }
  .page-title { font-size: 1.35rem; }
  .admin-grid { grid-template-columns: 1fr; }
  .collection-grid { grid-template-columns: 1fr; }
  .toolbar { flex-direction: column; align-items: stretch; }
  .toolbar .search-input { min-width: 0; }
}

@media (max-width: 600px) {
  .site-main { padding: 16px 12px 40px; }
  .page-title { font-size: 1.25rem; }
  .login-box { padding: 28px 16px; }
  .data-table .hide-mobile { display: none; }
  .pagination a, .pagination span { padding: 5px 9px; font-size: .82rem; }
}

/* ── Lightbox ── */
.lightbox-trigger {
  cursor: zoom-in;
  transition: opacity .15s;
}
.lightbox-trigger:hover { opacity: .85; }

#lightbox {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 99999;
  background: rgba(0,0,0,.92);
  align-items: center;
  justify-content: center;
  padding: 24px;
  /* Ensure it escapes any stacking context */
  transform: none !important;
  will-change: auto;
}
#lightbox.open { display: flex; }
#lightbox img {
  display: block;
  max-width: calc(100vw - 48px);
  max-height: calc(100vh - 48px);
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 6px;
  box-shadow: 0 8px 48px rgba(0,0,0,.6);
}
#lightbox-close {
  position: fixed;
  top: 16px;
  right: 20px;
  color: #fff;
  font-size: 2.5rem;
  cursor: pointer;
  line-height: 1;
  opacity: .7;
  background: none;
  border: none;
  padding: 4px 12px;
  z-index: 100000;
}
#lightbox-close:hover { opacity: 1; }
