﻿/* ===================================================
   toolbox.css — 深蓝政务风格
   主色：深海军蓝 #1b2f5e  侧边栏背景 #1a2b4a
   强调色：#4e9af1（亮蓝）
   =================================================== */

* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary:        #4e9af1;        /* 亮蓝强调 */
  --primary-light:  rgba(78,154,241,0.15);
  --primary-dark:   #2d7dd2;

  --sidebar-bg:     #1a2b4a;        /* 侧边栏深蓝底 */
  --sidebar-bg2:    #1b3462;        /* 侧边栏略浅区域 */
  --sidebar-active: #2a4a80;        /* 激活项背景 */
  --sidebar-hover:  rgba(255,255,255,0.07);
  --sidebar-border: rgba(255,255,255,0.08);
  --sidebar-text:   rgba(255,255,255,0.75);
  --sidebar-text-a: #ffffff;
  --sidebar-label:  rgba(255,255,255,0.35);

  --gold:           #f5c342;        /* 国徽金色 */

  --sidebar-w:      220px;
  --header-h:       48px;
  --radius:         8px;
  --shadow:         0 2px 12px rgba(0,0,0,0.10);
  --border:         1px solid #dde3ef;
  --text1:          #1a2540;
  --text2:          #4a5578;
  --text3:          #8e99b5;
  --bg:             #eef1f8;
  --white:          #ffffff;
  --danger:         #e84d4d;
  --success:        #22c55e;
  --warning:        #f59e0b;
  --info:           #3b82f6;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Microsoft YaHei', sans-serif;
  font-size: 14px;
  color: var(--text1);
  background: var(--bg);
  min-height: 100vh;
}

/* ===== 布局 ===== */
.layout { display: flex; min-height: 100vh; }

/* ===== 侧边栏 ===== */
.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  z-index: 100;
  transition: transform 0.3s, width 0.3s;
  box-shadow: 2px 0 12px rgba(0,0,0,0.2);
}
.sidebar-header {
  height: var(--header-h);
  display: flex;
  align-items: center;
  padding: 0 16px;
  border-bottom: var(--sidebar-border) solid;
  border-bottom: 1px solid var(--sidebar-border);
  gap: 10px;
  flex-shrink: 0;
  background: var(--sidebar-bg2);
}
.sidebar-header .logo-icon {
  width: 34px; height: 34px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: transparent;
}
.sidebar-header .logo-icon i.fas { font-size: 24px; color: var(--gold); }
.sidebar-header .logo-name  { font-size: 14px; font-weight: 700; color: var(--sidebar-text-a); letter-spacing: 0.5px; }
.sidebar-header .logo-sub   { font-size: 10px; color: var(--gold); margin-top: 2px; letter-spacing: 0.3px; }

.nav-scroll { flex: 1; overflow-y: auto; padding: 10px 8px; }
.nav-scroll::-webkit-scrollbar { width: 4px; }
.nav-scroll::-webkit-scrollbar-track { background: transparent; }
.nav-scroll::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 4px; }

.nav-section { margin-bottom: 8px; }
.nav-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--sidebar-label);
  letter-spacing: 1px;
  padding: 0 10px;
  margin-bottom: 6px;
  margin-top: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 12px;
  border-radius: 6px;
  cursor: pointer;
  color: var(--sidebar-text);
  font-size: 13.5px;
  transition: all 0.15s;
  margin-bottom: 2px;
  text-decoration: none;
  user-select: none;
  position: relative;
}
.nav-item:hover  { background: var(--sidebar-hover); color: var(--sidebar-text-a); }
.nav-item.active {
  background: var(--sidebar-active);
  color: var(--sidebar-text-a);
  font-weight: 600;
}
.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 20%; bottom: 20%;
  width: 3px;
  background: var(--primary);
  border-radius: 0 3px 3px 0;
}
.nav-item i.fas { width: 16px; height: 16px; flex-shrink: 0; opacity: 0.85; text-align: center; }
.nav-item.active i.fas { opacity: 1; }
.nav-count {
  margin-left: auto;
  background: rgba(78,154,241,0.2);
  color: var(--primary);
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 10px;
  min-width: 18px;
  text-align: center;
}
.nav-item.active .nav-count { background: rgba(78,154,241,0.3); }

.sidebar-footer {
  padding: 12px 8px;
  border-top: 1px solid var(--sidebar-border);
  flex-shrink: 0;
}
.sidebar-foot-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 6px;
  color: var(--sidebar-text);
  font-size: 13px;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s;
}
.sidebar-foot-link:hover { background: var(--sidebar-hover); color: var(--sidebar-text-a); }
.sidebar-foot-link i.fas { width: 15px; height: 15px; flex-shrink: 0; opacity: 0.8; text-align: center; }

/* ===== 主内容 ===== */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-w);
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: margin-left 0.3s;
}

/* ===== 顶部栏 ===== */
.topbar {
  height: var(--header-h);
  background: var(--white);
  border-bottom: var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 50;
  gap: 12px;
  box-shadow: 0 1px 6px rgba(0,0,0,0.06);
}
.menu-toggle { display: none; background: none; border: none; cursor: pointer; padding: 4px; color: var(--text2); }
.breadcrumb { 
  font-size: 13px; 
  color: var(--text3); 
  display: flex; 
  align-items: baseline; 
  gap: 8px; 
}
.bread-main { 
  font-size: 20px; 
  font-weight: 800; 
  color: var(--primary-dark) !important; 
}
.bread-icon {
  font-size: 18px;
  color: var(--primary-dark);
  margin-right: 2px;
}
.bread-sub { 
  font-size: 13px; 
  color: var(--text3); 
}
/* 先保留原样式，但 bread-main 已加 !important */
.breadcrumb span { color: var(--text1); font-weight: 500; }

.topbar-links {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  flex-wrap: wrap;
}
.quick-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 14px;
  font-size: 12px;
  font-weight: 500;
  text-decoration: none;
  transition: all 0.15s;
  border: 1px solid #d0d9ee;
  color: var(--text2);
  background: var(--white);
  white-space: nowrap;
}
.quick-link:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-light); }
.quick-link i.fas { font-size: 13px; margin-right: 6px; flex-shrink: 0; }
.quick-link.featured {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}
.quick-link.featured:hover { background: var(--primary-dark); border-color: var(--primary-dark); }

/* ===== 页面内容区 ===== */
.page-wrap {
  flex: 1;
  padding: 10px 24px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ===== 页头 ===== */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}
.page-title { font-size: 20px; font-weight: 700; color: var(--text1); }
.page-subtitle { font-size: 13px; color: var(--text2); margin-top: 3px; }

.search-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  background: white;
  border: 1px solid #d0d9ee;
  border-radius: 8px;
  padding: 9px 16px;
  width: 560px;
  transition: border 0.2s, box-shadow 0.2s;
}
.search-wrap:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(78,154,241,0.12); }
.search-wrap i.fas { width: 15px; height: 15px; color: var(--text3); flex-shrink: 0; }
.search-wrap input {
  border: none; outline: none; font-size: 13px;
  width: 100%; background: transparent; color: var(--text1);
}

/* ===== 分类筛选栏 ===== */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 14px;
  border-radius: 16px;
  font-size: 12.5px;
  font-weight: 500;
  border: 1px solid #d0d9ee;
  background: var(--white);
  color: var(--text2);
  cursor: pointer;
  transition: all 0.15s;
  user-select: none;
}
.filter-chip:hover { border-color: var(--primary); color: var(--primary); }
.filter-chip.active { background: var(--primary); color: white; border-color: var(--primary); }
.filter-chip .dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.7;
}

/* ===== 工具卡片网格 ===== */
.tools-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}
.tool-card {
  background: var(--white);
  border-radius: var(--radius);
  border: 1px solid #dde3ef;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: all 0.2s;
  cursor: default;
  text-decoration: none;
  color: inherit;
  position: relative;
  overflow: hidden;
  user-select: text;
}
.tool-card:hover {
  border-color: var(--primary);
  box-shadow: 0 4px 20px rgba(78,154,241,0.14);
  transform: translateY(-2px);
}
.tool-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--card-color, var(--primary));
  opacity: 0;
  transition: opacity 0.2s;
}
.tool-card:hover::before { opacity: 1; }

.tool-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.tool-icon-wrap {
  width: 44px; height: 44px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: var(--icon-bg, var(--primary-light));
}
.tool-icon-wrap svg { width: 22px; height: 22px; }
.tool-icon-wrap i.fas { font-size: 22px; color: var(--card-color, var(--primary)); }
.tool-badge {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  flex-shrink: 0;
}
.badge-free { background: #d9f5e7; color: #16a34a; }
.badge-new  { background: rgba(78,154,241,0.12); color: var(--primary); }
.badge-hot  { background: #fee2e2; color: #dc2626; }
.badge-beta { background: #fef3c7; color: #b45309; }

.tool-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--text1);
  line-height: 1.4;
  flex: 1;
  margin-top: 2px;
  user-select: text;
}
.tool-desc {
  font-size: 13px;
  color: var(--text2);
  line-height: 1.6;
  max-height: calc(1.6em * 2);
  overflow: hidden;
  user-select: text;
  cursor: text;
}
.tool-card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: auto;
  padding-top: 10px;
  border-top: 1px solid #edf0f7;
}
.tool-tags { display: flex; gap: 5px; flex-wrap: wrap; }
.tool-tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  color: var(--text3);
  background: var(--bg);
  user-select: text;
}

/* ===== 点击查看按钮 ===== */
.btn-view {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 12.5px;
  font-weight: 500;
  background: var(--primary-light);
  color: var(--primary);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.18s;
  text-decoration: none;
  white-space: nowrap;
  flex-shrink: 0;
}

.btn-view:hover {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 2px 8px rgba(78,154,241,0.30);
}

/* hidden via category filter */
.tool-card.hidden { display: none; }

/* ===== 空状态 ===== */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  grid-column: 1 / -1;
}
.empty-state i.fas { font-size: 48px; color: var(--text3); margin-bottom: 12px; display: block; }
.empty-state p { font-size: 15px; color: var(--text2); }
.empty-state small { font-size: 13px; color: var(--text3); }

/* ===== Toast ===== */
.toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 999; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: white; border-radius: 10px; padding: 12px 16px;
  display: flex; align-items: center; gap: 10px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.12); min-width: 220px;
  animation: slideIn 0.25s ease; border: 1px solid #dde3ef; border-left: 3px solid var(--success);
}
.toast i.fas { width: 16px; height: 16px; flex-shrink: 0; }
.toast-msg { font-size: 13px; color: var(--text1); }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes fadeOut { to { opacity: 0; transform: translateX(30px); } }
.toast.out { animation: fadeOut 0.3s ease forwards; }

/* ===== 侧边栏遮罩 ===== */
.sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 99;
}
.sidebar-overlay.open { display: block; }

/* ===== 响应式 ===== */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .menu-toggle { display: flex; }
  .topbar-links { display: none; }
  .topbar-actions { display: none; }
  .page-wrap { padding: 16px; }
  .tools-grid { grid-template-columns: 1fr; }
  .search-wrap { width: 100%; }
  .sidebar-toggle { display: none; }
}
@media (max-width: 480px) {
  .tools-grid { grid-template-columns: 1fr; }
  .page-header { flex-direction: column; align-items: flex-start; }
}

/* ===== 侧边栏收缩状态 ===== */
.sidebar-toggle {
  margin-left: auto;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  color: var(--sidebar-text);
  border-radius: 6px;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.sidebar-toggle:hover { background: var(--sidebar-hover); color: var(--sidebar-text-a); }
.sidebar-toggle svg { width: 18px; height: 18px; transition: transform 0.25s; }

.sidebar.collapsed { width: 56px; }
.sidebar.collapsed .sidebar-title,
.sidebar.collapsed .nav-label,
.sidebar.collapsed .nav-count,
.sidebar.collapsed .sidebar-footer { display: none; }
.sidebar.collapsed .sidebar-header { justify-content: center; padding: 0 8px; gap: 0; }
.sidebar.collapsed .logo-icon { margin: 0 auto; }
.sidebar.collapsed .sidebar-toggle { margin: 0 auto; }
.sidebar.collapsed .nav-item { justify-content: center; padding: 9px 0; gap: 0; }
.sidebar.collapsed .nav-item i.fas { margin: 0 auto; }
.sidebar.collapsed .sidebar-footer { padding: 8px 0; }
.sidebar.collapsed .sidebar-footer .sidebar-foot-link { justify-content: center; padding: 8px 0; }
.sidebar.collapsed .sidebar-footer .nav-text { display: none; }
.sidebar.collapsed .sidebar-title,
.sidebar.collapsed .nav-label,
.sidebar.collapsed .nav-count,
.sidebar.collapsed .nav-text { display: none; }
.sidebar.collapsed ~ .main-content { margin-left: 56px; }

/* 移动端不展示收缩按钮 */
@media (max-width: 768px) {
  .sidebar-toggle { display: none; }
}

/* ===== 底部版权信息 ===== */
.page-footer {
  text-align: center;
  font-size: 12px;
  color: var(--text3);
  padding: 16px 24px;
  border-top: 1px solid #dde3ef;
  margin-top: auto;
  line-height: 1.6;
}

/* ===== 底部版权按钮 ===== */
.footer-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 5px;
  padding: 8px 20px;
  border-radius: 6px;
  font-size: 12.5px;
  font-weight: 500;
  text-decoration: none;
  color: var(--text2);
  background: var(--bg);
  border: 1px solid #d0d9ee;
  cursor: pointer;
  transition: all 0.15s;
  max-width: 100%;
  line-height: 1.6;
}
.footer-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-light);
}

/* ===== Font Awesome 图标尺寸 ===== */
.sidebar-toggle i.fas,
.menu-toggle i.fas     { font-size: 16px; color: inherit; }
.nav-item i.fas,
.sidebar-foot-link i.fas   { font-size: 15px; width: 20px; text-align: center; }
.quick-link i.fas          { font-size: 13px; margin-right: 6px; }
.search-wrap i.fas          { font-size: 13px; color: var(--text3); flex-shrink: 0; }
.btn-view i.fas             { font-size: 12px; margin-left: 6px; }
.empty-state i.fas          { font-size: 48px; color: var(--text3); margin-bottom: 12px; display: block; }
.toast i.fas                 { font-size: 18px; flex-shrink: 0; }

/* ===== 工具嵌入区 ===== */
.tool-embed-wrap {
  display: none;
  flex: 1;
  min-height: 0;
  flex-direction: column;
  overflow: hidden;
}
.tool-embed-wrap.active {
  display: flex;
}
.tool-embed-header {
  display: flex;
  align-items: center;
  height: 48px;
  padding: 0 20px;
  background: var(--white);
  border-bottom: 1px solid #e5e9f2;
  flex-shrink: 0;
  gap: 12px;
}
.tool-embed-header .embed-tool-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--text1);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tool-embed-header .embed-close {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 14px;
  font-size: 13px;
  color: var(--text2);
  background: var(--bg);
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: background .15s;
  text-decoration: none;
  white-space: nowrap;
}
.tool-embed-header .embed-close:hover {
  background: #dde3ef;
  color: var(--text1);
}
.tool-embed-frame {
  flex: 1;
  min-height: 0;
  border: none;
  width: 100%;
  background: var(--white);
}

/* page-wrap 嵌入时隐藏 */
.page-wrap.hidden { display: none; }

/* 移动端：嵌入区全屏 */
@media (max-width: 768px) {
  .tool-embed-header { padding: 0 12px; }
}

/* ===== 嵌入页顶部栏（在 topbar 中） ===== */
.embed-topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
}
.embed-back {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 14px;
  font-size: 13px;
  color: var(--text2);
  background: var(--bg);
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: background .15s;
  white-space: nowrap;
}
.embed-back:hover {
  background: #dde3ef;
  color: var(--text1);
}
.embed-tool-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--text1);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}


/* 传世工具子分类缩进 */
.woool-sub { padding-left: 32px !important; font-size: 13px; opacity: 0.85; }
.woool-sub.active { opacity: 1; }
.sidebar.collapsed .woool-sub { display: none; }

/* ===== 捐赠弹窗 ===== */
.donate-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(27,47,94,0.85);
  justify-content: center;
  align-items: center;
}
.donate-overlay.active {
  display: flex;
}
.donate-modal {
  background: #fff;
  border-radius: 12px;
  max-width: 400px;
  width: 90%;
  overflow: hidden;
  position: relative;
  box-shadow: 0 12px 40px rgba(0,0,0,0.3);
  animation: donateIn 0.25s ease;
}
@keyframes donateIn {
  from { opacity: 0; transform: scale(0.92); }
  to   { opacity: 1; transform: scale(1); }
}
.donate-close {
  position: absolute;
  top: 8px;
  right: 12px;
  background: rgba(0,0,0,0.35);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 30px;
  height: 30px;
  font-size: 20px;
  line-height: 30px;
  text-align: center;
  cursor: pointer;
  z-index: 2;
  transition: background 0.15s;
}
.donate-close:hover { background: rgba(0,0,0,0.55); }
.donate-img-wrap {
  width: 100%;
  text-align: center;
  background: #f0f4fa;
  padding: 20px;
}
.donate-img {
  max-width: 100%;
  max-height: 360px;
  border-radius: 8px;
}
.donate-text {
  padding: 16px 20px 20px;
  text-align: center;
  color: var(--text1);
}
.donate-text p {
  font-size: 14px;
  line-height: 1.8;
  margin: 0;
}

/* 导航分类折叠箭头 */
.nav-toggle {
  font-size: 10px;
  transition: transform 0.2s;
  opacity: 0.5;
}
.nav-section.collapsed .nav-toggle {
  transform: rotate(-90deg);
}
.nav-section.collapsed > .nav-item,
.nav-section.collapsed > a.nav-item {
  display: none;
}
