/* ========================================
   通用组件库
   基于 Projects Skill 规范
   ======================================== */

/* ========== 1. 统计卡片组件 ========== */

/* 统计卡片网格 */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}

/* 统计卡片基础样式 */
.stat-card {
    background: var(--card-bg, #fff);
    border-radius: 8px;
    padding: 20px;
    box-shadow: var(--shadow-sm, 0 2px 8px rgba(0, 0, 0, 0.06));
    display: flex;
    align-items: center;
    gap: 16px;
    transition: transform 0.3s ease, opacity 0.3s ease;
}

.stat-card:hover {
    box-shadow: var(--shadow-md, 0 4px 12px rgba(0, 0, 0, 0.1));
    transform: translateY(-2px);
}

/* 统计卡片图标 */
.stat-card-icon {
    width: 56px;
    height: 56px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: #fff;
    flex-shrink: 0;
}

.stat-card-icon.bg-primary { background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); }
.stat-card-icon.bg-success { background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%); }
.stat-card-icon.bg-info { background: linear-gradient(135deg, #0fbcf9 0%, #3cba92 100%); }
.stat-card-icon.bg-warning { background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%); }
.stat-card-icon.bg-danger { background: linear-gradient(135deg, #ff0844 0%, #ffb199 100%); }
.stat-card-icon.bg-secondary { background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); }

/* 纯色版本 */
.stat-card-icon.solid.bg-primary { background: #007bff; }
.stat-card-icon.solid.bg-success { background: #28a745; }
.stat-card-icon.solid.bg-info { background: #17a2b8; }
.stat-card-icon.solid.bg-warning { background: #ffc107; }
.stat-card-icon.solid.bg-danger { background: #dc3545; }
.stat-card-icon.solid.bg-secondary { background: #6c757d; }

/* 统计卡片内容 */
.stat-card-body {
    flex: 1;
    min-width: 0;
}

.stat-card-label {
    font-size: 13px;
    color: var(--text-secondary, #888);
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.stat-card-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary, #333);
    line-height: 1.2;
    margin-bottom: 4px;
}

.stat-card-trend {
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.stat-card-trend.up {
    color: #28a745;
}

.stat-card-trend.down {
    color: #dc3545;
}

.stat-card-trend.neutral {
    color: #999;
}

/* 统计卡片变体 - 紧凑版 */
.stat-card.compact {
    padding: 16px;
    gap: 12px;
}

.stat-card.compact .stat-card-icon {
    width: 44px;
    height: 44px;
    font-size: 20px;
    border-radius: 10px;
}

.stat-card.compact .stat-card-value {
    font-size: 22px;
}

/* 统计卡片变体 - 大数字版 */
.stat-card.large .stat-card-icon {
    width: 64px;
    height: 64px;
    font-size: 28px;
}

.stat-card.large .stat-card-value {
    font-size: 36px;
}

/* ========== 2. 数据表格组件 ========== */

/* 表格容器 */
.table-container {
    background: var(--card-bg, #fff);
    border-radius: 8px;
    box-shadow: var(--shadow-sm, 0 2px 8px rgba(0, 0, 0, 0.06));
    overflow: hidden;
}

/* 表格头部 */
.table-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color, #eee);
}

.table-header h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary, #333);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.table-header h3 i {
    color: var(--text-secondary, #888);
}

/* 表格主体 */
.table-wrapper {
    overflow-x: auto;
}

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

.data-table thead {
    background: var(--table-header-bg, #f8f9fa);
}

.data-table th {
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    color: var(--text-primary, #333);
    border-bottom: 1px solid var(--border-color, #eee);
    white-space: nowrap;
    position: relative;
}

/* 可排序列 */
.data-table th.sortable {
    cursor: pointer;
    user-select: none;
}

.data-table th.sortable:hover {
    background: var(--table-header-hover, #e9ecef);
}

.data-table th.sortable::after {
    content: '\f0dc';
    font-family: 'Font Awesome 5 Free';
    font-weight: 900;
    font-size: 12px;
    color: #ccc;
    margin-left: 6px;
}

.data-table th.sort-asc::after {
    content: '\f0de';
    color: var(--primary-color, #007bff);
}

.data-table th.sort-desc::after {
    content: '\f0dd';
    color: var(--primary-color, #007bff);
}

/* 表格单元格 */
.data-table td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-color, #eee);
    color: var(--text-primary, #333);
    vertical-align: middle;
}

.data-table tbody tr {
    transition: background-color 0.15s ease;
}

.data-table tbody tr:hover {
    background-color: var(--table-row-hover, #f5f7fa);
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

/* 选中行 */
.data-table tbody tr.selected {
    background-color: rgba(0, 123, 255, 0.08);
}

/* 操作列 */
.data-table .action-col {
    text-align: right;
    white-space: nowrap;
}

.data-table .action-col button,
.data-table .action-col a {
    margin-left: 8px;
}

.data-table .action-col button:first-child,
.data-table .action-col a:first-child {
    margin-left: 0;
}

/* 复选框列 */
.data-table .checkbox-col {
    width: 40px;
    text-align: center;
}

.data-table .checkbox-col input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

/* 状态标签 */
.status-tag {
    display: inline-block;
    padding: 4px 10px;
    font-size: 12px;
    font-weight: 500;
    border-radius: 4px;
    line-height: 1;
}

.status-tag.active,
.status-tag.enabled,
.status-tag.success {
    background-color: rgba(40, 167, 69, 0.1);
    color: #28a745;
}

.status-tag.inactive,
.status-tag.disabled,
.status-tag.danger {
    background-color: rgba(220, 53, 69, 0.1);
    color: #dc3545;
}

.status-tag.pending,
.status-tag.warning {
    background-color: rgba(255, 193, 7, 0.1);
    color: #ffc107;
}

.status-tag.info {
    background-color: rgba(23, 162, 184, 0.1);
    color: #17a2b8;
}

/* 批量操作栏 */
.batch-actions {
    display: none;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    background: var(--primary-light, rgba(0, 123, 255, 0.05));
    border-bottom: 1px solid var(--primary-color, #007bff);
}

.batch-actions.show {
    display: flex;
}

.batch-actions .selected-count {
    font-size: 14px;
    color: var(--primary-color, #007bff);
    font-weight: 500;
}

.batch-actions .selected-count strong {
    font-size: 16px;
}

/* ========== 3. 分页组件 ========== */

.pagination-wrapper {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    margin-top: 15px;
    padding: 10px 10px;
    gap: 16px;
}

.pagination-left {
    display: flex;
    align-items: center;
    gap: 2px;
}

.pagination-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 60px;
    height: 34px;
    padding: 0 10px;
    border: 1px solid var(--border-color, #ddd);
    border-radius: 4px;
    background: var(--card-bg, #fff);
    color: var(--text-primary, #333);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
    margin: 0;
}

.pagination-btn:hover:not(:disabled) {
    border-color: var(--primary-color, #007bff);
    color: var(--primary-color, #007bff);
}

.pagination-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.pagination-num {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 34px;
    height: 34px;
    padding: 0 10px;
    border: 1px solid var(--border-color, #ddd);
    border-radius: 4px;
    background: var(--card-bg, #fff);
    color: var(--text-primary, #333);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
    margin: 0;
}

.pagination-num:hover:not(.active) {
    border-color: var(--primary-color, #007bff);
    color: var(--primary-color, #007bff);
}

.pagination-num.active {
    background: var(--primary-color, #007bff);
    border-color: var(--primary-color, #007bff);
    color: #fff;
}

.pagination-ellipsis {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    color: #999;
    font-size: 13px;
}

.pagination-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.pagination-page-size {
    height: 34px;
    padding: 0 10px;
    border: 1px solid var(--border-color, #ddd);
    border-radius: 4px;
    background: var(--card-bg, #fff);
    color: var(--text-primary, #333);
    font-size: 13px;
    cursor: pointer;
    outline: none;
    min-width: 90px;
}

.pagination-page-size:focus {
    border-color: var(--primary-color, #007bff);
}

.pagination-total {
    font-size: 13px;
    color: var(--text-secondary, #666);
}

.pagination-go {
    font-size: 13px;
    color: var(--text-secondary, #666);
}

.pagination-input {
    width: 50px;
    height: 34px;
    padding: 0 8px;
    border: 1px solid var(--border-color, #ddd);
    border-radius: 4px;
    font-size: 13px;
    text-align: center;
    outline: none;
}

.pagination-input:focus {
    border-color: var(--primary-color, #007bff);
}

.pagination-go-btn {
    height: 34px;
    padding: 0 12px;
    border: 1px solid var(--primary-color, #007bff);
    border-radius: 4px;
    background: var(--primary-color, #007bff);
    color: #fff;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
    margin: 0;
}

.pagination-go-btn:hover {
    background: var(--primary-dark, #0069d9);
    border-color: var(--primary-dark, #0069d9);
}

/* ========== 4. 加载状态组件 ========== */

/* 骨架屏 */
.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: 4px;
}

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

.skeleton-text {
    height: 14px;
    margin-bottom: 8px;
}

.skeleton-text.short { width: 40%; }
.skeleton-text.medium { width: 70%; }
.skeleton-text.long { width: 100%; }

.skeleton-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
}

.skeleton-card {
    height: 120px;
}

/* 加载中状态 */
.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

.loading-overlay.dark {
    background: rgba(0, 0, 0, 0.5);
}

.loading-spinner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.loading-spinner .spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-color, #eee);
    border-top-color: var(--primary-color, #007bff);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.loading-spinner .spinner.white {
    border-color: rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
}

.loading-spinner span {
    font-size: 14px;
    color: var(--text-secondary, #888);
}

.loading-spinner.white span {
    color: #fff;
}

/* 表格加载占位 */
.table-loading td {
    padding: 16px;
}

/* 空状态 */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary, #999);
}

.empty-state i {
    font-size: 64px;
    margin-bottom: 16px;
    opacity: 0.3;
}

.empty-state h4 {
    font-size: 18px;
    font-weight: 500;
    color: var(--text-primary, #333);
    margin-bottom: 8px;
}

.empty-state p {
    font-size: 14px;
    margin-bottom: 20px;
}

.empty-state .btn {
    display: inline-block;
}

/* ========== 提示组件 ========== */

/* Toast 提示 */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    max-width: 360px;
}

.toast {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    padding: 12px 16px;
    margin-bottom: 10px;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    /* 宽度随文字自适应（覆盖 Bootstrap .toast 的固定 width:350px），超长文本由容器 360px 兜底 */
    width: fit-content;
    max-width: 100%;
    opacity: 0;
    transform: translateX(100%);
    transition: all 0.3s ease;
}

.toast.show {
    opacity: 1;
    transform: translateX(0);
}

.toast.show {
    opacity: 1;
    transform: translateX(0);
}

.toast-icon {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    flex-shrink: 0;
}

.toast.success .toast-icon {
    background: #52c41a;
    color: #fff;
}

/* 成功提示：浅绿卡片风格（绿色边框 + 深绿文字） */
.toast.success {
    background: #f6ffed;
    border: 1px solid #b7eb8f;
}

.toast.success .toast-title {
    color: #135200;
}

.toast.success .toast-message {
    color: #389e0d;
}

.toast.error .toast-icon {
    background: rgba(220, 53, 69, 0.1);
    color: #dc3545;
}

.toast.warning .toast-icon {
    background: rgba(255, 193, 7, 0.1);
    color: #ffc107;
}

.toast.info .toast-icon {
    background: rgba(0, 123, 255, 0.1);
    color: #007bff;
}

.toast-content {
    flex: 1;
}

.toast-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary, #333);
    margin-bottom: 2px;
}

.toast-message {
    font-size: 13px;
    color: var(--text-secondary, #666);
}

/* ========== 7. 卡片组件 ========== */

/* 基础卡片 */
.card {
    background: var(--card-bg, #fff);
    border-radius: 8px;
    box-shadow: var(--shadow-sm, 0 2px 8px rgba(0, 0, 0, 0.06));
    margin-bottom: 20px;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color, #eee);
}

.card-header h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary, #333);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.card-header h3 i {
    color: var(--text-secondary, #888);
}

.card-body {
    padding: 20px;
}

.card-footer {
    padding: 12px 20px;
    border-top: 1px solid var(--border-color, #eee);
    background: var(--table-header-bg, #f8f9fa);
}

/* 卡片变体 */
.card.bordered {
    box-shadow: none;
    border: 1px solid var(--border-color, #ddd);
}

.card.hover:hover {
    box-shadow: var(--shadow-md, 0 4px 12px rgba(0, 0, 0, 0.1));
}

/* 卡片网格 */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.card-grid .card {
    margin-bottom: 0;
}

/* ========== 8. 按钮组件 ========== */

/* 按钮组 */
.btn-group {
    display: inline-flex;
    gap: 4px;
}

.btn-group .btn {
    margin-left: 0;
}

/* 按钮尺寸 */
.btn.btn-xs {
    padding: 2px 8px;
    font-size: 12px;
}

.btn.btn-sm {
    padding: 4px 12px;
    gap: 4px;
    font-size: 13px;
}

.btn.btn-lg {
    padding: 10px 24px;
    font-size: 16px;
}

/* 按钮图标 */
.btn i {
    margin-right: 0px;
}

.btn.icon-only {
    padding: 8px;
}

.btn.icon-only i {
    margin-right: 0;
}

/* 按钮状态 */
.btn.loading {
    position: relative;
    color: transparent !important;
    pointer-events: none;
}

.btn.loading::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    top: 50%;
    left: 50%;
    margin-top: -8px;
    margin-left: -8px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* ========== 9. 动画 ========== */

/* 旋转动画 */
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* 淡入动画 */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* 滑入动画 */
@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* 脉冲动画 */
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* 动画类 */
.animate-fadeIn {
    animation: fadeIn 0.3s ease;
}

.animate-slideInUp {
    animation: slideInUp 0.3s ease;
}

.animate-slideInRight {
    animation: slideInRight 0.3s ease;
}

.animate-pulse {
    animation: pulse 1.5s ease infinite;
}

/* ========== 10. 响应式 ========== */

@media (max-width: 768px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }
    
    .stat-card {
        padding: 16px;
        gap: 12px;
    }
    
    .stat-card-icon {
        width: 44px;
        height: 44px;
        font-size: 20px;
    }
    
    .stat-card-value {
        font-size: 22px;
    }
    
    .table-header {
        flex-direction: column;
        gap: 12px;
        align-items: flex-start;
    }
    
    .pagination-wrapper {
        flex-direction: column;
        gap: 12px;
    }
    
    .modal {
        width: 95%;
        margin: 10px;
    }
    
    .card-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
}
