/* Studio K Wigs admin — shares the retail site's palette so previews read true. */

:root {
  --cream:       #F5F1EC;
  --warm-taupe:  #B7A79A;
  --deep-mocha:  #4E4038;
  --soft-sand:   #D8CFC7;
  --accent-black:#1E1E1E;
  --body-text:   #5a5550;

  --ok:      #3f7d58;
  --warn:    #a8761f;
  --danger:  #a4443a;

  --font-serif: 'Cormorant Garamond', Georgia, serif;
  --font-sans:  'Inter', system-ui, -apple-system, sans-serif;

  --radius: 4px;
  --border: 1px solid var(--soft-sand);
  --shadow: 0 1px 3px rgba(30, 30, 30, 0.06), 0 8px 24px rgba(30, 30, 30, 0.05);
}

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

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.6;
  color: var(--body-text);
  background: var(--cream);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { font-family: var(--font-serif); color: var(--accent-black); font-weight: 500; margin: 0; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }

a { color: var(--deep-mocha); }

/* ── Chrome ──────────────────────────────────────────────────────────────── */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 12px 24px;
  background: #fff;
  border-bottom: var(--border);
}

.topbar__brand { font-family: var(--font-serif); font-size: 1.15rem; color: var(--accent-black); text-decoration: none; }
.topbar__nav { display: flex; gap: 4px; }
.topbar__nav a {
  padding: 6px 12px;
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--body-text);
}
.topbar__nav a:hover { background: var(--cream); }
.topbar__nav a[aria-current='page'] { background: var(--deep-mocha); color: #fff; }
.topbar__spacer { flex: 1; }

.layout { display: grid; grid-template-columns: 340px 1fr; gap: 0; min-height: calc(100vh - 57px); }
.panel { padding: 20px 24px; }
.panel--list { border-right: var(--border); background: #fff; overflow-y: auto; max-height: calc(100vh - 57px); }
.panel--edit { overflow-y: auto; max-height: calc(100vh - 57px); }

.panel__head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.panel__head h2 { flex: 1; }

/* ── Controls ────────────────────────────────────────────────────────────── */

.btn {
  font: inherit;
  font-size: 13px;
  padding: 7px 14px;
  border: 1px solid var(--deep-mocha);
  border-radius: var(--radius);
  background: var(--deep-mocha);
  color: #fff;
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover:not(:disabled) { background: var(--accent-black); border-color: var(--accent-black); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn--ghost { background: transparent; color: var(--deep-mocha); }
.btn--ghost:hover:not(:disabled) { background: var(--soft-sand); color: var(--accent-black); }
.btn--danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn--danger:hover:not(:disabled) { background: var(--danger); color: #fff; }
.btn--sm { padding: 4px 9px; font-size: 12px; }

label { display: block; font-size: 12px; font-weight: 500; color: var(--deep-mocha); margin-bottom: 4px; }

input[type='text'], input[type='password'], textarea, select {
  font: inherit;
  width: 100%;
  padding: 8px 10px;
  border: var(--border);
  border-radius: var(--radius);
  background: #fff;
  color: var(--accent-black);
}
input:focus, textarea:focus, select:focus {
  outline: 2px solid var(--warm-taupe);
  outline-offset: -1px;
  border-color: var(--warm-taupe);
}
textarea { resize: vertical; min-height: 70px; }

.field { margin-bottom: 14px; }
.field__hint { font-size: 11.5px; color: var(--warm-taupe); margin-top: 4px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }

/* ── Product list ────────────────────────────────────────────────────────── */

.plist { list-style: none; margin: 0; padding: 0; }

.pitem {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  cursor: pointer;
  margin-bottom: 2px;
}
.pitem:hover { background: var(--cream); }
.pitem[aria-selected='true'] { background: var(--cream); border-color: var(--warm-taupe); }
.pitem.is-dragging { opacity: 0.4; }
.pitem.is-over { border-top: 2px solid var(--deep-mocha); }

.pitem__handle { cursor: grab; color: var(--warm-taupe); font-size: 15px; line-height: 1; user-select: none; }
.pitem__handle:active { cursor: grabbing; }
.pitem__thumb { width: 34px; height: 42px; object-fit: cover; border-radius: 2px; background: var(--soft-sand); flex-shrink: 0; }
.pitem__body { flex: 1; min-width: 0; }
.pitem__name { color: var(--accent-black); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pitem__meta { font-size: 11.5px; color: var(--warm-taupe); }
.pitem.is-hidden .pitem__name { color: var(--warm-taupe); font-style: italic; }

/* ── Media manager ───────────────────────────────────────────────────────── */

.media { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 10px; }

.mcard {
  width: 118px;
  border: var(--border);
  border-radius: var(--radius);
  background: #fff;
  overflow: hidden;
  position: relative;
}
.mcard.is-dragging { opacity: 0.4; }
.mcard.is-over { outline: 2px solid var(--deep-mocha); }
.mcard__media { width: 100%; height: 146px; object-fit: cover; display: block; background: var(--soft-sand); cursor: grab; }
.mcard__tag {
  position: absolute; top: 4px; left: 4px;
  background: rgba(30,30,30,0.72); color: #fff;
  font-size: 10px; padding: 1px 5px; border-radius: 2px;
}
.mcard__x {
  position: absolute; top: 4px; right: 4px;
  width: 20px; height: 20px; line-height: 18px; text-align: center;
  border: none; border-radius: 50%;
  background: rgba(30,30,30,0.72); color: #fff; cursor: pointer; font-size: 13px;
}
.mcard__x:hover { background: var(--danger); }
.mcard__alt { width: 100%; border: none; border-top: var(--border); border-radius: 0; font-size: 11px; padding: 5px 6px; }
.mcard__alt:invalid { background: #fdf3f2; }

/* ── Details rows ────────────────────────────────────────────────────────── */

.detail { display: grid; grid-template-columns: 150px 1fr auto; gap: 8px; margin-bottom: 8px; align-items: start; }

/* ── Rich text editor ────────────────────────────────────────────────────── */

.rte { border: var(--border); border-radius: var(--radius); background: #fff; overflow: hidden; }

.rte__bar {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 5px 6px;
  border-bottom: var(--border);
  background: var(--cream);
  flex-wrap: wrap;
}

.rte__btn {
  font: inherit;
  font-size: 12px;
  min-width: 28px;
  padding: 3px 7px;
  border: 1px solid transparent;
  border-radius: 3px;
  background: transparent;
  color: var(--deep-mocha);
  cursor: pointer;
}
.rte__btn:hover { background: var(--soft-sand); }
.rte__btn:active { background: var(--warm-taupe); color: #fff; }

.rte__body {
  min-height: 240px;
  max-height: 60vh;
  overflow-y: auto;
  padding: 14px 16px;
  font-size: 14px;
  line-height: 1.75;
  color: var(--accent-black);
}
.rte__body:focus { outline: 2px solid var(--warm-taupe); outline-offset: -2px; }
.rte__body p { margin: 0 0 10px; }
.rte__body h4 { font-family: var(--font-serif); font-size: 1.05rem; margin: 16px 0 6px; color: var(--accent-black); }
.rte__body ul, .rte__body ol { margin: 8px 0; padding-left: 1.4em; }
.rte__body a { color: var(--deep-mocha); }
.rte__body:empty::before { content: 'Write the answer…'; color: var(--warm-taupe); }

.rte__source {
  width: 100%;
  min-height: 240px;
  max-height: 60vh;
  border: none;
  border-radius: 0;
  padding: 14px 16px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12.5px;
  line-height: 1.6;
}

/* ── History ─────────────────────────────────────────────────────────────── */

.snap {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border: var(--border);
  border-radius: var(--radius);
  background: #fff;
  margin-bottom: 8px;
}
.snap__body { flex: 1; min-width: 0; }
.snap__when { color: var(--accent-black); font-weight: 500; }
.snap__note { font-size: 12.5px; color: var(--body-text); }
.snap__meta { font-size: 11.5px; color: var(--warm-taupe); }
.snap--current { border-color: var(--warm-taupe); background: var(--cream); }

/* ── Status ──────────────────────────────────────────────────────────────── */

.badge {
  font-size: 11.5px;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--soft-sand);
  color: var(--deep-mocha);
  white-space: nowrap;
}
.badge--dirty { background: #f6ecd8; color: var(--warn); }
.badge--clean { background: #e4efe6; color: var(--ok); }
.badge--error { background: #f9e6e4; color: var(--danger); }

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 60;
  max-width: 380px;
  padding: 12px 16px;
  border-radius: var(--radius);
  background: var(--accent-black);
  color: #fff;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.18s, transform 0.18s;
  pointer-events: none;
}
.toast.is-open { opacity: 1; transform: none; }
.toast--error { background: var(--danger); }
.toast--ok { background: var(--ok); }

.empty { padding: 48px 20px; text-align: center; color: var(--warm-taupe); }
.errors { background: #f9e6e4; border: 1px solid #e8c4bf; border-radius: var(--radius); padding: 10px 14px; margin-bottom: 14px; }
.errors ul { margin: 6px 0 0; padding-left: 18px; font-size: 12.5px; }

/* ── Login ───────────────────────────────────────────────────────────────── */

.login { display: grid; place-items: center; min-height: 100vh; padding: 20px; }
.login__card { width: 100%; max-width: 340px; background: #fff; border: var(--border); border-radius: var(--radius); padding: 32px; box-shadow: var(--shadow); }
.login__card h1 { text-align: center; margin-bottom: 4px; }
.login__sub { text-align: center; color: var(--warm-taupe); font-size: 12.5px; margin: 0 0 24px; }
.login__error { color: var(--danger); font-size: 12.5px; min-height: 18px; margin-top: 10px; }

/* ── Modal ───────────────────────────────────────────────────────────────── */

dialog {
  border: var(--border);
  border-radius: var(--radius);
  padding: 24px;
  max-width: 520px;
  width: calc(100% - 40px);
  box-shadow: var(--shadow);
  color: var(--body-text);
}
dialog::backdrop { background: rgba(30, 30, 30, 0.42); }
.dialog__actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }

@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .panel--list { border-right: none; border-bottom: var(--border); max-height: 40vh; }
  .panel--edit { max-height: none; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}
