:root {
  color-scheme: only light;
  font-family: 'Noto Sans SC', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  background-color: #f0f4fa;
}

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

body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 20% 20%, rgba(99, 166, 255, 0.2), transparent 60%),
    radial-gradient(circle at 80% 0%, rgba(167, 132, 232, 0.2), transparent 55%),
    linear-gradient(160deg, #f7faff 0%, #eef2ff 100%);
  color: #1f2933;
}

.login-wrapper {
  width: min(92vw, 380px);
  padding: 2.8rem 2.4rem;
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(12px);
  box-shadow: 0 18px 48px rgba(54, 84, 136, 0.15);
}

.login-header {
  margin-bottom: 1.4rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  text-align: center;
}

.login-title {
  font-size: 1.6rem;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.login-subtitle {
  font-size: 0.95rem;
  color: #61748f;
}

.form-group {
  margin-bottom: 1.6rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

label {
  font-size: 0.92rem;
  color: #4a5974;
}

input[type="password"] {
  height: 48px;
  border: 1px solid rgba(88, 110, 146, 0.28);
  border-radius: 12px;
  padding: 0 1rem;
  font-size: 1rem;
  color: #1f2933;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  background-color: rgba(255, 255, 255, 0.9);
}

input[type="password"]:focus {
  border-color: #688dff;
  box-shadow: 0 0 0 4px rgba(104, 141, 255, 0.22);
  outline: none;
}

button {
  width: 100%;
  height: 50px;
  border: none;
  border-radius: 14px;
  background: linear-gradient(135deg, #5d8bff 0%, #846bff 60%, #ae5aff 100%);
  color: #ffffff;
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

button:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 24px rgba(102, 125, 255, 0.22);
}

button:active {
  transform: translateY(1px);
  box-shadow: none;
}

.shake {
  animation: shake 0.42s ease;
}

@keyframes shake {
  10%,
  90% {
    transform: translateX(-2px);
  }

  20%,
  80% {
    transform: translateX(4px);
  }

  30%,
  50%,
  70% {
    transform: translateX(-6px);
  }

  40%,
  60% {
    transform: translateX(6px);
  }
}

.footer-note {
  margin-top: 1.4rem;
  font-size: 0.82rem;
  text-align: center;
  color: #8593aa;
}

.footer-note a {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s ease;
}

.footer-note a:hover {
  border-color: currentColor;
}


@media (max-width: 420px) {
  .login-wrapper {
    padding: 2.4rem 2rem;
    border-radius: 20px;
  }

  .login-title {
    font-size: 1.45rem;
  }
}

/* ==================== 消息通知样式 ==================== */

/**
 * 表单消息通知容器
 * 预定义容器，避免动态生成导致的布局变化
 */
.form-notice {
  margin-top: 12px;
  /* 预留足够空间，确保布局稳定 */
  min-height: 48px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.5;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  transition: all 0.2s ease;
  /* 确保容器始终占据空间 */
  display: flex;
  align-items: center;
}

/* 有内容时显示样式 */
.form-notice:not(:empty) {
  padding: 12px 16px;
  border: 1px solid transparent;
}

/* 消息类型样式 */
.form-notice.success {
  background: rgba(34, 197, 94, 0.1);
  border-color: rgba(34, 197, 94, 0.3);
  color: #166534;
}

.form-notice.error {
  background: rgba(239, 68, 68, 0.1);
  border-color: rgba(239, 68, 68, 0.3);
  color: #dc2626;
}

.form-notice.info {
  background: rgba(59, 130, 246, 0.1);
  border-color: rgba(59, 130, 246, 0.3);
  color: #2563eb;
}

/* 响应式调整 */
@media (max-width: 420px) {
  .form-notice:not(:empty) {
    padding: 10px 12px;
    font-size: 13px;
  }
}

/* Button + busy state tweaks */
button[disabled],
[aria-busy="true"] [type="submit"] {
  cursor: not-allowed;
  opacity: 0.85;
}

/* Prefer reduced motion users: soften shake */
@media (prefers-reduced-motion: reduce) {
  .shake { animation-duration: .2s; }
}

/* ==================== 管理页面样式 ==================== */

.admin-wrapper {
  width: min(95vw, 800px);
  max-width: 800px;
  padding: 2rem;
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(12px);
  box-shadow: 0 18px 48px rgba(54, 84, 136, 0.15);
  margin: 2rem auto;
}

.admin-header {
  text-align: center;
  margin-bottom: 2rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid rgba(88, 110, 146, 0.15);
}

.admin-title {
  font-size: 1.8rem;
  font-weight: 600;
  color: #1f2933;
  margin: 0;
}

/* ==================== 搜索功能样式 ==================== */

.search-section {
  margin-bottom: 2rem;
}

.search-container {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.search-input-group {
  position: relative;
  display: flex;
  align-items: center;
}

.search-input {
  width: 100%;
  height: 48px;
  border: 1px solid rgba(88, 110, 146, 0.28);
  border-radius: 12px;
  padding: 0 1rem;
  padding-right: 2.5rem;
  font-size: 1rem;
  color: #1f2933;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  background-color: rgba(255, 255, 255, 0.9);
}

.search-input:focus {
  border-color: #688dff;
  box-shadow: 0 0 0 4px rgba(104, 141, 255, 0.22);
  outline: none;
}

.search-clear-btn {
  position: absolute;
  right: 0.5rem;
  top: 50%;
  transform: translateY(-50%);
  width: 24px;
  height: 24px;
  border: none;
  background: rgba(107, 114, 128, 0.2);
  border-radius: 50%;
  color: #6b7280;
  font-size: 0.8rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.search-clear-btn:hover {
  background: rgba(107, 114, 128, 0.3);
  color: #374151;
  transform: translateY(-50%);
}

.search-stats {
  font-size: 0.85rem;
  color: #8593aa;
  text-align: right;
}

/* 搜索高亮样式 */
mark {
  background: rgba(255, 235, 59, 0.3);
  color: #1f2933;
  padding: 0.1em 0.2em;
  border-radius: 3px;
  font-weight: 600;
}

.add-rule-section,
.rules-section {
  margin-bottom: 2rem;
}

.add-rule-section h2,
.rules-section h2 {
  font-size: 1.3rem;
  font-weight: 600;
  color: #1f2933;
  margin-bottom: 1rem;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 2fr auto;
  gap: 1rem;
  align-items: end;
}

.form-row .form-group {
  margin-bottom: 0;
}

.form-row input {
  height: 48px;
  border: 1px solid rgba(88, 110, 146, 0.28);
  border-radius: 12px;
  padding: 0 1rem;
  font-size: 1rem;
  color: #1f2933;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  background-color: rgba(255, 255, 255, 0.9);
  width: 100%;
}

.form-row input:focus {
  border-color: #688dff;
  box-shadow: 0 0 0 4px rgba(104, 141, 255, 0.22);
  outline: none;
}

.form-row button {
  height: 48px;
  padding: 0 1.5rem;
  border: none;
  border-radius: 12px;
  background: linear-gradient(135deg, #5d8bff 0%, #846bff 60%, #ae5aff 100%);
  color: #ffffff;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
  white-space: nowrap;
}

.form-row button:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 24px rgba(102, 125, 255, 0.22);
}

.rules-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.rule-item {
  background: rgba(255, 255, 255, 0.6);
  border: 1px solid rgba(88, 110, 146, 0.15);
  border-radius: 16px;
  padding: 1.2rem;
  transition: all 0.2s ease;
  position: relative;
  padding-bottom: 2.5rem;
}

.rule-item:hover {
  background: rgba(255, 255, 255, 0.8);
  box-shadow: 0 8px 24px rgba(54, 84, 136, 0.1);
}

.rule-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 0;
  gap: 1.5rem;
}

.rule-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.rule-key {
  font-size: 1.6rem;
  font-weight: 600;
  color: #1f2933;
  margin-bottom: 0.25rem;
}

.rule-target {
  font-size: 1.2rem;
  color: #61748f;
  word-break: break-all;
  margin-bottom: 0.25rem;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
}

.clickable-target {
  cursor: pointer;
  transition: all 0.2s ease;
  border-radius: 4px;
  padding: 0.2rem 0.4rem;
  margin: -0.2rem -0.4rem;
}

.clickable-target:hover {
  background: rgba(104, 141, 255, 0.1);
  color: #2563eb;
}

.clickable-target.copy-success {
  background: rgba(34, 197, 94, 0.1);
  color: #166534;
  animation: copySuccess 0.3s ease;
}

.rule-time {
  position: absolute;
  bottom: 0.8rem;
  left: 1.2rem;
  font-size: 0.75rem;
  color: #8593aa;
  font-weight: 500;
  background: rgba(255, 255, 255, 0.8);
  padding: 0.2rem 0.5rem;
  border-radius: 6px;
  backdrop-filter: blur(4px);
  border: 1px solid rgba(88, 110, 146, 0.1);
}

.rule-item .rule-actions {
  display: flex !important;
  flex-direction: row !important;
  gap: 0.5rem;
  flex-shrink: 0;
  align-items: center;
  flex-wrap: wrap;
}

.action-btn {
  padding: 0.15rem 0.8rem;
  border: 0.5px solid;
  border-radius: 8px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  white-space: nowrap;
  justify-content: center;
  height: auto;
}

.copy-btn {
  background: rgba(34, 197, 94, 0.1);
  border-color: rgba(34, 197, 94, 0.3);
  color: #166534;
}

.copy-btn:hover {
  background: rgba(34, 197, 94, 0.2);
  transform: translateY(-1px);
}

.copy-btn.success {
  background: rgba(34, 197, 94, 0.3);
  border-color: rgba(34, 197, 94, 0.5);
  color: #166534;
  animation: copySuccess 0.3s ease;
}

@keyframes copySuccess {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.05);
  }
  100% {
    transform: scale(1);
  }
}

.qr-btn {
  background: rgba(59, 130, 246, 0.1);
  border-color: rgba(59, 130, 246, 0.3);
  color: #2563eb;
}

.qr-btn:hover {
  background: rgba(59, 130, 246, 0.2);
  transform: translateY(-1px);
}

.edit-btn {
  background: rgba(245, 158, 11, 0.1);
  border-color: rgba(245, 158, 11, 0.3);
  color: #d97706;
}

.edit-btn:hover {
  background: rgba(245, 158, 11, 0.2);
  transform: translateY(-1px);
}

.delete-btn {
  background: rgba(239, 68, 68, 0.1);
  border-color: rgba(239, 68, 68, 0.3);
  color: #dc2626;
}

.delete-btn:hover {
  background: rgba(239, 68, 68, 0.2);
  transform: translateY(-1px);
}

.qr-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

.qr-modal.show {
  opacity: 1;
  visibility: visible;
}

.qr-modal-content {
  background: white;
  border-radius: 16px;
  padding: 2rem;
  max-width: 400px;
  width: 90%;
  text-align: center;
  transform: scale(0.9);
  transition: transform 0.3s ease;
}

.qr-modal.show .qr-modal-content {
  transform: scale(1);
}

.qr-code {
  margin: 1rem 0;
}

.qr-code img {
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.qr-actions {
  display: flex;
  gap: 1rem;
  justify-content: center;
  margin-top: 1.5rem;
}

.qr-actions button {
  padding: 0.6rem 1.2rem;
  border: none;
  border-radius: 8px;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.download-btn {
  background: linear-gradient(135deg, #5d8bff 0%, #846bff 60%, #ae5aff 100%);
  color: white;
}

.download-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 16px rgba(102, 125, 255, 0.3);
}

.close-btn {
  background: #f3f4f6;
  color: #6b7280;
}

.close-btn:hover {
  background: #e5e7eb;
}

.download-tip {
  font-size: 0.8rem;
  color: #8593aa;
  text-align: center;
  margin-top: 1rem;
  font-style: italic;
}

/* ==================== 删除确认模态框样式 ==================== */

.delete-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

.delete-modal.show {
  opacity: 1;
  visibility: visible;
}

.delete-modal-content {
  background: white;
  border-radius: 12px;
  padding: 1.5rem;
  max-width: 350px;
  width: 85%;
  text-align: center;
  transform: scale(0.9);
  transition: transform 0.3s ease;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
}

.delete-modal.show .delete-modal-content {
  transform: scale(1);
}

.delete-modal h3 {
  color: #dc2626;
  margin-bottom: 0.8rem;
  font-size: 1.2rem;
}

.delete-modal p {
  margin-bottom: 0.4rem;
  color: #374151;
  font-size: 0.95rem;
}

.delete-warning {
  color: #dc2626;
  font-size: 0.85rem;
  font-weight: 500;
  margin-top: 0.5rem;
}

.delete-actions {
  display: flex;
  gap: 0.8rem;
  justify-content: center;
  margin-top: 1.2rem;
}


.delete-actions button {
  padding: 0.6rem 1.2rem;
  border: none;
  border-radius: 8px;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.delete-confirm-btn {
  background: #dc2626;
  color: white;
}

.delete-confirm-btn:hover {
  background: #b91c1c;
  transform: translateY(-1px);
}

.delete-cancel-btn {
  background: #f3f4f6;
  color: #6b7280;
}

.delete-cancel-btn:hover {
  background: #e5e7eb;
}

/* ==================== 编辑模态框样式 ==================== */

.edit-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

.edit-modal.show {
  opacity: 1;
  visibility: visible;
}

.edit-modal-content {
  background: white;
  border-radius: 16px;
  padding: 2rem;
  max-width: 500px;
  width: 90%;
  transform: scale(0.9);
  transition: transform 0.3s ease;
}

.edit-modal.show .edit-modal-content {
  transform: scale(1);
}

.edit-modal h3 {
  color: #1f2933;
  margin-bottom: 1.5rem;
  font-size: 1.3rem;
  text-align: center;
}

.edit-modal .form-group {
  margin-bottom: 1rem;
}

.edit-modal label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 500;
  color: #374151;
}

.edit-modal input {
  width: 100%;
  height: 48px;
  border: 1px solid rgba(88, 110, 146, 0.28);
  border-radius: 12px;
  padding: 0 1rem;
  font-size: 1rem;
  color: #1f2933;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  background-color: rgba(255, 255, 255, 0.9);
}

.edit-modal input:focus {
  border-color: #688dff;
  box-shadow: 0 0 0 4px rgba(104, 141, 255, 0.22);
  outline: none;
}

.edit-actions {
  display: flex;
  gap: 1rem;
  justify-content: center;
  margin-top: 1.5rem;
}

.edit-actions button {
  padding: 0.6rem 1.2rem;
  border: none;
  border-radius: 8px;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.edit-save-btn {
  background: linear-gradient(135deg, #5d8bff 0%, #846bff 60%, #ae5aff 100%);
  color: white;
}

.edit-save-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 16px rgba(102, 125, 255, 0.3);
}

.edit-cancel-btn {
  background: #f3f4f6;
  color: #6b7280;
}

.edit-cancel-btn:hover {
  background: #e5e7eb;
}

.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: #8593aa;
}

.empty-state h3 {
  font-size: 1.2rem;
  margin-bottom: 0.5rem;
  color: #61748f;
}

.empty-state p {
  font-size: 0.95rem;
}

/* ==================== 返回顶部按钮样式 ==================== */

.back-to-top-btn {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  width: 50px;
  height: 50px;
  border: none;
  border-radius: 50%;
  background: linear-gradient(135deg, #5d8bff 0%, #846bff 60%, #ae5aff 100%);
  color: white;
  font-size: 1.2rem;
  font-weight: bold;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(102, 125, 255, 0.3);
  transition: all 0.3s ease;
  z-index: 100;
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px);
}

.back-to-top-btn.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.back-to-top-btn:hover {
  transform: translateY(-3px);
  box-shadow: 0 12px 32px rgba(102, 125, 255, 0.4);
}

.back-to-top-btn:active {
  transform: translateY(-1px);
}

/* 宽屏优化 */
@media (min-width: 1200px) {
  .copy-btn,
  .qr-btn {
    padding: 0.15rem 0.8rem;
  }
}

/* 响应式设计 */
@media (max-width: 768px) {
  .admin-wrapper {
    padding: 1.5rem;
    margin: 1rem;
  }
  
  .admin-header {
    text-align: center;
  }
  
  .form-row {
    grid-template-columns: 1fr;
    gap: 1rem;
  }
  
  .rule-header {
    flex-direction: column;
    gap: 1rem;
  }
  
  .rule-actions {
    flex-direction: row;
    justify-content: flex-start;
    flex-wrap: wrap;
    align-items: center;
  }
  
  .qr-actions {
    flex-direction: column;
  }
  
  .back-to-top-btn {
    bottom: 1rem;
    right: 1rem;
    width: 45px;
    height: 45px;
    font-size: 1.1rem;
  }
}
