/* ============================================
   以诺AI文案助手 · 现代化 UI 样式
   设计：深红色品牌色 + 干净卡片风格
   移动端优先
   ============================================ */

/* ---- 变量 ---- */
:root {
  --p: #bf3b50;
  --ph: #a83045;
  --p-light: #fff5f5;
  --p-ghost: rgba(191, 59, 80, 0.08);
  --sb-bg: #111118;
  --sb-w: 240px;
  --bg: #f5f6f8;
  --c: #ffffff;
  --t: #0f141e;
  --ts: #5c6b7a;
  --tl: #97a6b3;
  --b: #e2e6ed;
  --br: 10px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 1px 3px rgba(0, 0, 0, 0.04), 0 6px 24px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 38px rgba(0, 0, 0, 0.1), 0 2px 8px rgba(0, 0, 0, 0.04);
  --radius: 10px;
  --radius-sm: 7px;
  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html { height: 100%; }

body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "PingFang SC",
    "Noto Sans SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--t);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

/* ---- Sidebar ---- */
.sb {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sb-w);
  height: 100vh;
  background: var(--sb-bg);
  display: flex;
  flex-direction: column;
  z-index: 1000;
  transition: transform var(--transition);
}

.sb-brand {
  padding: 22px 18px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.sb-logo {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  flex-shrink: 0;
  background: linear-gradient(135deg, var(--p), #7d2535);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 16px;
}

.sb-title {
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  line-height: 1.3;
}

.sb-subtitle {
  font-size: 9px;
  color: rgba(255, 255, 255, 0.3);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.sb-nav {
  padding: 8px 8px;
  flex: 1;
  overflow-y: auto;
}

.sb-nav a {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 6px;
  color: rgba(255, 255, 255, 0.4);
  font-size: 12px;
  text-decoration: none;
  transition: all 0.15s ease;
  margin-bottom: 1px;
}

.sb-nav a:hover {
  background: rgba(255, 255, 255, 0.05);
  color: rgba(255, 255, 255, 0.7);
}

.sb-nav a.active {
  background: rgba(191, 59, 80, 0.15);
  color: #fff;
  font-weight: 500;
}

.sb-user {
  padding: 12px 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  display: flex;
  align-items: center;
  gap: 8px;
}

.sb-avatar {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  flex-shrink: 0;
  background: linear-gradient(135deg, var(--p), #1a1a3e);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 11px;
  font-weight: 600;
}

.sb-user-name {
  font-size: 11px;
  font-weight: 500;
  color: #fff;
}

.sb-user-role {
  font-size: 9px;
  color: rgba(255, 255, 255, 0.3);
}

.sb-logout {
  width: 24px;
  height: 24px;
  border-radius: 5px;
  border: none;
  margin-left: auto;
  background: rgba(255, 255, 255, 0.06);
  color: rgba(255, 255, 255, 0.4);
  cursor: pointer;
  font-size: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  transition: all 0.15s;
}

.sb-logout:hover {
  background: rgba(191, 59, 80, 0.2);
  color: #fff;
}

/* ---- Hamburger toggle (mobile) ---- */
.sb-toggle {
  display: none;
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 1001;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: none;
  background: var(--c);
  color: var(--t);
  font-size: 18px;
  cursor: pointer;
  box-shadow: var(--shadow-md);
  transition: var(--transition);
  align-items: center;
  justify-content: center;
}

.sb-toggle:hover {
  box-shadow: var(--shadow-lg);
}

.sb-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.4);
  z-index: 999;
  opacity: 0;
  transition: opacity 0.25s ease;
}

/* ---- Main Content ---- */
.main {
  margin-left: var(--sb-w);
  flex: 1;
  min-height: 100vh;
  max-width: 860px;
}

.header {
  padding: 32px 40px 0;
}

.header h1 {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 8px;
}

.header p {
  font-size: 12px;
  color: var(--ts);
  margin-top: 2px;
  margin-bottom: 8px;
  line-height: 1.5;
}

.body {
  padding: 24px 40px 40px;
}

/* ---- Card ---- */
.card {
  background: var(--c);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 24px;
  margin-bottom: 14px;
  transition: box-shadow 0.2s;
}

.card-header {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--b);
}

.card-icon {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  flex-shrink: 0;
  background: var(--p-light);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--p);
  font-size: 13px;
}

.card-header h3 {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

/* ---- Tip Banner ---- */
.tip-banner {
  background: #fff8e1;
  border: 1.5px solid #ffe69c;
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 16px;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 12px;
  color: #664d03;
  line-height: 1.5;
}

.tip-banner .tip-icon {
  flex-shrink: 0;
  font-size: 15px;
  margin-top: 1px;
}

/* ---- Progress Bar ---- */
.progress-bar {
  border-radius: 8px;
  overflow: hidden;
  background: var(--c);
  box-shadow: var(--shadow-md);
  display: flex;
  margin-bottom: 20px;
  position: relative;
}

.progress-track {
  position: absolute;
  top: 0;
  left: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--p), #e06074);
  transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  width: 0%;
  z-index: 1;
}

.progress-step {
  flex: 1;
  padding: 12px 12px;
  display: flex;
  align-items: center;
  gap: 9px;
  position: relative;
  z-index: 2;
  opacity: 0.35;
  transition: all 0.3s ease;
}

.progress-step.active { opacity: 1; }
.progress-step.done { opacity: 0.55; }

.progress-step + .progress-step::before {
  content: "";
  position: absolute;
  left: 0;
  top: 14px;
  bottom: 14px;
  width: 1px;
  background: var(--b);
}

.progress-circle {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 600;
  background: var(--bg);
  color: var(--ts);
  transition: all 0.3s;
}

.progress-step.active .progress-circle {
  background: var(--p);
  color: #fff;
  box-shadow: 0 0 0 3px rgba(191, 59, 80, 0.15);
}

.progress-step.done .progress-circle {
  background: #10b981;
  color: #fff;
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.15);
}

.progress-label {
  font-size: 11px;
  color: var(--ts);
  line-height: 1.3;
}

.progress-label b {
  display: block;
  font-size: 12px;
  color: var(--t);
  font-weight: 500;
  margin-bottom: 1px;
}

.progress-step.active .progress-label b {
  color: var(--p);
}

/* ---- Form Groups ---- */
.form-group {
  margin-bottom: 16px;
}

.form-group:last-child {
  margin-bottom: 0;
}

.form-label {
  display: block;
  margin-bottom: 5px;
  font-size: 11px;
  font-weight: 500;
  color: var(--ts);
  letter-spacing: 0.02em;
}

.form-label .optional {
  font-weight: 400;
  color: var(--tl);
}

.form-input,
.form-textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1.5px solid var(--b);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: inherit;
  color: var(--t);
  background: var(--c);
  outline: none;
  transition: border-color 0.18s, box-shadow 0.18s;
  line-height: 1.5;
}

.form-textarea {
  height: 76px;
  resize: vertical;
}

.form-input:focus,
.form-textarea:focus {
  border-color: var(--p);
  box-shadow: 0 0 0 3px rgba(191, 59, 80, 0.1);
}

.form-input::placeholder,
.form-textarea::placeholder {
  color: var(--tl);
}

.form-hint {
  font-size: 11px;
  color: var(--tl);
  margin-top: 4px;
  line-height: 1.4;
}

/* ---- Custom Dropdown ---- */
.dropdown {
  position: relative;
}

.dropdown-trigger {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  border: 1.5px solid var(--b);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  color: var(--tl);
  background: var(--c);
  transition: border-color 0.18s;
  user-select: none;
}

.dropdown-trigger.selected {
  color: var(--t);
}

.dropdown-trigger .arrow {
  margin-left: auto;
  width: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.25s;
  color: var(--tl);
}

.dropdown-trigger.open .arrow {
  transform: rotate(180deg);
}

.dropdown-trigger:hover {
  border-color: #8b9baa;
}

.dropdown-trigger.open {
  border-color: var(--p);
  box-shadow: 0 0 0 3px rgba(191, 59, 80, 0.1);
}

.dropdown-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--c);
  border: 1.5px solid var(--b);
  border-radius: 8px;
  box-shadow: var(--shadow-lg);
  z-index: 50;
  display: none;
  overflow: hidden;
  max-height: 340px;
  overflow-y: auto;
}

.dropdown-menu.show {
  display: block;
  animation: dropIn 0.2s ease;
}

@keyframes dropIn {
  from {
    opacity: 0;
    transform: translateY(-5px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.dropdown-group {
  padding: 6px 8px;
}

.dropdown-group-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--ts);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 6px 8px 4px;
  position: sticky;
  top: 0;
  background: var(--c);
  z-index: 1;
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px 8px;
  border-radius: 5px;
  cursor: pointer;
  font-size: 13px;
  color: var(--t);
  transition: background 0.1s;
}

.dropdown-item:hover {
  background: var(--bg);
}

.dropdown-item.selected {
  background: var(--p-light);
  color: var(--p);
  font-weight: 500;
}

/* ---- Pills / Tags ---- */
.pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
  min-height: 26px;
}

.pill {
  padding: 5px 11px;
  border-radius: 14px;
  font-size: 11px;
  font-family: inherit;
  background: #f6f7f9;
  border: 1.5px solid var(--b);
  color: var(--t);
  cursor: pointer;
  transition: all 0.15s;
  line-height: 1.4;
}

.pill:hover {
  border-color: var(--p);
  color: var(--p);
  background: var(--p-light);
}

.pill.active {
  background: var(--p);
  border-color: var(--p);
  color: #fff;
}

.pill.loading {
  opacity: 0.5;
  cursor: default;
}

.pill-spacer {
  font-size: 11px;
  color: var(--tl);
  padding: 5px 0;
}

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 9px 18px;
  background: linear-gradient(135deg, var(--p), var(--ph));
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  transition: opacity 0.15s, transform 0.08s, box-shadow 0.15s;
  line-height: 1;
  box-shadow: 0 1px 3px rgba(191, 59, 80, 0.2);
}

.btn:hover {
  opacity: 0.9;
  box-shadow: 0 2px 8px rgba(191, 59, 80, 0.25);
}

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

.btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-ghost {
  background: transparent;
  color: var(--ts);
  border: 1.5px solid var(--b);
  box-shadow: none;
}

.btn-ghost:hover {
  background: var(--bg);
  opacity: 1;
  box-shadow: none;
}

.btn-tiny {
  padding: 4px 8px;
  font-size: 10px;
  border-radius: 5px;
  background: transparent;
  color: var(--ts);
  border: 1.5px solid var(--b);
}

.btn-tiny:hover {
  background: var(--bg);
  opacity: 1;
}

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

.btn-danger {
  background: #dc3545;
  box-shadow: 0 1px 3px rgba(220, 53, 69, 0.2);
}

.btn-danger:hover {
  background: #b8252f;
  box-shadow: 0 2px 8px rgba(220, 53, 69, 0.25);
}

.btn-block {
  width: 100%;
  justify-content: center;
  padding: 11px;
  font-size: 14px;
}

/* ---- Result Window ---- */
.result-wrap {
  border: 1.5px solid var(--b);
  border-radius: 8px;
  overflow: hidden;
  margin-top: 8px;
  animation: dropIn 0.2s ease;
}

.result-wrap.hidden {
  display: none;
}

.result-header {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 10px 14px;
  background: #fafbfc;
  font-size: 11px;
  font-weight: 500;
  color: var(--ts);
  border-bottom: 1px solid var(--b);
}

.result-body {
  padding: 16px;
  white-space: pre-wrap;
  line-height: 1.8;
  font-size: 13px;
  color: var(--t);
  min-height: 50px;
}

.result-body.loading {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ts);
  font-size: 12px;
}

.spinner {
  width: 15px;
  height: 15px;
  border: 2px solid var(--b);
  border-top-color: var(--p);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  flex-shrink: 0;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ---- Toast ---- */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #1a1f2e;
  color: #fff;
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 12px;
  display: none;
  z-index: 9999;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.18);
  animation: toastIn 0.25s ease;
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ---- Login Page ---- */
.login-page {
  background: var(--bg);
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  background-image: radial-gradient(ellipse 35% 55% at 0% 50%, hsla(348, 50%, 55%, 0.07) 0%, transparent 60%),
    radial-gradient(ellipse 45% 65% at 100% 30%, hsla(240, 4%, 10%, 0.03) 0%, transparent 60%);
}

.login-card {
  background: var(--c);
  padding: 48px 40px 40px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  width: 400px;
  max-width: 92vw;
}

.login-brand {
  text-align: center;
  margin-bottom: 28px;
}

.login-logo {
  width: 46px;
  height: 46px;
  margin: 0 auto 12px;
  background: linear-gradient(135deg, var(--p) 0%, #8a2435 100%);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 20px;
  box-shadow: 0 2px 8px rgba(191, 59, 80, 0.2);
}

.login-brand h1 {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.login-brand p {
  font-size: 14px;
  color: var(--ts);
  margin-top: 3px;
}

.login-field {
  margin-bottom: 20px;
}

.login-field label {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  font-weight: 500;
}

.login-field input {
  width: 100%;
  padding: 10px 13px;
  border: 1.5px solid var(--b);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  color: var(--t);
  background: var(--c);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.login-field input:focus {
  border-color: var(--p);
  box-shadow: 0 0 0 3px rgba(191, 59, 80, 0.1);
}

.login-field input::placeholder {
  color: var(--tl);
}

.login-error {
  background: var(--p-light);
  border: 1px solid #fecaca;
  color: #b91c1c;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  text-align: center;
  margin-bottom: 20px;
}

.login-footer {
  text-align: center;
  margin-top: 24px;
  font-size: 13px;
  color: var(--ts);
}

.login-footer a {
  color: var(--p);
  text-decoration: none;
  font-weight: 500;
}

.login-footer a:hover {
  text-decoration: underline;
}

/* ---- Tables ---- */
.table-wrap {
  overflow-x: auto;
  margin-top: 4px;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th {
  padding: 9px 12px;
  font-size: 10px;
  font-weight: 600;
  color: var(--ts);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 2px solid var(--b);
  text-align: left;
  white-space: nowrap;
}

td {
  padding: 9px 12px;
  font-size: 13px;
  border-bottom: 1px solid var(--b);
}

tr:hover td {
  background: #f8f9fb;
}

.badge-admin {
  background: var(--p-light);
  color: var(--p);
  padding: 1px 8px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 500;
  display: inline-block;
}

.badge-user {
  background: var(--bg);
  color: var(--ts);
  padding: 1px 8px;
  border-radius: 10px;
  font-size: 10px;
  display: inline-block;
}

/* ---- Add Row (Admin) ---- */
.add-row {
  display: flex;
  gap: 10px;
  margin-bottom: 18px;
  flex-wrap: wrap;
  align-items: end;
}

.add-row .field {
  display: flex;
  flex-direction: column;
  min-width: 130px;
}

.add-row .field label {
  font-size: 11px;
  margin-bottom: 4px;
  color: var(--ts);
  font-weight: 500;
}

.add-row .field input,
.add-row .field select {
  padding: 8px 11px;
  border: 1.5px solid var(--b);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: inherit;
  color: var(--t);
  background: var(--c);
  outline: none;
  transition: border-color 0.18s, box-shadow 0.18s;
}

.add-row .field input:focus,
.add-row .field select:focus {
  border-color: var(--p);
  box-shadow: 0 0 0 3px rgba(191, 59, 80, 0.1);
}

/* ---- Scrollbar ---- */
::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--b);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--tl);
}

/* ============================================
   移动端适配
   ============================================ */

@media (max-width: 768px) {
  /* 侧栏：默认隐藏，通过 toggle 显示 */
  .sb {
    transform: translateX(-100%);
  }

  .sb.open {
    transform: translateX(0);
  }

  .sb-toggle {
    display: flex;
  }

  .sb-overlay.active {
    display: block;
    opacity: 1;
  }

  .main {
    margin-left: 0;
  }

  .header {
    padding: 56px 16px 0;
  }

  .header h1 {
    font-size: 17px;
  }

  .body {
    padding: 16px;
  }

  .card {
    padding: 18px;
  }

  /* 进度条在手机上更紧凑 */
  .progress-step {
    padding: 10px 8px;
    flex-direction: column;
    text-align: center;
    gap: 5px;
  }

  .progress-step + .progress-step::before {
    display: none;
  }

  .progress-label {
    font-size: 10px;
  }

  .progress-label b {
    font-size: 11px;
  }

  /* 登录卡片 */
  .login-card {
    padding: 36px 24px 32px;
  }

  /* Toast 在手机上居中 */
  .toast {
    bottom: 16px;
    right: 16px;
    left: 16px;
    text-align: center;
  }

  /* 管理面板添加行 */
  .add-row .field {
    min-width: 100%;
  }

  /* 手机端导航按钮不再过度 padding */
  .sb-nav a {
    padding: 10px 12px;
    font-size: 13px;
  }
}

@media (max-width: 480px) {
  .header {
    padding: 56px 12px 0;
  }

  .body {
    padding: 12px;
  }

  .card {
    padding: 14px;
  }

  .progress-bar {
    flex-direction: column;
  }

  .progress-step {
    flex-direction: row;
    text-align: left;
  }
}
