/* 在线尺子工具样式 */

/* 头部区域样式 */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 20px;
    margin-bottom: 20px;
}

/* 修复：覆盖全局 header-actions 的 absolute 定位 */
.header .header-actions {
    position: static;
    transform: none;
    display: flex;
    align-items: center;
    gap: 10px;
}

/* 返回按钮样式 - 更柔和的浅蓝色 */
.back-btn {
    display: inline-flex;
    align-items: center;
    padding: 6px 18px;
    background-color: #f5f5f5;
    color: #666;
    text-decoration: none;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s ease;
    height: 36px;
    box-sizing: border-box;
}

.back-btn:hover {
    background-color: #e8e8e8;
    color: #333;
    transform: translateY(-1px);
}

/* 收藏按钮样式 - 以返回按钮为模板 */
.favorite-button {
    display: inline-flex;
    align-items: center;
    padding: 6px 18px;
    background-color: #f5f5f5;
    color: #666;
    text-decoration: none;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s ease;
    height: 36px;
    box-sizing: border-box;
    cursor: pointer;
    font-family: inherit;
}

.favorite-button:hover {
    background-color: #e8e8e8;
    color: #333;
    transform: translateY(-1px);
}

.favorite-button.favorited {
    background-color: #fff8e1;
    color: #f9a825;
}

.favorite-button.favorited:hover {
    background-color: #ffecb3;
    color: #f57f17;
}

@media (max-width: 768px) {
    .header {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        gap: 16px;
        margin-top: 15px;
        margin-bottom: 15px;
    }

    .back-btn {
        padding: 8px 12px;
        font-size: 13px;
    }

    .favorite-button {
        padding: 8px 12px;
        font-size: 13px;
    }
}

/* 工具内容区域 */
.tool-content {
    background: #fff;
    border-radius: 12px;
    padding: 30px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

/* 校准区域 */
.calibration-section {
    background: #0066cc;
    border-radius: 12px;
    padding: 25px;
    margin-bottom: 30px;
    color: #fff;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 20px;
}

.calibration-info h3 {
    font-size: 20px;
    margin-bottom: 10px;
}

.calibration-info p {
    font-size: 14px;
    opacity: 0.9;
    margin-bottom: 5px;
}

.calibration-hint {
    font-size: 12px !important;
    opacity: 0.8 !important;
}

.calibration-controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.dpi-display {
    font-size: 14px;
    background: rgba(255, 255, 255, 0.2);
    padding: 5px 15px;
    border-radius: 20px;
}

/* 按钮样式 */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
}

.btn-primary {
    background: #fff;
    color: #0066cc;
    font-weight: 600;
}

.btn-primary:hover {
    background: #f0f0f0;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.btn-secondary {
    background: #f5f5f5;
    color: #333;
    border: 1px solid #ddd;
}

.btn-secondary:hover {
    background: #e8e8e8;
}

/* 尺子控制区域 */
.ruler-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    align-items: center;
    margin-bottom: 30px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 10px;
}

.unit-switch {
    display: flex;
    align-items: center;
    gap: 10px;
}

.switch-label {
    font-weight: 600;
    color: #333;
}

.switch-buttons {
    display: flex;
    border: 1px solid #ddd;
    border-radius: 8px;
    overflow: hidden;
}

.unit-btn {
    padding: 8px 16px;
    border: none;
    background: #fff;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s ease;
}

.unit-btn.active {
    background: #0066cc;
    color: #fff;
}

.unit-btn:not(.active):hover {
    background: #f0f0f0;
}

.ruler-length {
    display: flex;
    align-items: center;
    gap: 10px;
}

.ruler-length label {
    font-weight: 600;
    color: #333;
}

.ruler-length select {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
}

/* 尺子容器 */
.ruler-container {
    background: #f0f0f0;
    border-radius: 10px;
    padding: 30px;
    margin-bottom: 30px;
    overflow: auto;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 200px;
    position: relative;
}

#rulerCanvas {
    background: #fff;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* 使用说明 */
.usage-tips {
    background: #f8f9fa;
    border-radius: 10px;
    padding: 25px;
}

.usage-tips h3 {
    font-size: 18px;
    color: #333;
    margin-bottom: 15px;
}

.usage-tips ul {
    list-style: none;
    padding: 0;
}

.usage-tips li {
    padding: 8px 0;
    padding-left: 25px;
    position: relative;
    color: #666;
    font-size: 14px;
}

.usage-tips li::before {
    content: '✓';
    position: absolute;
    left: 0;
    color: #0066cc;
    font-weight: bold;
}

/* 校准弹窗 */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-content {
    background: #fff;
    border-radius: 12px;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid #e5e5e5;
}

.modal-header h3 {
    font-size: 18px;
    color: #333;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #999;
    line-height: 1;
}

.modal-close:hover {
    color: #333;
}

.modal-body {
    padding: 20px;
    overflow: visible;
}

.modal-body p {
    color: #666;
    margin-bottom: 20px;
    line-height: 1.6;
}

.calibration-ruler {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 30px 0;
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    overflow: visible;
}

.card-reference-wrapper {
    position: relative;
    width: 100%;
    height: 70px;
    padding: 10px 0;
    overflow: visible;
}

.card-reference {
    background: #0066cc;
    height: 54px;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
}

.card-edge {
    position: absolute;
    font-size: 24px;
    color: #0066cc;
    font-weight: bold;
    top: 50%;
    transform: translateY(-50%);
}

.card-edge.left-edge {
    left: -5px;
}

.card-edge.right-edge {
    color: #ff6b6b;
    font-size: 28px;
    top: 50%;
    transform: translateY(-50%);
}

/* 纵向校准区域 */
.calibration-ruler-vertical {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    overflow: visible;
    width: 100%;
}

.card-reference-wrapper-vertical {
    position: relative;
    width: 100px;
    height: 300px;
    margin: 0 auto;
    overflow: visible;
}

.card-reference-vertical {
    background: #0066cc;
    width: 54px;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    position: absolute;
    left: 50%;
    top: 10px;
    transform: translateX(-50%);
}

.card-edge.top-edge {
    left: 50%;
    transform: translateX(-50%);
    top: 5px;
    color: #0066cc;
    font-size: 20px;
}

.card-edge.bottom-edge {
    color: #ff6b6b;
    font-size: 20px;
    left: 50%;
    transform: translateX(-50%);
}

.calibration-scale {
    font-size: 14px;
    color: #0066cc;
    font-weight: 600;
}

/* 校准方向选择 */
.calibration-orientation {
    margin-bottom: 20px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
}

.calibration-orientation label {
    display: block;
    margin-bottom: 10px;
    font-weight: 600;
    color: #333;
}

.orientation-buttons {
    display: flex;
    gap: 10px;
}

.orientation-btn {
    flex: 1;
    padding: 10px 20px;
    border: 2px solid #ddd;
    background: #fff;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s ease;
}

.orientation-btn:hover {
    border-color: #0066cc;
}

.orientation-btn.active {
    background: #0066cc;
    color: #fff;
    border-color: #0066cc;
}

/* 当前 DPI 信息显示 */
.current-dpi-info {
    margin-top: 15px;
    padding: 10px;
    background: #e8f4fd;
    border-radius: 6px;
    display: flex;
    justify-content: space-around;
}

.current-dpi-info p {
    margin: 0;
    font-size: 14px;
    color: #333;
}

.current-dpi-info span {
    font-weight: bold;
    color: #0066cc;
}

.calibration-slider {
    margin-top: 10px;
}

.calibration-slider label {
    display: block;
    margin-bottom: 10px;
    color: #333;
    font-weight: 600;
}

.calibration-slider input[type="range"] {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: #e5e5e5;
    outline: none;
    -webkit-appearance: none;
}

.calibration-slider input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #0066cc;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0, 102, 204, 0.4);
}

.calibration-slider input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #0066cc;
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 6px rgba(0, 102, 204, 0.4);
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 20px;
    border-top: 1px solid #e5e5e5;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .tool-content {
        padding: 20px;
    }
    
    .calibration-section {
        flex-direction: column;
        text-align: center;
    }
    
    .ruler-controls {
        flex-direction: column;
        align-items: stretch;
    }
    
    .unit-switch,
    .ruler-length {
        justify-content: space-between;
    }
    
    .switch-buttons {
        flex: 1;
    }
    
    .unit-btn {
        flex: 1;
    }
    
    .ruler-length select {
        flex: 1;
    }
    
    .ruler-container {
        padding: 15px;
    }
    
    /* 手机端校准弹窗优化 */
    .modal-content {
        width: 95%;
        max-width: none;
        margin: 10px;
    }
    
    .calibration-ruler {
        padding: 20px 0;
    }
    
    .card-reference-wrapper {
        height: 60px;
    }
    
    .card-reference {
        height: 44px;
    }
}

/* 手机端横向校准 */
@media (max-width: 480px) {
    .modal {
        align-items: flex-start;
        padding-top: 20px;
    }
    
    .modal-content {
        width: 100%;
        max-width: 100%;
        margin: 0;
        border-radius: 0;
        min-height: 100vh;
    }
    
    .calibration-ruler {
        background: transparent;
        padding: 10px 0;
    }
    
    .card-reference-wrapper {
        height: 80px;
        width: 100vw;
        position: relative;
        left: 50%;
        transform: translateX(-50%);
    }
}

/* 垂直尺子样式 */
.ruler-container.vertical {
    flex-direction: column;
    min-height: 600px;
}

.ruler-container.vertical #rulerCanvas {
    max-width: none;
    max-height: 100%;
}
