/* 监控页面样式重构 */

#monitoring-page .monitoring-header {
  display: none;
  text-align: center;
  margin-bottom: 30px;
  padding-top: 20px;
}

#monitoring-page .monitoring-description {
  color: var(--font-color);
  opacity: 0.7;
  font-size: 1rem;
  max-width: 600px;
  margin: 0 auto;
}

/* 解除主容器宽度限制，实现全宽布局 */
#content-inner.layout.hide-aside {
  max-width: 100%;
  padding: 0;
}

/* 移除默认的内容卡片样式（背景、阴影等），让卡片直接展示在背景上 */
#content-inner.layout > #monitoring-page {
  background: transparent;
  box-shadow: none;
  padding: 20px;
  width: 100%;
  border-radius: 0;
}

/* Footer 背景存在 */
#footer {
  background: none !important;
}

/* --------------------------------------
 * 监控卡片 Grid 布局
 * -------------------------------------- */

/* 页面标题区域美化 */
#monitoring-page .page-title {
  font-size: 2rem;
  margin-bottom: 10px;
  font-weight: 700;
  /* 渐变色标题，增加科技感 */
  background: linear-gradient(120deg, #1890ff, #36cfc9);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  display: inline-block;
}

#monitoring-container {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  width: 100%;
  max-width: 1800px;
  margin: 0 auto;
  padding: 10px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); /* 稍微调宽单个卡片最小宽度 */
  gap: 16px; /* 增加间距 */
}

@media (min-width: 600px) {
  #monitoring-container {
     grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 800px) {
  #monitoring-container {
     grid-template-columns: repeat(3, 1fr);
  }
}

@media (min-width: 1300px) {
  #monitoring-container {
     grid-template-columns: repeat(4, 1fr); /* 大屏显示4列 */
  }
}

@media (min-width: 1800px) {
  #monitoring-container {
     grid-template-columns: repeat(5, 1fr); /* 超大屏显示5列 */
  }
}

.loading-message, .none-message, .error-message {
  grid-column: 1 / -1;
  padding: 40px;
  text-align: center;
  border-radius: 8px;
  background-color: var(--card-bg, #fff);
  color: var(--font-color, #333);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
  font-size: 16px;
}

.error-message {
  color: #ff4d4f;
  background-color: #fff1f0;
  border: 1px solid #ffccc7;
}

/* 监控卡片主体 */
.monitor-item {
  display: flex;
  flex-direction: column;
  background-color: var(--card-bg, #fff);
  border-radius: 12px;
  padding: 12px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  overflow: hidden;
  font-size: 14px;
  border: 1px solid transparent;
  position: relative;
}

/* 状态指示条 - 顶部边框 */
.monitor-item.status-available {
  border-top: 4px solid #52c41a;
}

.monitor-item.status-unavailable {
  border-top: 4px solid #ff4d4f;
  background-color: #fff1f0; /* 异常时淡红背景提醒 */
}

/* 异常状态下的文字颜色调整 */
.monitor-item.status-unavailable .site-title {
  color: #cf1322;
}

.monitor-item:hover {
  transform: translateY(-4px);
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
}

/* 顶部头部区域 */
.site-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  gap: 10px;
}

/* 头部左侧：头像+信息 */
.site-header-left {
  display: flex;
  align-items: center;
  overflow: hidden; /* 关键：防止子元素溢出 */
  flex: 1; /* 占据剩余空间 */
}

.site-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  overflow: hidden;
  margin-right: 10px;
  background-color: #f0f0f0;
  flex-shrink: 0; /* 防止头像被压缩 */
  border: 1px solid rgba(0,0,0,0.05);
}

.site-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.site-meta {
  display: flex;
  flex-direction: column;
  overflow: hidden; /* 触发 BFC，配合子元素 truncate */
  flex: 1;
}

.site-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--font-color);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.2;
}

.site-url {
  font-size: 12px;
  color: #999;
  text-decoration: none;
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
  opacity: 0.8;
}

/* 头部右侧：状态+按钮 */
.site-header-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.history-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 6px;
  border-radius: 50%;
  color: #aaa;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.history-btn:hover {
  background-color: rgba(0, 0, 0, 0.05);
  color: #1890ff;
}

.history-btn svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

/* 截图区域 */
.site-screenshot {
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 6px;
  overflow: hidden;
  margin-bottom: 0; /* 截图直接接状态条 */
  background-color: #f5f5f5;
  border: 1px solid rgba(0,0,0,0.05);
  position: relative;
}

.site-screenshot::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  box-shadow: inset 0 0 10px rgba(0,0,0,0.02);
  pointer-events: none;
}

.site-screenshot img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
  transition: transform 0.5s ease;
}

.monitor-item:hover .site-screenshot img {
  transform: scale(1.05);
}

/* 每日状态条 */
.daily-status-container {
  height: 12px; /* 变得更细，类似进度条 */
  margin-top: 12px;
  margin-bottom: 0;
  display: flex;
  gap: 1px;
  background-color: rgba(0, 0, 0, 0.05);
  border-radius: 6px;
  overflow: hidden;
}

.daily-status-loading {
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: loading 1.5s infinite;
}

@keyframes loading {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.daily-status-item {
  flex: 1;
  height: 100%;
  background-color: #ebedf0;
  position: relative;
  cursor: pointer;
  transition: opacity 0.2s;
}

.daily-status-item:hover {
  opacity: 0.8;
}

.daily-status-item.status-success { background-color: #52c41a; }
.daily-status-item.status-partial { background-color: #faad14; }
.daily-status-item.status-fail { background-color: #ff4d4f; }
.daily-status-item.status-none { background-color: #ebedf0; }

/* Tooltip & Modal Styles */
.daily-status-tooltip {
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  background-color: rgba(0, 0, 0, 0.85);
  color: white;
  padding: 6px 10px;
  border-radius: 4px;
  font-size: 11px;
  line-height: 1.4;
  white-space: nowrap;
  display: none;
  z-index: 100;
  margin-bottom: 6px;
  pointer-events: none;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.daily-status-tooltip::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  margin-left: -4px;
  border-width: 4px;
  border-style: solid;
  border-color: rgba(0,0,0,0.85) transparent transparent transparent;
}

.daily-status-item:hover .daily-status-tooltip {
  display: block;
}

/* Modal Styles */
.history-modal {
  display: none;
  position: fixed;
  top: 0; left: 0; width: 100%; height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 9999;
  justify-content: center;
  align-items: center;
  backdrop-filter: blur(2px);
}

.history-modal.active { display: flex; }

.history-modal-content {
  background-color: var(--card-bg, #fff);
  width: 90%;
  max-width: 600px;
  max-height: 85vh;
  border-radius: 16px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.history-modal-header {
  padding: 16px 24px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.history-modal-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--font-color);
}

.history-modal-close {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: #999;
  transition: color 0.2s;
  padding: 4px;
  line-height: 1;
}

.history-modal-close:hover { color: #666; }

.history-modal-body {
  padding: 0;
  overflow-y: auto;
  flex: 1;
}

.history-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.history-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 24px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.04);
  font-size: 14px;
}

.history-section-title {
  padding: 10px 24px;
  font-size: 12px;
  font-weight: 600;
  color: #888;
  background-color: #fafafa;
  border-bottom: 1px solid rgba(0, 0, 0, 0.04);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.history-item.history-monthly {
  border-left: 4px solid #1890ff;
  background-color: rgba(24, 144, 255, 0.02);
}

.history-item.success { border-left: 4px solid #52c41a; }
.history-item.fail { border-left: 4px solid #ff4d4f; background-color: rgba(255, 77, 79, 0.02); }

.history-time { color: #555; font-family: monospace; }
.history-status { font-weight: 600; }
.history-item.success .history-status { color: #52c41a; }
.history-item.fail .history-status { color: #ff4d4f; }

.history-meta {
  color: #999;
  font-size: 12px;
}

.load-more-container {
  padding: 20px;
  text-align: center;
  border-top: 1px solid rgba(0, 0, 0, 0.05);
}

.load-more-btn {
  padding: 8px 24px;
  background-color: #f5f5f5;
  border: 1px solid rgba(0,0,0,0.05);
  border-radius: 20px;
  cursor: pointer;
  color: #666;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.2s;
}

.load-more-btn:hover {
  background-color: #e6e6e6;
  color: #333;
}

/* 深色模式适配 */
[data-theme="dark"] .monitor-item {
  background-color: var(--card-bg, #2c2c2c);
  border-color: rgba(255,255,255,0.05);
}

[data-theme="dark"] .site-title { color: rgba(255, 255, 255, 0.9); }
[data-theme="dark"] .site-url { color: rgba(255, 255, 255, 0.5); }
[data-theme="dark"] .site-avatar { 
  background-color: #333; 
  border-color: rgba(255,255,255,0.1); 
}

[data-theme="dark"] .history-btn { color: rgba(255, 255, 255, 0.4); }
[data-theme="dark"] .history-btn:hover { 
  background-color: rgba(255, 255, 255, 0.1); 
  color: #fff; 
}

[data-theme="dark"] .site-screenshot {
  background-color: #1f1f1f;
  border-color: rgba(255,255,255,0.05);
}

[data-theme="dark"] .daily-status-container {
  background-color: rgba(255, 255, 255, 0.05);
}
[data-theme="dark"] .daily-status-item {
  border-right: 1px solid rgba(0,0,0,0.2);
}
/* 确保深色模式下状态颜色不被覆盖 */
[data-theme="dark"] .daily-status-item.status-success { background-color: #49aa19; }
[data-theme="dark"] .daily-status-item.status-partial { background-color: #d89614; }
[data-theme="dark"] .daily-status-item.status-fail { background-color: #e84749; }
[data-theme="dark"] .daily-status-item.status-none { background-color: rgba(255, 255, 255, 0.1); }

[data-theme="dark"] .daily-status-item:hover { opacity: 0.8; }

[data-theme="dark"] .monitor-item.status-available {
  border-top: 4px solid #52c41a;
}


/* 深色模式下异常卡片背景调整 */
[data-theme="dark"] .monitor-item.status-unavailable {
  background-color: rgba(166, 29, 36, 0.15);
  border-top-color: #d32029;
}
[data-theme="dark"] .monitor-item.status-unavailable .site-title {
  color: #ff7875;
}

[data-theme="dark"] .status-detail { border-top-color: rgba(255,255,255,0.1); }
[data-theme="dark"] .metric-item .label { color: rgba(255,255,255,0.4); }
[data-theme="dark"] .metric-item .value { color: rgba(255,255,255,0.8); }

[data-theme="dark"] .history-modal-content {
  background-color: var(--card-bg, #2c2c2c);
}
[data-theme="dark"] .history-modal-header {
  border-bottom-color: rgba(255, 255, 255, 0.1);
}
[data-theme="dark"] .history-modal-title {
  color: rgba(255, 255, 255, 0.9);
}
[data-theme="dark"] .history-section-title {
  background-color: rgba(255,255,255,0.05);
  color: rgba(255,255,255,0.6);
  border-bottom-color: rgba(255,255,255,0.05);
}
[data-theme="dark"] .history-item {
  border-bottom-color: rgba(255, 255, 255, 0.05);
  color: rgba(255, 255, 255, 0.8);
}
[data-theme="dark"] .history-time { color: rgba(255,255,255,0.5); }
[data-theme="dark"] .load-more-container { border-top-color: rgba(255,255,255,0.05); }
[data-theme="dark"] .load-more-btn {
  background-color: rgba(255,255,255,0.1);
  color: rgba(255,255,255,0.8);
  border-color: transparent;
}
[data-theme="dark"] .load-more-btn:hover {
  background-color: rgba(255,255,255,0.2);
}

/* 每日明细滚动区域样式 */
.history-detail-list {
  max-height: 300px;
  overflow-y: auto;
  /* 美化滚动条 (Webkit) */
}

.history-detail-list::-webkit-scrollbar {
  width: 6px;
}

.history-detail-list::-webkit-scrollbar-thumb {
  background-color: rgba(0, 0, 0, 0.2);
  border-radius: 3px;
}

.history-detail-list::-webkit-scrollbar-track {
  background-color: transparent;
}

[data-theme="dark"] .history-detail-list::-webkit-scrollbar-thumb {
  background-color: rgba(255, 255, 255, 0.2);
}