/**
 * 应用工具卡片样式
 * 符合代码规范：<400行
 * 4x4网格布局，响应式设计
 * 使用独立前缀 app-tool-card- 保证面板独立性
 */

/* 应用工具卡片网格容器 - 缩小卡片尺寸，增加列数 */
.app-tool-card-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: var(--spacing-md);
    padding: var(--spacing-md);
    width: 100%;
    min-height: 400px;
}

/* 响应式布局 */
@media (max-width: 2000px) {
    .app-tool-card-grid {
        grid-template-columns: repeat(6, 1fr);
    }
}

@media (max-width: 1600px) {
    .app-tool-card-grid {
        grid-template-columns: repeat(5, 1fr);
    }
}

@media (max-width: 1200px) {
    .app-tool-card-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

@media (max-width: 900px) {
    .app-tool-card-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 600px) {
    .app-tool-card-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .app-tool-card-grid {
        grid-template-columns: 1fr;
    }
}

/* 应用工具卡片 */
.app-tool-card {
    display: flex;
    flex-direction: column;
    background: var(--bg-card);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-md);
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    position: relative;
    height: auto;
    font-family: "Microsoft YaHei", "微软雅黑", "SimSun", "宋体", "Arial", sans-serif;
}

.app-tool-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    border-color: var(--border-primary);
}

/* 卡片预览区域 - 1:1 正方形比例 */
.app-tool-card-preview {
    width: 100%;
    aspect-ratio: 1 / 1;
    height: auto;
    background: var(--bg-tertiary);
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

/* 分类标签（预览区域左下角） */
.app-tool-card-category-tag {
    position: absolute;
    bottom: 3px;
    left: 3px;
    padding: 4px 8px;
    background: rgba(0, 0, 0, 0.75);
    color: #ffffff;
    font-size: 11px;
    font-weight: 600;
    border-radius: 4px;
    font-family: "Microsoft YaHei", "微软雅黑", "SimSun", "宋体", "Arial", sans-serif;
    line-height: 1.3;
    z-index: 10;
    pointer-events: none;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    transition: all 0.2s ease;
    max-width: calc(100% - 12px);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.app-tool-card:hover .app-tool-card-category-tag {
    background: rgba(0, 0, 0, 0.85);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.app-tool-card-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
    filter: none !important;
    mix-blend-mode: normal !important;
    opacity: 1 !important;
}

.app-tool-card:hover .app-tool-card-image {
    transform: scale(1.05);
}

/* 卡片遮罩层 */
.app-tool-card-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: transparent !important;
    opacity: 0;
    transition: opacity 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.app-tool-card:hover .app-tool-card-overlay {
    opacity: 1;
    background: transparent !important;
}

/* 卡片操作按钮 */
.app-tool-card-actions {
    display: flex;
    gap: var(--spacing-sm);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.app-tool-card:hover .app-tool-card-actions {
    opacity: 1;
}

.app-tool-card-action-btn {
    padding: 8px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 12px;
    font-family: "Microsoft YaHei", "微软雅黑", "SimSun", "宋体", "Arial", sans-serif;
    cursor: pointer;
    transition: all 0.2s ease;
}

.app-tool-card-action-btn:hover {
    background: var(--bg-hover);
    border-color: var(--border-accent);
    color: var(--text-accent);
}

/* 卡片信息区域 */
.app-tool-card-info {
    padding: 8px 10px;
    padding-bottom: 50px; /* 为打开按钮留出更多空间，避免重叠 */
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 0 0 auto;
    min-height: auto;
    overflow: visible;
}

/* 标题行（名称 + 推荐度） */
.app-tool-card-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    min-height: 20px;
}

/* 卡片名称 */
.app-tool-card-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    line-height: 1.4;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
    min-width: 0;
    font-family: "Microsoft YaHei", "微软雅黑", "SimSun", "宋体", "Arial", sans-serif;
}

/* 推荐度区域 */
.app-tool-card-rating {
    display: flex;
    align-items: center;
    gap: 2px;
    flex-shrink: 0;
}

.app-tool-rating-stars {
    display: flex;
    gap: 2px;
    align-items: center;
}

.app-tool-rating-star {
    width: 12px;
    height: 12px;
    color: var(--text-muted);
    transition: color 0.2s ease;
}

.app-tool-rating-star.filled {
    color: #ffc107;
}

.app-tool-rating-star.half {
    color: #ffc107;
    position: relative;
}

.app-tool-rating-star.half::after {
    content: '★';
    position: absolute;
    left: 0;
    width: 50%;
    overflow: hidden;
    color: var(--text-muted);
}

/* 详情信息区域 */
.app-tool-card-description {
    font-size: 11px;
    color: var(--text-secondary);
    line-height: 1.4;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
    position: relative;
    font-family: "Microsoft YaHei", "微软雅黑", "SimSun", "宋体", "Arial", sans-serif;
    transition: all 0.3s ease;
}

.app-tool-card-description.has-overflow {
    cursor: help;
}

/* 详情信息弹窗 */
.app-tool-card-description-tooltip {
    position: fixed;
    background: var(--bg-card);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    font-size: 12px;
    color: var(--text-primary);
    max-width: 300px;
    word-wrap: break-word;
    word-break: break-all;
    z-index: 10000;
    box-shadow: var(--shadow-lg);
    opacity: 0;
    transform: translateY(-5px);
    transition: opacity 0.2s ease, transform 0.2s ease;
    pointer-events: none;
    font-family: "Microsoft YaHei", "微软雅黑", "SimSun", "宋体", "Arial", sans-serif;
    line-height: 1.4;
}

.app-tool-card-description-tooltip.show {
    opacity: 1;
    transform: translateY(0);
}

/* 标签区域 */
.app-tool-card-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 2px;
}

.app-tool-card-tag {
    display: inline-block;
    padding: 3px 8px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-sm);
    font-size: 11px;
    color: var(--text-secondary);
    font-family: "Microsoft YaHei", "微软雅黑", "SimSun", "宋体", "Arial", sans-serif;
    line-height: 1.3;
    transition: all 0.2s ease;
}

.app-tool-card-tag:hover {
    background: var(--bg-hover);
    border-color: var(--border-accent);
    color: var(--text-accent);
}

/* 按钮容器（卡片窗口右下角，固定位置） */
.app-tool-card-button-container {
    position: absolute;
    bottom: 8px;
    right: 8px;
    left: 8px;
    display: flex;
    align-items: stretch;
    gap: 6px;
    z-index: 10;
    padding-top: 8px;
    border-top: 1px solid var(--border-primary);
    justify-content: flex-end;
}

/* 打开按钮（主按钮） */
.app-tool-card-open-btn {
    position: relative;
    padding: 8px 18px;
    background: #4CAF50;
    border: 1px solid #45a049;
    border-radius: var(--radius-sm);
    color: #ffffff;
    font-size: 12px;
    font-weight: 500;
    font-family: "Microsoft YaHei", "微软雅黑", "SimSun", "宋体", "Arial", sans-serif;
    letter-spacing: 0.5px;
    cursor: pointer;
    transition: all 0.2s ease;
    line-height: 1;
    outline: none;
    min-width: 70px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* 按钮文本 */
.app-tool-card-open-btn-text {
    display: block;
}

/* 进度条容器 */
.app-tool-card-open-btn-progress {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.app-tool-card-open-btn-progress-bar {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    background: linear-gradient(90deg, #4CAF50, #45a049);
    transition: width 0.3s ease;
    width: 0%;
}

.app-tool-card-open-btn-progress-text {
    position: relative;
    z-index: 1;
    font-size: 11px;
    font-weight: 500;
    color: var(--text-primary);
    font-family: "Microsoft YaHei", "微软雅黑", "SimSun", "宋体", "Arial", sans-serif;
}

/* 独立的打开按钮（已下载时显示） */
.app-tool-card-open-only-btn {
    padding: 8px 18px;
    background: #4CAF50;
    border: 1px solid #45a049;
    border-radius: var(--radius-sm);
    color: #ffffff;
    font-size: 12px;
    font-weight: 500;
    font-family: "Microsoft YaHei", "微软雅黑", "SimSun", "宋体", "Arial", sans-serif;
    letter-spacing: 0.5px;
    cursor: pointer;
    transition: all 0.2s ease;
    line-height: 1;
    outline: none;
    min-width: 35px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.app-tool-card-open-only-btn:hover {
    background: #45a049;
    border-color: #3d8b40;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(76, 175, 80, 0.3);
}

.app-tool-card-open-only-btn:active {
    transform: translateY(0);
    box-shadow: none;
}

/* 下拉箭头按钮 */
.app-tool-card-open-btn-dropdown {
    padding: 8px 9px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    outline: none;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    min-width: 35px;
    height: 100%;
    box-sizing: border-box;
}

.app-tool-card-open-btn-dropdown:hover {
    background: var(--bg-hover);
    border-color: var(--border-accent);
    color: var(--text-accent);
}

/* 下拉菜单 */
.app-tool-card-open-btn-menu {
    position: absolute;
    bottom: 100%;
    right: 0;
    margin-bottom: 4px;
    background: var(--bg-card);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    min-width: 120px;
    overflow: hidden;
    z-index: 100;
}

/* 当主按钮是禁用或下载中状态时，下拉菜单保持灰色（虽然通常不会显示） */
.app-tool-card-open-btn.disabled ~ .app-tool-card-open-btn-menu,
.app-tool-card-open-btn.downloading ~ .app-tool-card-open-btn-menu {
    background: var(--bg-card);
    border-color: var(--border-primary);
}

.app-tool-card-open-btn.disabled ~ .app-tool-card-open-btn-menu .app-tool-card-open-btn-menu-item,
.app-tool-card-open-btn.downloading ~ .app-tool-card-open-btn-menu .app-tool-card-open-btn-menu-item {
    color: var(--text-primary);
}

.app-tool-card-open-btn.disabled ~ .app-tool-card-open-btn-menu .app-tool-card-open-btn-menu-item:hover,
.app-tool-card-open-btn.downloading ~ .app-tool-card-open-btn-menu .app-tool-card-open-btn-menu-item:hover {
    background: var(--bg-hover);
    color: var(--text-accent);
}

.app-tool-card-open-btn.disabled ~ .app-tool-card-open-btn-menu .app-tool-card-open-btn-menu-item:not(:last-child),
.app-tool-card-open-btn.downloading ~ .app-tool-card-open-btn-menu .app-tool-card-open-btn-menu-item:not(:last-child) {
    border-bottom: 1px solid var(--border-primary);
}

.app-tool-card-open-btn-menu-item {
    padding: 8px 16px;
    font-size: 12px;
    color: var(--text-primary);
    font-family: "Microsoft YaHei", "微软雅黑", "SimSun", "宋体", "Arial", sans-serif;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.app-tool-card-open-btn-menu-item:hover {
    background: var(--bg-hover);
    color: var(--text-accent);
}

.app-tool-card-open-btn-menu-item:not(:last-child) {
    border-bottom: 1px solid var(--border-primary);
}

/* 删除菜单项（危险操作，红色） */
.app-tool-card-open-btn-menu-item[data-action="delete"] {
    color: #ff4444;
}

.app-tool-card-open-btn-menu-item[data-action="delete"]:hover {
    background: rgba(255, 68, 68, 0.1);
    color: #ff0000;
}

/* 按钮状态：已下载（绿色可用） */
.app-tool-card-open-btn.downloaded {
    background: #4CAF50;
    border-color: #45a049;
    color: #ffffff;
}

.app-tool-card-open-btn.downloaded:hover {
    background: #45a049;
    border-color: #3d8b40;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(76, 175, 80, 0.3);
}

/* 已下载状态下，下拉箭头按钮保持深灰色（不再使用绿色） */
.app-tool-card-open-btn.downloaded + .app-tool-card-open-btn-dropdown {
    background: var(--bg-tertiary);
    border-color: var(--border-primary);
    color: var(--text-primary);
}

.app-tool-card-open-btn.downloaded + .app-tool-card-open-btn-dropdown:hover {
    background: var(--bg-hover);
    border-color: var(--border-accent);
    color: var(--text-accent);
}

/* 当主按钮是禁用或下载中状态时，下拉箭头按钮保持灰色 */
.app-tool-card-open-btn.disabled + .app-tool-card-open-btn-dropdown,
.app-tool-card-open-btn.downloading + .app-tool-card-open-btn-dropdown {
    background: var(--bg-tertiary);
    border-color: var(--border-primary);
    color: var(--text-muted);
}

.app-tool-card-open-btn.disabled + .app-tool-card-open-btn-dropdown:hover,
.app-tool-card-open-btn.downloading + .app-tool-card-open-btn-dropdown:hover {
    background: var(--bg-tertiary);
    border-color: var(--border-primary);
    color: var(--text-muted);
}

/* 按钮状态：下载中（灰色禁用） */
.app-tool-card-open-btn.downloading {
    background: var(--bg-tertiary);
    border-color: var(--border-primary);
    color: var(--text-muted);
    cursor: not-allowed;
}

.app-tool-card-open-btn.downloading:hover {
    transform: none;
    box-shadow: none;
}

/* 按钮状态：不可用（灰色禁用） */
.app-tool-card-open-btn.disabled {
    background: var(--bg-tertiary);
    border-color: var(--border-primary);
    color: var(--text-muted);
    cursor: not-allowed;
    opacity: 0.6;
}

.app-tool-card-open-btn.disabled:hover {
    transform: none;
    box-shadow: none;
    background: var(--bg-tertiary);
    border-color: var(--border-primary);
    color: var(--text-muted);
}

/* 按钮悬停效果（非禁用状态） */
.app-tool-card-open-btn:not(.disabled):not(.downloading):not(.downloaded):hover {
    background: #45a049;
    border-color: #3d8b40;
    color: #ffffff;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(76, 175, 80, 0.3);
}

.app-tool-card-open-btn:not(.disabled):not(.downloading):active {
    transform: translateY(0);
    box-shadow: none;
}

/* 空状态 */
.app-tool-card-grid-empty {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--spacing-xxl);
    color: var(--text-muted);
    font-family: "Microsoft YaHei", "微软雅黑", "SimSun", "宋体", "Arial", sans-serif;
}

.app-tool-card-grid-empty-icon {
    font-size: 64px;
    margin-bottom: var(--spacing-md);
    opacity: 0.5;
}

.app-tool-card-grid-empty-text {
    font-size: 16px;
    color: var(--text-secondary);
    margin-bottom: var(--spacing-xs);
}

.app-tool-card-grid-empty-hint {
    font-size: 14px;
    color: var(--text-muted);
}

/* 加载状态 */
.app-tool-card-loading {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--spacing-xxl);
    color: var(--text-muted);
    font-family: "Microsoft YaHei", "微软雅黑", "SimSun", "宋体", "Arial", sans-serif;
}

/* 骨架屏 */
.app-tool-card-skeleton {
    display: flex;
    flex-direction: column;
    background: var(--bg-card);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-md);
    overflow: hidden;
    height: auto;
}

.app-tool-card-skeleton-preview {
    width: 100%;
    aspect-ratio: 1 / 1;
    height: auto;
    background: linear-gradient(90deg, var(--bg-tertiary) 25%, var(--bg-hover) 50%, var(--bg-tertiary) 75%);
    background-size: 200% 100%;
    animation: app-tool-skeleton-loading 1.5s ease-in-out infinite;
    flex-shrink: 0;
}

.app-tool-card-skeleton-info {
    padding: 8px 10px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 0 0 auto;
}

.app-tool-card-skeleton-line {
    height: 12px;
    background: linear-gradient(90deg, var(--bg-tertiary) 25%, var(--bg-hover) 50%, var(--bg-tertiary) 75%);
    background-size: 200% 100%;
    animation: app-tool-skeleton-loading 1.5s ease-in-out infinite;
    border-radius: var(--radius-sm);
}

.app-tool-card-skeleton-line.short {
    width: 60%;
}

.app-tool-card-skeleton-line.medium {
    width: 80%;
}

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

