/* =========================================================
   小花个人主页 · 手机端管理后台样式表
   ========================================================= */

:root {
  --bg-page: #fdf6ec;
  --bg-card: #ffffff;
  --bg-soft: #fff6e8;
  --bg-input: #fffdf9;

  --accent: #e8844c;
  --accent-deep: #d26b34;
  --accent-soft: rgba(232, 132, 76, 0.14);

  --danger: #d94b4b;
  --danger-soft: rgba(217, 75, 75, 0.11);
  --success: #2c8f5c;

  --text-main: #44352c;
  --text-sub: #7a685b;
  --text-muted: #9f8f82;

  --border: rgba(164, 126, 92, 0.22);
  --shadow: 0 10px 28px rgba(140, 96, 60, 0.08);
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --font-sans: "PingFang SC", "Hiragino Sans GB", "HarmonyOS Sans SC", "Microsoft YaHei", -apple-system, BlinkMacSystemFont, sans-serif;
}

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

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  color: var(--text-main);
  background: linear-gradient(180deg, #fffdf9 0%, var(--bg-page) 100%);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

button,
input,
textarea,
select {
  font-family: inherit;
  font-size: 16px; /* 防止 iOS 聚焦输入框时自动缩放 */
}

a {
  color: inherit;
  text-decoration: none;
}

/* ---------- 登录视图 ---------- */
.login-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}

.login-card {
  width: 100%;
  max-width: 390px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 26px;
  padding: 32px 24px 26px;
  box-shadow: var(--shadow);
  text-align: center;
}

.login-avatar-wrap {
  width: 88px;
  height: 88px;
  margin: 0 auto 14px;
  border-radius: 50%;
  padding: 4px;
  background: linear-gradient(135deg, #ffd2a8, var(--accent));
}

.login-avatar {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
  display: block;
}

.login-title {
  margin: 0 0 6px;
  font-size: 22px;
}

.login-sub {
  margin: 0 0 22px;
  color: var(--text-sub);
  font-size: 14px;
}

.login-form {
  text-align: left;
}

.password-row {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.back-home-link {
  display: inline-block;
  margin-top: 18px;
  font-size: 14px;
  color: var(--text-sub);
}

.error-text {
  margin: 0 0 12px;
  color: var(--danger);
  font-size: 14px;
}

/* ---------- 顶部栏与 Tab ---------- */
.admin-shell {
  padding-bottom: calc(90px + env(safe-area-inset-bottom));
}

.admin-header {
  position: sticky;
  top: 0;
  z-index: 30;
  background: rgba(255, 253, 249, 0.94);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  max-width: 860px;
  margin: 0 auto;
  padding: 12px 16px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-emoji {
  font-size: 22px;
}

.header-brand strong {
  display: block;
  font-size: 16px;
  line-height: 1.25;
}

.dirty-badge {
  display: inline-block;
  margin-top: 2px;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-deep);
  font-size: 11px;
  font-weight: 600;
}

.header-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.tab-bar {
  max-width: 860px;
  margin: 0 auto;
  padding: 0 12px 10px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.tab-btn {
  border: 1px solid transparent;
  background: var(--bg-soft);
  color: var(--text-sub);
  border-radius: 12px;
  padding: 10px 6px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  transition: all 0.18s ease;
}

.tab-btn.is-active {
  background: var(--accent);
  color: #ffffff;
  box-shadow: 0 6px 16px rgba(232, 132, 76, 0.28);
}

.count-pill {
  padding: 1px 6px;
  border-radius: 999px;
  font-size: 12px;
  background: rgba(255, 255, 255, 0.28);
}

.tab-btn:not(.is-active) .count-pill {
  background: rgba(164, 126, 92, 0.16);
  color: var(--text-main);
}

/* ---------- 主体与卡片 ---------- */
.admin-main {
  max-width: 860px;
  margin: 0 auto;
  padding: 16px 14px 24px;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 16px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}

.card-title {
  margin: 0 0 8px;
  font-size: 17px;
  font-weight: 700;
}

.card-hint {
  margin: 0 0 14px;
  font-size: 13px;
  color: var(--text-sub);
  line-height: 1.5;
}

.danger-card {
  border-color: rgba(217, 75, 75, 0.28);
}

/* ---------- 表单控件 ---------- */
.field {
  margin-bottom: 14px;
}

.field:last-child {
  margin-bottom: 0;
}

.field-label {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-sub);
}

.input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 11px 12px;
  background: var(--bg-input);
  color: var(--text-main);
  outline: none;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.textarea {
  resize: vertical;
  line-height: 1.55;
}

.form-row-2 {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin-bottom: 14px;
}

.form-row-2 .field {
  margin-bottom: 0;
}

.stack-form .btn {
  margin-top: 6px;
}

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 11px 16px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.12s ease, opacity 0.15s ease, background 0.15s ease;
}

.btn:active {
  transform: scale(0.98);
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-primary {
  background: linear-gradient(135deg, #f0955a, var(--accent-deep));
  color: #ffffff;
  box-shadow: 0 6px 18px rgba(210, 107, 52, 0.24);
}

.btn-soft {
  background: var(--bg-soft);
  color: var(--text-main);
  border-color: var(--border);
}

.btn-ghost {
  background: transparent;
  color: var(--text-sub);
  border-color: var(--border);
}

.btn-danger {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: rgba(217, 75, 75, 0.25);
}

.btn-sm {
  padding: 7px 11px;
  font-size: 13px;
  border-radius: 10px;
}

.btn-lg {
  padding: 14px 18px;
  font-size: 16px;
}

.btn-full {
  width: 100%;
}

.btn-icon-text {
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--text-sub);
  border-radius: var(--radius-sm);
  padding: 0 12px;
  font-size: 13px;
  font-weight: 600;
  flex-shrink: 0;
  cursor: pointer;
}

.inline-btns {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* ---------- 上传进度 ---------- */
.upload-progress {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--bg-soft);
  color: var(--accent-deep);
  font-size: 14px;
  font-weight: 600;
  text-align: center;
}

/* ---------- 照片管理列表 ---------- */
.list-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin: 18px 2px 12px;
}

.section-sub-title {
  margin: 0;
  font-size: 16px;
}

.mini-filter {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.chip {
  border: 1px solid var(--border);
  background: #ffffff;
  color: var(--text-sub);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.chip.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}

.photo-manage-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.photo-item-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 12px;
  box-shadow: 0 6px 20px rgba(140, 96, 60, 0.06);
  display: grid;
  grid-template-columns: 92px 1fr;
  gap: 12px;
  align-items: start;
}

.photo-item-thumb-btn {
  padding: 0;
  border: none;
  background: none;
  border-radius: 12px;
  overflow: hidden;
  width: 92px;
  height: 108px;
  cursor: pointer;
  position: relative;
}

.photo-item-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.photo-index-tag {
  position: absolute;
  top: 6px;
  left: 6px;
  background: rgba(45, 32, 24, 0.72);
  color: #ffffff;
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 999px;
}

.photo-item-body {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.photo-item-body .input {
  padding: 9px 10px;
  font-size: 15px;
}

.photo-item-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.photo-cat-select {
  flex: 1 1 110px;
  min-width: 105px;
}

.photo-order-btns {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.empty-box {
  background: var(--bg-card);
  border: 1px dashed var(--border);
  border-radius: var(--radius-lg);
  padding: 36px 20px;
  text-align: center;
  color: var(--text-muted);
}

/* ---------- 头像 & 标签编辑器 ---------- */
.avatar-editor {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.avatar-preview {
  width: 86px;
  height: 86px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid #ffd8b4;
  flex-shrink: 0;
}

.avatar-editor-actions {
  flex: 1;
  min-width: 200px;
}

.tag-editor-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.edit-tag-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  color: var(--text-main);
  padding: 6px 10px 6px 12px;
  border-radius: 999px;
  font-size: 14px;
}

.edit-tag-remove {
  border: none;
  background: rgba(164, 126, 92, 0.2);
  color: var(--text-main);
  width: 20px;
  height: 20px;
  border-radius: 50%;
  font-size: 13px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.tag-add-row {
  display: flex;
  gap: 8px;
}

/* ---------- 吸底保存栏 ---------- */
.save-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 35;
  background: rgba(255, 253, 249, 0.96);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--border);
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
}

.save-bar-inner {
  max-width: 860px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.save-status-text {
  font-size: 13px;
  color: var(--text-sub);
}

.save-status-text.is-dirty {
  color: var(--accent-deep);
  font-weight: 600;
}

/* ---------- 大图预览 & Toast ---------- */
.preview-modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.preview-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(26, 18, 13, 0.78);
}

.preview-box {
  position: relative;
  z-index: 1;
  max-width: 92vw;
  max-height: 86vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.preview-box img {
  max-width: 92vw;
  max-height: 74vh;
  border-radius: 16px;
  object-fit: contain;
  background: #1a120d;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(82px + env(safe-area-inset-bottom));
  transform: translate(-50%, 16px);
  z-index: 80;
  background: rgba(45, 32, 24, 0.92);
  color: #ffffff;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 500;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  max-width: 88vw;
  text-align: center;
}

.toast.is-show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.toast.is-error {
  background: rgba(196, 52, 52, 0.95);
}

@media (min-width: 640px) {
  .form-row-2 {
    grid-template-columns: 1fr 1fr;
  }

  .photo-item-card {
    grid-template-columns: 112px 1fr;
    padding: 14px;
  }

  .photo-item-thumb-btn {
    width: 112px;
    height: 118px;
  }
}
