/**
 * emlog 勋章插件 - 样式文件
 * 包含后台管理和前台展示样式
 */

/* ========== 后台管理卡片系统（参考 wx_user / wx_ddz） ========== */

.wx-card {
    background: #fff;
    border-radius: 14px;
    border: none;
    box-shadow: 0 2px 20px rgba(225,112,85,0.08);
    margin-bottom: 22px;
    overflow: hidden;
    transition: box-shadow 0.3s, transform 0.3s;
    animation: wxFadeIn 0.35s ease both;
}
.wx-card:hover { box-shadow: 0 6px 30px rgba(225,112,85,0.15); }

@keyframes wxFadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.wx-card .card-header {
    background: linear-gradient(135deg, #e17055 0%, #fdcb6e 100%);
    color: #fff;
    font-weight: 600;
    font-size: 15px;
    padding: 15px 22px;
    display: flex;
    align-items: center;
    gap: 8px;
    border-bottom: none;
}
.wx-card .card-header .header-icon { font-size: 18px; color: #fff; }
.wx-card .card-header .header-badge {
    margin-left: auto;
    font-size: 12px;
    font-weight: 500;
    opacity: 0.85;
}
.wx-card .card-header .header-actions {
    margin-left: auto;
    display: flex;
    gap: 8px;
}

/* Card variants */
.wx-card.card-rules .card-header   { background: linear-gradient(135deg, #e17055, #fdcb6e); }
.wx-card.card-pink .card-header    { background: linear-gradient(135deg, #f093fb, #f5576c); }
.wx-card.card-blue .card-header    { background: linear-gradient(135deg, #e84393, #fd79a8); color: #5a1a3a; }
.wx-card.card-green .card-header   { background: linear-gradient(135deg, #43e97b, #38f9d7); color: #1a5a1a; }
.wx-card.card-orange .card-header  { background: linear-gradient(135deg, #f2994a, #f2c94a); color: #5a3a00; }
.wx-card.card-dark .card-header    { background: linear-gradient(135deg, #2d3436, #636e72); }

.wx-card .card-body { padding: 22px; }
.wx-card .card-body.compact { padding: 16px 22px; }
.wx-card .card-body.p-0 { padding: 0; }
.wx-card .card-footer {
    background: #f8f9fe;
    border-top: 1px solid #eef0f5;
    padding: 14px 22px;
}

/* ====== wx-btn 按钮系统 ====== */
.wx-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: none;
    border-radius: 8px;
    padding: 10px 24px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s;
    background: linear-gradient(135deg, #e17055, #fdcb6e);
    color: #fff;
    text-decoration: none;
    line-height: 1.4;
}
.wx-btn:hover {
    opacity: 0.92;
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(225,112,85,0.4);
    color: #fff;
    text-decoration: none;
}
.wx-btn:active { transform: translateY(0); }

.wx-btn-danger   { background: linear-gradient(135deg, #ff6b6b, #ee5a5a); }
.wx-btn-danger:hover   { box-shadow: 0 6px 20px rgba(255,107,107,0.4); }

.wx-btn-success  { background: linear-gradient(135deg, #43e97b, #38f9d7); color: #1a5a1a; }
.wx-btn-success:hover   { box-shadow: 0 6px 20px rgba(67,233,123,0.4); color: #1a5a1a; }

.wx-btn-warning  { background: linear-gradient(135deg, #f2994a, #f2c94a); color: #5a3a00; }
.wx-btn-warning:hover   { box-shadow: 0 6px 20px rgba(242,153,74,0.4); color: #5a3a00; }

.wx-btn-info     { background: linear-gradient(135deg, #e84393, #fd79a8); color: #5a1a3a; }
.wx-btn-info:hover     { box-shadow: 0 6px 20px rgba(232,67,147,0.4); color: #5a1a3a; }

.wx-btn-outline {
    background: #fff;
    color: #e17055;
    border: 1.5px solid #e17055;
}
.wx-btn-outline:hover {
    background: linear-gradient(135deg, #e17055, #fdcb6e);
    color: #fff;
    border-color: transparent;
}

.wx-btn-outline-danger {
    background: #fff;
    color: #ff6b6b;
    border: 1.5px solid #ff6b6b;
}
.wx-btn-outline-danger:hover {
    background: linear-gradient(135deg, #ff6b6b, #ee5a5a);
    color: #fff;
    border-color: transparent;
}

.wx-btn-sm { padding: 6px 14px; font-size: 12px; border-radius: 6px; }
.wx-btn-lg { padding: 12px 32px; font-size: 15px; border-radius: 10px; }

/* ====== 表格系统 ====== */
.wx-table {
    width: 100%;
    border-collapse: collapse;
}
.wx-table thead th {
    background: #f8f9fe;
    color: #e17055;
    font-weight: 600;
    padding: 10px 12px;
    border-bottom: 2px solid #e8e8f0;
    font-size: 13px;
    text-align: center;
}
.wx-table tbody td {
    padding: 10px 12px;
    border-bottom: 1px solid #f0f0f5;
    font-size: 13px;
    vertical-align: middle;
}
.wx-table tbody tr:hover td { background: #f8f9fe; }
.wx-table tbody tr:last-child td { border-bottom: none; }

/* ====== 后台通用 ====== */
.wx-mt-22 { margin-top: 22px; }

/* ========== 标签页导航（后台） — Bootstrap nav-tabs 已原生支持 ========== */

.medal-tab {
    display: inline-block;
    padding: 10px 20px;
    text-decoration: none;
    color: #666;
    font-size: 14px;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all 0.2s;
}

.medal-tab:hover {
    color: #333;
    background: #f9f9f9;
}

.medal-tab.active {
    color: #1890ff;
    border-bottom-color: #1890ff;
    font-weight: 600;
}

/* 面板 */
.medal-panel {
    background: #fff;
    border-radius: 4px;
    padding: 20px;
    margin-bottom: 20px;
}

.medal-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 1px solid #f0f0f0;
}

.medal-panel-header h3 {
    margin: 0;
    font-size: 16px;
    color: #333;
}

.medal-count {
    font-weight: normal;
    font-size: 13px;
    color: #999;
}

/* 按钮 */
.medal-btn {
    display: inline-block;
    padding: 6px 16px;
    border: 1px solid #d9d9d9;
    border-radius: 4px;
    background: #fff;
    color: #333;
    font-size: 13px;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s;
    line-height: 1.5;
    text-align: center;
}

.medal-btn:hover {
    border-color: #40a9ff;
    color: #40a9ff;
}

.medal-btn-primary {
    background: #1890ff;
    border-color: #1890ff;
    color: #fff;
}

.medal-btn-primary:hover {
    background: #40a9ff;
    border-color: #40a9ff;
    color: #fff;
}

.medal-btn-danger {
    background: #ff4d4f;
    border-color: #ff4d4f;
    color: #fff;
}

.medal-btn-danger:hover {
    background: #ff7875;
    border-color: #ff7875;
    color: #fff;
}

.medal-btn-sm {
    padding: 3px 10px;
    font-size: 12px;
}

/* 表格 */
.medal-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.medal-table th {
    background: #fafafa;
    padding: 10px 12px;
    text-align: left;
    font-weight: 600;
    color: #333;
    border-bottom: 1px solid #e8e8e8;
    white-space: nowrap;
}

.medal-table td {
    padding: 10px 12px;
    border-bottom: 1px solid #f0f0f0;
    vertical-align: middle;
}

.medal-table tr:hover {
    background: #fafafa;
}

.medal-desc {
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #888;
}

/* 状态标签 */
.medal-status {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 3px;
    font-size: 12px;
}

.medal-status-1 {
    background: #f6ffed;
    color: #52c41a;
    border: 1px solid #b7eb8f;
}

.medal-status-0 {
    background: #fff7e6;
    color: #fa8c16;
    border: 1px solid #ffd591;
}

/* 链接 */
.medal-link {
    color: #1890ff;
    text-decoration: none;
    font-size: 13px;
    margin-right: 8px;
}

.medal-link:hover {
    text-decoration: underline;
}

.medal-link-danger {
    color: #ff4d4f;
}

.medal-link-danger:hover {
    color: #ff7875;
}

/* 表单 */
.medal-form {
    max-width: 600px;
}

.medal-form-row {
    margin-bottom: 20px;
}

.medal-label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    font-size: 14px;
    color: #333;
}

.medal-required {
    color: #ff4d4f;
}

.medal-input {
    width: 100%;
    max-width: 400px;
    padding: 8px 12px;
    border: 1px solid #d9d9d9;
    border-radius: 4px;
    font-size: 14px;
    transition: border-color 0.2s;
    box-sizing: border-box;
}

.medal-input:focus {
    border-color: #40a9ff;
    outline: none;
    box-shadow: 0 0 0 2px rgba(24, 144, 255, 0.1);
}

.medal-input-sm {
    width: 100px;
}

.medal-textarea {
    width: 100%;
    max-width: 400px;
    padding: 8px 12px;
    border: 1px solid #d9d9d9;
    border-radius: 4px;
    font-size: 14px;
    min-height: 80px;
    resize: vertical;
    box-sizing: border-box;
    transition: border-color 0.2s;
}

.medal-textarea:focus {
    border-color: #40a9ff;
    outline: none;
    box-shadow: 0 0 0 2px rgba(24, 144, 255, 0.1);
}

.medal-select {
    width: 100%;
    max-width: 400px;
    padding: 8px 12px;
    border: 1px solid #d9d9d9;
    border-radius: 4px;
    font-size: 14px;
    background: #fff;
    box-sizing: border-box;
}

.medal-radio {
    display: inline-flex;
    align-items: center;
    margin-right: 16px;
    font-size: 14px;
    cursor: pointer;
}

.medal-radio input {
    margin-right: 4px;
}

.medal-form-hint {
    margin-top: 4px;
    font-size: 12px;
    color: #999;
}

.medal-form-actions {
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid #f0f0f0;
}

.medal-form-actions .medal-btn {
    margin-right: 8px;
}

/* 图标预览 */
.medal-icon-preview {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: contain;
    border: 1px solid #eee;
}

.medal-no-icon {
    display: inline-block;
    width: 32px;
    height: 32px;
    line-height: 32px;
    text-align: center;
    background: #f5f5f5;
    border-radius: 50%;
    color: #ccc;
    font-size: 12px;
}

.medal-icon-preview-box {
    margin-top: 8px;
}

/* 搜索栏 */
.medal-search-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
}

.medal-search-bar .medal-input {
    max-width: 300px;
}

/* 批量操作栏 */
.medal-batch-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid #f0f0f0;
}

.medal-page-info {
    font-size: 13px;
    color: #999;
}

/* 空状态 */
.medal-empty {
    text-align: center;
    padding: 40px 20px;
    color: #aaa;
    font-size: 14px;
}

/* 批量颁发信息 */
.medal-batch-info {
    background: #e6f7ff;
    border: 1px solid #91d5ff;
    border-radius: 4px;
    padding: 12px 16px;
    margin-bottom: 16px;
    font-size: 13px;
    color: #0050b3;
}

/* 颁发方式 Tab */
.medal-grant-tabs {
    border-bottom: 2px solid #dee2e6;
    padding: 0 16px;
    background: #f8f9fa;
    border-radius: 4px 4px 0 0;
}

.medal-grant-tabs .nav-link {
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    padding: 10px 20px;
    color: #6c757d;
    font-weight: 500;
    transition: all 0.2s;
}

.medal-grant-tabs .nav-link:hover {
    color: #495057;
    border-bottom-color: #adb5bd;
}

.medal-grant-tabs .nav-link.active {
    color: #1677ff;
    border-bottom-color: #1677ff;
    background: transparent;
}

/* 用户列表顶部颁发按钮 */
.medal-grant-submit-btn {
    padding: 4px 16px;
    font-size: 13px;
}

/* 快速批量颁发（文本模式） */
.medal-text-grant-area {
    background: #f0f9ff;
    border: 1px solid #bae7ff;
    border-radius: 6px;
    padding: 16px 20px;
    margin-bottom: 16px;
}

.medal-text-grant-area textarea {
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 13px;
    line-height: 1.6;
}

.medal-text-grant-area .form-row {
    margin-left: -8px;
    margin-right: -8px;
}

.medal-text-grant-area .form-group {
    padding-left: 8px;
    padding-right: 8px;
}

/* 颁发勋章区域 */
.medal-grant-section {
    background: #f6ffed;
    border: 1px solid #b7eb8f;
    border-radius: 4px;
    padding: 16px;
    margin-bottom: 20px;
}

.medal-grant-section h4 {
    margin: 0 0 12px 0;
    font-size: 15px;
    color: #389e0d;
}

.medal-grant-list {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 12px;
}

.medal-grant-item {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    background: #fff;
    border: 1px solid #d9d9d9;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
}

.medal-grant-item:hover {
    border-color: #52c41a;
}

.medal-grant-item input {
    margin-right: 8px;
}

.medal-grant-info {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
}

.medal-grant-icon {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    object-fit: contain;
}

/* ========== 后台用户勋章卡片（管理已有勋章） ========== */
.wx-medal-user-grid {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.wx-medal-user-card {
    display: flex;
    align-items: center;
    gap: 14px;
    background: #fff;
    border: 1px solid #eef0f5;
    border-radius: 12px;
    padding: 14px 18px;
    transition: all 0.25s;
    box-shadow: 0 1px 6px rgba(102,126,234,0.04);
}
.wx-medal-user-card:hover {
    border-color: #d0d5f0;
    box-shadow: 0 3px 16px rgba(225,112,85,0.08);
    transform: translateY(-1px);
}
.wx-medal-user-card.expired {
    background: #fafbfc;
    opacity: 0.75;
}
.wx-medal-user-card.expired:hover {
    opacity: 0.85;
}

.wx-medal-user-check {
    display: flex;
    align-items: center;
    flex-shrink: 0;
    cursor: pointer;
}
.wx-medal-user-check input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.wx-medal-user-icon {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: #f8f9fe;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    overflow: hidden;
    border: 1px solid #eef0f5;
}
.wx-medal-user-icon img {
    width: 32px;
    height: 32px;
    object-fit: contain;
}
.wx-medal-user-noicon {
    font-size: 22px;
    line-height: 1;
}

.wx-medal-user-info {
    flex: 1;
    min-width: 0;
}
.wx-medal-user-name {
    font-weight: 600;
    font-size: 14px;
    color: #2c3e50;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 2px;
}
.wx-medal-user-desc {
    font-size: 12px;
    color: #999;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 3px;
}
.wx-medal-user-meta {
    font-size: 11px;
    color: #bbb;
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}
.wx-medal-user-admin {
    color: #ccc;
}

.wx-medal-user-status {
    flex-shrink: 0;
    display: flex;
    align-items: center;
}
.wx-medal-status-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    line-height: 1.4;
    white-space: nowrap;
}
.wx-medal-status-badge.valid {
    background: #f0fff4;
    color: #38a169;
    border: 1px solid #c6f6d5;
}
.wx-medal-status-badge.expiring {
    background: #fffaf0;
    color: #d69e2e;
    border: 1px solid #fde68a;
}
.wx-medal-status-badge.expired {
    background: #f7fafc;
    color: #a0aec0;
    border: 1px solid #e2e8f0;
}

.wx-medal-user-action {
    flex-shrink: 0;
    display: flex;
    align-items: center;
}

.wx-medal-user-footer {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid #eef0f5;
}
.wx-medal-user-check-all {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: #666;
    cursor: pointer;
    user-select: none;
}
.wx-medal-user-check-all input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

/* 颁发新勋章 - 选中样式（使用卡片背景色） */
.medal-grant-item:has(input:checked) {
    background-color: #f6ffed !important;
    border-color: #b7eb8f !important;
    color: #389e0d !important;
    font-weight: 600 !important;
}

.medal-grant-item input:checked ~ div img,
.medal-grant-item:has(input:checked) img {
    border: 2px solid #52c41a;
    box-shadow: 0 0 0 2px rgba(82, 196, 26, 0.3);
}

/* 勋章分类按钮 - 选中样式（颜色由 JS 动态注入，支持自定义分类配色） */
.medal-category-label {
    position: relative;
    transition: all 0.2s;
    border-radius: 6px;
}

.medal-category-label span {
    transition: all 0.2s;
    display: inline-block;
    background: transparent !important;
}

/* 已有勋章区域 */
.medal-owned-section h4 {
    margin: 0 0 12px 0;
    font-size: 15px;
    color: #333;
}

/* ========== 前台评论区勋章样式 ========== */

.medal-list {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
    margin-top: 6px;
    line-height: 1;
}

.medal-list-comment {
    margin-top: 4px;
    margin-bottom: 4px;
}

.medal-item {
    display: inline-flex;
    align-items: center;
    cursor: default;
    transition: transform 0.2s;
}

.medal-item:hover {
    transform: scale(1.2);
}

.medal-item img {
    border: 1px solid rgba(0, 0, 0, 0.06);
    display: block;
    object-fit: contain;
}

.medal-more {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    color: #999;
    background: #f5f5f5;
    border-radius: 10px;
    padding: 0 6px;
    height: 20px;
    line-height: 20px;
}

/* ========== 响应式 ========== */

@media screen and (max-width: 768px) {
    .medal-tabs {
        flex-wrap: wrap;
    }

    .medal-tab {
        padding: 8px 14px;
        font-size: 13px;
    }

    .medal-panel {
        padding: 12px;
    }

    .medal-table {
        font-size: 12px;
    }

    .medal-table th,
    .medal-table td {
        padding: 8px 6px;
    }

    .medal-form-row .medal-input,
    .medal-form-row .medal-textarea,
    .medal-form-row .medal-select {
        max-width: 100%;
    }

    .medal-search-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .medal-search-bar .medal-input {
        max-width: 100%;
    }

    .medal-batch-bar {
        flex-wrap: wrap;
    }
}

/* ========== 通用勋章灯箱（评论区/用户中心弹出卡片） ========== */
.medal-lightbox-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.65);
    z-index: 99999;
    justify-content: center;
    align-items: center;
}
.medal-lightbox-overlay.active { display: flex; }

.medal-lightbox-card {
    width: 300px;
    border-radius: 20px;
    overflow: hidden;
    background: #fff;
    box-shadow: 0 25px 80px rgba(0,0,0,0.4);
    transform: scale(1) translateY(0);
    opacity: 1;
    cursor: default;
}
.medal-lightbox-card.anim-open {
    animation: medalLbOpen 0.45s cubic-bezier(0.34,1.56,0.64,1) forwards;
}
.medal-lightbox-card.anim-close {
    animation: medalLbClose 0.3s ease forwards;
}

@keyframes medalLbOpen {
    0% { transform: scale(0.6) translateY(40px); opacity: 0; box-shadow: 0 25px 80px transparent; }
    100% { transform: scale(1) translateY(0); opacity: 1; box-shadow: 0 25px 80px rgba(0,0,0,0.4); }
}
@keyframes medalLbClose {
    0% { transform: scale(1) translateY(0); opacity: 1; box-shadow: 0 25px 80px rgba(0,0,0,0.4); }
    100% { transform: scale(0.6) translateY(40px); opacity: 0; box-shadow: 0 25px 80px transparent; }
}

.medal-lightbox-close {
    position: fixed;
    top: 20px;
    right: 20px;
    width: 40px; height: 40px;
    border-radius: 50%;
    border: none;
    background: rgba(255,255,255,0.15);
    color: rgba(255,255,255,0.7);
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100000;
    line-height: 1;
    padding: 0;
    opacity: 0;
    transform: scale(0.5);
    animation: medalLbCloseBtnIn 0.3s ease 0.15s forwards;
}
@keyframes medalLbCloseBtnIn {
    0% { opacity: 0; transform: scale(0.5); }
    100% { opacity: 1; transform: scale(1); }
}
.medal-lightbox-close:hover { background: rgba(255,255,255,0.3); color: #fff; }

.medal-lightbox-top {
    padding: 36px 24px 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}
.medal-lightbox-top::before {
    content: '';
    position: absolute;
    top: -40%; left: -40%;
    width: 180%; height: 180%;
    background: radial-gradient(circle, rgba(255,255,255,0.12) 0%, transparent 55%);
    pointer-events: none;
}
.medal-lightbox-icon-wrap {
    width: 140px; height: 140px;
    border-radius: 50%;
    background: rgba(255,255,255,0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 32px rgba(0,0,0,0.2);
    animation: medalIconFloat 3s ease-in-out infinite;
}
@keyframes medalIconFloat {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-6px); }
}
.medal-lightbox-icon-wrap img {
    width: 128px; height: 128px;
    object-fit: contain;
}

.medal-lightbox-bottom {
    padding: 20px 24px 24px;
}
.medal-lightbox-bottom h3 {
    font-size: 20px;
    color: #2c3e50;
    margin: 0 0 8px;
    text-align: center;
}
.medal-lightbox-bottom .medal-lightbox-desc {
    font-size: 13px;
    color: #666;
    line-height: 1.7;
    margin: 0 0 12px;
    text-align: center;
}
.medal-lightbox-bottom .medal-lightbox-holders {
    text-align: center;
    font-size: 12px;
    color: #aaa;
}
