/* ============================================================
   admin.css – Admin panel styles
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+JP:wght@400;500;700&display=swap');

:root {
  --ink: #1a1108;
  --paper: #f5f5f3;
  --card: #ffffff;
  --accent: #b5370a;
  --accent-light: #fdf0ec;
  --gold: #c9930a;
  --success: #2e7d32;
  --danger: #c0392b;
  --border: #e0dcd6;
  --muted: #7a7268;
  --sidebar-bg: #1a1108;
  --sidebar-text: #e8dfd0;
  --sidebar-active: #b5370a;
  --font: 'Noto Sans JP', system-ui, sans-serif;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 4px 12px rgba(0,0,0,.04);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; font-family: var(--font); background: var(--paper); color: var(--ink); font-size: 14px; -webkit-font-smoothing: antialiased; }
button { cursor: pointer; font-family: inherit; }
input, select, textarea { font-family: inherit; }

/* ── Layout ────────────────────────────────────────────────── */
.admin-layout { display: flex; height: 100vh; overflow: hidden; }
.admin-sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}
.admin-content {
  flex: 1;
  overflow-y: auto;
  padding: 28px 32px;
  max-width: 1100px;
}
@media (max-width: 768px) {
  .admin-layout { flex-direction: column; }
  .admin-sidebar { width: 100%; height: auto; flex-direction: row; overflow-x: auto; flex-shrink: 0; }
  .admin-content { padding: 16px; }
}

/* ── Sidebar ────────────────────────────────────────────────── */
.sidebar-brand {
  padding: 20px 16px 14px;
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: .04em;
  border-bottom: 1px solid rgba(255,255,255,.1);
}
.sidebar-brand span { display: block; font-size: 10px; color: var(--sidebar-text); font-weight: 400; margin-top: 2px; letter-spacing: .06em; }
.sidebar-nav { display: flex; flex-direction: column; padding: 8px 0; flex: 1; }
@media (max-width: 768px) {
  .sidebar-nav { flex-direction: row; padding: 4px 8px; gap: 2px; }
  .sidebar-brand { display: none; }
}
.nav-group-label {
  font-size: 10px;
  font-weight: 700;
  color: rgba(255,255,255,.35);
  letter-spacing: .12em;
  text-transform: uppercase;
  padding: 14px 16px 6px;
}
@media (max-width: 768px) { .nav-group-label { display: none; } }
.nav-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  color: var(--sidebar-text);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  background: none;
  text-align: left;
  width: 100%;
  border-radius: 0;
  transition: background .15s;
}
@media (max-width: 768px) {
  .nav-item { padding: 8px 10px; white-space: nowrap; border-radius: 4px; width: auto; }
}
.nav-item:hover { background: rgba(255,255,255,.08); }
.nav-item--active { background: var(--sidebar-active) !important; color: #fff; }
.nav-item__icon { font-size: 16px; flex-shrink: 0; }

/* ── Section ────────────────────────────────────────────────── */
.admin-section { display: none; }
.admin-section--active { display: block; }
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}
.section-title { font-size: 22px; font-weight: 700; color: var(--ink); }
.section-subtitle { font-size: 13px; color: var(--muted); margin-top: 2px; }

/* ── Cards ──────────────────────────────────────────────────── */
.admin-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}
.admin-card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.admin-card__title { font-size: 15px; font-weight: 700; }

/* ── Table ──────────────────────────────────────────────────── */
.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.admin-table th {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 2px solid var(--border);
  font-weight: 700;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .06em;
  white-space: nowrap;
}
.admin-table td {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.admin-table tr:last-child td { border-bottom: none; }
.admin-table tr:hover td { background: var(--paper); }
.table-actions { display: flex; gap: 6px; }
.status-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 20px;
  letter-spacing: .04em;
}
.status-badge--visible { background: #e8f5e9; color: #1b5e20; }
.status-badge--hidden { background: #f5f5f5; color: #757575; }
.status-badge--sold_out { background: #fce4ec; color: #880e4f; }
.status-badge--active { background: #e3f2fd; color: #0d47a1; }
.status-badge--closed { background: #f5f5f5; color: #757575; }
.status-badge--expired { background: #fff3e0; color: #e65100; }
.status-badge--deleted { background: #fce4ec; color: #880e4f; }

/* ── Form ───────────────────────────────────────────────────── */
.form-row { display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 14px; }
.form-group { display: flex; flex-direction: column; gap: 5px; flex: 1; min-width: 160px; }
.form-label { font-size: 12px; font-weight: 700; color: var(--muted); letter-spacing: .04em; }
.form-input, .form-select, .form-textarea {
  padding: 8px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  background: var(--card);
  color: var(--ink);
  transition: border-color .15s;
  width: 100%;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none;
  border-color: var(--accent);
}
.form-textarea { resize: vertical; min-height: 80px; }
.form-hint { font-size: 11px; color: var(--muted); }

/* ── Checkbox group ──────────────────────────────────────────── */
.check-group { display: flex; flex-wrap: wrap; gap: 10px; }
.check-item { display: flex; align-items: center; gap: 6px; font-size: 13px; cursor: pointer; }
.check-item input { accent-color: var(--accent); }

/* ── Image upload ────────────────────────────────────────────── */
.img-upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s;
}
.img-upload-zone:hover { border-color: var(--accent); }
.img-upload-zone img { max-height: 120px; margin: 0 auto 10px; object-fit: contain; }
.img-upload-zone input { display: none; }
.img-upload-zone__label { font-size: 13px; color: var(--muted); }

/* ── Buttons ─────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 700;
  font-family: inherit;
  border: 1.5px solid transparent;
  cursor: pointer;
  transition: background .15s, opacity .15s;
  letter-spacing: .02em;
  white-space: nowrap;
}
.btn:active { opacity: .85; }
.btn--primary { background: var(--accent); color: #fff; }
.btn--primary:hover { background: #922b08; }
.btn--secondary { background: var(--paper); border-color: var(--border); color: var(--ink); }
.btn--secondary:hover { background: var(--border); }
.btn--success { background: var(--success); color: #fff; }
.btn--danger { background: var(--danger); color: #fff; }
.btn--danger:hover { background: #992b22; }
.btn--sm { padding: 5px 10px; font-size: 12px; }
.btn--xs { padding: 3px 8px; font-size: 11px; }
.btn--ghost { background: transparent; border-color: var(--border); color: var(--muted); }
.btn--ghost:hover { background: var(--paper); }
.btn--icon { padding: 6px; border-radius: 6px; }

/* ── Modal ──────────────────────────────────────────────────── */
.modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-backdrop--open { display: flex; }
.modal {
  background: var(--card);
  border-radius: 12px;
  padding: 28px;
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
}
.modal__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}
.modal__title { font-size: 18px; font-weight: 700; }
.modal__close { background: none; border: none; font-size: 22px; color: var(--muted); line-height: 1; padding: 2px 6px; border-radius: 4px; }
.modal__close:hover { background: var(--paper); color: var(--ink); }
.modal__footer { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; padding-top: 14px; border-top: 1px solid var(--border); }

/* ── Stats ──────────────────────────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; margin-bottom: 20px; }
.stat-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; text-align: center; box-shadow: var(--shadow); }
.stat-card__val { font-size: 28px; font-weight: 700; color: var(--accent); margin-bottom: 4px; }
.stat-card__label { font-size: 12px; color: var(--muted); }

/* ── Toasts ──────────────────────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 9999;
}
.toast {
  background: var(--ink);
  color: #fff;
  padding: 10px 18px;
  border-radius: var(--radius);
  font-size: 13px;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity .2s, transform .2s;
}
.toast--show { opacity: 1; transform: translateY(0); }
.toast--success { background: var(--success); }
.toast--error { background: var(--danger); }

/* ── Item thumbnail ──────────────────────────────────────────── */
.item-thumb {
  width: 44px;
  height: 44px;
  object-fit: cover;
  border-radius: 6px;
  background: var(--paper);
}
.item-thumb--placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--paper);
  color: var(--muted);
  font-size: 20px;
  border-radius: 6px;
  width: 44px;
  height: 44px;
}

/* ── Color swatch ─────────────────────────────────────────────── */
.color-swatch {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 3px;
  vertical-align: middle;
  margin-right: 4px;
  border: 1px solid rgba(0,0,0,.1);
}

/* ── Settings ────────────────────────────────────────────────── */
.settings-form { max-width: 480px; }
.settings-row { display: flex; align-items: center; justify-content: space-between; padding: 12px 0; border-bottom: 1px solid var(--border); gap: 12px; }
.settings-row:last-child { border-bottom: none; }
.settings-row__label { font-size: 14px; font-weight: 600; }
.settings-row__hint { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* ── Empty state ─────────────────────────────────────────────── */
.empty-state { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty-state__icon { font-size: 40px; margin-bottom: 12px; }
.empty-state__text { font-size: 14px; }

/* Loading spinner ─────────────────────────────────────────────── */
.spinner {
  width: 20px; height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-row td { text-align: center; padding: 24px; color: var(--muted); }

/* Tab bar (for sections that have sub-tabs) ───────────────────── */
.tab-bar { display: flex; gap: 4px; border-bottom: 2px solid var(--border); margin-bottom: 20px; }
.tab-btn {
  padding: 8px 16px;
  border: none;
  background: none;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color .15s;
}
.tab-btn--active { color: var(--accent); border-bottom-color: var(--accent); }
.tab-btn:hover { color: var(--ink); }
/* タブが多い場合に横スクロール（品目管理のカテゴリータブ用） */
.tab-bar--scroll {
  overflow-x: auto;
  flex-wrap: nowrap;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.tab-bar--scroll::-webkit-scrollbar { display: none; }
.tab-bar--scroll .tab-btn { flex-shrink: 0; white-space: nowrap; }

/* ドラッグ&ドロップ並び替え ─────────────────────────────────── */
.drag-handle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  font-size: 16px;
  color: var(--muted);
  cursor: grab;
  border-radius: 6px;
  user-select: none;
  touch-action: none; /* タッチ端末でもドラッグ可能に */
}
.drag-handle:hover { background: var(--paper); color: var(--ink); }
.row-dragging { opacity: .55; }
.row-dragging .drag-handle { cursor: grabbing; }
.row-dragging td { background: var(--paper) !important; }
body.dragging-rows { user-select: none; cursor: grabbing; }
.drag-hint {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 10px;
}

/* オプション管理 ─────────────────────────────────────────────── */
.option-group-row { cursor: pointer; }
.option-group-row--selected td { background: var(--paper) !important; }
.og-badge {
  display: inline-block;
  font-size: 10.5px;
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 10px;
  padding: 1px 8px;
  margin-top: 3px;
}
/* 品目モーダル内のオプション紐付け */
.option-link-list {
  border: 1px solid var(--border);
  border-radius: 8px;
  max-height: 260px;
  overflow-y: auto;
  padding: 6px 10px;
}
.option-link-group { padding: 6px 0; border-bottom: 1px dashed var(--border); }
.option-link-group:last-child { border-bottom: none; }
.option-link-group__head { display: flex; align-items: center; gap: 8px; }
.option-link-group__options {
  margin: 4px 0 2px 26px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
}
