/* ─── TOKENS ─── */
:root {
  --bg:      #0f0e0c;
  --surface: #1a1814;
  --card:    #211f1b;
  --border:  #2e2b26;
  --border2: #3a3730;
  --ink:     #f0ece4;
  --muted:   #7a766e;
  --gold:    #c8a96a;
  --gold2:   #e8c98a;
  --red:     #c06050;
  --green:   #5a8a6a;
  --radius:  8px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow-x: hidden; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: 'DM Sans', sans-serif;
  font-weight: 300;
  line-height: 1.5;
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
button, input, textarea, select { font-family: inherit; }

/* ─── SCROLLBAR ─── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }

/* ════════════════════════
   LOGIN SCREEN
════════════════════════ */
#loginScreen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  padding: 24px;
}

#loginScreen::before {
  content: '';
  position: fixed;
  inset: 0;
  background: radial-gradient(ellipse 60% 50% at 50% 0%, rgba(200,169,106,.07) 0%, transparent 60%);
  pointer-events: none;
}

.login-box {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 56px 48px 48px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 32px 80px rgba(0,0,0,.5);
  position: relative;
}

@media (max-width: 480px) {
  .login-box { padding: 40px 28px 36px; }
}

.login-logo {
  font-family: 'Cormorant Garamond', serif;
  font-size: 22px;
  font-weight: 400;
  letter-spacing: .15em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 8px;
}

.login-sub {
  font-size: 12px;
  color: var(--muted);
  letter-spacing: .1em;
  text-transform: uppercase;
  margin-bottom: 40px;
}

.field-group {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 28px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field label {
  font-size: 10px;
  letter-spacing: .15em;
  text-transform: uppercase;
  color: var(--muted);
}

.field input,
.field textarea,
.field select {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 11px 14px;
  font-size: 14px;
  color: var(--ink);
  outline: none;
  transition: border-color .2s;
  width: 100%;
}

.field input:focus,
.field textarea:focus,
.field select:focus {
  border-color: var(--gold);
}

.field textarea { resize: vertical; min-height: 80px; }

.login-error {
  color: var(--red);
  font-size: 12px;
  margin-bottom: 16px;
  min-height: 18px;
}

.btn-primary {
  background: var(--gold);
  color: #1a1814;
  border: none;
  border-radius: 6px;
  padding: 13px 28px;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: .12em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background .2s, transform .1s;
  width: 100%;
}

.btn-primary:hover  { background: var(--gold2); }
.btn-primary:active { transform: scale(.98); }

/* ════════════════════════
   APP SHELL
════════════════════════ */
#app {
  display: none;
  min-height: 100vh;
  flex-direction: column;
}

/* ─── TOP BAR ─── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  height: 60px;
  background: rgba(15,14,12,.92);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 28px;
  gap: 16px;
}

.topbar-brand {
  font-family: 'Cormorant Garamond', serif;
  font-size: 16px;
  font-weight: 400;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--gold);
  flex: 1;
}

.topbar-tag {
  font-size: 10px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 4px 12px;
}

.btn-icon {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--muted);
  padding: 7px 14px;
  font-size: 11px;
  letter-spacing: .1em;
  text-transform: uppercase;
  cursor: pointer;
  transition: color .2s, border-color .2s;
}

.btn-icon:hover { color: var(--ink); border-color: var(--border2); }

/* ─── MAIN AREA ─── */
.main {
  flex: 1;
  padding: 32px 28px;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
}

/* ─── PAGE HEADER ─── */
.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 32px;
  flex-wrap: wrap;
  gap: 16px;
}

.page-title {
  font-family: 'Cormorant Garamond', serif;
  font-size: clamp(28px, 4vw, 40px);
  font-weight: 300;
  line-height: 1.1;
}

.page-title span {
  display: block;
  font-size: 11px;
  font-family: 'DM Sans', sans-serif;
  letter-spacing: .15em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 6px;
}

.btn-add {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--gold);
  color: #1a1814;
  border: none;
  border-radius: 8px;
  padding: 11px 22px;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: .1em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background .2s, transform .1s;
  white-space: nowrap;
}

.btn-add:hover  { background: var(--gold2); }
.btn-add:active { transform: scale(.97); }

/* ─── STATS ROW ─── */
.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 32px;
}

@media (max-width: 640px) {
  .stats { grid-template-columns: 1fr 1fr; }
}

.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
}

.stat-label {
  font-size: 10px;
  letter-spacing: .15em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
}

.stat-val {
  font-family: 'Cormorant Garamond', serif;
  font-size: 32px;
  font-weight: 400;
  color: var(--gold);
  line-height: 1;
}

/* ─── SEARCH / FILTER ─── */
.toolbar {
  display: flex;
  gap: 10px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.search-wrap {
  flex: 1;
  min-width: 200px;
  position: relative;
}

.search-wrap input {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 14px 10px 38px;
  font-size: 13px;
  color: var(--ink);
  outline: none;
  width: 100%;
  transition: border-color .2s;
}

.search-wrap input:focus { border-color: var(--gold); }

.search-wrap::before {
  content: '⌕';
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  font-size: 16px;
}

.filter-btn {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 16px;
  font-size: 11px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--muted);
  cursor: pointer;
  transition: all .2s;
}

.filter-btn.active,
.filter-btn:hover {
  border-color: var(--gold);
  color: var(--gold);
}

/* ─── ARTWORK GRID ─── */
#artworkGrid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}

.aw-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: border-color .2s, transform .2s;
  position: relative;
}

.aw-card:hover {
  border-color: var(--border2);
  transform: translateY(-2px);
}

.aw-img {
  aspect-ratio: 3/4;
  overflow: hidden;
  background: var(--surface);
  position: relative;
}

.aw-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform .5s ease;
}

.aw-card:hover .aw-img img { transform: scale(1.05); }

.aw-img-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 36px;
  color: var(--border2);
}

.aw-sold-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(15,14,12,.8);
  backdrop-filter: blur(6px);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 3px 10px;
  font-size: 9px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--red);
}

.aw-avail-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(15,14,12,.8);
  backdrop-filter: blur(6px);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 3px 10px;
  font-size: 9px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--green);
}

.aw-body {
  padding: 14px 16px 16px;
}

.aw-title {
  font-family: 'Cormorant Garamond', serif;
  font-size: 16px;
  font-weight: 400;
  line-height: 1.3;
  margin-bottom: 4px;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.aw-meta {
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 10px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.aw-price {
  font-family: 'Cormorant Garamond', serif;
  font-size: 18px;
  color: var(--gold);
}

/* ─── EMPTY STATE ─── */
.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 80px 20px;
  color: var(--muted);
}

.empty-state-icon { font-size: 48px; margin-bottom: 16px; opacity: .4; }
.empty-state p { font-size: 14px; }

/* ════════════════════════
   DRAWER / SLIDE PANEL
════════════════════════ */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.6);
  backdrop-filter: blur(4px);
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity .3s ease;
}

.overlay.show {
  opacity: 1;
  pointer-events: auto;
}

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(520px, 100vw);
  background: var(--surface);
  border-left: 1px solid var(--border);
  z-index: 201;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform .35s cubic-bezier(.4, 0, .2, 1);
  overflow: hidden;
}

.drawer.show { transform: translateX(0); }

.drawer-head {
  padding: 24px 28px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-shrink: 0;
}

.drawer-title {
  font-family: 'Cormorant Garamond', serif;
  font-size: 24px;
  font-weight: 300;
  line-height: 1.2;
}

.drawer-title small {
  display: block;
  font-family: 'DM Sans', sans-serif;
  font-size: 10px;
  letter-spacing: .15em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 4px;
}

.btn-close {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--muted);
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 16px;
  flex-shrink: 0;
  transition: color .2s, border-color .2s;
}

.btn-close:hover { color: var(--ink); border-color: var(--border2); }

.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 28px;
}

.drawer-form {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

@media (max-width: 480px) {
  .field-row { grid-template-columns: 1fr; }
}

/* ─── IMAGE UPLOAD ─── */
.img-upload-zone {
  border: 1.5px dashed var(--border2);
  border-radius: var(--radius);
  padding: 28px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color .2s, background .2s;
  position: relative;
}

.img-upload-zone:hover,
.img-upload-zone.drag-over {
  border-color: var(--gold);
  background: rgba(200,169,106,.04);
}

.img-upload-zone input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
}

.img-preview {
  width: 100%;
  max-height: 200px;
  object-fit: contain;
  border-radius: 4px;
  margin-bottom: 10px;
}

.img-upload-label {
  font-size: 12px;
  color: var(--muted);
}

.img-upload-label strong {
  color: var(--gold);
  font-weight: 400;
}

/* ─── TOGGLE SOLD ─── */
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
}

.toggle-label {
  font-size: 13px;
  color: var(--ink);
}

.toggle-label small {
  display: block;
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
}

.toggle {
  position: relative;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}

.toggle input { opacity: 0; width: 0; height: 0; }

.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--border2);
  border-radius: 12px;
  cursor: pointer;
  transition: background .2s;
}

.toggle-slider::before {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  left: 3px;
  top: 3px;
  background: var(--muted);
  border-radius: 50%;
  transition: transform .2s, background .2s;
}

.toggle input:checked + .toggle-slider { background: rgba(200,169,106,.25); }
.toggle input:checked + .toggle-slider::before {
  transform: translateX(20px);
  background: var(--gold);
}

/* ─── TAGS INPUT ─── */
.tags-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  min-height: 44px;
  align-items: center;
  cursor: text;
  transition: border-color .2s;
}

.tags-wrap:focus-within { border-color: var(--gold); }

.tag-chip {
  background: rgba(200,169,106,.15);
  border: 1px solid rgba(200,169,106,.3);
  color: var(--gold);
  border-radius: 20px;
  padding: 2px 10px 2px 10px;
  font-size: 11px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.tag-chip button {
  background: none;
  border: none;
  color: var(--gold);
  cursor: pointer;
  font-size: 13px;
  line-height: 1;
  padding: 0;
  opacity: .7;
}

.tag-chip button:hover { opacity: 1; }

.tags-input {
  background: none;
  border: none;
  outline: none;
  color: var(--ink);
  font-size: 13px;
  min-width: 80px;
  flex: 1;
}

/* ─── DRAWER FOOTER ─── */
.drawer-foot {
  padding: 20px 28px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 10px;
  flex-shrink: 0;
}

.btn-save {
  flex: 1;
  background: var(--gold);
  color: #1a1814;
  border: none;
  border-radius: 6px;
  padding: 13px;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: .1em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background .2s;
}

.btn-save:hover { background: var(--gold2); }

.btn-delete {
  background: none;
  border: 1px solid rgba(192,96,80,.4);
  color: var(--red);
  border-radius: 6px;
  padding: 13px 18px;
  font-size: 12px;
  cursor: pointer;
  transition: background .2s, border-color .2s;
}

.btn-delete:hover {
  background: rgba(192,96,80,.1);
  border-color: var(--red);
}

/* ─── TOAST ─── */
#toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--card);
  border: 1px solid var(--border2);
  border-radius: 8px;
  padding: 12px 22px;
  font-size: 13px;
  color: var(--ink);
  box-shadow: 0 8px 32px rgba(0,0,0,.4);
  z-index: 300;
  transition: transform .3s ease;
  white-space: nowrap;
}

#toast.show { transform: translateX(-50%) translateY(0); }
#toast.error { border-color: var(--red); color: var(--red); }
#toast.success { border-color: var(--green); color: var(--green); }

/* ─── CONFIRM DIALOG ─── */
.confirm-dialog {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(0,0,0,.6);
  backdrop-filter: blur(4px);
}

.confirm-box {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 36px 32px 28px;
  max-width: 380px;
  width: 100%;
  box-shadow: 0 24px 60px rgba(0,0,0,.5);
}

.confirm-box h3 {
  font-family: 'Cormorant Garamond', serif;
  font-size: 22px;
  font-weight: 300;
  margin-bottom: 10px;
}

.confirm-box p {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 28px;
  line-height: 1.6;
}

.confirm-actions {
  display: flex;
  gap: 10px;
}

.btn-cancel {
  flex: 1;
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 11px;
  font-size: 12px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--muted);
  cursor: pointer;
  transition: color .2s, border-color .2s;
}

.btn-cancel:hover { color: var(--ink); border-color: var(--border2); }

.btn-confirm-del {
  flex: 1;
  background: var(--red);
  border: none;
  border-radius: 6px;
  padding: 11px;
  font-size: 12px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: #fff;
  cursor: pointer;
  transition: opacity .2s;
}

.btn-confirm-del:hover { opacity: .85; }

/* ─── LOADING ─── */
.spinner {
  display: inline-block;
  width: 16px; height: 16px;
  border: 2px solid rgba(200,169,106,.2);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  vertical-align: middle;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ─── FADE IN ─── */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.aw-card { animation: fadeIn .3s ease both; }

/* stagger */
.aw-card:nth-child(1) { animation-delay: .03s; }
.aw-card:nth-child(2) { animation-delay: .06s; }
.aw-card:nth-child(3) { animation-delay: .09s; }
.aw-card:nth-child(4) { animation-delay: .12s; }
.aw-card:nth-child(5) { animation-delay: .15s; }
.aw-card:nth-child(6) { animation-delay: .18s; }
