/* ============================================================
 *  指尖西点蛋糕 · 后台管理样式
 *  与前台同一套粉色系，保证品牌一致；布局偏工具化
 * ============================================================ */

:root {
  --pink-50:  #fff5f8;
  --pink-100: #ffe9f1;
  --pink-200: #ffd3e2;
  --pink-300: #ffb3cd;
  --pink-400: #ff8fab;
  --pink-500: #ff6b9d;
  --pink-600: #e75480;
  --cream:    #fffafc;
  --cocoa:    #6b4a56;
  --cocoa-60: rgba(107, 74, 86, .6);
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 999px;
  --shadow-card: 0 8px 26px rgba(255, 107, 157, .12);
  --font: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

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

body {
  font-family: var(--font);
  color: var(--cocoa);
  background: linear-gradient(160deg, var(--pink-50), var(--pink-100));
  background-attachment: fixed;
  min-height: 100vh;
}

a { text-decoration: none; color: inherit; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }

/* ============ 顶部 ============ */
.admin-header {
  padding: 22px 20px;
  color: #fff;
  background: linear-gradient(135deg, #ff9ebb, #ff7eb3);
  box-shadow: 0 8px 24px rgba(255, 107, 157, .3);
}
.header-inner {
  max-width: 1080px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.admin-header h1 { font-size: 22px; letter-spacing: 1px; }
.back-link {
  padding: 7px 16px;
  font-size: 14px;
  color: var(--pink-600);
  background: rgba(255, 255, 255, .92);
  border-radius: var(--radius-sm);
  transition: transform .2s ease;
}
.back-link:hover { transform: translateY(-2px); }

/* ============ 面板 ============ */
.container {
  max-width: 1080px;
  margin: 0 auto;
  padding: 26px 20px 60px;
  display: flex;
  flex-direction: column;
  gap: 26px;
}

.panel {
  padding: 24px;
  background: var(--cream);
  border-radius: var(--radius-lg);
  border: 2px solid #fff;
  box-shadow: var(--shadow-card);
}

.panel-title {
  font-size: 18px;
  margin-bottom: 18px;
  color: var(--pink-600);
  display: flex;
  align-items: center;
  gap: 8px;
}

.count-badge {
  min-width: 24px;
  padding: 2px 8px;
  font-size: 13px;
  color: #fff;
  text-align: center;
  background: var(--pink-400);
  border-radius: var(--radius-sm);
}

/* ============ 表单布局 ============ */
.form-grid {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 22px;
}

.form-fields {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: 14px; font-weight: 700; }
.field-label em { color: var(--pink-500); font-style: normal; }
.field-tip { font-size: 12px; color: var(--cocoa-60); }

.field input {
  padding: 10px 14px;
  font-size: 15px;
  font-family: inherit;
  color: var(--cocoa);
  background: var(--pink-50);
  border: 2px solid var(--pink-200);
  border-radius: var(--radius-md);
  outline: none;
  transition: border-color .2s ease;
}
.field input:focus { border-color: var(--pink-400); background: #fff; }
.field input.invalid { border-color: #ff5a5a; background: #fff0f0; }

/* ============ 图片上传区 ============ */
.dropzone {
  position: relative;
  aspect-ratio: 1 / 1;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 16px;
  background: var(--pink-50);
  border: 2px dashed var(--pink-300);
  border-radius: var(--radius-lg);
  cursor: pointer;
  overflow: hidden;
  transition: border-color .2s ease, background .2s ease;
}
.dropzone:hover,
.dropzone.dragover { border-color: var(--pink-500); background: var(--pink-100); }

.dropzone-hint { pointer-events: none; }
.dropzone-icon { font-size: 40px; }
.dropzone-hint p { font-size: 14px; margin-top: 8px; }
.dropzone-sub { font-size: 12px !important; color: var(--cocoa-60); }

.dropzone-preview {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.dropzone-clear {
  position: absolute;
  top: 8px; right: 8px;
  width: 28px; height: 28px;
  font-size: 13px;
  color: #fff;
  background: rgba(107, 74, 86, .75);
  border-radius: 50%;
  z-index: 2;
}
.dropzone-clear:hover { background: rgba(107, 74, 86, .95); }

/* ============ 标签输入 ============ */
.tag-input-box {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  padding: 8px 10px;
  background: var(--pink-50);
  border: 2px solid var(--pink-200);
  border-radius: var(--radius-md);
  cursor: text;
}
.tag-input-box:focus-within { border-color: var(--pink-400); background: #fff; }

.tag-input-box input {
  flex: 1;
  min-width: 180px;
  border: none;
  outline: none;
  background: transparent;
  font-size: 14px;
  font-family: inherit;
  color: var(--cocoa);
  padding: 4px 2px;
}

/* 生成的标签胶囊（带删除叉） */
.tag-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 8px 4px 12px;
  font-size: 13px;
  color: var(--pink-600);
  background: var(--pink-100);
  border-radius: var(--radius-sm);
}
.tag-pill button {
  font-size: 11px;
  color: var(--pink-600);
  opacity: .7;
  line-height: 1;
}
.tag-pill button:hover { opacity: 1; }

/* ============ 常用标签推荐（点选历史标签） ============ */
.tag-suggest {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
}
.tag-suggest-label {
  font-size: 12px;
  color: var(--cocoa-60);
}
.suggest-chip {
  padding: 3px 10px;
  font-size: 12px;
  color: var(--pink-600);
  background: var(--pink-50);
  border: 1px dashed var(--pink-300);
  border-radius: var(--radius-sm);
  transition: background .15s ease, border-color .15s ease;
}
.suggest-chip:hover {
  background: var(--pink-100);
  border-style: solid;
}
/* 当前表单已添加的标签：置灰不可点 */
.suggest-chip.used {
  opacity: .45;
  text-decoration: line-through;
  pointer-events: none;
}

/* ============ 按钮 ============ */
.btn-primary {
  padding: 11px 30px;
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, var(--pink-400), var(--pink-500));
  border-radius: var(--radius-sm);
  box-shadow: 0 4px 14px rgba(255, 107, 157, .35);
  transition: transform .2s ease, box-shadow .2s ease;
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(255, 107, 157, .45); }
.btn-primary:disabled { opacity: .6; transform: none; cursor: not-allowed; }

.btn-ghost {
  padding: 11px 24px;
  font-size: 15px;
  color: var(--cocoa);
  background: var(--pink-100);
  border-radius: var(--radius-sm);
}
.btn-ghost:hover { background: var(--pink-200); }

.form-actions { display: flex; justify-content: flex-end; }

/* ============ 商品表格 ============ */
.table-wrap { overflow-x: auto; }

.product-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.product-table th {
  padding: 10px 12px;
  text-align: left;
  color: var(--pink-600);
  background: var(--pink-50);
  white-space: nowrap;
}
.product-table th:first-child { border-radius: var(--radius-md) 0 0 var(--radius-md); }
.product-table th:last-child  { border-radius: 0 var(--radius-md) var(--radius-md) 0; }
.product-table td {
  padding: 10px 12px;
  border-bottom: 1.5px dashed var(--pink-200);
  vertical-align: middle;
}
.product-table tr:last-child td { border-bottom: none; }
.product-table tr:hover td { background: var(--pink-50); }

.table-empty {
  text-align: center;
  color: var(--cocoa-60);
  padding: 30px 0 !important;
}

.thumb {
  width: 64px; height: 64px;
  object-fit: cover;
  border-radius: var(--radius-md);
  border: 2px solid var(--pink-100);
}

.cell-price { font-weight: 800; color: var(--pink-500); white-space: nowrap; }

.cell-tags { display: flex; flex-wrap: wrap; gap: 4px; max-width: 220px; }
.cell-tag {
  padding: 2px 9px;
  font-size: 12px;
  color: var(--pink-600);
  background: var(--pink-100);
  border-radius: var(--radius-sm);
}

.cell-time { color: var(--cocoa-60); font-size: 13px; white-space: nowrap; }

.row-actions { display: flex; gap: 8px; }
.btn-edit, .btn-del {
  padding: 6px 14px;
  font-size: 13px;
  border-radius: var(--radius-sm);
  transition: transform .15s ease;
}
.btn-edit { color: var(--pink-600); background: var(--pink-100); }
.btn-edit:hover { background: var(--pink-200); }
.btn-del { color: #c92a2a; background: #ffe3e3; }
.btn-del:hover { background: #ffc9c9; }

/* ============ 编辑弹窗 ============ */
/* 注意：下面给 .modal-mask 设置了 display:grid，会覆盖浏览器默认的
   [hidden]{display:none}，导致弹窗初始就可见。
   所以必须显式声明 hidden 时的 display，把隐藏属性找回来。 */
.modal-mask[hidden] { display: none; }

.modal-mask {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(107, 74, 86, .4);
  backdrop-filter: blur(3px);
  z-index: 100;
  overflow: auto;
}
.modal {
  width: 100%;
  max-width: 640px;
  padding: 26px;
  background: var(--cream);
  border-radius: var(--radius-lg);
  box-shadow: 0 24px 60px rgba(0, 0, 0, .25);
  animation: modal-in .25s ease;
}
@keyframes modal-in {
  from { opacity: 0; transform: translateY(24px) scale(.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-title { font-size: 18px; color: var(--pink-600); margin-bottom: 18px; }
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 20px;
}

/* ============ toast ============ */
.toast {
  position: fixed;
  left: 50%;
  bottom: 40px;
  transform: translateX(-50%) translateY(20px);
  padding: 10px 22px;
  font-size: 14px;
  color: #fff;
  background: rgba(107, 74, 86, .92);
  border-radius: var(--radius-sm);
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s ease, transform .25s ease;
  z-index: 200;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ============ 响应式 ============ */
@media (max-width: 720px) {
  .form-grid { grid-template-columns: 1fr; }
  .dropzone { max-width: 320px; margin: 0 auto; }
  .panel { padding: 18px; }
}
