/* ==========================================================================
   API Hub · 接口导航
   纯白纯黑高对比度极简样式表 (自动适配系统深浅色模式)
   ========================================================================== */

/* 1. CSS Reset & 基础设置 */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "WenQuanYi Micro Hei", sans-serif;
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* 2. 颜色变量：默认纯白浅色模式 */
:root {
  --bg: #ffffff;
  --text-main: #000000;
  --text-muted: #666666;
  --text-sub: #999999;
  --card-bg: #ffffff;
  --card-hover-bg: #fafafa;
  --border-color: #e4e4e7;
  --border-hover: #000000;
  --badge-bg: #f4f4f5;
  --badge-text: #52525b;
  --badge-border: #e4e4e7;
  --btn-primary-bg: #000000;
  --btn-primary-text: #ffffff;
  --btn-primary-hover: #27272a;
  --btn-sec-bg: #f4f4f5;
  --btn-sec-text: #18181b;
  --btn-sec-border: #e4e4e7;
  --btn-sec-hover: #ebebeb;
  --header-bg: rgba(255, 255, 255, 0.85);
  --input-bg: #ffffff;
  --input-border: #d4d4d8;
  --input-focus: #000000;
  --toast-bg: #000000;
  --toast-text: #ffffff;
  --shadow-card: 0 4px 16px rgba(0, 0, 0, 0.04);
  color-scheme: light dark;
}

/* 自动适配深色模式 (系统设置深色时自动切换为纯黑模式) */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --text-main: #ffffff;
    --text-muted: #888888;
    --text-sub: #555555;
    --card-bg: #09090b;
    --card-hover-bg: #121215;
    --border-color: #222225;
    --border-hover: #666670;
    --badge-bg: #141416;
    --badge-text: #999999;
    --badge-border: #26262a;
    --btn-primary-bg: #ffffff;
    --btn-primary-text: #000000;
    --btn-primary-hover: #e4e4e7;
    --btn-sec-bg: #141416;
    --btn-sec-text: #cccccc;
    --btn-sec-border: #27272a;
    --btn-sec-hover: #1f1f23;
    --header-bg: rgba(0, 0, 0, 0.85);
    --input-bg: #09090b;
    --input-border: #26262a;
    --input-focus: #71717a;
    --toast-bg: #ffffff;
    --toast-text: #000000;
    --shadow-card: 0 4px 16px rgba(0, 0, 0, 0.5);
  }
}

body {
  background-color: var(--bg);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: background-color 0.2s ease, color 0.2s ease;
}

/* 3. 两边不贴边：居中容器与自适应安全边距 */
.container {
  width: 100%;
  max-width: 1320px;
  margin-left: auto;
  margin-right: auto;
  padding-left: 16px;
  padding-right: 16px;
}

@media (min-width: 640px) {
  .container {
    padding-left: 24px;
    padding-right: 24px;
  }
}

@media (min-width: 1024px) {
  .container {
    padding-left: 32px;
    padding-right: 32px;
  }
}

/* 4. 顶部导航栏 (极简设计) */
header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--header-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  transition: background-color 0.2s ease, border-color 0.2s ease;
}

.header-inner {
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo-area {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: inherit;
}

.logo-badge {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--text-main);
  color: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 13px;
  letter-spacing: 0.5px;
  border: 1px solid var(--border-color);
}

.logo-title-wrap {
  display: flex;
  flex-direction: column;
}

.logo-title {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.3px;
}

.logo-subtitle {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 1px;
}

@media (max-width: 600px) {
  .logo-subtitle {
    display: none;
  }
}

/* 5. 主体内容布局 */
main {
  flex: 1;
  padding-top: 28px;
  padding-bottom: 50px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* 控制栏：标题与搜索框 */
.controls-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.search-title-row {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

@media (min-width: 768px) {
  .search-title-row {
    flex-direction: row;
    align-items: flex-end;
    justify-content: space-between;
  }
}

.page-title {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.5px;
}

@media (min-width: 640px) {
  .page-title {
    font-size: 28px;
  }
}

.page-desc {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
}

.search-box-wrap {
  position: relative;
  width: 100%;
}

@media (min-width: 768px) {
  .search-box-wrap {
    width: 320px;
  }
}

@media (min-width: 1024px) {
  .search-box-wrap {
    width: 360px;
  }
}

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--text-muted);
  pointer-events: none;
}

.search-input {
  width: 100%;
  padding: 10px 36px 10px 36px;
  font-size: 13px;
  font-weight: 500;
  background: var(--input-bg);
  color: var(--text-main);
  border: 1px solid var(--input-border);
  border-radius: 12px;
  outline: none;
  transition: all 0.15s ease;
}

.search-input:focus {
  border-color: var(--input-focus);
  box-shadow: 0 0 0 1px var(--input-focus);
}

.search-clear-btn {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  display: none;
  padding: 2px;
}

.search-clear-btn.visible {
  display: flex;
}

/* 6. 响应式卡片网格 (适配手机与电脑端，两边不贴边) */
.card-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

@media (min-width: 600px) {
  .card-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
  }
}

@media (min-width: 960px) {
  .card-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 18px;
  }
}

@media (min-width: 1240px) {
  .card-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
  }
}

/* 单个接口卡片 */
.api-card {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 16px;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: var(--shadow-card);
}

.api-card:hover {
  transform: translateY(-2px);
  border-color: var(--border-hover);
  background: var(--card-hover-bg);
}

.card-badges {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.badge {
  font-size: 10px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 6px;
  border: 1px solid var(--badge-border);
  background: var(--badge-bg);
  color: var(--badge-text);
  letter-spacing: 0.5px;
}

.badge-proto.https {
  color: var(--text-main);
}

.badge-proto.http {
  opacity: 0.7;
}

.card-title {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.2px;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-url {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 5px;
  font-size: 11px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  color: var(--text-muted);
  overflow: hidden;
}

.icon-link {
  width: 12px;
  height: 12px;
  flex-shrink: 0;
  opacity: 0.6;
}

.domain-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-bottom {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-top: 12px;
  border-top: 1px solid var(--border-color);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 600;
  padding: 7px 12px;
  border-radius: 10px;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s ease;
  white-space: nowrap;
}

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

.btn-secondary {
  background: var(--btn-sec-bg);
  color: var(--btn-sec-text);
  border: 1px solid var(--btn-sec-border);
  padding: 7px 10px;
}

.btn-secondary:hover {
  background: var(--btn-sec-hover);
  border-color: var(--border-hover);
}

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

.btn-primary:hover {
  background: var(--btn-primary-hover);
  border-color: var(--btn-primary-hover);
}

.btn-icon {
  width: 12px;
  height: 12px;
}

/* 7. 空状态 */
.empty-state {
  display: none;
  padding: 60px 20px;
  text-align: center;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.empty-state.visible {
  display: flex;
}

.empty-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}

.empty-title {
  font-size: 15px;
  font-weight: 700;
}

.empty-desc {
  font-size: 12px;
  color: var(--text-muted);
}

/* 8. 页脚 */
footer {
  border-top: 1px solid var(--border-color);
  padding: 24px 0;
  font-size: 12px;
  color: var(--text-muted);
}

.footer-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  text-align: center;
}

@media (min-width: 640px) {
  .footer-inner {
    flex-direction: row;
    text-align: left;
  }
}

.footer-link {
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.15s ease;
}

.footer-link:hover {
  color: var(--text-main);
}

/* 9. 浮动回到顶部 */
.back-to-top {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--card-bg);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: all 0.2s ease;
  z-index: 40;
  box-shadow: var(--shadow-card);
}

.back-to-top.visible {
  opacity: 1;
  pointer-events: auto;
}

.back-to-top:hover {
  border-color: var(--border-hover);
}

/* 10. 提示 Toast */
.toast {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%) translateY(12px);
  background: var(--toast-bg);
  color: var(--toast-text);
  font-size: 12px;
  font-weight: 600;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  padding: 9px 18px;
  border-radius: 9999px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  opacity: 0;
  pointer-events: none;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 6px;
}

.toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
