/* =====================================================================
   ADMIN DASHBOARD — Duhovna Biblioteka
   ===================================================================== */

/* ── Theme Variables ─────────────────────────────────────────────────── */
:root {
  /* Dark theme (default) */
  --admin-body-bg:    #111a22;
  --admin-surface:    #172332;
  --admin-surface-2:  #1a2838;
  --admin-border:     #2a3a48;
  --admin-border-2:   #1e2d3d;
  --admin-text:       #e0e6ea;
  --admin-text-head:  #e9e8e0;
  --admin-text-muted: #5a6a78;
  --admin-text-dim:   #a0adb5;
  --admin-text-label: #7a8a98;
  --admin-gold:       #99793d;
  --admin-gold-dark:  #7a5f2e;
  --admin-gold-light: #f5f0e6;
  --admin-danger:     #cc4444;
  --admin-row-hover:  #1b2b3a;
  --admin-table-head: #131f2b;
  --admin-table-text: #c0ccd8;
  --admin-pill-bg:    #1e3550;
  --admin-pill-text:  #7aaad0;
  --admin-input-bg:   #1a2838;
  --admin-input-border: #2e3f50;
  --admin-login-bg:   #0e1620;
  --admin-success-bg: #1a3a1a;
  --admin-success-border: #2a5a2a;
  --admin-success-text: #66cc88;
  --admin-error-bg:   #3a1a1a;
  --admin-error-border: #5a2a2a;
  --admin-error-text: #ff9090;
  --admin-warn-bg:    #3a2a0a;
  --admin-warn-border: #5a4a1a;
  --admin-warn-text:  #ffcc66;
}

/* Light theme overrides */
[data-theme="light"] {
  --admin-body-bg:    #f0f2f5;
  --admin-surface:    #ffffff;
  --admin-surface-2:  #f7f9fb;
  --admin-border:     #d0d8e0;
  --admin-border-2:   #e4eaf0;
  --admin-text:       #1a2530;
  --admin-text-head:  #111a22;
  --admin-text-muted: #8a9aaa;
  --admin-text-dim:   #5a6a78;
  --admin-text-label: #6a7a88;
  --admin-row-hover:  #eef2f6;
  --admin-table-head: #e8edf2;
  --admin-table-text: #2a3a48;
  --admin-pill-bg:    #ddeeff;
  --admin-pill-text:  #2266aa;
  --admin-input-bg:   #ffffff;
  --admin-input-border: #c0ccd8;
  --admin-login-bg:   #e8edf2;
  --admin-success-bg: #e8f5e9;
  --admin-success-border: #a5d6a7;
  --admin-success-text: #2e7d32;
  --admin-error-bg:   #ffebee;
  --admin-error-border: #ef9a9a;
  --admin-error-text: #c62828;
  --admin-warn-bg:    #fff8e1;
  --admin-warn-border: #ffe082;
  --admin-warn-text:  #e65100;
  /* Sidebar stays dark in light mode */
}

/* ── Font Size Classes (applied to <html>) ───────────────────────────── */
.font-sm body  { font-size: 11px; }
.font-md body  { font-size: 15px; }
.font-lg body  { font-size: 20px; }

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

/* Prevent ANY element from making the page wider than the screen */
html, body { overflow-x: hidden; max-width: 100%; }

body {
  font-family: var(--font-body, 'Lato', sans-serif);
  background: var(--admin-body-bg);
  color: var(--admin-text);
  font-size: 15px;
  line-height: 1.5;
  transition: background-color 0.45s ease, color 0.45s ease;
}

/* ── Login Page ──────────────────────────────────────────────────────── */
.admin-login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--admin-login-bg);
}

.login-wrap { width: 100%; padding: 20px; }

.login-card {
  background: var(--admin-surface);
  border: 1px solid var(--admin-border);
  border-radius: 6px;
  padding: 40px 36px;
  width: 100%;
  max-width: 400px;
  margin: 0 auto;
}

.login-logo { text-align: center; margin-bottom: 24px; }
.login-logo img { max-width: 140px; }

.login-title {
  font-family: var(--font-display, 'EB Garamond', Georgia, serif);
  font-size: 1.5rem;
  font-weight: 500;
  color: var(--admin-text-head);
  text-align: center;
  margin-bottom: 28px;
}

.login-form .form-field { margin-bottom: 18px; }

/* ── Admin Shell Layout ──────────────────────────────────────────────── */
.admin-page {
  display: flex;
  min-height: 100vh;
}

/* Sidebar — always dark regardless of theme */
.admin-sidebar {
  width: 220px;
  flex-shrink: 0;
  background: #172332;
  border-right: 1px solid #2a3a48;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
}

.sidebar-logo {
  padding: 24px 20px 16px;
  border-bottom: 1px solid #2a3a48;
}
.sidebar-logo img { max-width: 130px; display: block; }

.sidebar-nav {
  flex: 1;
  padding: 12px 0;
  list-style: none;
  overflow-y: auto;
}
.sidebar-nav li a {
  display: flex;
  align-items: center;
  padding: 10px 20px;
  color: #a0adb5;
  text-decoration: none;
  font-size: 0.875rem;
  transition: background 0.28s ease, color 0.28s ease;
}
.sidebar-nav li a:hover,
.sidebar-nav li a.active {
  background: #1e2d3d;
  color: #e9e8e0;
}
.sidebar-nav li a.active { border-left: 3px solid #99793d; }
.sidebar-nav .nav-divider {
  height: 1px;
  background: #2a3a48;
  margin: 6px 16px;
}

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid #2a3a48;
  font-size: 0.75rem;
  color: #5a6a78;
}
.sidebar-footer a { color: #a0adb5; text-decoration: none; }
.sidebar-footer a:hover { color: #e9e8e0; }

/* Main content */
.admin-main {
  margin-left: 220px;
  flex: 1;
  min-width: 0; /* critical: prevents flex child from overflowing viewport */
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.admin-topbar {
  background: var(--admin-surface);
  border-bottom: 1px solid var(--admin-border);
  padding: 18px 28px 16px;
  transition: background 0.45s ease, border-color 0.45s ease;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 14px;
}
.admin-topbar h1 {
  font-family: var(--font-display, 'EB Garamond', serif);
  font-size: 1.25rem;
  font-weight: 500;
  color: var(--admin-text-head);
}
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.admin-topbar .stats-bar {
  margin-bottom: 0;
  border-top: 1px solid var(--admin-border);
  padding: 10px 0 12px;
  gap: 10px;
}
.admin-topbar .stat-card {
  border: none;
  background: transparent;
  padding: 6px 14px;
  min-width: 90px;
}

.admin-content { padding: 28px; flex: 1; }

/* ── Form Elements ───────────────────────────────────────────────────── */
.form-field { margin-bottom: 18px; }
.form-field label {
  display: block;
  font-family: var(--font-ui, 'Neue Plak', sans-serif);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--admin-text-label);
  margin-bottom: 5px;
}
.form-field input,
.form-field textarea,
.form-field select {
  width: 100%;
  padding: 9px 12px;
  background: var(--admin-input-bg);
  border: 1px solid var(--admin-input-border);
  border-radius: 3px;
  color: var(--admin-text);
  font-family: var(--font-body, 'Lato', sans-serif);
  font-size: 0.9rem;
  transition: border-color 0.28s ease, background 0.28s ease;
}
.form-field input:focus,
.form-field textarea:focus,
.form-field select:focus {
  outline: none;
  border-color: var(--admin-gold);
}
.form-field textarea { resize: vertical; min-height: 100px; }
.form-field select option { background: var(--admin-input-bg); }

.form-field .field-hint {
  font-size: 0.75rem;
  color: var(--admin-text-muted);
  margin-top: 4px;
}
.form-field .field-error {
  font-size: 0.75rem;
  color: var(--admin-error-text);
  margin-top: 4px;
}

/* Standalone label + input helpers (used in modals / inline forms) */
.admin-label {
  display: block;
  font-family: var(--font-ui, 'Neue Plak', sans-serif);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--admin-text-label);
  margin-bottom: 5px;
}
.admin-input {
  padding: 9px 12px;
  background: var(--admin-input-bg);
  border: 1px solid var(--admin-input-border);
  border-radius: 3px;
  color: var(--admin-text);
  font-family: var(--font-body, 'Lato', sans-serif);
  font-size: 0.9rem;
  transition: border-color 0.28s ease, background 0.28s ease;
}
.admin-input:focus {
  outline: none;
  border-color: var(--admin-gold);
}

/* Slug auto-badge */
.slug-wrap { position: relative; }
.slug-auto-badge {
  position: absolute;
  right: 10px; top: 50%;
  transform: translateY(-50%);
  font-size: 0.65rem;
  background: var(--admin-input-border);
  color: var(--admin-text-label);
  padding: 1px 6px;
  border-radius: 10px;
  pointer-events: none;
}

/* Form grid */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 24px; }
.form-grid .form-field--full { grid-column: 1 / -1; }

/* Checkbox toggle */
.toggle-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-top: 4px;
}
.toggle-wrap input[type="checkbox"] {
  width: 18px; height: 18px;
  accent-color: var(--admin-gold);
  cursor: pointer;
}
.toggle-wrap span { font-size: 0.85rem; color: var(--admin-text-dim); }

/* ── Buttons ─────────────────────────────────────────────────────────── */
.btn-admin-primary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  background: var(--admin-gold);
  color: #fff;
  border: none;
  border-radius: 3px;
  font-size: 0.8rem;
  font-family: var(--font-ui, 'Neue Plak', sans-serif);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.28s ease, transform 0.2s ease, box-shadow 0.2s ease;
}
.btn-admin-primary:hover { background: var(--admin-gold-dark); transform: translateY(-1px); box-shadow: 0 3px 10px rgba(122,95,46,0.25); }

.btn-admin-secondary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  background: transparent;
  color: var(--admin-text-dim);
  border: 1px solid var(--admin-input-border);
  border-radius: 3px;
  font-size: 0.8rem;
  font-family: var(--font-ui, 'Neue Plak', sans-serif);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  cursor: pointer;
  text-decoration: none;
  transition: border-color 0.28s ease, color 0.28s ease, transform 0.2s ease;
}
.btn-admin-secondary:hover { border-color: var(--admin-gold); color: var(--admin-text-head); transform: translateY(-1px); }

.btn-admin-danger {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: transparent;
  color: var(--admin-danger);
  border: 1px solid var(--admin-danger);
  border-radius: 3px;
  font-size: 0.75rem;
  font-family: var(--font-ui, 'Neue Plak', sans-serif);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  cursor: pointer;
  transition: background 0.28s ease, color 0.28s ease, border-color 0.28s ease;
}
.btn-admin-danger:hover { background: var(--admin-danger); color: #fff; }

.btn-admin-sm {
  padding: 5px 10px !important;
  font-size: 0.8rem !important;
}

.btn-full { width: 100%; justify-content: center; }

/* ── Admin Modals ────────────────────────────────────────────────────── */
.admin-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0,0,0,0.45);
  display: flex;
  align-items: center;
  justify-content: center;
}
.admin-modal-box {
  background: var(--admin-surface);
  border: 1px solid var(--admin-border);
  border-radius: 6px;
  padding: 28px;
  max-width: 95vw;
  box-shadow: 0 12px 48px rgba(0,0,0,0.30);
}
.admin-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}
.admin-modal-title {
  font-family: var(--font-display, 'EB Garamond', Georgia, serif);
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--admin-text-head);
  line-height: 1.2;
}
.admin-modal-rule {
  height: 2px;
  background: var(--admin-gold);
  width: 32px;
  margin-bottom: 16px;
  border: none;
}

/* ── Alerts ──────────────────────────────────────────────────────────── */
.admin-alert {
  padding: 10px 14px;
  border-radius: 3px;
  font-size: 0.85rem;
  margin-bottom: 18px;
}
.admin-alert--error   { background: var(--admin-error-bg);   color: var(--admin-error-text);   border: 1px solid var(--admin-error-border); }
.admin-alert--success { background: var(--admin-success-bg); color: var(--admin-success-text); border: 1px solid var(--admin-success-border); }
.admin-alert--warning { background: var(--admin-warn-bg);    color: var(--admin-warn-text);    border: 1px solid var(--admin-warn-border); }

/* ── Books Table ─────────────────────────────────────────────────────── */
.table-controls {
  display: flex;
  gap: 12px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.table-controls input,
.table-controls select {
  padding: 8px 12px;
  background: var(--admin-input-bg);
  border: 1px solid var(--admin-input-border);
  border-radius: 3px;
  color: var(--admin-text);
  font-size: 0.875rem;
}
.table-controls input { flex: 1; min-width: 200px; }
.table-controls input:focus,
.table-controls select:focus { outline: none; border-color: var(--admin-gold); }

.admin-table-wrap {
  background: var(--admin-surface);
  border: 1px solid var(--admin-border);
  border-radius: 4px;
  overflow-x: auto;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
}
.admin-table th {
  padding: 11px 14px;
  text-align: left;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--admin-text-muted);
  background: var(--admin-table-head);
  border-bottom: 1px solid var(--admin-border);
  white-space: nowrap;
}
.admin-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--admin-border-2);
  vertical-align: middle;
  color: var(--admin-table-text);
  transition: background 0.22s ease;
}
.admin-table tr:last-child td { border-bottom: none; }
.admin-table tr:hover td { background: var(--admin-row-hover); }
.admin-table tr.inactive td { opacity: 0.45; }

.book-thumb {
  width: 80px; height: 110px;
  object-fit: cover;
  border-radius: 2px;
  display: block;
}
.book-thumb-placeholder {
  width: 80px; height: 110px;
  background: var(--admin-border);
  border-radius: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--admin-text-muted);
  font-size: 1.6rem;
}

.book-title-cell { max-width: 200px; font-size: 0.95rem; }
.book-title-cell a { color: var(--admin-text); text-decoration: none; }
.book-title-cell a:hover { color: var(--admin-gold); }
.book-title-cell strong { display: block; font-weight: 600; font-size: 1.05rem; }
.book-title-cell span  { font-size: 0.875rem; color: var(--admin-text-muted); }

.stock-cell { display: flex; gap: 10px; font-size: 1rem; }
.stock-item { text-align: center; }
.stock-label { display: block; color: var(--admin-text-muted); font-size: 0.78rem; font-weight: 700; }

.cat-pill {
  display: inline-block;
  padding: 2px 8px;
  background: var(--admin-pill-bg);
  color: var(--admin-pill-text);
  border-radius: 10px;
  font-size: 0.73rem;
}

.active-toggle { accent-color: var(--admin-gold); cursor: pointer; width: 16px; height: 16px; }

.order-btns { display: flex; flex-direction: column; gap: 2px; }
.order-btn {
  background: none;
  border: 1px solid var(--admin-input-border);
  color: var(--admin-text-label);
  border-radius: 2px;
  padding: 1px 5px;
  cursor: pointer;
  font-size: 0.65rem;
  line-height: 1.4;
  transition: border-color 0.22s ease, color 0.22s ease;
}
.order-btn:hover { border-color: var(--admin-gold); color: var(--admin-gold); }

.row-actions { display: flex; gap: 6px; align-items: center; }

/* ── Bulk action bar ─────────────────────────────────────────────────── */
.bulk-bar {
  display: none;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: var(--admin-surface);
  border: 1px solid var(--admin-gold);
  border-radius: 4px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.bulk-bar.visible { display: flex; }
.bulk-bar__count { font-size: 0.85rem; color: var(--admin-gold); font-weight: 600; flex: 1; }

/* ── Quick stock buttons ─────────────────────────────────────────────── */
.stock-quick-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px; height: 24px;
  background: none;
  border: 1px solid var(--admin-input-border);
  border-radius: 3px;
  color: var(--admin-text-dim);
  font-size: 1rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  transition: border-color 0.22s ease, color 0.22s ease, background 0.22s ease;
}
.stock-quick-btn:hover { border-color: var(--admin-gold); color: var(--admin-gold); }
.stock-quick-btn.minus:hover { border-color: var(--admin-danger); color: var(--admin-danger); }

/* Stock adjust popover */
.stock-popover {
  position: absolute;
  background: var(--admin-surface);
  border: 1px solid var(--admin-border);
  border-radius: 5px;
  padding: 14px 16px;
  width: 230px;
  z-index: 300;
  box-shadow: 0 6px 24px rgba(0,0,0,0.4);
}
.stock-popover h4 { font-size: 0.8rem; color: var(--admin-text-label); text-transform: uppercase; margin-bottom: 10px; }
.stock-popover .form-field { margin-bottom: 10px; }
.stock-popover .form-field label { font-size: 0.7rem; }
.stock-popover .form-field input,
.stock-popover .form-field select {
  padding: 6px 9px;
  font-size: 0.85rem;
}

/* ── Pagination ──────────────────────────────────────────────────────── */
.pagination-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 0 4px;
  justify-content: center;
}
.pagination-info {
  font-size: 0.85rem;
  color: var(--admin-text-muted);
  padding: 0 8px;
  min-width: 100px;
  text-align: center;
}

/* ── Filter Drawer ───────────────────────────────────────────────────── */
.filter-drawer-overlay {
  position: fixed;
  inset: 0;
  z-index: 290;
  background: rgba(0,0,0,0.3);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.38s ease;
}
.filter-drawer-overlay.open { opacity: 1; pointer-events: auto; }
.filter-drawer {
  position: fixed;
  right: 0;
  top: 0;
  height: 100vh;
  width: 300px;
  max-width: 90vw;
  z-index: 300;
  background: var(--admin-surface);
  border-left: 1px solid var(--admin-border);
  box-shadow: -4px 0 24px rgba(0,0,0,0.18);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.38s cubic-bezier(0.4, 0, 0.2, 1);
}
.filter-drawer.open { transform: translateX(0); }
.filter-drawer__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--admin-border);
  flex-shrink: 0;
}
.filter-drawer__body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}
.filter-drawer__footer {
  padding: 14px 20px;
  border-top: 1px solid var(--admin-border);
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

/* ── Stats bar ───────────────────────────────────────────────────────── */
.stats-bar {
  display: flex;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.stat-card {
  background: var(--admin-surface);
  border: 1px solid var(--admin-border);
  border-radius: 4px;
  padding: 14px 20px;
  min-width: 120px;
}
.stat-card__num {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--admin-gold);
  line-height: 1;
}
.stat-card__label {
  font-size: 0.73rem;
  color: var(--admin-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 4px;
}

/* ── Home Dashboard Tiles ────────────────────────────────────────────── */
.home-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}
.tile-card {
  background: var(--admin-surface);
  border: 1px solid var(--admin-border);
  border-radius: 6px;
  padding: 20px 18px 16px;
  cursor: pointer;
  text-decoration: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
  position: relative;
  transition: border-color 0.28s ease, box-shadow 0.28s ease, transform 0.22s ease;
}
.tile-card:hover { border-color: var(--admin-gold); box-shadow: 0 4px 18px rgba(153,121,61,0.18); transform: translateY(-2px); }
.tile-card__icon { line-height: 1; color: var(--admin-text-muted); flex-shrink: 0; }
.tile-card__icon svg { display: block; }
.tile-card__header { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.tile-card__name { font-size: 0.95rem; font-weight: 600; color: var(--admin-text-head); }
.tile-card__desc { font-size: 0.75rem; color: var(--admin-text-muted); }
.tile-card__preview { font-size: 2rem; font-weight: 700; color: var(--admin-gold); line-height: 1; }
.tile-pin-btn {
  position: absolute;
  top: 10px; right: 10px;
  background: none;
  border: none;
  color: var(--admin-text-muted);
  font-size: 1rem;
  cursor: pointer;
  line-height: 1;
  padding: 2px;
  transition: color 0.28s ease;
}
.tile-pin-btn:hover { color: var(--admin-gold); }
.tile-pin-btn.pinned { color: var(--admin-gold); }

.home-section-title {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--admin-text-muted);
  margin-bottom: 12px;
}
.home-welcome {
  margin-bottom: 28px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--admin-border);
}
.home-welcome h2 {
  font-family: var(--font-display, 'EB Garamond', serif);
  font-size: 1.6rem;
  font-weight: 500;
  color: var(--admin-text-head);
}
.home-welcome .role-badge {
  display: inline-block;
  margin-left: 10px;
  font-size: 0.7rem;
  padding: 2px 8px;
  background: var(--admin-pill-bg);
  color: var(--admin-pill-text);
  border-radius: 10px;
  vertical-align: middle;
}

/* ── Settings Page ───────────────────────────────────────────────────── */
.settings-section {
  background: var(--admin-surface);
  border: 1px solid var(--admin-border);
  border-radius: 4px;
  padding: 22px 24px;
  max-width: 500px;
  margin-bottom: 20px;
}
.settings-section h3 {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--admin-text-muted);
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--admin-border);
}
.settings-options { display: flex; gap: 10px; flex-wrap: wrap; }
.settings-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border: 1px solid var(--admin-border);
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.875rem;
  color: var(--admin-text-dim);
  background: none;
  transition: border-color 0.28s ease, color 0.28s ease, background 0.28s ease;
  white-space: nowrap;
}
.settings-option:hover { border-color: var(--admin-gold); }
.settings-option.active { border-color: var(--admin-gold); color: var(--admin-gold); background: rgba(153,121,61,0.08); }
.settings-option input[type="radio"] { display: none; }

/* ── Book Edit Page ──────────────────────────────────────────────────── */
.edit-card {
  background: var(--admin-surface);
  border: 1px solid var(--admin-border);
  border-radius: 4px;
  padding: 28px 32px;
  max-width: 860px;
}

/* Book title heading on edit page */
.edit-book-title {
  font-family: var(--font-display, 'EB Garamond', serif);
  font-size: 1.5rem;
  font-weight: 500;
  color: var(--admin-text-head);
  margin-bottom: 6px;
  line-height: 1.3;
}
.edit-book-title-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--admin-text-muted);
  margin-bottom: 4px;
}

.edit-section-title {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--admin-text-muted);
  padding-bottom: 8px;
  border-bottom: 1px solid var(--admin-border);
  margin-bottom: 18px;
  margin-top: 28px;
}
.edit-section-title:first-child { margin-top: 0; }

/* Image upload field */
.image-upload-field { display: flex; gap: 16px; align-items: flex-start; }
.image-preview-box {
  width: 80px; height: 110px;
  background: var(--admin-input-bg);
  border: 1px solid var(--admin-input-border);
  border-radius: 3px;
  overflow: hidden;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--admin-text-muted);
  font-size: 1.5rem;
}
.image-preview-box img { width: 100%; height: 100%; object-fit: cover; }
.image-upload-controls { flex: 1; }
.image-upload-controls .form-field { margin-bottom: 8px; }
.image-path-display {
  font-size: 0.75rem;
  color: var(--admin-text-muted);
  word-break: break-all;
  margin-top: 4px;
}
.upload-progress {
  display: none;
  font-size: 0.75rem;
  color: var(--admin-gold);
  margin-top: 4px;
}

/* Tags input */
.tags-wrap { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--admin-pill-bg);
  color: var(--admin-pill-text);
  border-radius: 10px;
  padding: 2px 8px 2px 10px;
  font-size: 0.75rem;
}
.tag-chip button {
  background: none; border: none; color: var(--admin-pill-text); cursor: pointer;
  padding: 0; font-size: 0.8rem; line-height: 1;
}
.tag-chip button:hover { color: var(--admin-danger); }

/* Form actions bar */
.form-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  padding-top: 24px;
  margin-top: 8px;
  border-top: 1px solid var(--admin-border);
}

/* ── Categories / Deskriptori Page ───────────────────────────────────── */
.category-edit-row { display: none; background: var(--admin-table-head); }
.category-edit-row.open { display: table-row; }
.category-edit-form {
  padding: 14px 20px;
  display: flex;
  gap: 12px;
  align-items: flex-end;
  flex-wrap: wrap;
}
.category-edit-form .form-field { margin-bottom: 0; flex: 1; min-width: 160px; }

/* ── Toast Notification ──────────────────────────────────────────────── */
.admin-toast {
  position: fixed;
  top: 20px; right: 20px;
  background: var(--admin-success-bg);
  color: var(--admin-success-text);
  border: 1px solid var(--admin-success-border);
  border-radius: 4px;
  padding: 12px 18px;
  font-size: 0.875rem;
  z-index: 9999;
  transform: translateX(140%);
  transition: transform 0.38s cubic-bezier(0.4, 0, 0.2, 1);
  max-width: 320px;
}
.admin-toast.error { background: var(--admin-error-bg); color: var(--admin-error-text); border-color: var(--admin-error-border); }
.admin-toast.show  { transform: translateX(0); }

/* ── Loading spinner ─────────────────────────────────────────────────── */
.spinner {
  display: inline-block;
  width: 14px; height: 14px;
  border: 2px solid var(--admin-input-border);
  border-top-color: var(--admin-gold);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Empty state ─────────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--admin-text-muted);
}
.empty-state p { font-size: 0.875rem; }

/* ── Password visibility toggle ──────────────────────────────────────── */
.pw-wrap { position: relative; display: flex; align-items: center; }
.pw-wrap input { flex: 1; padding-right: 38px !important; }
.pw-toggle {
  position: absolute;
  right: 9px;
  background: none;
  border: none;
  color: var(--admin-text-muted);
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  transition: color 0.28s ease;
  flex-shrink: 0;
}
.pw-toggle:hover { color: var(--admin-text-dim); }
.pw-toggle svg { width: 15px; height: 15px; }

/* ── Hamburger toggle button (hidden on desktop) ─────────────────────── */
.sidebar-toggle {
  display: none;
  background: none;
  border: none;
  color: #a0adb5;
  cursor: pointer;
  padding: 6px 8px;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  border-radius: 3px;
  transition: background 0.28s ease, color 0.28s ease;
}
.sidebar-toggle:hover { background: #1e2d3d; color: #e9e8e0; }
.sidebar-toggle svg { display: block; }

/* ── Sidebar backdrop (mobile only) ─────────────────────────────────── */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 150;
  backdrop-filter: blur(1px);
}
.sidebar-backdrop.active { display: block; }

/* ── Responsive ──────────────────────────────────────────────────────── */

/* Tablet (769–1024px) */
@media (max-width: 1024px) and (min-width: 769px) {
  .admin-sidebar { width: 180px; }
  .admin-main    { margin-left: 180px; }
  .admin-content { padding: 20px; }
  .edit-card     { padding: 22px 24px; }
}

/* Mobile (≤ 768px) */
@media (max-width: 768px) {

  /* Larger base font so text is readable */
  body { font-size: 15px; }

  /* Sidebar slides in as overlay */
  .admin-sidebar {
    transform: translateX(-100%);
    transition: transform 0.38s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 200;
    width: 260px;
  }
  .admin-sidebar.sidebar-open {
    transform: translateX(0);
    box-shadow: 4px 0 28px rgba(0, 0, 0, 0.6);
  }

  /* Sidebar nav links bigger for touch */
  .sidebar-nav li a {
    padding: 13px 20px;
    font-size: 0.95rem;
  }

  /* Show hamburger */
  .sidebar-toggle { display: flex; }

  /* Main fills full width */
  .admin-main { margin-left: 0; }

  /* Topbar */
  .admin-topbar { padding: 14px 14px 12px; }
  .topbar-row { padding-bottom: 12px; }
  .admin-topbar h1 { font-size: 1.05rem; }
  .topbar-actions { flex-wrap: wrap; gap: 6px; }
  .admin-topbar .stat-card { padding: 4px 10px; min-width: 70px; }

  /* Content padding */
  .admin-content { padding: 14px; }

  /* ── Buttons — large touch targets ───────────────────────── */
  .btn-admin-primary,
  .btn-admin-secondary {
    min-height: 44px;
    padding: 11px 18px;
    font-size: 0.92rem;
  }
  .btn-admin-danger {
    min-height: 40px;
    padding: 9px 14px;
    font-size: 0.85rem;
  }
  .btn-admin-sm {
    min-height: 36px !important;
    padding: 7px 12px !important;
    font-size: 0.83rem !important;
  }

  /* ── Forms ───────────────────────────────────────────────── */
  .form-grid { grid-template-columns: 1fr; }
  .edit-card  { padding: 16px 14px; }

  /* font-size: 16px on inputs prevents iOS auto-zoom on focus */
  .form-field input,
  .form-field textarea,
  .form-field select,
  .table-controls input,
  .table-controls select {
    font-size: 16px;
    padding: 11px 12px;
  }
  .form-field label { font-size: 0.8rem; }

  /* Image upload stack */
  .image-upload-field { flex-direction: column; }
  .image-preview-box  { width: 100%; height: 180px; }

  /* Form actions wrap */
  .form-actions { flex-wrap: wrap; gap: 8px; }

  /* ── Stats bar — 2 per row ───────────────────────────────── */
  .stats-bar  { gap: 10px; }
  .stat-card  { flex: 1 1 calc(50% - 5px); min-width: unset; padding: 12px 14px; }
  .stat-card__num { font-size: 1.5rem; }

  /* ── Table ───────────────────────────────────────────────── */
  .admin-table-wrap { border-radius: 3px; }
  .admin-table th   { font-size: 0.72rem; padding: 10px 10px; white-space: nowrap; }
  .admin-table td   { padding: 10px 10px; font-size: 0.88rem; }
  .book-thumb { width: 56px; height: 78px; }
  .book-thumb-placeholder { width: 56px; height: 78px; font-size: 1.4rem; }
  .stock-cell { flex-direction: row; gap: 4px; align-items: center; font-size: 0.82rem; }
  .stock-item { display: flex; align-items: center; gap: 2px; }
  .stock-label { display: inline; font-size: 0.7rem; }
  .stock-item:not(:last-child)::after { content: '/'; color: var(--admin-text-muted); margin-left: 3px; }

  /* Hide less-important columns on mobile */
  .col-hide-mobile { display: none !important; }

  /* Table controls stack */
  .table-controls { flex-direction: column; gap: 8px; }
  .table-controls input,
  .table-controls select { min-width: unset; width: 100%; }

  /* Row actions */
  .row-actions { flex-wrap: wrap; gap: 4px; }

  /* ── Toast — bottom of screen ────────────────────────────── */
  .admin-toast {
    top: auto;
    bottom: 16px;
    right: 14px;
    left: 14px;
    max-width: none;
    transform: translateY(140%);
    font-size: 0.9rem;
  }
  .admin-toast.show { transform: translateY(0); }

  /* ── Login page ──────────────────────────────────────────── */
  .login-card { padding: 28px 20px; }
  .login-title { font-size: 1.3rem; }
}

/* ── Stock qty color indicators ──────────────────────────────────────── */
.stock-zero { color: var(--admin-danger); font-weight: 700; }
.stock-low  { color: #e08c30;             font-weight: 700; }

/* ── Icon-only button ────────────────────────────────────────────────── */
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px; height: 30px;
  padding: 0;
  background: none;
  border: 1px solid var(--admin-input-border);
  border-radius: 4px;
  color: var(--admin-text-dim);
  cursor: pointer;
  transition: border-color 0.28s ease, color 0.28s ease, background 0.28s ease;
  flex-shrink: 0;
}
.icon-btn:hover { border-color: var(--admin-gold); color: var(--admin-gold); }
.icon-btn.danger:hover { border-color: var(--admin-danger); color: var(--admin-danger); }
.icon-btn svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ── Clickable table row ─────────────────────────────────────────────── */
.admin-table tbody tr.row-link { cursor: pointer; }
.admin-table tbody tr.row-link:hover td { background: var(--admin-table-row-hover); }

/* ── Report charts ───────────────────────────────────────────────────── */
.chart-card {
  background: var(--admin-surface);
  border: 1px solid var(--admin-border);
  border-radius: 6px;
  padding: 20px 24px;
  margin-bottom: 20px;
}
.chart-card__title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--admin-text-head);
  margin-bottom: 14px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.chart-card canvas { max-height: 260px; width: 100% !important; }

/* ── Home tile manage button ─────────────────────────────────────────── */
.home-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.home-section-title { font-size: 0.75rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.07em; color: var(--admin-text-muted); }

/* ── Book stock section in edit ──────────────────────────────────────── */
.book-stock-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--admin-border);
}
.book-stock-row:last-child { border-bottom: none; }
.book-stock-label { flex: 1; font-size: 0.875rem; color: var(--admin-text); }
.book-stock-qty { font-size: 1.1rem; font-weight: 700; min-width: 36px; text-align: center; color: var(--admin-text-head); }
