/* 友链页样式可能遗留为 a, .api-title 等设置颜色，主页强制重置关键颜色，防止跨页干扰 */
.api-card .api-title,
.api-card .api-title a,
.api-card .friend-link-card .api-title {
  color: #1f2937 !important; /* 标题深色 */
  text-decoration: none !important;
}

.api-card .api-title a:hover {
  color: #111827 !important;
}
/* API卡片链接样式 */
.api-card-link {
    text-decoration: none;
    color: inherit;
    display: block;
}

/* API卡片容器样式 */
.api-cards-container {
    display: flex;
    flex-wrap: wrap;
    gap: 20px; /* 固定间距，更容易计算 */
    width: 100%;
    justify-content: flex-start;
    box-sizing: border-box;
}

/* API卡片样式 */
.api-list {
    background: #ffffff;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    padding: 2rem;
    margin-bottom: 2rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    position: relative;
    min-height: 300px;
    width: 100%;
    box-sizing: border-box;
    overflow: hidden;
}

/* 暗色主题覆盖 */
html.theme-dark .api-list {
    background: rgba(22,24,28,0.85);
    border-color: rgba(255,255,255,0.06);
    box-shadow: 0 8px 24px rgba(0,0,0,0.5);
}
html.theme-dark .api-title,
html.theme-dark .api-title a { color: #e8e8e8 !important; }
html.theme-dark .api-description { color: #c9ced6; }
html.theme-dark .api-card { background: rgba(24,26,31,0.85); border-color: rgba(255,255,255,0.06) !important; background-clip: padding-box; }
html.theme-dark .api-card:hover { box-shadow: 0 8px 20px rgba(0,0,0,0.5); border-color: rgba(255,255,255,0.12) !important; outline: none; }
html.theme-dark .api-stats, html.theme-dark .RESTAPI-text { color: #aab4bf; }
html.theme-dark .RESTAPI-text { background: rgba(255,255,255,0.06); }

/* 修改为使用grid布局替代flex，确保每行对齐 */
.api-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr); /* 4列布局 */
    grid-gap: 20px; /* 统一间距 */
    margin-top: 1.5rem;
    width: 100%;
    box-sizing: border-box;
}

/* 标准卡片样式 - 使用grid-item */
.api-card {
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 1.5rem;
    transition: all 0.3s ease;
    position: relative;
    background: #ffffff;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-sizing: border-box;
    height: 200px; /* 固定卡片高度 */
    width: 100%; /* 确保宽度填满单元格 */
    cursor: pointer; /* 添加手型光标，表明可点击 */
}

/* 少量卡片的布局 (2-4张卡片) */
.api-grid.few-cards {
    grid-template-columns: repeat(4, 1fr); /* 保持4列 */
}

/* 单个卡片时的样式 */
.api-grid.single-card {
    grid-template-columns: 1fr; /* 单列 */
    max-width: 450px;
    margin-left: 0;
    margin-right: auto;
}

.api-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    border-color: #d0d0d0;
    outline: none; /* 修复白色外框 */
}
/* 去除 focus 时浏览器默认轮廓，防止白框 */
.api-card:focus { outline: none; }
html.theme-dark .api-card:focus { outline: none; }

/* 修复可点击卡片链接的焦点外框在暗色主题下显眼的白边 */
.api-card-link { outline: none; }
.api-card-link:focus { outline: none; }
.api-card-link:focus-visible { outline: none; }

.status-indicator {
    position: absolute;
    top: 1rem;
    right: 1rem;
    z-index: 2;
}

.status-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
}

.status-dot:hover {
    transform: scale(1.2);
}

.status-dot[data-status="在线"] {
    background-color: #4caf50;
    box-shadow: 0 0 5px rgba(76, 175, 80, 0.5);
}

.status-dot[data-status="维护中"] {
    background-color: #ff9800;
    box-shadow: 0 0 5px rgba(255, 152, 0, 0.5);
}

.status-dot[data-status="离线"] {
    background-color: #f44336;
    box-shadow: 0 0 5px rgba(244, 67, 54, 0.5);
}

.api-title {
    font-size: 1.3rem;
    font-weight: bold;
    margin-bottom: 0.5rem;
    margin-right: 20px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    cursor: default;
    max-width: 100%;
    box-sizing: border-box;
    color: #000000;
}

.api-description {
    color: #666;
    margin-bottom: 1rem;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    word-wrap: break-word;
    word-break: break-word;
    height: 4.2em; /* 固定高度：3 lines * 1.4 line-height */
    width: 100%;
    flex-shrink: 0; /* 防止高度被压缩 */
}

/* 移除描述悬停提示效果 */
.api-description::after {
    display: none;
}

.api-stats {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.9rem;
    color: #999;
    margin-top: auto;
    width: 100%;
    flex-shrink: 0; /* 防止被压缩 */
}

.star-count {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.star-svg {
    vertical-align: middle;
    display: inline-block;
}

.RESTAPI-text {
    color: #999;
    font-size: 0.8rem;
    background: #f3f3f3;
    border-radius: 6px 6px 6px 6px;
    padding: 0.4em 0.4em;
    display: inline-block;
}

/* 兼容：若搜索页的 rtsp-api-card 被错误插入到首页网格，应用同等样式，避免显示为纯文本 */
.api-grid .rtsp-api-card { 
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 1.5rem;
    transition: all 0.3s ease;
    position: relative;
    background: #ffffff;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-sizing: border-box;
    height: 200px;
    width: 100%;
    cursor: pointer;
}
.api-grid .rtsp-api-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.15); border-color: #d0d0d0; }
.api-grid .rtsp-api-card .api-name { 
    font-size: 1.3rem; font-weight: bold; margin-bottom: 0.5rem; margin-right: 20px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #000000; 
}
.api-grid .rtsp-api-card .api-description {
    color: #666; margin-bottom: 1rem; line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; text-overflow: ellipsis; height: 4.2em; width: 100%; flex-shrink: 0;
}
.api-grid .rtsp-api-card .api-meta { display: flex; justify-content: space-between; align-items: center; font-size: 0.9rem; color: #999; margin-top: auto; width: 100%; flex-shrink: 0; }

/* 暗色主题下的兼容样式 */
html.theme-dark .rtsp-api-card { background: rgba(24,26,31,0.85); border-color: rgba(255,255,255,0.06); }
html.theme-dark .rtsp-api-card:hover { box-shadow: 0 8px 20px rgba(0,0,0,0.5); border-color: rgba(255,255,255,0.12); }
html.theme-dark .rtsp-api-card .api-name { color: #e8e8e8; }
html.theme-dark .rtsp-api-card .api-description { color: #c9ced6; }
html.theme-dark .rtsp-api-card .api-meta { color: #aab4bf; }

/* 响应式设计 - 使用媒体查询控制每行卡片数 */

/* 特殊情况：3个卡片/行 (1200px-1600px) */
@media (max-width: 1600px) {
    .api-grid {
        grid-template-columns: repeat(3, 1fr); /* 3列布局 */
    }
    
    .api-grid.few-cards {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* 平板端：2个卡片/行 (768px-1200px) */
@media (max-width: 1200px) {
    .api-grid {
        grid-template-columns: repeat(2, 1fr); /* 2列布局 */
    }
    
    .api-grid.few-cards {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* 移动端：1个卡片/行 (小于768px) */
@media (max-width: 768px) {
    .api-list {
        padding: 1rem;
    }
    
    .api-grid, .api-grid.few-cards {
        grid-template-columns: 1fr; /* 1列布局 */
    }
    
    .api-title {
        width: calc(100% - 20px); /* 留出状态点的空间 */
    }
}

/* 小屏幕移动端优化 */
@media (max-width: 480px) {
    .api-card {
        padding: 1rem;
        height: auto; /* 在超小屏幕上允许卡片高度自适应 */
        min-height: 180px; /* 设置最小高度确保统一 */
    }
    
    .api-title {
        font-size: 1.1rem;
        margin-bottom: 0.3rem;
    }
}
