/* 基础样式重置 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --secondary-color: #64748b;
    --secondary-hover: #475569;
    --success-color: #22c55e;
    --danger-color: #ef4444;
    --bg-color: #f8fafc;
    --card-bg: #ffffff;
    --border-color: #e2e8f0;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.07);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --transition: all 0.2s ease;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

.container {
    max-width: none;
    margin: 0 auto;
    padding: 20px;
}

/* 头部样式 */
header {
    text-align: center;
    margin-bottom: 30px;
    padding: 24px 0;
}

header h1 {
    font-size: 28px;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.5px;
}

/* 主内容区域 */
main {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: 24px;
    margin-bottom: 20px;
}

.table-wrapper {
    overflow-x: auto;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

/* 表格样式 */
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
    table-layout: fixed; /* 固定表格布局，列宽自动均分 */
}

thead {
    background: #f1f5f9;
    color: var(--text-primary);
}

thead tr:first-child th {
    padding: 14px 8px;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 12px;
    letter-spacing: 0.5px;
    border-bottom: 2px solid var(--border-color);
    border-right: 1px solid rgba(226, 232, 240, 0.5);
}

thead tr:first-child th:last-child {
    border-right: none;
}

thead tr:nth-child(2) th {
    padding: 12px 6px;
    font-weight: 500;
    font-size: 13px;
    background: #e2e8f0;
    border-bottom: 1px solid var(--border-color);
    border-right: 1px solid rgba(226, 232, 240, 0.3);
}

thead tr:nth-child(2) th:last-child {
    border-right: none;
}

.section-header {
    text-align: center;
    position: relative;
    background: #f1f5f9 !important;
    border-left: 2px solid #cbd5e1 !important;
    border-right: 2px solid #cbd5e1 !important;
}

.action-header {
    width: 40px;
    background: transparent !important;
}

th.tooltip {
    cursor: help;
    position: relative;
}

th.tooltip::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: #1e293b;
    color: white;
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: normal;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
    z-index: 100;
}

th.tooltip:hover::after {
    opacity: 1;
    visibility: visible;
}

/* 行号表头样式 - 固定宽度不参与均分 */
.row-number-header {
    width: 50px;
    min-width: 50px;
    max-width: 50px;
}

/* 表格主体 */
tbody tr {
    border-bottom: 1px solid var(--border-color);
    transition: var(--transition);
}

tbody tr:hover {
    background: #f8fafc;
}

tbody tr.baseline-row {
    background: #eff6ff;
    border-left: 3px solid var(--primary-color);
}

tbody td {
    padding: 12px 6px;
    text-align: center;
    vertical-align: middle;
    border-right: 1px solid rgba(226, 232, 240, 0.3);
}

tbody td:last-child {
    border-right: none;
}

/* 第一列行号样式 - 固定宽度不参与均分 */
tbody td:first-child {
    width: 50px;
    min-width: 50px;
    max-width: 50px;
    padding: 12px 4px;
}

/* 输入框样式 */
input[type="number"],
input[type="text"] {
    width: 95%;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 14px;
    text-align: center;
    transition: var(--transition);
    background: var(--card-bg);
}

input[type="number"]:focus,
input[type="text"]:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

input[type="number"]:disabled {
    background: #f8fafc;
    color: var(--text-secondary);
    cursor: not-allowed;
}

input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

input[type="number"] {
    -moz-appearance: textfield;
}

/* 技能列样式 */
.skill-column {
    background: #e0e7ff !important;
    border-left: 1px solid #c7d2fe !important;
    border-right: 1px solid #c7d2fe !important;
}

tbody td.skill-cell {
    background: #f1f5f9;
    border-left: 1px solid rgba(226, 232, 240, 0.5);
    border-right: 1px solid rgba(226, 232, 240, 0.5);
}

/* 技能占比输入框样式 */
.skill-cell input[type="number"] {
    font-weight: 500;
    background: #eef2ff;
    border-color: #c7d2fe;
}

.skill-cell input[type="number"]:focus {
    background: #e0e7ff;
    border-color: var(--primary-color);
}

/* 技能占比校验警告样式 */
.skill-cell input[type="number"].ratio-warning {
    border-color: #ef4444 !important;
    background: #fef2f2 !important;
    animation: shake 0.3s ease;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-3px); }
    75% { transform: translateX(3px); }
}

/* 下拉框样式 */
select {
    width: 95%;
    padding: 10px 6px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 14px;
    text-align: center;
    transition: var(--transition);
    background: var(--card-bg);
    cursor: pointer;
}

select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* 计算值样式 */
.calculated-value {
    display: inline-block;
    min-width: 50px;
    padding: 8px 12px;
    background: #f1f5f9;
    border-radius: var(--radius-sm);
    font-weight: 500;
    color: var(--text-primary);
}

/* 伤害比率样式 */
.damage-ratio {
    display: inline-block;
    min-width: 70px;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 14px;
}

.damage-ratio.positive {
    color: var(--success-color);
    background: #f0fdf4;
}

.damage-ratio.negative {
    color: var(--danger-color);
    background: #fef2f2;
}

.damage-ratio.baseline {
    color: var(--primary-color);
    background: #eff6ff;
    font-weight: 600;
}

/* 结果列样式 - 固定宽度防止被压缩 */
thead tr:nth-child(2) th:nth-last-child(2),
thead tr:nth-child(2) th:last-child {
    width: 100px;
}

td:nth-last-child(2) {
    width: 100px;
    background: #fafafa !important;
    border-left: 2px solid #e2e8f0 !important;
}

/* 按钮样式 */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 12px 24px;
    border: none;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
}

.btn .icon {
    font-size: 18px;
    font-weight: bold;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
    box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
    background: var(--primary-hover);
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--secondary-color);
    color: white;
    box-shadow: var(--shadow-sm);
}

.btn-secondary:hover {
    background: var(--secondary-hover);
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.btn-baseline {
    background: var(--primary-color);
    color: white;
    padding: 8px 16px;
    font-size: 13px;
    margin-right: 4px;
}

.btn-baseline:hover {
    background: var(--primary-hover);
}

.btn-baseline.active {
    background: var(--success-color);
    cursor: default;
}

.btn-baseline.active:hover {
    background: var(--success-color);
}

.btn-delete {
    background: transparent;
    color: var(--danger-color);
    padding: 8px 12px;
    font-size: 13px;
    border: 1px solid var(--danger-color);
}

.btn-delete:hover {
    background: var(--danger-color);
    color: white;
}

.action-cell {
    width: 160px;
    background: #f8fafc !important;
    border-left: 2px solid #cbd5e1 !important;
}

/* 操作按钮容器 */
.action-buttons-container {
    display: flex;
    gap: 4px;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
}

/* 操作按钮区域 */
.action-buttons {
    display: flex;
    gap: 12px;
    margin-top: 20px;
    justify-content: center;
    flex-wrap: wrap;
}

/* 隐藏元素 */
.hidden {
    display: none !important;
}

/* 页脚 */
footer {
    text-align: center;
    padding: 16px;
    color: var(--text-secondary);
    font-size: 13px;
}

footer p {
    background: #f1f5f9;
    padding: 12px 20px;
    border-radius: var(--radius-md);
    display: inline-block;
    text-align: left;
}

footer p strong {
    display: block;
    margin-bottom: 4px;
}

.tip-item {
    display: block;
    padding-left: 4px;
    line-height: 1.6;
}

/* 响应式设计 */
@media (max-width: 1200px) {
    .container {
        padding: 15px;
    }
    
    header h1 {
        font-size: 24px;
    }
    
    main {
        padding: 16px;
    }
    
    input[type="number"],
    input[type="text"] {
        padding: 8px 10px;
        font-size: 13px;
    }
    
    select {
        padding: 8px 4px;
    }
}

@media (max-width: 768px) {
    header h1 {
        font-size: 20px;
    }
    
    thead tr:first-child th {
        padding: 10px 6px;
        font-size: 11px;
    }
    
    thead tr:nth-child(2) th {
        font-size: 11px;
        padding: 8px 4px;
    }
    
    tbody td {
        padding: 8px 4px;
    }
    
    .btn {
        padding: 10px 18px;
        font-size: 13px;
    }
}

/* 基准行标记 */
.baseline-marker {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--primary-color);
}

/* 行号 */
.row-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    background: #e2e8f0;
    border-radius: 50%;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
}

.baseline-row .row-number {
    background: var(--primary-color);
    color: white;
}

/* 技能区域分隔线 */
.skill-divider {
    border-left: 2px dashed var(--border-color);
}

/* 动画效果 */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

tbody tr {
    animation: fadeIn 0.3s ease;
}

/* 删除按钮区域 */
.delete-cell {
    width: 50px;
}