/* 全局样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #333;
    line-height: 1.6;
    min-height: 100vh;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
    background-color: #f5f5f5;
    min-height: 100vh;
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.3);
}

/* 头部样式 */
header {
    text-align: center;
    padding: 30px 20px;
    background: linear-gradient(135deg, #2c3e50 0%, #3498db 100%);
    color: white;
    border-radius: 10px;
    margin-bottom: 30px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

header h1 {
    font-size: 2.5em;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.subtitle {
    font-size: 1.1em;
    opacity: 0.9;
    font-style: italic;
}

/* 控制面板 */
.control-panel {
    background: white;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 30px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.view-selector {
    display: flex;
    align-items: center;
    gap: 15px;
}

.view-selector label {
    font-weight: 600;
    font-size: 1.1em;
    color: #2c3e50;
    white-space: nowrap;
}

#viewSelect {
    flex: 1;
    padding: 12px 15px;
    font-size: 1em;
    border: 2px solid #3498db;
    border-radius: 5px;
    background-color: white;
    cursor: pointer;
    transition: all 0.3s ease;
}

#viewSelect:hover {
    border-color: #2980b9;
    box-shadow: 0 2px 8px rgba(52, 152, 219, 0.3);
}

#viewSelect:focus {
    outline: none;
    border-color: #2980b9;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.2);
}

/* 主内容区域 */
.main-content {
    display: grid;
    grid-template-columns: 1fr 400px;
    gap: 30px;
    margin-bottom: 30px;
}

/* 左侧面板 */
.left-panel {
    display: flex;
    flex-direction: column;
    gap: 30px;
}

/* 右侧面板 */
.right-panel {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* 通用区块样式 */
.model-section, .video-section, .position-section, .labeled-section, .info-section {
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.model-section h2, .video-section h2, .position-section h2, .labeled-section h2, .info-section h2 {
    font-size: 1.4em;
    color: #2c3e50;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 3px solid #3498db;
}

/* 视图模式选择器 */
.view-mode-selector {
    margin-bottom: 15px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 5px;
}

.view-mode-selector label {
    display: block;
    margin-bottom: 10px;
    font-weight: 600;
    color: #2c3e50;
    font-size: 1.05em;
}

.mode-buttons {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.mode-btn {
    flex: 1;
    min-width: 100px;
    padding: 10px 15px;
    font-size: 0.95em;
    border: 2px solid #3498db;
    border-radius: 5px;
    background: white;
    color: #3498db;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 600;
}

.mode-btn:hover {
    background: #e8f4f8;
    transform: translateY(-2px);
    box-shadow: 0 2px 5px rgba(52, 152, 219, 0.3);
}

.mode-btn.active {
    background: #3498db;
    color: white;
    box-shadow: 0 2px 8px rgba(52, 152, 219, 0.4);
}

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

/* 视频信息显示 */
.video-info {
    margin-top: 10px;
    padding: 10px 15px;
    background: #f8f9fa;
    border-radius: 5px;
    text-align: center;
}

#videoFrameNumber {
    display: inline-block;
    padding: 5px 12px;
    background: #27ae60;
    color: white;
    border-radius: 3px;
    font-size: 0.9em;
    font-weight: 600;
}

/* Canvas容器 */
.model-container, .video-container {
    position: relative;
    background: #000;
    border-radius: 5px;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 350px;
}

#modelCanvas {
    display: block;
    max-width: 100%;
    height: auto;
    cursor: grab;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
}

#modelCanvas:active {
    cursor: grabbing;
}

#videoCanvas {
    display: block;
    max-width: 100%;
    height: auto;
}

/* 加载提示 */
.loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-size: 1.2em;
    background: rgba(0, 0, 0, 0.7);
    padding: 15px 30px;
    border-radius: 5px;
}

/* 拖动提示 */
.drag-hint {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    color: white;
    font-size: 1em;
    background: rgba(52, 152, 219, 0.8);
    padding: 10px 20px;
    border-radius: 20px;
    pointer-events: none;
    animation: fadeInOut 3s ease-in-out infinite;
    z-index: 5;
}

@keyframes fadeInOut {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 1; }
}

.drag-hint.hidden {
    display: none;
}

/* 滑块容器 */
.slider-container {
    margin-top: 15px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 5px;
}

.slider-container label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #2c3e50;
}

/* 帧数输入容器 */
.frame-input-container {
    margin-top: 15px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 5px;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.frame-input-container label {
    font-weight: 600;
    color: #2c3e50;
    white-space: nowrap;
}

#frameInput {
    flex: 1;
    min-width: 100px;
    padding: 8px 12px;
    font-size: 1em;
    border: 2px solid #3498db;
    border-radius: 5px;
    background-color: white;
    transition: all 0.3s ease;
}

#frameInput:focus {
    outline: none;
    border-color: #2980b9;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.2);
}

#frameInput::-webkit-inner-spin-button,
#frameInput::-webkit-outer-spin-button {
    opacity: 1;
}

.btn-small {
    padding: 8px 16px;
    font-size: 0.95em;
}


#rotationSlider {
    width: 100%;
    height: 8px;
    border-radius: 5px;
    background: #d3d3d3;
    outline: none;
    margin-bottom: 10px;
    cursor: pointer;
}

#rotationSlider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #3498db;
    cursor: pointer;
    transition: all 0.3s ease;
}

#rotationSlider::-webkit-slider-thumb:hover {
    background: #2980b9;
    transform: scale(1.2);
}

#rotationSlider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #3498db;
    cursor: pointer;
    border: none;
}

#frameNumber {
    display: inline-block;
    padding: 5px 10px;
    background: #3498db;
    color: white;
    border-radius: 3px;
    font-size: 0.9em;
    font-weight: 600;
}

/* 按钮样式 */
.model-controls, .video-controls {
    margin-top: 15px;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.btn {
    padding: 10px 20px;
    font-size: 1em;
    border: none;
    border-radius: 5px;
    background: #3498db;
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 600;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.btn:hover {
    background: #2980b9;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

.btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.btn:disabled {
    background: #95a5a6;
    cursor: not-allowed;
    transform: none;
}

/* 速度控制 */
.speed-control {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-left: auto;
}

.speed-control label {
    font-weight: 600;
    color: #2c3e50;
}

#speedControl {
    padding: 8px 12px;
    border: 2px solid #3498db;
    border-radius: 5px;
    background: white;
    cursor: pointer;
    font-size: 0.95em;
}

/* 图片容器 */
.position-container, .labeled-container {
    position: relative;
    background: #f8f9fa;
    border-radius: 5px;
    padding: 10px;
    min-height: 200px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.position-container img, .labeled-container img {
    max-width: 100%;
    height: auto;
    border-radius: 5px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* 信息文本 */
.info-text {
    text-align: center;
    color: #7f8c8d;
    font-style: italic;
    padding: 20px;
}

.view-description {
    padding: 15px;
    background: #f8f9fa;
    border-radius: 5px;
    line-height: 1.8;
}

.view-description p {
    margin-bottom: 10px;
}

.view-description strong {
    color: #2c3e50;
}

.view-description ul {
    margin-left: 20px;
    margin-top: 10px;
}

.view-description li {
    margin-bottom: 5px;
}

/* 快捷键说明 */
.keyboard-shortcuts {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 2px solid #e0e0e0;
}

.keyboard-shortcuts p {
    margin-bottom: 8px;
    color: #2c3e50;
}

.keyboard-shortcuts ul {
    margin-left: 20px;
    list-style: none;
}

.keyboard-shortcuts li {
    margin-bottom: 5px;
    color: #555;
    font-size: 0.95em;
}

.keyboard-shortcuts li::before {
    content: "⌨ ";
    margin-right: 5px;
}

/* 页脚 */
footer {
    text-align: center;
    padding: 20px;
    background: #2c3e50;
    color: white;
    border-radius: 8px;
    margin-top: 30px;
}

footer p {
    margin: 5px 0;
}

.copyright {
    font-size: 0.9em;
    opacity: 0.8;
}

/* 响应式设计 */

/* 平板和小屏幕笔记本 */
@media (max-width: 1200px) {
    .main-content {
        grid-template-columns: 1fr;
    }

    .right-panel {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
        gap: 20px;
    }
}

/* 平板竖屏 */
@media (max-width: 768px) {
    body {
        font-size: 14px;
    }

    .container {
        padding: 15px;
    }

    header h1 {
        font-size: 1.8em;
    }

    .subtitle {
        font-size: 1em;
    }

    /* 视图选择器优化 */
    .view-selector {
        flex-direction: column;
        align-items: stretch;
    }

    .view-selector label {
        white-space: normal;
        margin-bottom: 8px;
    }

    #viewSelect {
        font-size: 1em;
    }

    /* 模式按钮优化 */
    .mode-buttons {
        gap: 8px;
    }

    .mode-btn {
        font-size: 0.9em;
        padding: 8px 12px;
        min-width: 80px;
    }

    /* 右侧面板改为单列 */
    .right-panel {
        grid-template-columns: 1fr;
    }

    /* 控制按钮优化 */
    .model-controls, .video-controls {
        justify-content: center;
        gap: 8px;
    }

    .speed-control {
        margin-left: 0;
        width: 100%;
        justify-content: space-between;
        flex-wrap: wrap;
    }

    .speed-control label {
        width: 100%;
        text-align: center;
        margin-bottom: 5px;
    }

    #speedControl {
        flex: 1;
        min-width: 120px;
    }

    /* Canvas容器 */
    .model-container, .video-container {
        min-height: 300px;
    }

    /* 滑块容器 */
    .slider-container {
        padding: 12px;
    }

    /* 帧数输入容器 */
    .frame-input-container {
        padding: 12px;
    }

    #frameNumber, #videoFrameNumber {
        font-size: 0.85em;
        padding: 4px 8px;
    }
}

/* 手机横屏和小平板 */
@media (max-width: 640px) {
    header h1 {
        font-size: 1.6em;
    }

    .subtitle {
        font-size: 0.9em;
    }

    /* 区块标题 */
    .model-section h2, .video-section h2,
    .position-section h2, .labeled-section h2, .info-section h2 {
        font-size: 1.2em;
    }

    /* 视图模式选择器 */
    .view-mode-selector {
        padding: 12px;
    }

    .mode-buttons {
        flex-direction: column;
    }

    .mode-btn {
        width: 100%;
        padding: 10px;
    }

    /* 按钮 */
    .btn {
        padding: 10px 15px;
        font-size: 0.95em;
        flex: 1;
        min-width: 80px;
    }

    /* 视频控制 */
    .video-controls {
        flex-wrap: wrap;
        gap: 8px;
    }

    .video-controls .btn {
        flex: 1 1 calc(33.333% - 8px);
    }

    .speed-control {
        width: 100%;
        margin-top: 8px;
    }
}

/* 手机竖屏 */
@media (max-width: 480px) {
    body {
        font-size: 13px;
    }

    .container {
        padding: 8px;
    }

    header {
        padding: 15px 10px;
    }

    header h1 {
        font-size: 1.4em;
    }

    .subtitle {
        font-size: 0.85em;
    }

    /* 控制面板 */
    .control-panel {
        padding: 12px;
        margin-bottom: 15px;
    }

    /* 所有区块 */
    .model-section, .video-section,
    .position-section, .labeled-section, .info-section {
        padding: 12px;
        margin-bottom: 15px;
    }

    .model-section h2, .video-section h2,
    .position-section h2, .labeled-section h2, .info-section h2 {
        font-size: 1.1em;
        margin-bottom: 10px;
        padding-bottom: 8px;
    }

    /* 视图模式选择器 */
    .view-mode-selector {
        padding: 10px;
        margin-bottom: 10px;
    }

    .view-mode-selector label {
        font-size: 0.95em;
        margin-bottom: 8px;
    }

    .mode-buttons {
        gap: 6px;
    }

    .mode-btn {
        font-size: 0.85em;
        padding: 8px;
    }

    /* Canvas容器 */
    .model-container, .video-container {
        min-height: 250px;
    }

    /* 拖动提示 */
    .drag-hint {
        font-size: 0.85em;
        padding: 8px 15px;
        bottom: 10px;
    }

    /* 滑块容器 */
    .slider-container {
        padding: 10px;
        margin-top: 10px;
    }

    /* 帧数输入容器 */
    .frame-input-container {
        padding: 10px;
        margin-top: 10px;
    }

    .slider-container label {
        font-size: 0.9em;
        margin-bottom: 6px;
    }

    .frame-input-container label {
        font-size: 0.9em;
    }

    #frameInput {
        font-size: 0.9em;
        padding: 6px 10px;
    }

    #rotationSlider {
        height: 6px;
    }

    #frameNumber, #videoFrameNumber {
        font-size: 0.8em;
        padding: 3px 8px;
    }

    /* 视频信息 */
    .video-info {
        padding: 8px;
        margin-top: 8px;
    }

    /* 按钮组 */
    .model-controls, .video-controls {
        margin-top: 10px;
        gap: 6px;
    }

    .btn {
        padding: 8px 12px;
        font-size: 0.85em;
        min-width: 70px;
    }

    /* 速度控制 */
    .speed-control label {
        font-size: 0.85em;
    }

    #speedControl {
        font-size: 0.85em;
        padding: 6px 10px;
    }

    /* 图片容器 */
    .position-container, .labeled-container {
        min-height: 150px;
        padding: 8px;
    }

    /* 视图描述 */
    .view-description {
        padding: 10px;
        font-size: 0.9em;
        line-height: 1.6;
    }

    .view-description ul {
        margin-left: 15px;
    }

    /* 快捷键说明 */
    .keyboard-shortcuts {
        font-size: 0.85em;
    }

    .keyboard-shortcuts ul {
        margin-left: 15px;
    }

    /* 页脚 */
    footer {
        padding: 15px 10px;
        margin-top: 15px;
        font-size: 0.85em;
    }

    .copyright {
        font-size: 0.8em;
    }
}

/* 小屏手机 */
@media (max-width: 360px) {
    header h1 {
        font-size: 1.2em;
    }

    .subtitle {
        font-size: 0.8em;
    }

    .model-section h2, .video-section h2,
    .position-section h2, .labeled-section h2, .info-section h2 {
        font-size: 1em;
    }

    .mode-btn {
        font-size: 0.8em;
        padding: 6px;
    }

    .btn {
        padding: 6px 10px;
        font-size: 0.8em;
        min-width: 60px;
    }

    .drag-hint {
        font-size: 0.75em;
        padding: 6px 12px;
    }
}

/* 触摸设备优化 */
@media (hover: none) and (pointer: coarse) {
    /* 增大可点击区域 */
    .btn, .mode-btn {
        min-height: 44px;
        padding: 10px 15px;
    }

    #viewSelect, #speedControl, #frameInput {
        min-height: 44px;
        font-size: 16px; /* 防止iOS自动缩放 */
    }

    /* 优化滑块 */
    #rotationSlider {
        height: 10px;
    }

    #rotationSlider::-webkit-slider-thumb {
        width: 24px;
        height: 24px;
    }

    #rotationSlider::-moz-range-thumb {
        width: 24px;
        height: 24px;
    }

    /* 禁用悬停效果，使用触摸反馈 */
    .btn:hover, .mode-btn:hover {
        transform: none;
    }

    .btn:active, .mode-btn:active {
        transform: scale(0.95);
        opacity: 0.8;
    }
}

/* 横屏优化 */
@media (max-height: 600px) and (orientation: landscape) {
    .container {
        padding: 10px;
    }

    header {
        padding: 10px;
        margin-bottom: 15px;
    }

    header h1 {
        font-size: 1.3em;
    }

    .subtitle {
        display: none;
    }

    .main-content {
        gap: 15px;
    }

    .model-section, .video-section,
    .position-section, .labeled-section, .info-section {
        padding: 10px;
    }

    .model-container, .video-container {
        min-height: 200px;
    }

    footer {
        margin-top: 15px;
        padding: 10px;
    }
}

/* 动画效果 */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.model-section, .video-section, .position-section, .labeled-section, .info-section {
    animation: fadeIn 0.5s ease-out;
}

/* 滚动条样式 */
::-webkit-scrollbar {
    width: 10px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: #555;
}
