/* ScriptBridge 共享样式 */

:root {
  --cream: #f3efe8;
  --ink:   #1c2430;
  --coral: #f26a4f;
  --sage:  #4d7661;
  --sage-light: #618f76;
  --coral-light: #f48b73;
  --warm-white: #faf7f1;
  --muted: #6f7784;
  --border: rgba(28, 36, 48, 0.12);
  --error: #E53E3E;
  --success: #38A169;
  --r: 14px;
  --r-sm: 8px;
  --r-lg: 24px;
  --r-pill: 100px;
}

:root.theme-dark {
  --cream: #0c1420;
  --ink: #f4f7fb;
  --coral: #ff7a5f;
  --sage: #6f9f86;
  --sage-light: #88b89f;
  --coral-light: #ff9b86;
  --warm-white: #1a2634;
  --muted: #c2cedd;
  --border: rgba(244, 247, 251, 0.2);
  --error: #f87171;
  --success: #4ade80;
}

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

html {
  scroll-behavior: smooth;
}

body {
  background: var(--cream);
  color: var(--ink);
  font-family: 'DM Sans', 'Noto Sans SC', sans-serif;
  font-size: 16px;
  line-height: 1.6;
  overflow-x: hidden;
  position: relative;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(circle at 12% 8%, rgba(242, 106, 79, 0.08), transparent 32%),
    radial-gradient(circle at 88% 92%, rgba(77, 118, 97, 0.1), transparent 34%);
}

:root.theme-dark body::before {
  background:
    radial-gradient(circle at 12% 8%, rgba(255, 122, 95, 0.07), transparent 32%),
    radial-gradient(circle at 88% 92%, rgba(111, 159, 134, 0.09), transparent 34%);
}

/* ===== 导航栏 ===== */
nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  padding: 16px 40px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(250, 247, 241, 0.82);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  transition: transform 0.4s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.35s ease, background 0.2s ease, border-color 0.2s ease, padding 0.3s ease;
  will-change: transform;
}

html.nav-hidden nav {
  transform: translateY(calc(-100% - 8px));
  opacity: 0;
  pointer-events: none;
}

html.nav-compact nav {
  padding-top: 7px;
  padding-bottom: 7px;
}

html.nav-compact .nav-logo-mark {
  width: 30px;
  height: 30px;
}

html.nav-compact .nav-logo-zh {
  font-size: 15px;
}

html.nav-compact .nav-logo-en {
  font-size: 10px;
}

html.nav-compact .nav-logo-text {
  font-size: 15px;
}

html.nav-compact .lang-pill button {
  padding: 3px 9px;
  font-size: 11px;
}

html.nav-compact .theme-pill button {
  padding: 3px 7px;
  font-size: 11px;
}

html.nav-compact .btn-logout {
  padding: 6px 12px;
  font-size: 12px;
}

:root.theme-dark nav {
  background: rgba(15, 20, 27, 0.92);
}

.nav-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: var(--ink);
}

.nav-logo-mark {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  border-radius: 10px;
  overflow: hidden;
  background-color: #faf4ec;
  background-image: url('../images/scriptbridge-mark.svg');
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  box-shadow:
    0 1px 2px rgba(28, 36, 48, 0.12),
    0 4px 12px rgba(242, 106, 79, 0.28);
}

/* img tag is kept in HTML for accessibility fallback but hidden visually */
.nav-logo-mark img {
  display: none;
}

.nav-logo-text-wrap {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0;
  line-height: 1.15;
}

.nav-logo-zh {
  font-family: 'Noto Sans SC', 'PingFang SC', 'Hiragino Sans GB', sans-serif;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--ink);
}

.nav-logo-en {
  font-family: 'Fraunces', serif;
  font-size: 11px;
  font-weight: 500;
  font-style: italic;
  letter-spacing: 0.06em;
  color: var(--muted);
  text-transform: none;
}

/* Legacy single-line title (optional fallbacks) */
.nav-logo-text {
  font-family: 'Fraunces', serif;
  font-size: 18px;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -0.02em;
}

:root.theme-dark .nav-logo-zh {
  color: #f8fafc;
}

:root.theme-dark .nav-logo-en {
  color: rgba(248, 250, 252, 0.58);
}

/* 深色模式：换深色背景 + 深色 Logo */
:root.theme-dark .nav-logo-mark {
  background-color: #1e293b;
  background-image: url('../images/scriptbridge-mark-dark.svg');
  box-shadow:
    0 1px 3px rgba(0, 0, 0, 0.55),
    0 10px 28px rgba(0, 0, 0, 0.38),
    0 0 0 1px rgba(255, 255, 255, 0.13);
}

.nav-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.lang-pill {
  display: flex;
  background: #0f172a;
  border-radius: var(--r-pill);
  overflow: hidden;
  padding: 3px;
  gap: 2px;
  border: 1px solid rgba(248, 250, 252, 0.2);
}

.lang-pill button {
  border: none;
  background: transparent;
  color: rgba(248, 250, 252, 0.78);
  font-family: 'DM Sans', sans-serif;
  font-size: 12px;
  font-weight: 500;
  padding: 4px 12px;
  border-radius: var(--r-pill);
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.lang-pill button.active {
  background: var(--coral);
  color: #fff;
}

.nav-links {
  display: flex;
  gap: 20px;
  align-items: center;
}

.nav-links a {
  text-decoration: none;
  color: var(--ink);
  font-size: 14px;
  font-weight: 500;
  transition: color 0.2s;
}

.nav-links a:hover {
  color: var(--coral);
}

.btn-logout {
  background: var(--error);
  color: #fff;
  border: none;
  padding: 8px 16px;
  border-radius: var(--r-pill);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-logout:hover {
  background: #c53030;
  transform: translateY(-1px);
}

.theme-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px;
  border-radius: var(--r-pill);
  background: rgba(26, 26, 26, 0.08);
  border: 1px solid var(--border);
}

.theme-pill button {
  border: none;
  background: transparent;
  color: var(--muted);
  font-family: 'DM Sans', sans-serif;
  font-size: 12px;
  font-weight: 600;
  border-radius: var(--r-pill);
  padding: 5px 10px;
  cursor: pointer;
  transition: all 0.2s;
}

.theme-pill button.active {
  background: var(--ink);
  color: var(--cream);
}

:root.theme-dark .theme-pill {
  background: rgba(255, 255, 255, 0.06);
}

:root.theme-dark .theme-pill button.active {
  background: var(--coral);
  color: #fff;
}

/* ===== 按钮 ===== */
.btn {
  border: none;
  border-radius: var(--r);
  font-family: 'DM Sans', sans-serif;
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  padding: 12px 24px;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn-primary {
  background: linear-gradient(140deg, #416852 0%, #4d7661 100%);
  color: #fff;
}

.btn-primary:hover {
  background: var(--sage-light);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(61, 107, 79, 0.2);
}

.btn-secondary {
  background: linear-gradient(140deg, #e86045 0%, #f26a4f 100%);
  color: #fff;
}

.btn-secondary:hover {
  background: var(--coral-light);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(255, 77, 46, 0.2);
}

.btn-outline {
  background: rgba(255, 255, 255, 0.46);
  color: var(--ink);
  border: 1px solid var(--border);
}

.btn-outline:hover {
  background: rgba(255, 255, 255, 0.72);
}

:root.theme-dark .btn-outline {
  background: rgba(255, 255, 255, 0.07);
  border-color: rgba(244, 247, 251, 0.28);
  color: #f4f7fb;
}

:root.theme-dark .btn-outline:hover {
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(244, 247, 251, 0.45);
}

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

/* ===== 表单 ===== */
.form-group {
  margin-bottom: 20px;
}

/* 仅字段标题：避免套在卡片选项、版权行里的 label 继承成「整页小标题」样式 */
.form-group > label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--ink);
}

.form-group input:not([type="radio"]):not([type="checkbox"]),
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: var(--r);
  font-family: 'DM Sans', sans-serif;
  font-size: 16px;
  color: var(--ink);
  background: var(--warm-white);
  transition: all 0.2s;
}

.form-group input[type="radio"],
.form-group input[type="checkbox"] {
  width: auto;
  max-width: none;
  margin: 0;
  padding: 0;
  border: none;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  font: inherit;
  color: inherit;
}

.form-group input[type="checkbox"] {
  width: 1.15rem;
  height: 1.15rem;
  min-width: 1.15rem;
  flex-shrink: 0;
  accent-color: var(--coral);
  cursor: pointer;
  vertical-align: top;
}

.form-group input:not([type="radio"]):not([type="checkbox"]):focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--coral);
  box-shadow: 0 0 0 3px rgba(255, 77, 46, 0.1);
}

.form-group textarea {
  resize: vertical;
  min-height: 100px;
}

.form-group input:not([type="radio"]):not([type="checkbox"])::placeholder,
.form-group textarea::placeholder {
  color: var(--muted);
  opacity: 1;
}

:root.theme-dark .form-group input:not([type="radio"]):not([type="checkbox"])::placeholder,
:root.theme-dark .form-group textarea::placeholder {
  color: #94a3b8;
  opacity: 1;
}

/* ===== 暗色模式全局增强（业务页面） ===== */
:root.theme-dark .auth-card,
:root.theme-dark .upload-card,
:root.theme-dark .list-card,
:root.theme-dark .filters-card,
:root.theme-dark .detail-content,
:root.theme-dark .error-state,
:root.theme-dark .metric-card,
:root.theme-dark .section-card {
  background: rgba(30, 41, 59, 0.82) !important;
  border-color: rgba(248, 250, 252, 0.2) !important;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.42) !important;
  backdrop-filter: blur(14px) !important;
}

:root.theme-dark .inquiry-item {
  background: rgba(15, 23, 42, 0.72) !important;
  border-color: rgba(248, 250, 252, 0.16) !important;
}

:root.theme-dark .section-title {
  color: #f1f5f9 !important;
}

:root.theme-dark .section-card .empty {
  color: #94a3b8 !important;
}

:root.theme-dark .form-group > label,
:root.theme-dark .switch-link,
:root.theme-dark .description-label,
:root.theme-dark .profile-field label,
:root.theme-dark .script-card-author,
:root.theme-dark .script-date,
:root.theme-dark .preview-meta,
:root.theme-dark .loading-row,
:root.theme-dark .loading-state,
:root.theme-dark .empty-state,
:root.theme-dark .muted,
:root.theme-dark .nav-user-menu {
  color: #cbd5e1 !important;
}

:root.theme-dark .auth-card h1,
:root.theme-dark .auth-card p,
:root.theme-dark .detail-title,
:root.theme-dark .description-text,
:root.theme-dark .preview-body,
:root.theme-dark .scripts-table td,
:root.theme-dark .scripts-table th,
:root.theme-dark .script-card-title,
:root.theme-dark .list-header h1,
:root.theme-dark .browse-header h1,
:root.theme-dark .upload-header h1 {
  color: #f8fafc !important;
}

:root.theme-dark .form-group input:not([type="radio"]):not([type="checkbox"]),
:root.theme-dark .form-group textarea,
:root.theme-dark .form-group select,
:root.theme-dark .filters-card input,
:root.theme-dark .filters-card select,
:root.theme-dark .signup-input {
  background: rgba(255, 255, 255, 0.1) !important;
  border-color: rgba(248, 250, 252, 0.28) !important;
  color: #f8fafc !important;
}

:root.theme-dark .role-option label,
:root.theme-dark .rights-option label {
  background: rgba(255, 255, 255, 0.08) !important;
  border-color: rgba(248, 250, 252, 0.24) !important;
  color: #e2e8f0 !important;
}

:root.theme-dark .form-group input[type="checkbox"] {
  background: rgba(255, 255, 255, 0.12) !important;
  border-color: rgba(248, 250, 252, 0.35) !important;
}

:root.theme-dark .switch-link a,
:root.theme-dark .back-link,
:root.theme-dark .auth-nav-links a {
  color: #f8fafc !important;
  border-bottom-color: rgba(248, 250, 252, 0.55) !important;
}

:root.theme-dark .scripts-table th,
:root.theme-dark .scripts-table td {
  border-bottom-color: rgba(248, 250, 252, 0.2) !important;
}

:root.theme-dark .preview-content,
:root.theme-dark .list-card,
:root.theme-dark .profile-section,
:root.theme-dark .action-card,
:root.theme-dark .script-card,
:root.theme-dark .market-small-card,
:root.theme-dark .hero-stat {
  background: #1e293b !important;
  border-color: rgba(248, 250, 252, 0.24) !important;
}

:root.theme-dark .action-card-desc,
:root.theme-dark .action-card-title,
:root.theme-dark .profile-field p {
  color: #f8fafc !important;
}

.form-error {
  color: var(--error);
  font-size: 13px;
  margin-top: 6px;
}

.form-success {
  color: var(--success);
  font-size: 13px;
  margin-top: 6px;
}

/* ===== 卡片 ===== */
.card {
  background: rgba(250, 247, 241, 0.8);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 24px;
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.08);
  backdrop-filter: blur(10px);
}

:root.theme-dark .card {
  background: rgba(30, 41, 59, 0.82);
  border-color: rgba(248, 250, 252, 0.2);
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.42);
}

.card-header {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 16px;
  color: var(--ink);
}

/* ===== 容器 ===== */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 40px;
}

.page-wrapper {
  min-height: 100vh;
  padding: 100px 40px 80px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.auth-container {
  width: 100%;
  max-width: 400px;
  margin: 0 auto;
}

/* ===== 加载状态 ===== */
.loading {
  opacity: 0.6;
  pointer-events: none;
}

.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 3px solid var(--border);
  border-top-color: var(--coral);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* ===== 提示消息 ===== */
.alert {
  padding: 12px 16px;
  border-radius: var(--r);
  font-size: 14px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.alert-error {
  background: rgba(229, 62, 62, 0.1);
  color: var(--error);
  border: 1px solid rgba(229, 62, 62, 0.3);
}

.alert-success {
  background: rgba(56, 161, 105, 0.1);
  color: var(--success);
  border: 1px solid rgba(56, 161, 105, 0.3);
}

/* ===== 响应式 ===== */
@media (max-width: 768px) {
  nav {
    padding: 10px 14px;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
  }

  .nav-logo {
    gap: 8px;
    min-width: 0;
  }

  .nav-logo-mark {
    width: 28px;
    height: 28px;
    font-size: 14px;
    flex-shrink: 0;
  }

  .nav-logo-text {
    font-size: 16px;
    line-height: 1.2;
  }

  .nav-right {
    gap: 8px;
    width: 100%;
    flex-wrap: nowrap;
    justify-content: flex-end;
  }

  .page-wrapper {
    padding: 74px 14px 48px;
  }

  .container {
    padding: 0 14px;
  }

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

  .card {
    padding: 16px;
  }

  .auth-container {
    max-width: 100%;
  }

  .lang-pill button {
    padding: 4px 10px;
  }

  .theme-pill button {
    padding: 4px 8px;
  }
}

@media (max-width: 480px) {
  body {
    font-size: 15px;
  }

  .btn {
    min-height: 42px;
    font-size: 13.5px;
  }

  .form-group {
    margin-bottom: 14px;
  }

  .form-group input:not([type="radio"]):not([type="checkbox"]),
  .form-group select,
  .form-group textarea {
    padding: 10px 12px;
    font-size: 15px;
  }

  .lang-pill button {
    padding: 2px 7px;
    font-size: 11px;
  }

  .theme-pill button {
    padding: 2px 6px;
    font-size: 11px;
  }

  .btn-logout {
    padding: 6px 12px;
    font-size: 12px;
  }
}

/* ===== 深色模式：页面内联浅色块（marketplace / script-detail 等）===== */
:root.theme-dark .browse-header p {
  color: #94a3b8 !important;
}

:root.theme-dark .empty-state {
  background: rgba(30, 41, 59, 0.88) !important;
  border-color: rgba(248, 250, 252, 0.22) !important;
  color: #e2e8f0 !important;
}

:root.theme-dark .license-extra-panel {
  background: rgba(15, 23, 42, 0.88) !important;
  border-color: rgba(248, 250, 252, 0.18) !important;
  color: #e2e8f0 !important;
}

:root.theme-dark .license-extra-panel #script-region,
:root.theme-dark .license-extra-panel #script-rights-years {
  color: #f8fafc !important;
}

:root.theme-dark .inquiry-modal-panel {
  background: rgba(30, 41, 59, 0.96) !important;
  border: 1px solid rgba(248, 250, 252, 0.2) !important;
  color: #e2e8f0 !important;
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.45);
}

:root.theme-dark .inquiry-modal-panel h3 {
  color: #f8fafc !important;
}

:root.theme-dark #inquiry-message {
  background: rgba(15, 23, 42, 0.65) !important;
  border-color: rgba(248, 250, 252, 0.22) !important;
  color: #f1f5f9 !important;
}

:root.theme-dark .detail-meta-row {
  border-bottom-color: rgba(248, 250, 252, 0.12) !important;
}

:root.theme-dark .detail-price-box {
  background: rgba(15, 23, 42, 0.55) !important;
  border-color: rgba(134, 239, 172, 0.28) !important;
}

:root.theme-dark .script-type-pill {
  background: rgba(61, 107, 79, 0.32) !important;
  color: #bbf7d0 !important;
}

:root.theme-dark .price-value {
  color: #86efac !important;
}

:root.theme-dark .rights-badge {
  background: rgba(242, 106, 79, 0.22) !important;
  color: #fecaca !important;
}

:root.theme-dark #preview-text {
  background: rgba(15, 23, 42, 0.72) !important;
  border-color: rgba(248, 250, 252, 0.18) !important;
  color: #e2e8f0 !important;
}

/* ===== 工具类 ===== */
.text-center {
  text-align: center;
}

.text-muted {
  color: var(--muted);
}

.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mt-4 { margin-top: 32px; }

.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.mb-4 { margin-bottom: 32px; }

.gap-1 { gap: 8px; }
.gap-2 { gap: 16px; }
.gap-3 { gap: 24px; }

/* ===== 语言切换 ===== */
.en-only {
  display: inline-block;
}

.zh-only {
  display: none;
}

body.zh .en-only {
  display: none !important;
}

body.zh .zh-only {
  display: inline-block;
}
