/* Art Gallery: one stylesheet for the public gallery and the admin app.
   Light by default; html.dark-mode (theme.js) switches the palette. */

:root {
  --bg: #faf8f5;
  --surface: #ffffff;
  --surface-2: #f2eee8;
  --text: #2b2724;
  --muted: #7a716a;
  --border: #e4ddd4;
  --accent: #9c5b3c;
  --accent-strong: #7d4429;
  --accent-text: #ffffff;
  --success: #2f7d4f;
  --success-bg: #e3f3e9;
  --danger: #b3382c;
  --danger-bg: #fbe7e4;
  --warn-bg: #fdf3dc;
  --shadow: 0 1px 3px rgba(43, 39, 36, .08), 0 4px 14px rgba(43, 39, 36, .06);
  --radius: 10px;
  --serif: "Cormorant Garamond", Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

html.dark-mode {
  --bg: #1b1917;
  --surface: #262321;
  --surface-2: #302c29;
  --text: #ece6df;
  --muted: #a39a91;
  --border: #3d3834;
  --accent: #d38b63;
  --accent-strong: #e7a57f;
  --accent-text: #1b1917;
  --success: #6cc493;
  --success-bg: #1f3a2a;
  --danger: #ee8073;
  --danger-bg: #43231f;
  --warn-bg: #3d3420;
  --shadow: 0 1px 3px rgba(0, 0, 0, .4);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
}
img { max-width: 100%; display: block; }
a { color: var(--accent); }
h1, h2, h3 { font-family: var(--serif); font-weight: 600; line-height: 1.15; margin: 0 0 .5em; }
h1 { font-size: 2.1rem; }
h2 { font-size: 1.6rem; }
h3 { font-size: 1.25rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.hidden { display: none !important; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }

/* ---------- Buttons & forms ---------- */
button, .btn {
  font: inherit;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: var(--accent-text);
  padding: .6em 1.1em;
  border-radius: 8px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4em;
  min-height: 44px;
}
button:hover, .btn:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
button:disabled { opacity: .55; cursor: default; }
button.secondary, .btn.secondary { background: transparent; color: var(--accent); }
button.secondary:hover { background: var(--surface-2); }
button.ghost { background: transparent; border-color: transparent; color: var(--text); }
button.ghost:hover { background: var(--surface-2); }
button.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
button.small { min-height: 34px; padding: .3em .8em; font-size: .9rem; }
button.block { width: 100%; }
.icon-btn { min-height: 40px; min-width: 40px; padding: 0; font-size: 1.2rem; background: transparent; border-color: transparent; color: var(--text); }
.icon-btn:hover { background: var(--surface-2); }

label { display: block; font-size: .9rem; color: var(--muted); margin-bottom: .25em; }
input, select, textarea {
  font: inherit;
  width: 100%;
  padding: .6em .7em;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  min-height: 44px;
}
textarea { min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent); }
input[type="checkbox"] { width: auto; min-height: 0; transform: scale(1.3); margin-right: .5em; }
.check { display: flex; align-items: center; color: var(--text); font-size: 1rem; }
.field { margin-bottom: .9rem; }
.row { display: flex; gap: .75rem; flex-wrap: wrap; }
.row > .field { flex: 1 1 140px; }
.actions { display: flex; gap: .6rem; flex-wrap: wrap; margin-top: 1rem; }
.actions.end { justify-content: flex-end; }

.error-message, .notice {
  padding: .7em .9em;
  border-radius: 8px;
  margin-bottom: 1rem;
  display: none;
}
.error-message { background: var(--danger-bg); color: var(--danger); }
.notice { background: var(--success-bg); color: var(--success); }
.error-message.show, .notice.show { display: block; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem;
  box-shadow: var(--shadow);
  margin-bottom: 1rem;
}

.badge {
  display: inline-block;
  font-size: .75rem;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  padding: .15em .55em;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
}
.badge.sold { background: var(--danger-bg); color: var(--danger); }
.badge.ok { background: var(--success-bg); color: var(--success); }
.badge.warn { background: var(--warn-bg); color: var(--text); }

/* ---------- Auth pages ---------- */
.auth-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.auth-card { width: 100%; max-width: 380px; }
.auth-card h1 { text-align: center; }
.auth-card .subtitle { text-align: center; color: var(--muted); margin-top: -.3em; margin-bottom: 1.4em; }
.auth-card button { width: 100%; margin-top: .4rem; }
.auth-links { text-align: center; margin-top: 1rem; font-size: .9rem; }

/* ---------- Public gallery ---------- */
.site-header { padding: 2.2rem 16px 1rem; text-align: center; position: relative; }
.site-header h1 { font-size: 2.6rem; margin-bottom: .1em; }
.site-header .tagline { color: var(--muted); font-style: italic; font-family: var(--serif); font-size: 1.2rem; }
.header-tools { position: absolute; top: 10px; right: 10px; display: flex; gap: .3rem; }
.gallery-wrap { max-width: 1200px; margin: 0 auto; padding: 0 16px 3rem; }

.segmented { display: inline-flex; border: 1px solid var(--border); border-radius: 999px; overflow: hidden; background: var(--surface); }
.segmented button { border: 0; border-radius: 0; background: transparent; color: var(--text); min-height: 40px; padding: .4em 1.1em; }
.segmented button.active { background: var(--accent); color: var(--accent-text); }
.filter-bar { display: flex; justify-content: center; gap: .6rem; flex-wrap: wrap; margin: .5rem 0 1.5rem; }
.event-banner { text-align: center; color: var(--muted); margin: -.8rem 0 1.4rem; font-size: .95rem; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 1.1rem; }
@media (max-width: 520px) { .grid { grid-template-columns: repeat(2, 1fr); gap: .7rem; } }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; cursor: pointer; box-shadow: var(--shadow); transition: transform .15s; text-align: left; padding: 0; color: var(--text); display: block; width: 100%; min-height: 0; }
.tile:hover { transform: translateY(-2px); background: var(--surface); }
.tile .thumb { aspect-ratio: 1 / 1; background: var(--surface-2); position: relative; overflow: hidden; }
.tile .thumb img { width: 100%; height: 100%; object-fit: cover; }
.tile .thumb .badge { position: absolute; top: 8px; left: 8px; }
.tile .info { padding: .6rem .75rem .75rem; }
.tile .title { font-family: var(--serif); font-size: 1.15rem; font-weight: 600; line-height: 1.2; }
.tile .price { color: var(--muted); font-size: .9rem; margin-top: .15rem; }
.empty { text-align: center; color: var(--muted); padding: 3rem 1rem; }

.modal-backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, .55); display: flex; align-items: flex-start; justify-content: center; padding: 16px; overflow-y: auto; z-index: 50; }
.modal { background: var(--surface); color: var(--text); border-radius: var(--radius); width: 100%; max-width: 900px; margin: auto; position: relative; overflow: hidden; }
.modal .close { position: absolute; top: 8px; right: 8px; z-index: 2; background: var(--surface); border-radius: 50%; }
.piece-detail { display: grid; grid-template-columns: 1.3fr 1fr; }
@media (max-width: 720px) { .piece-detail { grid-template-columns: 1fr; } }
.piece-detail .photo { background: var(--surface-2); display: flex; align-items: center; justify-content: center; }
.piece-detail .photo img { max-height: 80vh; object-fit: contain; }
.piece-detail .body { padding: 1.4rem; }
.variant-list { list-style: none; padding: 0; margin: 1rem 0; }
.variant-list li { display: flex; justify-content: space-between; gap: .5rem; padding: .55rem 0; border-bottom: 1px solid var(--border); }
.variant-list li:last-child { border-bottom: 0; }

/* ---------- Admin shell ---------- */
.admin-bar { position: sticky; top: 0; z-index: 20; background: var(--surface); border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: .4rem; padding: 6px 10px; }
.admin-bar .title { font-family: var(--serif); font-size: 1.3rem; font-weight: 600; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-menu { position: absolute; top: 100%; left: 8px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); min-width: 220px; padding: .3rem; display: none; }
.nav-menu.open { display: block; }
.nav-menu a { display: block; padding: .7rem .9rem; color: var(--text); text-decoration: none; border-radius: 6px; }
.nav-menu a:hover, .nav-menu a.active { background: var(--surface-2); }
.nav-menu hr { border: 0; border-top: 1px solid var(--border); margin: .3rem 0; }
.admin-main { max-width: 1000px; margin: 0 auto; padding: 16px 16px 6rem; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: .6rem; flex-wrap: wrap; margin-bottom: .8rem; }
.section-head h2 { margin: 0; }

.list { list-style: none; padding: 0; margin: 0; }
.list-item { display: flex; align-items: center; gap: .8rem; padding: .7rem; border-bottom: 1px solid var(--border); }
.list-item:last-child { border-bottom: 0; }
.list-item .grow { flex: 1; min-width: 0; }
.list-item img.mini { width: 56px; height: 56px; border-radius: 6px; object-fit: cover; background: var(--surface-2); flex-shrink: 0; }
.list-item .name { font-weight: 600; }
.clickable { cursor: pointer; }
.clickable:hover { background: var(--surface-2); }

table.data { width: 100%; border-collapse: collapse; font-size: .95rem; }
table.data th, table.data td { padding: .5rem .45rem; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
table.data th { color: var(--muted); font-weight: 600; font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; }
table.data td.num, table.data th.num { text-align: right; white-space: nowrap; }
.table-scroll { overflow-x: auto; }

.stepper { display: inline-flex; align-items: center; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.stepper button { min-height: 38px; min-width: 38px; padding: 0; border: 0; border-radius: 0; background: var(--surface-2); color: var(--text); font-size: 1.2rem; }
.stepper input { width: 52px; min-height: 38px; border: 0; border-radius: 0; text-align: center; padding: 0; }

.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: .7rem; margin-bottom: 1rem; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .8rem; }
.stat .label { color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; }
.stat .value { font-size: 1.4rem; font-weight: 600; font-variant-numeric: tabular-nums; }

.photo-preview { width: 100%; max-height: 360px; object-fit: contain; background: var(--surface-2); border-radius: 8px; }
.upload-drop { border: 2px dashed var(--border); border-radius: var(--radius); padding: 2rem 1rem; text-align: center; color: var(--muted); }
.spinner { display: inline-block; width: 1em; height: 1em; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .8s linear infinite; vertical-align: -2px; }
@keyframes spin { to { transform: rotate(360deg); } }

.variant-row { display: grid; grid-template-columns: 1fr 1.4fr .9fr .8fr auto; gap: .5rem; align-items: end; margin-bottom: .6rem; }
@media (max-width: 620px) {
  .variant-row { grid-template-columns: 1fr 1fr; padding-bottom: .6rem; border-bottom: 1px solid var(--border); }
}

/* Checkout */
.pos-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .6rem; }
.pos-tile { padding: 0; min-height: 0; display: flex; flex-direction: column; text-align: left; background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.pos-tile:hover { background: var(--surface-2); border-color: var(--accent); }
.pos-tile img { width: 100%; aspect-ratio: 1 / 1; object-fit: cover; background: var(--surface-2); }
.pos-tile .t { padding: .45rem .55rem .55rem; font-size: .9rem; line-height: 1.25; }
.pos-tile .t strong { display: block; }
.pos-tile.out { opacity: .45; }
.cart-bar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; background: var(--surface); border-top: 1px solid var(--border); box-shadow: 0 -4px 14px rgba(0, 0, 0, .08); padding: 10px 16px; display: flex; align-items: center; gap: .8rem; }
.cart-bar .grow { flex: 1; }
.cart-line { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; padding: .55rem 0; border-bottom: 1px solid var(--border); }
.cart-line .grow { flex: 1 1 150px; min-width: 0; }
.totals { margin-top: .8rem; }
.totals div { display: flex; justify-content: space-between; padding: .2rem 0; font-variant-numeric: tabular-nums; }
.totals .grand { font-size: 1.3rem; font-weight: 700; border-top: 1px solid var(--border); padding-top: .5rem; margin-top: .3rem; }

.toast { position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: .7em 1.1em; border-radius: 8px; z-index: 100; box-shadow: var(--shadow); max-width: calc(100% - 32px); }
.toast.error { background: var(--danger); color: #fff; }
