/* --- 1. 全局变量与重置 --- */
:root {
    --bg-color: #0f1011;       /* 背景极深色，接近黑色 */
    --card-bg: #1a1b1e;        /* 卡片背景 */
    --text-title: #f0f0f0;     /* 标题亮白 */
    --text-meta: #888888;      /* 信息灰 */
    --accent-green: #5ca84e;   /* 参考图片中的 Tag 绿色 */
    --btn-install: #4caf50;    /* 安装按钮绿 */
    --btn-uninstall: #d32f2f;  /* 卸载按钮红 */
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Segoe UI', 'Microsoft YaHei', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-title);
    padding: 40px;
    min-height: 100vh;
}

/* --- SDK 状态栏样式 --- */
.sdk-status-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background-color: var(--card-bg);
    border-bottom: 1px solid #2a2b2e;
    padding: 12px 20px;
    z-index: 1000;
    transition: opacity 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    display: block !important;
    opacity: 1 !important;
    visibility: visible !important;
}

.sdk-status-content {
    display: flex;
    align-items: center;
    gap: 12px;
    max-width: 1400px;
    margin: 0 auto;
}

.sdk-status-icon {
    font-size: 16px;
    flex-shrink: 0;
}

.sdk-status-text {
    font-size: 14px;
    font-weight: 500;
    flex: 1;
    min-width: 120px;
}

.sdk-progress-container {
    flex: 1;
    height: 6px;
    background-color: #151618;
    border-radius: 3px;
    overflow: hidden;
    max-width: 300px;
}

.sdk-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-green) 0%, #4caf50 100%);
    border-radius: 3px;
    transition: width 0.3s ease;
    width: 0%;
}

.sdk-progress-text {
    font-size: 12px;
    color: var(--text-meta);
    min-width: 40px;
    text-align: right;
}

/* 状态栏不同状态的颜色 */
.sdk-status-downloading .sdk-status-icon {
    color: #2196f3;
}

.sdk-status-loading .sdk-status-icon {
    color: #ff9800;
}

.sdk-status-success .sdk-status-icon {
    color: var(--accent-green);
}

.sdk-status-error .sdk-status-icon {
    color: var(--btn-uninstall);
}

.sdk-status-success .sdk-status-text {
    color: var(--accent-green);
}

.sdk-status-error .sdk-status-text {
    color: var(--btn-uninstall);
}

/* --- 自定义提示框样式 --- */
.custom-toast {
    position: fixed !important;
    top: 20px !important;
    right: 20px !important;
    min-width: 320px;
    max-width: 500px;
    padding: 16px 20px;
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(255, 255, 255, 0.1);
    z-index: 99999 !important;
    opacity: 0;
    transform: translateX(400px) scale(0.9);
    transition: opacity 0.3s ease, transform 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    display: flex !important;
    align-items: center;
    font-size: 14px;
    line-height: 1.5;
    backdrop-filter: blur(10px);
    font-weight: 500;
    pointer-events: auto;
}

.custom-toast.show {
    opacity: 1 !important;
    transform: translateX(0) scale(1) !important;
}

.custom-toast-success {
    background: linear-gradient(135deg, rgba(76, 175, 80, 0.95) 0%, rgba(69, 160, 73, 0.95) 100%);
    color: #ffffff;
    border-left: 4px solid #2e7d32;
}

.custom-toast-success .toast-icon {
    color: #c8e6c9;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.custom-toast-error {
    background: linear-gradient(135deg, rgba(244, 67, 54, 0.95) 0%, rgba(211, 47, 47, 0.95) 100%);
    color: #ffffff;
    border-left: 4px solid #b71c1c;
}

.custom-toast-error .toast-icon {
    color: #ffcdd2;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.custom-toast-warning {
    background: linear-gradient(135deg, rgba(255, 152, 0, 0.95) 0%, rgba(245, 124, 0, 0.95) 100%);
    color: #ffffff;
    border-left: 4px solid #e65100;
}

.custom-toast-warning .toast-icon {
    color: #ffe0b2;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.custom-toast-info {
    background: linear-gradient(135deg, rgba(33, 150, 243, 0.95) 0%, rgba(25, 118, 210, 0.95) 100%);
    color: #ffffff;
    border-left: 4px solid #0d47a1;
}

.custom-toast-info .toast-icon {
    color: #bbdefb;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.toast-content {
    display: flex;
    align-items: center;
    gap: 14px;
    width: 100%;
}

.toast-icon {
    font-size: 22px;
    flex-shrink: 0;
    animation: iconPulse 0.6s ease-out;
}

@keyframes iconPulse {
    0% {
        transform: scale(0);
        opacity: 0;
    }
    50% {
        transform: scale(1.2);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.toast-message {
    flex: 1;
    word-wrap: break-word;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

/* --- 2. 网格布局容器 --- */
.grid-container {
    display: grid;
    /* 响应式网格：每列最小宽 280px，自动填满 */
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
    max-width: 1400px;
    margin: 0 auto;
    margin-top: 60px; /* 为状态栏留出空间 */
}

/* --- 3. 卡片主体 --- */
.card {
    background-color: var(--card-bg);
    border-radius: 8px;
    overflow: hidden;
    transition: transform 0.2s, box-shadow 0.2s;
    border: 1px solid #2a2b2e;
    display: flex;
    flex-direction: column;
}

.card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
    border-color: #3a3b3e;
}

/* --- 4. 图片区域 --- */
.card-image {
    width: 100%;
    aspect-ratio: 16/9; /* 保持图片比例 */
    position: relative;
    background-color: #222;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

/* 图片左下角的下载量遮罩 */
.download-badge {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    background: linear-gradient(to top, rgba(0,0,0,0.8), transparent);
    padding: 10px;
    color: #ccc;
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 5px;
}

/* --- 5. 内容区域 --- */
.card-content {
    padding: 12px 15px;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* 标题 */
.mod-title {
    font-size: 16px;
    font-weight: bold;
    color: var(--text-title);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis; /* 超长省略 */
}

/* 时间信息和标签 (Meta Info) */
.mod-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    color: var(--text-meta);
}

.tags-container {
    display: flex;
    align-items: center;
    gap: 8px;
}

.date-box {
    display: flex;
    align-items: center;
    gap: 4px;
}


/* 右下角的 Tag (参考图中的 R.E.P.O 样式) */
.game-tag {
    font-size: 12px;
    color: var(--accent-green);
    border: 1px solid var(--accent-green);
    padding: 1px 6px;
    border-radius: 4px;
    letter-spacing: 0.5px;
}

/* 秒装标签 */
.instant-install-tag {
    font-size: 12px;
    color: #ff6b6b;
    border: 1px solid #ff6b6b;
    padding: 1px 6px;
    border-radius: 4px;
    letter-spacing: 0.5px;
    background-color: rgba(255, 107, 107, 0.1);
}

/* --- 7. 按钮组 (新增功能) --- */
/* 为了不破坏图片的极简美感，我们将按钮设计得扁平且紧凑 */
.action-row {
    padding: 10px 15px;
    border-top: 1px solid #2a2b2e;
    display: flex;
    gap: 10px;
    background-color: #151618;
}

.btn {
    flex: 1;
    padding: 6px 0;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: opacity 0.2s;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
}

.btn:hover {
    opacity: 0.9;
}

/* 安装按钮 */
.btn-install {
    background-color: var(--btn-install);
}

/* 卸载按钮 */
.btn-uninstall {
    background-color: transparent;
    border: 1px solid #444;
    color: #888;
}

.btn-uninstall:hover {
    background-color: rgba(211, 47, 47, 0.1);
    color: var(--btn-uninstall);
    border-color: var(--btn-uninstall);
}

/* 状态切换演示：如果已安装，显示不同样式 */
.card.installed .btn-install {
    display: none;
}
.card.not-installed .btn-uninstall {
    display: none;
}

/* --- 8. 自定义对话框 --- */
.dialog-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}

.dialog-overlay.show {
    opacity: 1;
    visibility: visible;
}

.dialog-container {
    background-color: var(--card-bg);
    border-radius: 8px;
    padding: 24px;
    min-width: 500px;
    max-width: 600px;
    width: 90%;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    border: 1px solid #2a2b2e;
    transform: scale(0.9);
    transition: transform 0.2s ease;
    position: relative;
}

.dialog-overlay.show .dialog-container {
    transform: scale(1);
}

.dialog-title {
    font-size: 18px;
    font-weight: bold;
    color: var(--text-title);
    margin-bottom: 16px;
}

.dialog-content {
    margin-bottom: 20px;
}

.dialog-content > div {
    margin-bottom: 16px;
}

.dialog-content > div:last-child {
    margin-bottom: 0;
}

.dialog-input-group {
    margin-bottom: 16px;
}

.dialog-input-group:last-child {
    margin-bottom: 0;
}

.dialog-label {
    display: block;
    font-size: 14px;
    color: var(--text-meta);
    margin-bottom: 8px;
}

.dialog-input-wrapper {
    display: flex;
    gap: 8px;
    align-items: center;
}

.dialog-input {
    flex: 1;
    padding: 10px 12px;
    background-color: #151618;
    border: 1px solid #2a2b2e;
    border-radius: 4px;
    color: var(--text-title);
    font-size: 14px;
    font-family: 'Segoe UI', 'Microsoft YaHei', sans-serif;
    transition: border-color 0.2s;
}

.dialog-select-btn {
    padding: 10px 16px;
    background-color: var(--accent-green);
    border: none;
    border-radius: 4px;
    color: white;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: opacity 0.2s;
    white-space: nowrap;
    font-family: 'Segoe UI', 'Microsoft YaHei', sans-serif;
}

.dialog-select-btn:hover {
    opacity: 0.9;
}

.dialog-input:focus {
    outline: none;
    border-color: var(--accent-green);
}

.dialog-input[readonly] {
    background-color: #1f2023;
    cursor: default;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

.dialog-input[readonly]:focus {
    outline: none;
    border-color: #2a2b2e;
    cursor: default;
    box-shadow: none;
}

.dialog-input[readonly]:active {
    outline: none;
    border-color: #2a2b2e;
    cursor: default;
}

.dialog-input::placeholder {
    color: #555;
}

.dialog-buttons {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
}

.dialog-btn {
    padding: 8px 20px;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: opacity 0.2s;
    font-family: 'Segoe UI', 'Microsoft YaHei', sans-serif;
}

.dialog-btn:hover {
    opacity: 0.9;
}

.dialog-btn-cancel {
    background-color: transparent;
    border: 1px solid #444;
    color: var(--text-meta);
}

.dialog-btn-cancel:hover {
    border-color: #666;
    color: var(--text-title);
}

.dialog-btn-confirm {
    background-color: var(--btn-install);
    color: white;
}