/* ===== 我的门户 · 模块 UI（参考 portal.html 视觉语言） =====
   注意：动态背景由 custom.js 的 Canvas 绘制，本文件【不改动背景逻辑】，
   下面第一段仅保留「内容层透明、黑底透出背景」的既有规则。 */

/* ---- 既有背景规则：保持不变 ---- */
html {
  background: #000000 !important;
}

html body {
  background: linear-gradient(180deg, #000000 0%, #020408 60%, #03070f 100%) !important;
}

html #page_wrapper,
html #wrapper,
html #__next {
  position: relative;
  z-index: 1;
  background: transparent !important;
}

/* ================= 设计变量（取自参考页） ================= */
:root {
  --accent: #5b8cff;
  --accent2: #7c5cff;
  --panel: rgba(10, 15, 30, .62);
  --card: rgba(255, 255, 255, .045);
  --card-hover: rgba(255, 255, 255, .085);
  --border: rgba(255, 255, 255, .09);
  --border-hover: rgba(120, 160, 255, .45);
  --text: #e8ecf6;
  --sub: #98a2b8;
  --faint: #5c667c;
  --accent-soft: rgba(91, 140, 255, .14);
  --topbar: rgba(6, 10, 22, .6);
  --input-bg: rgba(255, 255, 255, .06);
  --shadow: 0 14px 40px rgba(0, 0, 0, .45);
  --radius: 14px;
}

html body {
  font-family: "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
  color: var(--text);
  font-size: 14px;
}

::selection { background: rgba(91, 140, 255, .35); }
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb {
  background: rgba(130, 150, 190, .28); border-radius: 6px;
  border: 2px solid transparent; background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(130, 150, 190, .45); border: 2px solid transparent; background-clip: content-box;
}
::-webkit-scrollbar-track { background: transparent; }

@keyframes portalRise { from { opacity: 0; transform: translateY(12px); } }

/* ================= 顶栏：状态 / 搜索 / 天气 / 时钟 ================= */
#information-widgets {
  position: sticky !important;
  top: 0;
  z-index: 60;
  margin: 0 !important;
  padding: 10px 22px !important;
  background: var(--topbar) !important;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 0 !important;
  border-bottom: 1px solid var(--border) !important;
}

#widgets-wrap { align-items: center; }

/* 资源小卡（CPU / 内存 / 磁盘） */
.information-widget-resource {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-right: 8px !important;
  padding: 6px 11px !important;
  background: var(--card) !important;
  border: 1px solid var(--border);
  border-radius: 10px;
  transition: border-color .2s;
}
.information-widget-resource:hover { border-color: var(--border-hover); }
.information-widget-resource > svg {
  width: 15px; height: 15px; color: var(--accent); flex-shrink: 0;
}
.information-widget-resource > div { min-width: 64px; }
.information-widget-resource .resource-value {
  font-size: 11.5px; font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums;
}
.information-widget-resource .text-xs > div:last-child {
  font-size: 10px; color: var(--faint); letter-spacing: .5px;
}
.information-widget-resource .resource-usage {
  height: 3px !important; margin-top: 3px !important;
  background: var(--input-bg) !important; border-radius: 3px; overflow: hidden;
}
.information-widget-resource .resource-usage > div {
  background: linear-gradient(90deg, var(--accent), var(--accent2)) !important;
  border-radius: 3px;
}
/* 「服务器」标签：参考页无此元素，隐藏以免换行错位 */
#widgets-wrap > .widget-container > div:last-child { display: none; }

/* 搜索框 */
#information-widgets-right { gap: 10px; align-items: center; }
form.information-widget-search { min-width: 260px; max-width: 620px; }
form.information-widget-search > div:first-child {
  height: 42px !important; margin: 0 !important;
}
form.information-widget-search input {
  height: 42px !important;
  padding: 0 74px 0 36px !important;
  background: var(--card) !important;
  border: 1px solid var(--border) !important;
  border-radius: 12px !important;
  color: var(--text) !important;
  font-size: 13.5px !important;
  transition: border-color .2s, box-shadow .2s;
}
form.information-widget-search input::placeholder { color: var(--faint) !important; }
form.information-widget-search input:focus {
  border-color: var(--accent) !important;
  box-shadow: 0 0 0 3px var(--accent-soft);
  outline: none;
}
form.information-widget-search > div:first-child > div:first-child {
  padding-left: 12px !important; color: var(--faint) !important;
}
form.information-widget-search button {
  border-radius: 8px !important;
  background: var(--input-bg) !important;
  color: var(--accent) !important;
  font-size: 11px !important;
  padding: 5px 9px !important;
}

/* 天气 / 时钟 pill */
.information-widget-openmeteo .widget-inner,
.information-widget-datetime > div:first-child {
  height: 34px;
  padding: 5px 12px;
  gap: 7px;
  background: var(--card) !important;
  border: 1px solid var(--border);
  border-radius: 10px;
  white-space: nowrap;
}
.information-widget-openmeteo .widget-inner svg { width: 14px; height: 14px; color: var(--accent); }
.information-widget-openmeteo .primary-text {
  color: var(--text) !important; font-weight: 600; font-size: 12px !important;
  font-variant-numeric: tabular-nums;
}
.information-widget-openmeteo .secondary-text { color: var(--sub) !important; font-size: 11px !important; }
.information-widget-datetime span {
  color: var(--text) !important; font-size: 12px !important;
  font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: .4px;
}

/* ================= 分区标题：渐变竖条 ================= */
.services-group > button,
.bookmark-group > button { padding: 0 2px 0 0 !important; }

h2.service-group-name,
h2.bookmark-group-name {
  display: flex; align-items: center; gap: 10px;
  color: var(--text) !important;
  font-size: 15px !important; font-weight: 600 !important;
  letter-spacing: 1px; line-height: 1.6;
}
h2.service-group-name::before,
h2.bookmark-group-name::before {
  content: ''; width: 4px; height: 16px; border-radius: 3px;
  background: linear-gradient(180deg, var(--accent), var(--accent2));
}
h2.service-group-name::after {
  content: '自部署服务';
  font-size: 11.5px; color: var(--faint); font-weight: 400; letter-spacing: 0;
}
.services-group > button > svg,
.bookmark-group > button > svg { color: var(--faint) !important; opacity: .4; }
.services-group > button:hover > svg,
.bookmark-group > button:hover > svg { opacity: 1; }

/* ================= 常用工具：卡片网格 ================= */
#layout-groups { margin-top: 18px !important; }
ul.services-list { gap: 12px !important; margin-top: 14px !important; }

li.service:nth-child(1) { --g1: #5b8cff; --g2: #7c5cff; }
li.service:nth-child(2) { --g1: #22c55e; --g2: #14b8a6; }
li.service:nth-child(3) { --g1: #f59e0b; --g2: #f97316; }
li.service:nth-child(4) { --g1: #ec4899; --g2: #f43f5e; }
li.service:nth-child(5) { --g1: #06b6d4; --g2: #3b82f6; }
li.service:nth-child(6) { --g1: #a855f7; --g2: #6366f1; }

li.service > div {
  display: flex; flex-direction: column;
  padding: 15px 14px !important;
  margin-bottom: 0 !important;
  background: var(--card) !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--radius) !important;
  box-shadow: none !important;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: transform .22s, border-color .22s, box-shadow .22s, background .22s;
  animation: portalRise .5s ease backwards;
}
li.service:nth-child(1) > div { animation-delay: .00s; }
li.service:nth-child(2) > div { animation-delay: .05s; }
li.service:nth-child(3) > div { animation-delay: .10s; }
li.service:nth-child(4) > div { animation-delay: .15s; }
li.service:nth-child(5) > div { animation-delay: .20s; }
li.service:nth-child(6) > div { animation-delay: .25s; }

li.service:hover > div {
  transform: translateY(-3px);
  border-color: var(--border-hover) !important;
  background: var(--card-hover) !important;
  box-shadow: 0 10px 28px rgba(0, 0, 0, .28);
}

.service-title {
  display: flex !important; flex-direction: column;
  align-items: flex-start; gap: 10px;
}
a.service-icon {
  width: 38px !important; height: 38px;
  border-radius: 11px;
  background: linear-gradient(135deg, var(--g1, #5b8cff), var(--g2, #7c5cff)) !important;
  box-shadow: 0 4px 14px rgba(91, 140, 255, .4);
}
a.service-icon > div {
  width: 19px !important; height: 19px !important;
  max-width: 19px !important; max-height: 19px !important;
  background: #ffffff !important;
}
a.service-title-text { width: 100%; }
.service-title-text .service-name {
  padding: 0 !important;
  color: var(--text) !important; font-size: 13.5px !important; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.service-title-text .service-description {
  margin-top: 2px;
  color: var(--faint) !important; font-size: 11.5px !important; font-weight: 400 !important;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
/* 右上状态胶囊（保留真实的站点响应时间） */
.service-tags { top: 11px !important; right: 11px !important; margin-right: 0 !important; gap: 4px !important; }
.service-tags .site-monitor-status {
  background: var(--accent-soft) !important;
  border: 1px solid rgba(91, 140, 255, .3);
  border-radius: 5px !important;
  padding: 2px 6px !important;
}
.service-tags .site-monitor-status > div {
  color: var(--accent) !important; font-size: 9.5px !important; letter-spacing: .5px;
}

/* ================= 书签分类：四列玻璃卡片 ================= */
#bookmarks { gap: 14px !important; margin-top: 26px !important; }
#bookmarks > .bookmark-group {
  flex: 1 1 calc(25% - 14px) !important;
  min-width: calc(25% - 14px);
  max-width: calc(25% - 14px);
  padding: 0 !important;
  background: var(--card) !important;
  border: 1px solid var(--border);
  border-radius: 16px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  overflow: hidden;
  transition: border-color .25s;
  animation: portalRise .55s ease backwards;
}
#bookmarks > .bookmark-group:nth-child(1) { --c: #5b8cff; animation-delay: .06s; }
#bookmarks > .bookmark-group:nth-child(2) { --c: #22c55e; animation-delay: .12s; }
#bookmarks > .bookmark-group:nth-child(3) { --c: #f59e0b; animation-delay: .18s; }
#bookmarks > .bookmark-group:nth-child(4) { --c: #a855f7; animation-delay: .24s; }
#bookmarks > .bookmark-group:hover { border-color: color-mix(in srgb, var(--c) 45%, var(--border)); }

.bookmark-group > button {
  padding: 13px 15px !important;
  border-bottom: 1px solid var(--border);
}
h2.bookmark-group-name::before {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--c, var(--accent)) !important;
  box-shadow: 0 0 9px color-mix(in srgb, var(--c, var(--accent)) 70%, transparent);
}

.bookmark-list { padding: 7px !important; margin: 0 !important; gap: 2px; }
li.bookmark > a {
  position: relative;
  margin-bottom: 0 !important;
  padding: 8px 10px !important;
  background: transparent !important;
  border-radius: 11px;
  box-shadow: none !important;
  transition: background .18s, transform .18s;
}
li.bookmark > a::before {
  content: ''; position: absolute; left: 0; top: 22%; bottom: 22%;
  width: 2.5px; border-radius: 3px;
  background: var(--c, var(--accent));
  opacity: 0; transform: scaleY(.4); transition: .2s;
}
li.bookmark > a:hover { background: var(--card-hover) !important; transform: translateX(2px); }
li.bookmark > a:hover::before { opacity: 1; transform: scaleY(1); }

.bookmark-icon {
  width: 30px !important; height: 30px;
  border-radius: 8px;
  flex-shrink: 0;
  color: var(--c, var(--accent)) !important;
  background: color-mix(in srgb, var(--c, var(--accent)) 16%, transparent) !important;
  border: 1px solid color-mix(in srgb, var(--c, var(--accent)) 30%, transparent);
  font-size: 12px !important; font-weight: 700;
}
.bookmark-name {
  padding-left: 10px !important;
  color: var(--text) !important; font-size: 13px !important; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.bookmark-description {
  color: var(--faint) !important; font-size: 10.5px !important;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  opacity: .75; transition: opacity .2s, color .2s;
}
li.bookmark > a:hover .bookmark-description { opacity: 1; color: var(--accent) !important; }

/* ================= 页脚 / 右下按钮 ================= */
#footer { padding-top: 20px !important; }
#revalidate {
  background: rgba(15, 21, 40, .9) !important;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 6px;
  color: var(--sub) !important;
}

/* ================= 响应式 ================= */
@media (max-width: 1200px) {
  #bookmarks > .bookmark-group {
    flex-basis: calc(50% - 14px) !important;
    min-width: calc(50% - 14px); max-width: calc(50% - 14px);
  }
  #information-widgets { padding: 10px 16px !important; }
}
@media (max-width: 1020px) {
  form.information-widget-search { min-width: 100%; order: 3; }
  #layout-groups, #bookmarks { margin-left: 16px !important; margin-right: 16px !important; }
}
@media (max-width: 760px) {
  #bookmarks > .bookmark-group {
    flex-basis: 100% !important; min-width: 100%; max-width: 100%;
  }
  #information-widgets { padding: 10px 12px !important; }
  /* 手机上常用工具保持两列，卡片更紧凑 */
  ul.services-list { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
  li.service > div { padding: 12px 11px !important; }
  a.service-icon, a.service-icon > div { width: 32px !important; height: 32px !important; }
  a.service-icon > div { max-width: 17px !important; max-height: 17px !important; width: 17px !important; height: 17px !important; }
  .service-tags { top: 9px !important; right: 9px !important; }
  .service-title-text .service-description { font-size: 10.5px !important; }
  /* 天气/时钟靠右同排，搜索独占下一行（贴近参考页窄屏） */
  #information-widgets-right { justify-content: flex-end !important; }
  #information-widgets-right form.information-widget-search { order: 3; flex: 1 1 100% !important; }
  .information-widget-openmeteo { order: 1; }
  .information-widget-datetime { order: 2; }
}
@media (max-width: 560px) {
  .information-widget-resource:nth-child(2),
  .information-widget-resource:nth-child(3) { display: none; }
  .bookmark-description { display: none; }
}
