/* ==========================================================================
   潮匠·极链 (ChaoLink) - 现代东方雅奢 × 赛博极客设计语言
   ========================================================================== */

:root {
  /* 品牌核心主色 - 东方雅奢曜石与靛青紫 */
  --primary: #6366f1;
  --primary-rgb: 99, 102, 241;
  --primary-dark: #4f46e5;
  --primary-light: #818cf8;
  --secondary: #10b981;
  --secondary-rgb: 16, 185, 129;
  --accent: #f43f5e;
  --accent-rgb: 244, 63, 94;

  /* 背景与层次系统 (Dark Default) */
  --dark: #090d16;
  --dark-rgb: 9, 13, 22;
  --light: #f8fafc;
  --bg-main: rgba(15, 23, 42, 0.75);
  --bg-card: rgba(17, 24, 39, 0.82);
  --bg-input: rgba(10, 15, 29, 0.9);
  --bg-hover: rgba(99, 102, 241, 0.08);

  /* 文字系统 */
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  /* 边框与光晕 */
  --border-color: rgba(99, 102, 241, 0.2);
  --border-focus: rgba(99, 102, 241, 0.6);
  --card-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.5), 0 0 20px rgba(99, 102, 241, 0.08);
  --gradient-bg: radial-gradient(circle at 50% 0%, #1e1b4b 0%, #090d16 75%);
  --grid-color: rgba(99, 102, 241, 0.03);

  /* 状态反馈 */
  --error-bg: rgba(244, 63, 94, 0.12);
  --error-border: rgba(244, 63, 94, 0.4);
  --error-color: #fb7185;
  --success-bg: rgba(16, 185, 129, 0.12);
  --success-border: rgba(16, 185, 129, 0.4);
  --success-color: #34d399;

  /* 缓动与圆角 */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 9999px;
  --transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-bounce: 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

[data-theme="light"] {
  --primary: #4f46e5;
  --primary-rgb: 79, 70, 229;
  --primary-dark: #4338ca;
  --primary-light: #6366f1;
  --secondary: #059669;
  --secondary-rgb: 5, 150, 105;
  --accent: #e11d48;
  --accent-rgb: 225, 29, 72;

  --dark: #f8fafc;
  --bg-main: rgba(255, 255, 255, 0.85);
  --bg-card: rgba(255, 255, 255, 0.95);
  --bg-input: #ffffff;
  --bg-hover: rgba(79, 70, 229, 0.06);

  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;

  --border-color: rgba(79, 70, 229, 0.18);
  --border-focus: rgba(79, 70, 229, 0.5);
  --card-shadow: 0 10px 30px -10px rgba(79, 70, 229, 0.1), 0 4px 12px rgba(0, 0, 0, 0.03);
  --gradient-bg: radial-gradient(circle at 50% 0%, #e0e7ff 0%, #f8fafc 70%);
  --grid-color: rgba(79, 70, 229, 0.04);
}

/* ==========================================================================
   全局排版与重置
   ========================================================================== */

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

body {
  font-family: 'Noto Sans SC', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background-color: var(--dark);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.6;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

/* 优雅暗黑流光背景 */
.app-container {
  position: relative;
  background: var(--gradient-bg);
  min-height: 100vh;
  overflow: hidden;
}

.grid-background {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image:
    linear-gradient(var(--grid-color) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-color) 1px, transparent 1px);
  background-size: 36px 36px;
  pointer-events: none;
  z-index: 0;
}

#particles-js {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  opacity: 0.35;
  pointer-events: none;
}

/* 悬浮控制按钮组 (主题与后台入口) */
.theme-toggle,
.admin-entry-link {
  position: fixed;
  top: 1.25rem;
  z-index: 50;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: var(--radius-full);
  background: var(--bg-main);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: all var(--transition-normal);
  text-decoration: none;
}

.theme-toggle {
  right: 1.25rem;
}

.admin-entry-link {
  right: 4.25rem;
}

.theme-toggle:hover,
.admin-entry-link:hover {
  border-color: var(--primary);
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(var(--primary-rgb), 0.25);
  color: var(--primary);
}

.theme-toggle-btn {
  width: 100%;
  height: 100%;
  border: none;
  background: transparent;
  color: inherit;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ==========================================================================
   页面结构与头部
   ========================================================================== */

.content-container {
  position: relative;
  z-index: 1;
  padding: 1.5rem 1rem;
}

.main-container {
  max-width: 960px;
  margin: 0 auto;
  min-height: calc(100vh - 3rem);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.app-header {
  text-align: center;
  margin-bottom: 1.5rem;
}

.cyber-title {
  font-family: 'Orbitron', 'Noto Sans SC', sans-serif;
  font-weight: 800;
  font-size: 2.5rem;
  letter-spacing: 0.05em;
  background: linear-gradient(135deg, #ffffff 0%, #c7d2fe 50%, var(--primary) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 0.35rem;
}

[data-theme="light"] .cyber-title {
  background: linear-gradient(135deg, #0f172a 0%, #312e81 60%, var(--primary) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.app-description {
  font-size: 0.92rem;
  color: var(--text-secondary);
  letter-spacing: 0.08em;
  font-weight: 400;
}

/* ==========================================================================
   卡片组件与输入区域
   ========================================================================== */

.card {
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  box-shadow: var(--card-shadow);
  padding: 1.5rem;
  margin-bottom: 1.25rem;
  transition: border-color var(--transition-normal), box-shadow var(--transition-normal);
}

.card:hover {
  border-color: var(--border-focus);
}

#code-input-container {
  position: relative;
  width: 100%;
}

/* 语法类型徽章 */
.code-type-indicator {
  position: absolute;
  top: 12px;
  right: 14px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  background: rgba(99, 102, 241, 0.15);
  border: 1px solid rgba(99, 102, 241, 0.3);
  color: #a5b4fc;
  z-index: 20;
  pointer-events: none;
  backdrop-filter: blur(4px);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.code-type-indicator.markdown-type {
  background: rgba(16, 185, 129, 0.15);
  border-color: rgba(16, 185, 129, 0.3);
  color: #6ee7b7;
}

.code-type-indicator.json-type {
  background: rgba(245, 158, 11, 0.15);
  border-color: rgba(245, 158, 11, 0.3);
  color: #fcd34d;
}

.code-type-indicator.svg-type {
  background: rgba(236, 72, 153, 0.15);
  border-color: rgba(236, 72, 153, 0.3);
  color: #f472b6;
}

.code-type-indicator.mermaid-type {
  background: rgba(14, 165, 233, 0.15);
  border-color: rgba(14, 165, 233, 0.3);
  color: #7dd3fc;
}

/* 代码输入框 */
.cyber-input {
  width: 100%;
  min-height: 220px;
  padding: 1.25rem;
  padding-top: 2.25rem;
  background: var(--bg-input) !important;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: 'Fira Code', 'JetBrains Mono', Consolas, monospace;
  font-size: 0.9rem;
  line-height: 1.7;
  resize: vertical;
  outline: none;
  tab-size: 2;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.cyber-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.2);
}

/* ==========================================================================
   按钮与操作栏
   ========================================================================== */

.cyber-btn {
  padding: 0.65rem 1.25rem;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  transition: all var(--transition-normal);
  text-decoration: none;
  font-family: inherit;
}

.cyber-btn-primary {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.15);
  box-shadow: 0 4px 14px rgba(var(--primary-rgb), 0.35);
}

.cyber-btn-primary:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(var(--primary-rgb), 0.5);
  filter: brightness(1.05);
}

.cyber-btn-secondary {
  background: var(--bg-hover);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
}

.cyber-btn-secondary:hover:not(:disabled) {
  border-color: var(--primary);
  background: rgba(99, 102, 241, 0.12);
  color: var(--primary-light);
}

.cyber-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
}

/* 下拉选择框 */
.cyber-select {
  background: var(--bg-input);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.55rem 0.9rem;
  font-size: 0.85rem;
  outline: none;
  cursor: pointer;
  transition: border-color var(--transition-fast);
}

.cyber-select:focus {
  border-color: var(--primary);
}

/* ==========================================================================
   结果展示卡片与分享
   ========================================================================== */

.result-card {
  margin-top: 1rem;
  animation: fadeIn 0.4s var(--transition-bounce) forwards;
}

.result-container {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-input);
  border-radius: var(--radius-md);
  padding: 0.75rem 1rem;
  border: 1px solid var(--border-color);
  margin-bottom: 1rem;
}

.result-url {
  flex: 1;
  word-break: break-all;
  font-family: 'Fira Code', monospace;
  font-size: 0.88rem;
  color: var(--primary-light);
  user-select: all;
}

.action-btn {
  background: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-normal);
}

.action-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(var(--primary-rgb), 0.4);
}

/* 密码保护开关 */
.password-protection-toggle {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-top: 0.5rem;
}

.switch-container {
  position: relative;
  width: 44px;
  height: 24px;
}

.switch-checkbox {
  opacity: 0;
  width: 0;
  height: 0;
}

.switch-label {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(148, 163, 184, 0.2);
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: background-color var(--transition-normal);
  border: 1px solid var(--border-color);
}

.switch-label::before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 2px;
  bottom: 2px;
  background-color: white;
  border-radius: 50%;
  transition: transform var(--transition-normal);
}

.switch-checkbox:checked + .switch-label {
  background-color: var(--primary);
  border-color: var(--primary);
}

.switch-checkbox:checked + .switch-label::before {
  transform: translateX(20px);
}

.generated-password {
  font-family: 'Fira Code', monospace;
  font-size: 1.05rem;
  font-weight: 700;
  color: #fbbf24;
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.3);
  padding: 4px 10px;
  border-radius: var(--radius-sm);
}

/* ==========================================================================
   轻量模态 Toast 与 二维码抽屉 (Bottom Drawer)
   ========================================================================== */

.error-toast,
.success-toast {
  position: fixed;
  top: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(-20px);
  padding: 12px 20px;
  border-radius: var(--radius-md);
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  opacity: 0;
  transition: opacity 0.25s ease, transform 0.25s ease;
  z-index: 9999;
  pointer-events: none;
  font-size: 0.88rem;
  font-weight: 500;
}

.error-toast.show,
.success-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.error-toast {
  background: var(--error-bg);
  border: 1px solid var(--error-border);
  color: var(--error-color);
}

.success-toast {
  background: var(--success-bg);
  border: 1px solid var(--success-border);
  color: var(--success-color);
}

.toast-modal-content {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* 二维码居中弹窗 Modal (PC/手机居中自适应) */
.qr-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 10000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.qr-overlay.show {
  display: flex;
}

.qr-card {
  width: 100%;
  max-width: 380px;
  background: var(--bg-surface, #0f172a);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 1.75rem 1.5rem 1.5rem 1.5rem;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.65), 0 0 40px rgba(99, 102, 241, 0.15);
  animation: qrZoomIn 0.22s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  position: relative;
  text-align: center;
  margin: auto;
}

[data-theme="light"] .qr-card {
  background: #ffffff;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15), 0 0 30px rgba(99, 102, 241, 0.12);
}

@keyframes qrZoomIn {
  from {
    opacity: 0;
    transform: scale(0.92) translateY(12px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.qr-drag-handle {
  display: none;
}

.qr-card-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.8rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.qr-close {
  position: absolute;
  top: 12px;
  right: 14px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-color);
  border-radius: 50%;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  transition: all 0.2s;
}

.qr-close:hover {
  background: rgba(244, 63, 94, 0.15);
  color: #fb7185;
  border-color: rgba(244, 63, 94, 0.4);
}

#qr-container {
  background: white;
  padding: 12px;
  border-radius: 10px;
  display: inline-block;
  margin: 0.2rem auto 0.8rem;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
}

.qr-url {
  font-family: "Fira Code", "JetBrains Mono", Consolas, monospace;
  font-size: 0.8rem;
  color: var(--text-secondary);
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid var(--border-color);
  padding: 6px 10px;
  border-radius: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  margin: 0.4rem auto 0.8rem;
  user-select: all;
  cursor: pointer;
}

[data-theme="light"] .qr-url {
  background: #f1f5f9;
  color: #475569;
}

.qr-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-top: 0.8rem;
}

.qr-action-btn {
  flex: 1;
  padding: 0.65rem 1rem;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  cursor: pointer;
  font-size: 0.86rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all var(--transition-fast);
}

.qr-action-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: var(--primary);
}

.qr-action-btn.primary {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
  box-shadow: 0 2px 10px rgba(99, 102, 241, 0.3);
}

.qr-action-btn.primary:hover {
  filter: brightness(1.1);
  box-shadow: 0 4px 16px rgba(99, 102, 241, 0.45);
}


/* ==========================================================================
   通用页脚与动画
   ========================================================================== */

.app-footer {
  text-align: center;
  padding: 1.25rem 0 0.5rem;
}

.footer-text {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.footer-text a {
  color: var(--text-secondary);
  text-decoration: none;
  transition: color var(--transition-fast);
}

.footer-text a:hover {
  color: var(--primary-light);
}

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

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

.loading-indicator {
  display: none;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: var(--bg-card);
  padding: 1rem 1.5rem;
  border-radius: var(--radius-md);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  z-index: 100;
  flex-direction: column;
  align-items: center;
  backdrop-filter: blur(8px);
  border: 1px solid var(--border-color);
  font-size: 0.85rem;
}

.loading-indicator.show {
  display: flex;
}

.spinner {
  width: 28px;
  height: 28px;
  border: 2px solid rgba(var(--primary-rgb), 0.2);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 0.5rem;
}
