/* =====================================================================
   Admin — builds on the tokens in site.css
   ===================================================================== */

.admin-bar { background: var(--surface); border-bottom: 1px solid var(--line); }
.admin-bar-inner { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 20px; padding-top: 10px; padding-bottom: 10px; }
.admin-bar .brand img { width: 36px; height: 36px; }
.admin-bar .brand-name { font-size: 18px; }
.admin-nav { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.admin-nav a, .admin-nav .linkish { padding: 8px 12px; border-radius: 8px; color: var(--ink-2); text-decoration: none; font-weight: 600; font-size: 15px; }
.admin-nav a:hover, .admin-nav .linkish:hover { background: var(--surface-2); color: var(--ink); }
.admin-nav a[aria-current="page"] { background: var(--ink); color: var(--bg); }

.admin-main { padding-top: 26px; padding-bottom: 80px; }

.inline { display: inline; margin: 0; }
.linkish { padding: 0; border: 0; background: none; color: var(--wdw); font-weight: 600; font-size: 14px; text-decoration: underline; text-underline-offset: 3px; }
.linkish.danger, .danger { color: var(--danger); }
.muted { color: var(--ink-3); }
.crumb { margin: 0 0 4px; font-size: 14px; }
.crumb a { color: var(--ink-2); }

.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 14px 24px; margin-bottom: 22px; }
.page-head h1 { margin: 0 0 4px; font-family: var(--font-display); font-weight: 400; font-size: clamp(28px, 4vw, 38px); line-height: 1.1; }
.page-head p { margin: 0; max-width: 70ch; }

.btn.small { height: 36px; padding: 0 12px; font-size: 14px; }
.btn.danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn:disabled { opacity: .6; cursor: progress; }

.notice { margin: 0 0 18px; padding: 12px 16px; border-radius: var(--radius-ui); border: 1px solid var(--line); background: var(--surface); font-size: 15px; }
.notice ul { margin: 6px 0 0; padding-left: 20px; }
.notice-success { border-color: color-mix(in srgb, var(--d23) 45%, var(--line)); background: color-mix(in srgb, var(--d23) 9%, var(--surface)); }
.notice-error { border-color: color-mix(in srgb, var(--danger) 50%, var(--line)); background: color-mix(in srgb, var(--danger) 8%, var(--surface)); }

/* ---------- Forms ---------- */

.field input[type=text], .field input[type=password], .field input[type=date], .field input[type=url],
.field input[type=number], .field input[type=search], .field textarea {
  width: 100%; height: 44px; padding: 0 12px; border: 1px solid var(--line); border-radius: var(--radius-ui);
  background: var(--surface); font-size: 15px;
}
.field textarea { height: auto; min-height: 64px; padding: 10px 12px; resize: vertical; line-height: 1.45; }
.field select { width: 100%; max-width: none; }
.field input:focus, .field textarea:focus, .field select:focus { outline: none; border-color: var(--focus); box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 22%, transparent); }
.field > span em { font-style: normal; font-weight: 500; color: var(--ink-3); }
.field.has-error input, .field.has-error select, .has-error > .field select, .has-error > .field input { border-color: var(--danger); box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 18%, transparent); }

.money { position: relative; display: block; }
.money::before { content: "$"; position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--ink-3); }
.money input { padding-left: 26px !important; }

.check { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.check input, .check-inline input { width: 18px; height: 18px; accent-color: var(--ink); }
.check-inline { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; color: var(--ink-2); }

.stack { display: grid; gap: 14px; }

.form-grid { display: grid; gap: 14px; grid-template-columns: 1fr; }
@media (min-width: 700px) {
  .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-grid .span-2 { grid-column: span 2; }
}
@media (min-width: 1000px) {
  .form-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .form-grid.cols-4 .span-3 { grid-column: span 3; }
}
.align-end { align-self: end; }

.panel { margin-bottom: 20px; padding: 20px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; }
@media (min-width: 700px) { .panel { padding: 24px 26px; } }
.panel h2 { margin: 0 0 16px; font-family: var(--font-display); font-weight: 400; font-size: 23px; }
.panel h3 { margin: 18px 0 10px; font-size: 16px; }
.panel-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 20px; margin-bottom: 14px; }
.panel-head h2 { margin: 0; }
.panel-head p { margin: 0; font-size: 14px; }

.new-location { display: grid; gap: 14px; padding: 14px; border: 1px dashed var(--line-strong); border-radius: 12px; background: var(--surface-2); }
@media (min-width: 700px) { .new-location { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.new-location.has-error { border-color: var(--danger); }

/* ---------- Coin rows ---------- */

.coin-row { position: relative; margin: 0 0 16px; padding: 16px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface-2); min-width: 0; }
.coin-row legend { padding: 0 6px; margin-left: -6px; font-weight: 700; font-size: 15px; }
.coin-row-tools { position: absolute; right: 10px; top: 8px; display: flex; gap: 2px; }
.icon-btn.small { width: 34px; height: 34px; }
.icon-btn.small svg { width: 18px; height: 18px; }
.icon-btn.danger { color: var(--danger); }

.coin-row-grid { display: grid; gap: 16px; margin-top: 10px; }
@media (min-width: 860px) { .coin-row-grid { grid-template-columns: 330px minmax(0, 1fr); gap: 22px; } }

.photos { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; align-content: start; }

.drop { position: relative; display: grid; gap: 6px; }
.drop-preview {
  position: relative; display: grid; place-items: center; aspect-ratio: 1; overflow: hidden;
  border: 2px dashed var(--line-strong); border-radius: 16px; background: var(--surface);
  transition: border-color .15s, background-color .15s;
}
.drop-preview img { position: absolute; inset: 6px; width: calc(100% - 12px); height: calc(100% - 12px); object-fit: contain; }
.drop-preview.has-image { border-style: solid; border-color: var(--line); }
.drop-preview.has-image .drop-hint { opacity: 0; }
.drop:hover .drop-preview.has-image .drop-hint, .drop-input:focus-visible + .drop-tools, .drop.is-over .drop-hint { opacity: 1; }
.drop-hint { display: grid; gap: 2px; padding: 8px; text-align: center; font-size: 12.5px; color: var(--ink-3); z-index: 1; pointer-events: none; border-radius: 10px; transition: opacity .15s; }
.drop-preview.has-image .drop-hint { background: color-mix(in srgb, var(--surface) 88%, transparent); }
.drop-hint strong { color: var(--ink); font-size: 14px; }
.drop-input { position: absolute; left: 0; top: 0; z-index: 3; width: 100%; aspect-ratio: 1; opacity: 0; cursor: pointer; }
.drop-input:focus-visible { opacity: 0; }
.drop:focus-within .drop-preview { border-color: var(--focus); }
.drop.is-over .drop-preview { border-color: var(--brass); background: var(--brass-soft); }
.drop.is-busy .drop-preview { opacity: .6; }
.drop-tools { display: flex; flex-wrap: wrap; gap: 4px 12px; min-height: 20px; position: relative; z-index: 2; }

.coin-fields { display: grid; gap: 12px; grid-template-columns: 1fr 1fr; }
.coin-fields .span-2 { grid-column: span 2; }

.add-coin { width: 100%; border-style: dashed; }

.form-actions {
  position: sticky; bottom: 0; z-index: 20; display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
  margin: 0 -16px; padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--bg) 92%, transparent); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
}
.upload-status { font-size: 14px; color: var(--ink-2); }

.danger-zone { margin-top: 40px; padding-top: 20px; border-top: 1px solid var(--line); }

/* ---------- Dashboard ---------- */

.stat-row { display: flex; flex-wrap: wrap; gap: 10px; list-style: none; margin: 0 0 22px; padding: 0; }
.stat-row li { padding: 10px 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--ink-2); font-size: 14px; }
.stat-row strong { font-family: var(--font-display); font-weight: 400; font-size: 22px; color: var(--ink); margin-right: 4px; }
.stat-row .warn strong { color: var(--danger); }

.list-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; margin-bottom: 14px; }
.list-tools .search { flex: 1 1 260px; max-width: 460px; }

.set-table { display: grid; gap: 10px; }
.set-row { display: grid; grid-template-columns: 1fr; gap: 12px; padding: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; }
@media (min-width: 760px) { .set-row { grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 18px; } }
.set-thumbs { display: flex; gap: 6px; }
.set-thumbs img, .thumb-missing, .thumb-more { width: 54px; height: 54px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface-2); object-fit: contain; }
.thumb-missing { border-style: dashed; border-color: var(--danger); }
.thumb-more { display: grid; place-items: center; font-size: 13px; font-weight: 700; color: var(--ink-2); }
.set-info h2 { margin: 0; font-size: 17px; }
.set-info h2 a { color: var(--ink); text-decoration: none; }
.set-info h2 a:hover { text-decoration: underline; }
.set-info p { margin: 2px 0 0; font-size: 14px; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px !important; }
.tag { display: inline-flex; align-items: center; height: 24px; padding: 0 9px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.tag-retired { border-style: dashed; }
.tag-event { color: var(--d23); }
.tag-upcoming { color: var(--wdw); }
.tag-draft { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.tag-warn { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, var(--line)); }
.set-actions { display: flex; flex-wrap: wrap; gap: 8px; }

.empty-admin { padding: 40px 20px; text-align: center; background: var(--surface); border: 1px dashed var(--line-strong); border-radius: 16px; }
.empty-admin h2 { margin: 0 0 6px; font-family: var(--font-display); font-weight: 400; }
.empty-admin p { margin: 0 auto 18px; max-width: 52ch; color: var(--ink-2); }

/* ---------- Locations ---------- */

.park-block { padding: 14px 0; border-top: 1px solid var(--line); }
.park-block:first-of-type { border-top: 0; padding-top: 0; }
.park-edit summary { display: flex; align-items: baseline; gap: 10px; cursor: pointer; list-style: none; margin-bottom: 10px; }
.park-edit summary::-webkit-details-marker { display: none; }
.park-edit summary h3 { margin: 0; font-size: 17px; }
.park-edit summary::after { content: "Edit park"; margin-left: auto; font-size: 13px; font-weight: 600; color: var(--wdw); }
.park-edit[open] summary::after { content: "Close"; }

.inline-form { display: flex; flex-wrap: wrap; align-items: end; gap: 10px; margin: 0 0 12px; }
.inline-form .field { flex: 1 1 200px; }
.inline-form .field.narrow, .loc-row .field.narrow { flex: 0 0 90px; }

.loc-row { display: grid; gap: 10px; margin: 0 0 10px; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); }
@media (min-width: 860px) { .loc-row { grid-template-columns: 1.3fr 1fr 1.2fr 90px; } .loc-row .span-all { grid-column: 1 / -1; } }
.loc-row.is-inactive { opacity: .7; }
.loc-row-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; grid-column: 1 / -1; }
.loc-row-actions .btn { margin-left: auto; }

.add-park { margin-top: 12px; }
.add-park summary { cursor: pointer; font-weight: 600; color: var(--wdw); margin-bottom: 10px; }

/* ---------- Account / login ---------- */

.two-col { display: grid; gap: 20px; }
@media (min-width: 900px) { .two-col { grid-template-columns: 1fr 1fr; align-items: start; } }
.admin-list { list-style: none; margin: 0; padding: 0; }
.admin-list li { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.admin-list li span { display: block; font-size: 13px; }

.login-card { max-width: 400px; margin: 30px auto; padding: 30px 24px; background: var(--surface); border: 1px solid var(--line); border-radius: 18px; }
.login-card img { margin: 0 auto 12px; }
.login-card h1 { margin: 0 0 20px; text-align: center; font-family: var(--font-display); font-weight: 400; font-size: 24px; line-height: 1.2; }

/* Jumped to from the public site's "Edit this coin" link */
.coin-row { scroll-margin-top: 20px; }
.coin-row:target { border-color: var(--brass); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brass) 30%, transparent); }
.admin-nav .theme-btn { width: 38px; height: 38px; }

/* Discontinued controls */
.discontinued-field { display: grid; gap: 6px; align-content: start; }
.discontinued-field .check { margin-top: 26px; }
.discontinued-date input { width: 100%; height: 44px; padding: 0 12px; border: 1px solid var(--line); border-radius: var(--radius-ui); background: var(--surface); font-size: 15px; }
.discontinued-field small { font-size: 12.5px; line-height: 1.35; }
.set-row.is-discontinued { opacity: .72; }
.set-actions form { margin: 0; }

/* Coin-back tags */
.tag-suggest { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: -4px; font-size: 13px; }
.tag-chip { height: 28px; padding: 0 10px; border: 1px solid var(--line-strong); border-radius: 999px; background: var(--surface); font-size: 13px; font-weight: 600; color: var(--ink-2); }
.tag-chip:hover { border-color: var(--brass); color: var(--ink); }
.tag-chip.is-on { background: var(--brass-soft); border-color: var(--brass); color: var(--brass); }
.tag-row { display: grid; gap: 10px; margin: 0 0 10px; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); }
@media (min-width: 860px) { .tag-row { grid-template-columns: 1.2fr 1fr 90px; } .tag-row .span-all { grid-column: 1 / -1; } }
.tag-row-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; grid-column: 1 / -1; }
.tag-row-actions .btn { margin-left: auto; }

/* Photo boxes: click a photo to crop; the file picker only covers empty boxes */
.drop-preview.has-image { cursor: zoom-in; }
.drop-preview.has-image + .drop-input { pointer-events: none; }
.drop.is-busy .drop-preview { opacity: 1; }
.drop.is-busy .drop-preview::after {
  content: ""; position: absolute; inset: 0; z-index: 4; border-radius: inherit;
  background: color-mix(in srgb, var(--surface) 70%, transparent) no-repeat center / 34px
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 50 50'%3E%3Ccircle cx='25' cy='25' r='20' fill='none' stroke='%23A97B22' stroke-width='5' stroke-linecap='round' stroke-dasharray='80 200'%3E%3CanimateTransform attributeName='transform' type='rotate' from='0 25 25' to='360 25 25' dur='0.9s' repeatCount='indefinite'/%3E%3C/circle%3E%3C/svg%3E");
}
.drop.is-busy .drop-hint { opacity: 1 !important; z-index: 5; }
.drop-error { margin: 0; font-size: 12.5px; color: var(--danger); }

/* Dialogs (fal.ai prompt, crop) */
.admin-dialog { border: 0; border-radius: 18px; padding: 0; background: var(--surface); color: var(--ink); box-shadow: var(--shadow-pop); max-width: calc(100vw - 24px); }
.admin-dialog::backdrop { background: rgba(10, 13, 30, .6); }
.admin-dialog form { display: grid; gap: 10px; width: min(420px, calc(100vw - 24px)); padding: 22px; }
.admin-dialog h2 { margin: 4px 0 0; font-family: var(--font-display); font-weight: 400; font-size: 22px; }
.admin-dialog p { margin: 0; font-size: 14px; }
.ask-thumb { width: 120px; height: 120px; object-fit: contain; border-radius: 12px; border: 1px solid var(--line); background: var(--surface-2); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }
.crop-dialog { width: min(980px, calc(100vw - 24px)); }
.crop-stage { height: min(68vh, 640px); background: #0B0E1F; border-radius: 18px 18px 0 0; overflow: hidden; }
.crop-stage img { display: block; max-width: 100%; }
.crop-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 12px 14px; }
.crop-tools [aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.crop-spacer { flex: 1; }

/* Machine pin field */
.map-field .map-box { margin-top: 6px; cursor: crosshair; }
.map-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 16px; margin-top: 8px; font-size: 13px; }
.map-actions #pinStatus { margin-right: auto; }
