:root {
  --admin-sidebar-bg: #17171a;
  --admin-sidebar-text: #b8b8bd;
  --admin-accent: #b8862f;
  --admin-accent-contrast: #17171a;
  --admin-bg: #f3f2ee;
  --admin-card: #ffffff;
  --admin-border: #e6e4de;
}

.admin-body { background: var(--admin-bg); }

.admin-shell {
  display: flex;
  min-height: 100vh;
  align-items: stretch;
}

/* ---- sidebar ---- */
.admin-sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--admin-sidebar-bg);
  color: var(--admin-sidebar-text);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.admin-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 22px 20px 18px;
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.admin-brand em { display: block; font-style: normal; font-weight: 400; font-size: 11px; color: var(--admin-accent); letter-spacing: .06em; text-transform: uppercase; }
.admin-brand-mark { width: 16px; height: 16px; position: relative; flex-shrink: 0; }
.admin-brand-mark::before, .admin-brand-mark::after { content: ''; position: absolute; background: var(--admin-accent); }
.admin-brand-mark::before { left: 7px; top: 0; width: 2px; height: 16px; }
.admin-brand-mark::after { left: 0; top: 7px; width: 16px; height: 2px; }

.admin-sidenav { display: flex; flex-direction: column; padding: 14px 10px; gap: 2px; flex: 1; }
.admin-sidenav a {
  color: var(--admin-sidebar-text);
  font-size: 13.5px;
  padding: 9px 12px;
  border-radius: 5px;
}
.admin-sidenav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.admin-sidenav a.active { background: rgba(184,134,47,.16); color: var(--admin-accent); font-weight: 600; }

.admin-sidenav-footer {
  padding: 14px 20px 20px;
  border-top: 1px solid rgba(255,255,255,.08);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.admin-sidenav-footer a { color: var(--admin-sidebar-text); font-size: 12.5px; }
.admin-sidenav-footer a:hover { color: #fff; }

/* ---- content ---- */
.admin-content-wrap { flex: 1; min-width: 0; }
.admin-topbar {
  display: flex; justify-content: flex-end; align-items: center; gap: 14px;
  padding: 14px 32px;
  border-bottom: 1px solid var(--admin-border);
  background: var(--admin-card);
}
.undo-redo { display: flex; gap: 8px; }
.btn-icon {
  background: var(--admin-bg);
  border: 1px solid var(--admin-border);
  color: #444;
  font-size: 12.5px;
  padding: 6px 12px;
  border-radius: 5px;
  cursor: pointer;
  font-family: inherit;
}
.btn-icon:hover:not(:disabled) { border-color: var(--admin-accent); color: var(--admin-accent); }
.btn-icon:disabled { opacity: .4; cursor: default; }
.admin-logout-topbar {
  border-color: rgba(179,38,30,.3); color: #b3261e; text-decoration: none;
}
.admin-logout-topbar:hover { background: rgba(179,38,30,.06); border-color: #b3261e; }

.admin-main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 28px 32px 64px;
}

.admin-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
.admin-toolbar h1 { font-size: 21px; margin: 0; letter-spacing: -.01em; }
.admin-back-link {
  display: inline-block; font-size: 12.5px; color: #888; margin-bottom: 10px;
}
.admin-back-link:hover { color: var(--admin-accent); }

/* ---- cards ---- */
.admin-card {
  background: var(--admin-card);
  border: 1px solid var(--admin-border);
  border-radius: 8px;
  padding: 22px 24px;
  margin-bottom: 20px;
  box-shadow: 0 1px 2px rgba(0,0,0,.03);
}
.admin-card h2 { font-size: 14px; margin: 0 0 6px; text-transform: uppercase; letter-spacing: .05em; color: #444; }

/* ---- table ---- */
.admin-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--admin-card);
  border: 1px solid var(--admin-border);
  border-radius: 8px;
  overflow: hidden;
}
.admin-table th, .admin-table td {
  text-align: left;
  padding: 11px 14px;
  border-bottom: 1px solid var(--admin-border);
  font-size: 13.5px;
  vertical-align: middle;
}
.admin-table th { background: #faf9f6; font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: #7a7a7a; font-weight: 600; }
.admin-table tbody tr:hover { background: #fbfaf7; }
.admin-table tbody tr:last-child td { border-bottom: none; }
.admin-thumb { width: 46px; height: 46px; object-fit: cover; border-radius: 5px; background: var(--admin-bg); }
.admin-thumb-preview { width: 130px; height: 96px; object-fit: cover; border-radius: 6px; background: var(--admin-bg); display: block; margin-bottom: 8px; border: 1px solid var(--admin-border); }

/* Mirrors the customer-facing product page gallery (.thumb-large /
   .gallery-thumbs are defined in style.css) so admins see photos exactly
   as shoppers will, just constrained to a sane width inside the form. */
.admin-customer-preview { max-width: 360px; border: 1px solid var(--admin-border); border-radius: 8px; padding: 14px; background: #fff; }
.admin-customer-preview .thumb-large {
  aspect-ratio: 4/3;
  background: var(--admin-bg);
  border-radius: 4px;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
.admin-actions { display: flex; gap: 12px; align-items: center; }
.admin-actions a { color: #1a1a1a; font-weight: 500; }
.link-btn {
  background: none; border: none; padding: 0;
  color: #b3261e; font-weight: 500; font-size: 13.5px; cursor: pointer; font-family: inherit;
}

.admin-filter-row { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; flex-wrap: wrap; }
.admin-filter-row select {
  background: var(--admin-card); border: 1px solid var(--admin-border);
  padding: 8px 10px; border-radius: 5px; font-size: 13px; font-family: inherit;
}
.admin-search {
  display: flex; align-items: center; gap: 8px;
  background: var(--admin-card); border: 1px solid var(--admin-border);
  border-radius: 999px; padding: 6px 6px 6px 14px; max-width: 320px; flex: 1;
}
.admin-search svg { flex-shrink: 0; color: #999; }
.admin-search input[type="search"] {
  border: none; outline: none; background: transparent; font-family: inherit;
  font-size: 13.5px; flex: 1; min-width: 0;
}
.admin-search button {
  border: none; background: var(--admin-accent, #1a1a1a); color: #fff;
  padding: 7px 16px; border-radius: 999px; font-size: 12.5px; font-weight: 600; cursor: pointer;
}

/* ---- view toggle (list / grid) ---- */
.admin-view-toggle {
  display: flex; align-items: center; gap: 2px;
  background: var(--admin-card); border: 1px solid var(--admin-border);
  border-radius: 7px; padding: 3px;
}
.admin-view-btn {
  display: flex; align-items: center; justify-content: center;
  width: 32px; height: 30px; border: none; background: transparent;
  color: #888; border-radius: 5px; cursor: pointer;
  transition: background-color .15s ease, color .15s ease;
}
.admin-view-btn:hover { color: #333; }
.admin-view-btn.active { background: var(--admin-accent); color: #fff; }

.admin-bulk-visibility { display: flex; align-items: center; gap: 14px; }

/* ---- hidden-row / hidden-card state (product or category toggled off) ---- */
.admin-table tbody tr.is-hidden { background: #faf8f4; opacity: .68; }
.admin-table tbody tr.is-hidden:hover { background: #f5f2ec; }
.admin-product-card.is-hidden { opacity: .6; }

.admin-empty-state { padding: 30px; text-align: center; color: #888; font-size: 13.5px; grid-column: 1 / -1; }

/* ---- product/category grid view ---- */
.admin-product-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
}
.admin-product-card {
  background: var(--admin-card); border: 1px solid var(--admin-border);
  border-radius: 8px; overflow: hidden; display: flex; flex-direction: column;
  transition: box-shadow .15s ease;
}
.admin-product-card:hover { box-shadow: 0 4px 14px rgba(0,0,0,.06); }
.admin-product-card-thumb { position: relative; aspect-ratio: 4 / 3; background: var(--admin-bg); }
.admin-product-card-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.admin-visibility-pill { position: absolute; top: 8px; left: 8px; }
.admin-product-card-body { padding: 12px 14px; flex: 1; }
.admin-product-card-body-nothumb { padding-top: 16px; }
.admin-product-card-body h3 { margin: 0 0 4px; font-size: 14px; font-weight: 600; line-height: 1.3; }
.admin-product-card-meta { margin: 0 0 4px; font-size: 12px; color: #888; }
.admin-product-card-price { margin: 4px 0 8px; font-size: 13.5px; font-weight: 600; }
.admin-product-card-actions {
  padding: 10px 14px; border-top: 1px solid var(--admin-border);
  justify-content: space-between;
}

/* ---- pills / badges ---- */
.pill {
  display: inline-block; font-size: 10.5px; text-transform: uppercase; letter-spacing: .04em;
  padding: 3px 9px; border-radius: 999px; font-weight: 600;
}
.pill-branded { background: rgba(184,134,47,.15); color: #8a6420; }
.pill-unbranded { background: rgba(74,140,96,.15); color: #2f6b45; }
.pill-needs_review { background: rgba(178,91,58,.15); color: #a3451f; }
.pill-muted { background: #eee; color: #888; margin-left: 6px; }

/* ---- forms ---- */
.admin-form { background: var(--admin-card); border: 1px solid var(--admin-border); border-radius: 8px; padding: 26px; max-width: 640px; }
.admin-form textarea { font-family: inherit; }
.form-field { margin-bottom: 16px; }
.form-field label { display: block; font-size: 12.5px; font-weight: 600; color: #444; margin-bottom: 6px; text-transform: uppercase; letter-spacing: .03em; }
.form-field input[type=text], .form-field input[type=number], .form-field input[type=file],
.form-field select, .form-field textarea {
  width: 100%; box-sizing: border-box;
  border: 1px solid var(--admin-border); border-radius: 5px; padding: 9px 11px;
  font-size: 14px; font-family: inherit; background: #fff;
}
.form-field input:focus, .form-field select:focus, .form-field textarea:focus {
  outline: none; border-color: var(--admin-accent); box-shadow: 0 0 0 3px rgba(184,134,47,.12);
}
.form-field input[type=color] {
  width: 64px; height: 38px; padding: 3px; border: 1px solid var(--admin-border);
  border-radius: 5px; background: #fff; cursor: pointer;
}
.field-hint { font-size: 12px; color: #888; margin: 6px 0 0; }
.form-field-checkbox label,
.admin-form label.checkbox-label {
  display: flex; align-items: center; gap: 10px; font-weight: 500; font-size: 14px;
  text-transform: none; letter-spacing: normal; margin-bottom: 0; cursor: pointer;
}
/* Real, consistently-styled checkboxes everywhere inside an admin form —
   browser default checkboxes render wildly differently across OSes and
   were inheriting the bold/uppercase text-input label styling above, so
   every toggle in the admin panel (live exchange rates, enquiries line,
   featured product, etc.) gets this same clean, deliberate checkbox. */
.admin-form input[type=checkbox] {
  appearance: none; -webkit-appearance: none; -moz-appearance: none;
  width: 19px; height: 19px; min-width: 19px; margin: 0; flex-shrink: 0;
  border: 1.5px solid var(--admin-border); border-radius: 4px;
  background: #fff; cursor: pointer; position: relative;
  transition: background-color .15s ease, border-color .15s ease;
}
.admin-form input[type=checkbox]:hover { border-color: var(--admin-accent); }
.admin-form input[type=checkbox]:checked {
  background: var(--admin-accent); border-color: var(--admin-accent);
}
.admin-form input[type=checkbox]:checked::after {
  content: ""; position: absolute; left: 6px; top: 2px; width: 5px; height: 10px;
  border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg);
}
.admin-form input[type=checkbox]:focus-visible {
  outline: none; box-shadow: 0 0 0 3px rgba(184,134,47,.25);
}
.admin-form-actions { display: flex; gap: 12px; margin-top: 4px; }

.history-export-row { display: flex; gap: 10px; margin: 10px 0 18px; flex-wrap: wrap; }
.history-import-row { display: flex; gap: 10px; align-items: center; }
.history-import-row input[type=file] { border: 1px solid var(--admin-border); border-radius: 5px; padding: 7px 9px; font-size: 13px; }
.history-row-undone { opacity: .45; }
.history-row-undone td { text-decoration: line-through; }

.status-pill { display: inline-block; font-size: 11px; font-weight: 600; padding: 3px 9px; border-radius: 20px; text-transform: uppercase; letter-spacing: 0.02em; }
.status-new { background: #fbe6e6; color: #b3261e; }
.status-read { background: #fff4e0; color: #a06400; }
.status-replied { background: #e3f6e9; color: #1d7a44; }
.status-archived { background: #ececec; color: #666; }

.gallery-manage { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 12px; }
.gallery-manage-item { display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 11px; color: #b3261e; cursor: pointer; }
.gallery-manage-item img { width: 80px; height: 60px; object-fit: cover; border-radius: 5px; background: var(--admin-bg); border: 1px solid var(--admin-border); }
.gallery-manage-item { cursor: grab; }
.gallery-manage-item.dragging { opacity: 0.4; }
.gallery-manage-item img { pointer-events: none; }

/* ---- buttons ---- */
.btn { background: var(--admin-accent); color: #fff; border: none; padding: 10px 18px; border-radius: 6px; font-weight: 600; font-size: 13.5px; cursor: pointer; display: inline-block; }
.btn:hover { filter: brightness(1.05); }
.btn-outline { background: transparent; color: var(--admin-accent); border: 1px solid var(--admin-accent); }
.btn-outline:hover { background: rgba(184,134,47,.08); }
.btn-link { background: none; border: none; padding: 0; color: var(--admin-accent); text-decoration: underline; font-size: 13px; cursor: pointer; }
.btn-link:hover { opacity: 0.8; }

.alerts-list { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.alert-item {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  background: #fff8ec; border: 1px solid #f0dcae; border-radius: 8px; padding: 14px 16px;
}
.alert-item-body strong { font-size: 14px; }
.admin-nav-badge {
  display: inline-block; min-width: 18px; text-align: center; background: #c0392b; color: #fff;
  font-size: 11px; font-weight: 700; border-radius: 10px; padding: 1px 6px; margin-left: 6px;
}

.alert { padding: 11px 16px; border-radius: 6px; font-size: 13.5px; margin-bottom: 16px; }
.alert-success { background: rgba(74,140,96,.12); color: #2f6b45; }
.alert-error { background: #fbe9e7; color: #b3261e; }

.admin-login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--admin-sidebar-bg); }
.admin-login-card { background: #fff; border-radius: 10px; padding: 34px; width: 320px; box-shadow: 0 12px 40px rgba(0,0,0,.35); }
.admin-login-card h1 { font-size: 19px; margin: 0 0 20px; }
.admin-login-back-link {
  display: block;
  text-align: center;
  margin-top: 16px;
  font-size: 13px;
  color: var(--admin-muted, #888);
  text-decoration: none;
}
.admin-login-back-link:hover { color: var(--admin-accent); text-decoration: underline; }

/* SMATWALL: dashboard metrics */
.metrics-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 20px; }
.metric-card { text-align: center; padding: 20px 10px; }
.metric-value { display: block; font-size: 28px; font-weight: 800; color: #1a1a1a; }
.metric-label { display: block; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: #888; margin-top: 4px; }
@media (max-width: 900px) { .metrics-grid { grid-template-columns: repeat(2, 1fr); } }

/* Tables can have more columns than a phone screen fits — scroll sideways
   inside the wrapper rather than squeezing text unreadably small. */
.admin-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: 8px; }
.admin-table-wrap .admin-table { border-radius: 0; }

@media (max-width: 860px) {
  /* Sidebar becomes a horizontally-scrollable top bar instead of a fixed
     220px column, so it never pushes page content off-screen. */
  .admin-shell { flex-direction: column; }
  .admin-sidebar {
    width: 100%;
    height: auto;
    position: relative;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
  }
  .admin-brand { border-bottom: none; padding: 14px 16px; }
  .admin-sidenav {
    flex-direction: row;
    flex: 1 1 auto;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding: 4px 10px 12px;
    gap: 4px;
    min-width: 0;
  }
  .admin-sidenav a { white-space: nowrap; }
  .admin-sidenav-footer {
    flex-direction: row;
    border-top: none;
    border-left: 1px solid rgba(255,255,255,.08);
    padding: 10px 14px;
    gap: 14px;
    flex-shrink: 0;
  }
  .admin-main { padding: 20px 16px 48px; }
  .admin-topbar { padding: 12px 16px; }
  .admin-toolbar { flex-wrap: wrap; gap: 10px; }
  .admin-form { padding: 18px; max-width: 100%; }
  .admin-card { padding: 16px 18px; }
  .admin-filter-row { flex-wrap: wrap; }
  .admin-login-card { width: 100%; max-width: 320px; }
}

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