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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 1000px;
    margin: 0 auto;
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
    padding: 40px;
}

h1 {
    text-align: center;
    color: #333;
    margin-bottom: 40px;
    font-size: 28px;
}

h2 {
    color: #555;
    margin-bottom: 20px;
    font-size: 18px;
    border-bottom: 2px solid #667eea;
    padding-bottom: 10px;
}

.section {
    margin-bottom: 40px;
}

/* 文件上传区域 */
.upload-area {
    border: 2px dashed #667eea;
    border-radius: 8px;
    padding: 40px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: #f8f9ff;
}

.upload-area:hover {
    border-color: #764ba2;
    background: #f0f2ff;
}

.upload-area.drag-over {
    border-color: #764ba2;
    background: #e8ebff;
    transform: scale(1.02);
}

.upload-content p {
    color: #666;
    font-size: 16px;
    margin-bottom: 8px;
}

.file-hint {
    font-size: 14px;
    color: #999;
}

.file-info {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    padding: 15px;
    background: #e8f5e9;
    border-radius: 6px;
}

.file-info span {
    color: #2e7d32;
    font-weight: 500;
}

.btn-remove {
    background: #f44336;
    color: white;
    border: none;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 20px;
    line-height: 1;
    transition: background 0.3s ease;
}

.btn-remove:hover {
    background: #d32f2f;
}

/* 输入表单 */
.input-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
}

.input-group {
    display: flex;
    flex-direction: column;
}

.input-group.full-width {
    grid-column: 1 / -1;
}

.input-group label {
    color: #555;
    font-size: 14px;
    margin-bottom: 8px;
    font-weight: 500;
}

.input-group input {
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    transition: border-color 0.3s ease;
}

.input-group input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* 计算按钮 */
.btn-calculate {
    width: 100%;
    padding: 16px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 18px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.btn-calculate:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

.btn-calculate:active {
    transform: translateY(0);
}

.btn-calculate:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
}

/* 结果表格 */
.result-table-container {
    overflow-x: auto;
}

.result-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
}

.result-table thead {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.result-table th,
.result-table td {
    padding: 14px;
    text-align: center;
    border: 1px solid #e0e0e0;
}

.result-table th {
    font-weight: 600;
    font-size: 14px;
}

.result-table tbody tr:nth-child(even) {
    background: #f8f9ff;
}

.result-table tbody tr:hover {
    background: #f0f2ff;
}

.result-table td {
    color: #333;
    font-size: 14px;
}

/* 错误提示 */
.error-message {
    padding: 16px;
    background: #ffebee;
    border-left: 4px solid #f44336;
    border-radius: 6px;
    color: #c62828;
    margin-top: 20px;
}

/* URDF 校核样式 */
.validation-success {
    padding: 16px;
    background: #e8f5e9;
    border-left: 4px solid #4caf50;
    border-radius: 6px;
    color: #2e7d32;
    font-weight: 500;
    margin-bottom: 20px;
}

.validation-error {
    padding: 16px;
    background: #ffebee;
    border-left: 4px solid #f44336;
    border-radius: 6px;
    color: #c62828;
    font-weight: 500;
    margin-bottom: 20px;
}

.error-item {
    padding: 12px;
    background: #fff3e0;
    border-left: 3px solid #ff9800;
    border-radius: 4px;
    color: #e65100;
    margin-bottom: 10px;
    font-size: 14px;
}

.error-item:last-child {
    margin-bottom: 0;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .container {
        padding: 20px;
    }

    h1 {
        font-size: 24px;
    }

    .input-grid {
        grid-template-columns: 1fr;
    }
}

/* 标签页样式 */
.tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 30px;
    border-bottom: 2px solid #e0e0e0;
}

.tab-button {
    padding: 12px 24px;
    background: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    color: #666;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}

.tab-button:hover {
    color: #667eea;
    background: #f8f9ff;
}

.tab-button.active {
    color: #667eea;
    border-bottom-color: #667eea;
    font-weight: 600;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* STL 查看器样式 */
.stl-viewer {
    width: 100%;
    height: 600px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    background: #f0f0f0;
    position: relative;
    overflow: hidden;
}

.viewer-hint {
    margin-top: 20px;
    padding: 16px;
    background: #f8f9ff;
    border-left: 4px solid #667eea;
    border-radius: 6px;
}

.viewer-hint p {
    color: #555;
    font-weight: 600;
    margin-bottom: 10px;
}

.viewer-hint ul {
    list-style: none;
    padding-left: 0;
}

.viewer-hint li {
    color: #666;
    font-size: 14px;
    margin-bottom: 6px;
    padding-left: 20px;
    position: relative;
}

.viewer-hint li:before {
    content: "•";
    position: absolute;
    left: 8px;
    color: #667eea;
}

/* 响应式 - STL 查看器 */
@media (max-width: 768px) {
    .stl-viewer {
        height: 400px;
    }

    .tabs {
        flex-direction: column;
        gap: 0;
    }

    .tab-button {
        border-bottom: 1px solid #e0e0e0;
        border-left: 3px solid transparent;
    }

    .tab-button.active {
        border-bottom-color: #e0e0e0;
        border-left-color: #667eea;
    }
}

/* URDF 校核结果样式 */
#urdfValidationStatus {
    padding: 15px;
    border-radius: 6px;
    margin-bottom: 20px;
    font-weight: 500;
}

#urdfValidationStatus.success {
    background: #e8f5e9;
    color: #2e7d32;
    border-left: 4px solid #4caf50;
}

#urdfValidationStatus.error {
    background: #ffebee;
    color: #c62828;
    border-left: 4px solid #f44336;
}

/* 错误列表样式 */
#urdfErrorList {
    background: #fff3e0;
    border: 1px solid #ffb74d;
    border-radius: 6px;
    padding: 15px;
}

#urdfErrorList .error-item {
    margin-bottom: 10px;
    padding-bottom: 10px;
    border-bottom: 1px solid #ffe0b2;
}

#urdfErrorList .error-item:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

#urdfErrorList .error-type {
    font-weight: 600;
    color: #e65100;
}

#urdfErrorList .error-description {
    color: #666;
    margin-top: 5px;
}

/* DH 参数表格标题 */
#dhParametersContainer h3 {
    color: #555;
    margin-bottom: 15px;
    font-size: 16px;
}

/* 机械臂可视化容器 */
.robot-viewer {
    width: 100%;
    height: 400px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    background: #f5f5f5;
    position: relative;
    overflow: hidden;
    margin-bottom: 15px;
}

#robotVisualizationContainer {
    margin-bottom: 25px;
}

#robotVisualizationContainer h3 {
    color: #555;
    margin-bottom: 15px;
    font-size: 16px;
}

/* 可视化控制按钮区域 */
.viewer-controls {
    margin-bottom: 10px;
    display: flex;
    gap: 10px;
}

.btn-toggle {
    padding: 8px 16px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.3s ease;
}

.btn-toggle:hover {
    background: #764ba2;
}

/* 关节滑动条区域 - 侧边浮动面板 */
.robot-viewer-wrapper {
    position: relative;
}

.joint-sliders-panel {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 300px;
    padding: 12px;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 8px;
    border: 1px solid rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(4px);
    z-index: 10;
    box-sizing: border-box;
}

.joint-sliders-panel .slider-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid #e0e0e0;
}

.joint-sliders-panel .slider-header span {
    font-size: 13px;
    font-weight: 600;
    color: #444;
}

.joint-sliders-panel .btn-reset {
    padding: 4px 10px;
    background: #ff9800;
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
}

.joint-sliders-panel .btn-reset:hover {
    background: #f57c00;
}

.joint-sliders-panel .slider-group {
    display: flex;
    align-items: center;
    margin-bottom: 8px;
    gap: 10px;
    width: 100%;
    box-sizing: border-box;
}

.joint-sliders-panel .slider-group:last-child {
    margin-bottom: 0;
}

.joint-sliders-panel .slider-group label {
    flex-shrink: 0;
    width: 24px;
    font-size: 12px;
    color: #555;
    font-weight: 500;
}

.joint-sliders-panel .joint-slider {
    flex: 1;
    min-width: 0;
    height: 6px;
    -webkit-appearance: none;
    appearance: none;
    background: #ddd;
    border-radius: 3px;
    outline: none;
}

.joint-sliders-panel .joint-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    background: #667eea;
    border-radius: 50%;
    cursor: pointer;
}

.joint-sliders-panel .joint-slider::-moz-range-thumb {
    width: 14px;
    height: 14px;
    background: #667eea;
    border-radius: 50%;
    cursor: pointer;
    border: none;
}

.joint-sliders-panel .slider-value {
    flex-shrink: 0;
    width: 50px;
    font-size: 12px;
    color: #666;
    text-align: right;
}

/* 帮助按钮和气泡 */
.help-btn {
    position: absolute;
    bottom: 10px;
    right: 10px;
    width: 24px;
    height: 24px;
    background: rgba(102, 126, 234, 0.8);
    color: white;
    border: none;
    border-radius: 50%;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    z-index: 10;
}

.help-btn:hover {
    background: rgba(118, 75, 162, 0.9);
}

.help-tooltip {
    display: none;
    position: absolute;
    bottom: 40px;
    right: 10px;
    width: 180px;
    padding: 10px;
    background: rgba(50, 50, 50, 0.9);
    color: white;
    border-radius: 6px;
    font-size: 11px;
    z-index: 20;
}

.help-tooltip.show {
    display: block;
}

.help-tooltip p {
    margin: 0 0 5px 0;
    font-size: 11px;
}

.help-tooltip ul {
    margin: 0 0 8px 0;
    padding-left: 15px;
}

.help-tooltip li {
    margin-bottom: 2px;
}

/* 力矩结果容器 */
#torqueResultContainer {
    margin-top: 25px;
}

#torqueResultContainer h3 {
    color: #555;
    margin-bottom: 15px;
    font-size: 16px;
}

/* 百分比单元格样式 */
.percent-cell {
    font-weight: 500;
}

.percent-cell.low {
    color: #4caf50;
}

.percent-cell.medium {
    color: #ff9800;
}

.percent-cell.high {
    color: #f44336;
}

/* 轨迹力矩分析样式 */
.subsection-title {
    color: #666;
    font-size: 14px;
    margin: 20px 0 15px 0;
    padding-bottom: 8px;
    border-bottom: 1px solid #e0e0e0;
}

.inertia-grid {
    grid-template-columns: repeat(3, 1fr);
}

/* 图表容器样式 */
.chart-container {
    margin-bottom: 30px;
    padding: 20px;
    background: #fafafa;
    border-radius: 8px;
    border: 1px solid #e0e0e0;
}

.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 15px;
    flex-wrap: wrap;
    gap: 10px;
}

.chart-header h3 {
    color: #555;
    font-size: 16px;
    margin: 0;
}

.chart-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    background: white;
    border: 1px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s ease;
    user-select: none;
}

.legend-item:hover {
    border-color: #667eea;
}

.legend-item.hidden {
    opacity: 0.5;
    background: #f0f0f0;
}

.legend-item .color-box {
    width: 12px;
    height: 12px;
    border-radius: 2px;
}

.legend-item .label {
    color: #333;
}

.chart-wrapper {
    position: relative;
    height: 300px;
    width: 100%;
}

.chart-wrapper canvas {
    width: 100% !important;
    height: 100% !important;
}

.chart-tooltip {
    position: absolute;
    display: none;
    padding: 8px 12px;
    background: rgba(50, 50, 50, 0.9);
    color: white;
    border-radius: 4px;
    font-size: 12px;
    pointer-events: none;
    z-index: 100;
    white-space: nowrap;
}

.chart-tooltip.show {
    display: block;
}

/* 响应式 - 图表 */
@media (max-width: 768px) {
    .inertia-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .chart-wrapper {
        height: 250px;
    }

    .chart-header {
        flex-direction: column;
    }

    .chart-legend {
        width: 100%;
    }
}
